Logo ROOT  
Reference Guide
TGLViewerEditor.cxx
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Alja Mrak-Tadel, Matevz Tadel, Timur Pocheptsov 08/03/2006
3
4/*************************************************************************
5 * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include <cstring>
13
14#include "TGedEditor.h"
15#include "TGNumberEntry.h"
16#include "TGButtonGroup.h"
17#include "TGColorSelect.h"
18#include "TGTextEntry.h"
19#include "TVirtualGL.h"
20#include "TG3DLine.h"
21#include "TGButton.h"
22#include "TColor.h"
23#include "TString.h"
24#include "TGLabel.h"
25#include "TClass.h"
26#include "TGTab.h"
27#include "TGComboBox.h"
28#include "TError.h"
29
30#include "TGLViewerEditor.h"
31#include "TGLViewer.h"
32#include "TGLLightSetEditor.h"
33#include "TGLClipSetEditor.h"
34#include "TGLUtil.h"
35#include "TGLCameraOverlay.h"
36#include "TGLAutoRotator.h"
37
38/** \class TGLViewerEditor
39\ingroup opengl
40GUI editor for TGLViewer.
41*/
42
43namespace {
44
45void SetLabeledNEntryState(TGNumberEntry *entry, Bool_t enabled);
46
47}
48
50
52 TGedFrame(p, width, height, options | kVerticalFrame, back),
53 fGuidesFrame(0),
54 fClipFrame(0),
55 fClearColor(0),
56 fIgnoreSizesOnUpdate(0),
57 fResetCamerasOnUpdate(0),
58 fUpdateScene(0),
59 fCameraHome(0),
60 fMaxSceneDrawTimeHQ(0),
61 fMaxSceneDrawTimeLQ(0),
62 fPointSizeScale(0), fLineWidthScale(0),
63 fPointSmooth(0), fLineSmooth(0),
64 fWFLineWidth(0), fOLLineWidth(0),
65
66 fCameraCenterExt(0),
67 fCaptureCenter(0),
68 fCameraCenterX(0),
69 fCameraCenterY(0),
70 fCameraCenterZ(0),
71 fCaptureAnnotate(),
72 fAxesType(0),
73 fAxesContainer(0),
74 fAxesNone(0),
75 fAxesEdge(0),
76 fAxesOrigin(0),
77 fAxesDepthTest(0),
78 fRefContainer(0),
79 fReferenceOn(0),
80 fReferencePosX(0),
81 fReferencePosY(0),
82 fReferencePosZ(0),
83 fCamContainer(0),
84 fCamMode(0),
85 fCamOverlayOn(0),
86 fClipSet(0),
87 fARotDt(0), fARotWPhi(0), fARotATheta(0), fARotWTheta(0), fARotADolly(0), fARotWDolly(0),
88 fASavImageGUIBaseName(0), fASavImageGUIOutMode(0),
89 fStereoZeroParallax(0), fStereoEyeOffsetFac(0), fStereoFrustumAsymFac(0),
90 fViewer(0),
91 fIsInPad(kTRUE)
92{
93 // Constructor.
94
99}
100
101//______________________________________________________________________________
102
104{
105 // Destructor.
106
107}
108
109////////////////////////////////////////////////////////////////////////////////
110/// Connect signals to slots.
111
113{
114 fClearColor->Connect("ColorSelected(Pixel_t)", "TGLViewerEditor", this, "DoClearColor(Pixel_t)");
115 fIgnoreSizesOnUpdate->Connect("Toggled(Bool_t)", "TGLViewerEditor", this, "DoIgnoreSizesOnUpdate()");
116 fResetCamerasOnUpdate->Connect("Toggled(Bool_t)", "TGLViewerEditor", this, "DoResetCamerasOnUpdate()");
117 fUpdateScene->Connect("Pressed()", "TGLViewerEditor", this, "DoUpdateScene()");
118 fCameraHome->Connect("Pressed()", "TGLViewerEditor", this, "DoCameraHome()");
119 fMaxSceneDrawTimeHQ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateMaxDrawTimes()");
120 fMaxSceneDrawTimeLQ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateMaxDrawTimes()");
121 fPointSizeScale->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdatePointLineStuff()");
122 fLineWidthScale->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdatePointLineStuff()");
123 fPointSmooth->Connect("Clicked()", "TGLViewerEditor", this, "UpdatePointLineStuff()");
124 fLineSmooth ->Connect("Clicked()", "TGLViewerEditor", this, "UpdatePointLineStuff()");
125 fWFLineWidth->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdatePointLineStuff()");
126 fOLLineWidth->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdatePointLineStuff()");
127
128 fCameraCenterExt->Connect("Clicked()", "TGLViewerEditor", this, "DoCameraCenterExt()");
129 fCaptureCenter->Connect("Clicked()", "TGLViewerEditor", this, "DoCaptureCenter()");
130 fDrawCameraCenter->Connect("Clicked()", "TGLViewerEditor", this, "DoDrawCameraCenter()");
131 fCameraCenterX->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateCameraCenter()");
132 fCameraCenterY->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateCameraCenter()");
133 fCameraCenterZ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateCameraCenter()");
134
135 fCaptureAnnotate->Connect("Clicked()", "TGLViewerEditor", this, "DoAnnotation()");
136
137 fAxesContainer->Connect("Clicked(Int_t)", "TGLViewerEditor", this, "UpdateViewerAxes(Int_t)");
138
139 fReferenceOn->Connect("Clicked()", "TGLViewerEditor", this, "UpdateViewerReference()");
140 fReferencePosX->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateViewerReference()");
141 fReferencePosY->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateViewerReference()");
142 fReferencePosZ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateViewerReference()");
143
144 fCamMode->Connect("Selected(Int_t)", "TGLViewerEditor", this, "DoCameraOverlay()");
145 fCamOverlayOn->Connect("Clicked()", "TGLViewerEditor", this, "DoCameraOverlay()");
146
147 //
148 fRotateSceneOn->Connect("Clicked()", "TGLViewerEditor", this, "SetRotatorMode()");
149
150 fSceneRotDt->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateRotator()");
151 fARotDt ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateRotator()");
152 fARotWPhi ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateRotator()");
153 fARotATheta->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateRotator()");
154 fARotWTheta->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateRotator()");
155 fARotADolly->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateRotator()");
156 fARotWDolly->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateRotator()");
157
158 fASavImageGUIBaseName->Connect("TextChanged(char*", "TGLViewerEditor", this, "DoASavImageGUIBaseName(char*)");
159 fASavImageGUIOutMode->Connect("Clicked(Int_t)", "TGLViewerEditor", this, "DoASavImageGUIOutMode(Int_t)");
160
161 fStereoZeroParallax ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateStereo()");
162 fStereoEyeOffsetFac ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateStereo()");
163 fStereoFrustumAsymFac->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateStereo()");
164 fStereoZeroParallax ->Connect("ValueChanged(Long_t)", "TGLViewerEditor", this, "UpdateStereo()");
165 fStereoEyeOffsetFac ->Connect("ValueChanged(Long_t)", "TGLViewerEditor", this, "UpdateStereo()");
166 fStereoFrustumAsymFac->Connect("ValueChanged(Long_t)", "TGLViewerEditor", this, "UpdateStereo()");
167
168 fInit = kFALSE;
169}
170
171////////////////////////////////////////////////////////////////////////////////
172/// Initiate redraw of the viewer.
173
175{
176 if (gGLManager && fIsInPad)
177 gGLManager->MarkForDirectCopy(fViewer->GetDev(), kTRUE);
179}
180
181////////////////////////////////////////////////////////////////////////////////
182/// Sets model or disables/hides viewer.
183
185{
186 fViewer = 0;
187
188 fViewer = static_cast<TGLViewer *>(obj);
189 fIsInPad = (fViewer->GetDev() != -1);
190
191 SetGuides();
192
193 if (fInit)
195
198
199 // style tab
212 //camera look at
216 Double_t* la = cam.GetCenterVec();
223
224 // push action
227
228 {
230
231 fSceneRotDt->SetNumber(r->GetDeltaPhi());
232 fARotDt ->SetNumber(r->GetDt());
233 fARotWPhi ->SetNumber(r->GetWPhi());
234 fARotATheta->SetNumber(r->GetATheta());
235 fARotWTheta->SetNumber(r->GetWTheta());
236 fARotADolly->SetNumber(r->GetADolly());
237 fARotWDolly->SetNumber(r->GetWDolly());
238
239 fASavImageGUIBaseName->SetText(r->GetImageGUIBaseName());
240 fASavImageGUIOutMode ->SetButton(r->GetImageGUIOutMode());
241
242 Bool_t rotate_standard = ! fViewer->GetAutoRotator()->GetRotateScene();
243 fRotateSceneOn->SetState(rotate_standard ? kButtonUp : kButtonDown);
244 SetLabeledNEntryState(fSceneRotDt, ! rotate_standard);
245 SetLabeledNEntryState(fARotDt, rotate_standard);
246 SetLabeledNEntryState(fARotWPhi, rotate_standard);
247 SetLabeledNEntryState(fARotATheta, rotate_standard);
248 SetLabeledNEntryState(fARotWTheta, rotate_standard);
249 SetLabeledNEntryState(fARotADolly, rotate_standard);
250 SetLabeledNEntryState(fARotWDolly, rotate_standard);
251 }
252
253 if (fViewer->GetStereo())
254 {
259 }
260 else
261 {
263 }
264}
265
266////////////////////////////////////////////////////////////////////////////////
267/// Clear-color was changed.
268
270{
272 ViewerRedraw();
273}
274
275////////////////////////////////////////////////////////////////////////////////
276/// ResetCamerasOnUpdate was toggled.
277
279{
283}
284
285////////////////////////////////////////////////////////////////////////////////
286/// ResetCamerasOnUpdate was toggled.
287
289{
291}
292
293////////////////////////////////////////////////////////////////////////////////
294/// UpdateScene was clicked.
295
297{
299}
300
301////////////////////////////////////////////////////////////////////////////////
302/// CameraHome was clicked.
303
305{
307 ViewerRedraw();
308}
309
310////////////////////////////////////////////////////////////////////////////////
311/// Slot for fMaxSceneDrawTimeHQ and fMaxSceneDrawTimeLQ.
312
314{
317}
318
319////////////////////////////////////////////////////////////////////////////////
320/// Slot for point-sizes and line-widths.
321
323{
330 ViewerRedraw();
331}
332
333////////////////////////////////////////////////////////////////////////////////
334/// Update viewer with GUI state.
335
337{
339
341 {
344 }
345 else
346 {
349 }
350 ViewerRedraw();
351}
352
353////////////////////////////////////////////////////////////////////////////////
354/// Set external camera center.
355
357{
360
364
365 ViewerRedraw();
366}
367
368////////////////////////////////////////////////////////////////////////////////
369/// Capture camera-center via picking.
370
372{
374 ViewerRedraw();
375}
376
377////////////////////////////////////////////////////////////////////////////////
378/// Draw camera center.
379
381{
383 ViewerRedraw();
384}
385
386////////////////////////////////////////////////////////////////////////////////
387/// Update current camera with GUI state.
388
390{
393 ViewerRedraw();
394}
395
396////////////////////////////////////////////////////////////////////////////////
397/// Create annotation via picking.
398
400{
402}
403
404////////////////////////////////////////////////////////////////////////////////
405/// Update viewer with GUI state.
406
408{
409 if(id < 4)
410 {
411 fAxesType = id -1;
412 for (Int_t i = 1; i < 4; i++) {
413 TGButton * button = fAxesContainer->GetButton(i);
414 if (i == id)
415 button->SetDown(kTRUE);
416 else
417 button->SetDown(kFALSE);
418 }
419 }
424}
425
426////////////////////////////////////////////////////////////////////////////////
427/// Update viewer with GUI state.
428
430{
434}
435
436////////////////////////////////////////////////////////////////////////////////
437/// Helper function to create fixed width TGLabel and TGNumberEntry in same row.
438
440 Int_t labelw,Int_t nd, Int_t style)
441{
443 TGHorizontalFrame *labfr = new TGHorizontalFrame(rfr, labelw, 20, kFixedSize);
444 TGLabel *lab = new TGLabel(labfr, name);
445 labfr->AddFrame(lab, new TGLayoutHints(kLHintsLeft | kLHintsBottom, 0, 0, 0) );
446 rfr->AddFrame(labfr, new TGLayoutHints(kLHintsLeft | kLHintsBottom, 0, 0, 0));
447
448 TGNumberEntry* ne = new TGNumberEntry(rfr, 0.0f, nd, -1, (TGNumberFormat::EStyle)style);
450
451 p->AddFrame(rfr, new TGLayoutHints(kLHintsLeft, 0, 0, 1, 0));
452 return ne;
453}
454
455////////////////////////////////////////////////////////////////////////////////
456/// Creates "Style" tab.
457
459{
460 MakeTitle("Update behaviour");
461 fIgnoreSizesOnUpdate = new TGCheckButton(this, "Ignore sizes");
462 fIgnoreSizesOnUpdate->SetToolTipText("Ignore bounding-box sizes on scene update");
464 fResetCamerasOnUpdate = new TGCheckButton(this, "Reset on update");
465 fResetCamerasOnUpdate->SetToolTipText("Reset camera on scene update");
467
468 TGCompositeFrame* af = this;
469 fUpdateScene = new TGTextButton(af, "Update Scene", 130);
471 fCameraHome = new TGTextButton(af, "Camera Home", 130);
473 fMaxSceneDrawTimeHQ = MakeLabeledNEntry(af, "Max HQ draw time:", 120, 6, TGNumberFormat::kNESInteger);
475 fMaxSceneDrawTimeHQ->GetNumberEntry()->SetToolTipText("Maximum time spent in scene drawing\nin high-quality mode [ms].");
476 fMaxSceneDrawTimeLQ = MakeLabeledNEntry(af, "Max LQ draw time:", 120, 6, TGNumberFormat::kNESInteger);
478 fMaxSceneDrawTimeLQ->GetNumberEntry()->SetToolTipText("Maximum time spent in scene drawing\nin low-quality mode (during rotation etc).");
479
480 TGHorizontalFrame* hf = new TGHorizontalFrame(this);
481 TGLabel* lab = new TGLabel(hf, "Clear Color");
482 hf->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 4, 8, 3));
483 fClearColor = new TGColorSelect(hf, 0, -1);
484 hf->AddFrame(fClearColor, new TGLayoutHints(kLHintsLeft, 1, 1, 8, 1));
485 AddFrame(hf, new TGLayoutHints(kLHintsLeft, 2, 1, 1, 1));
486
487 // LightSet
489 fLightSet->Connect("Changed()", "TGLViewerEditor", this, "ViewerRedraw()");
491
492 // Point-sizes / line-widths.
493 hf = new TGHorizontalFrame(af);
494 fPointSizeScale = MakeLabeledNEntry(hf, "Point-size scale:", 116, 4, TGNumberFormat::kNESRealOne);
496 fPointSmooth = new TGCheckButton(hf);
497 fPointSmooth->SetToolTipText("Use smooth points.");
498 hf->AddFrame(fPointSmooth, new TGLayoutHints(kLHintsNormal, 3, 0, 3, 0));
499 af->AddFrame(hf);
500 hf = new TGHorizontalFrame(af);
501 fLineWidthScale = MakeLabeledNEntry(hf, "Line-width scale:", 116, 4, TGNumberFormat::kNESRealOne);
503 fLineSmooth = new TGCheckButton(hf);
504 fLineSmooth->SetToolTipText("Use smooth lines.");
505 hf->AddFrame(fLineSmooth, new TGLayoutHints(kLHintsNormal, 3, 0, 3, 0));
506 af->AddFrame(hf);
507 fWFLineWidth = MakeLabeledNEntry(af, "Wireframe line-width:", 116, 4, TGNumberFormat::kNESRealOne);
509 fOLLineWidth = MakeLabeledNEntry(af, "Outline line-width:", 116, 4, TGNumberFormat::kNESRealOne);
511}
512
513////////////////////////////////////////////////////////////////////////////////
514/// Create "Guides" tab.
515
517{
519
520 // external camera look at point
521 TGGroupFrame* grf = new TGGroupFrame(fGuidesFrame, "Camera center:", kVerticalFrame);
522 fDrawCameraCenter = new TGCheckButton(grf, "Show", 50);
524 fCameraCenterExt = new TGCheckButton(grf, "External", 50);
525 grf->AddFrame(fCameraCenterExt, new TGLayoutHints(kLHintsLeft, 0, 0, 1, 0));
527 Int_t labw = 20;
531 fCaptureCenter = new TGTextButton(grf, " Pick center ");
532 grf->AddFrame(fCaptureCenter, new TGLayoutHints(kLHintsNormal, labw + 2, 0, 2, 0));
533
534 // annotate
535 TGGroupFrame* annf = new TGGroupFrame(fGuidesFrame, "Annotation");
537 fCaptureAnnotate = new TGCheckButton(annf, "Pick annotation");
539
540 // reference container
541 fRefContainer = new TGGroupFrame(fGuidesFrame, "Reference marker");
548
549 // axes
551 fAxesNone = new TGRadioButton(fAxesContainer, "None", 1);
552 fAxesEdge = new TGRadioButton(fAxesContainer, "Edge", 2);
553 fAxesOrigin = new TGRadioButton(fAxesContainer, "Origin", 3);
554 fAxesDepthTest = new TGCheckButton(fAxesContainer, "DepthTest",4);
556
557 // camera overlay
558 fCamContainer = new TGGroupFrame(fGuidesFrame, "Camera overlay");
563 TGLabel* lab = new TGLabel(chf, "Mode");
564 chf->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 4, 1, 2));
565 fCamMode = new TGComboBox(chf);
572 lb->Resize(lb->GetWidth(), 5*18);
573 fCamMode->Resize(90, 20);
574 chf->AddFrame(fCamMode, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
576}
577
578////////////////////////////////////////////////////////////////////////////////
579/// Create GUI controls - clip type (none/plane/box) and plane/box properties.
580
582{
584
586 fClipSet->Connect("Changed()", "TGLViewerEditor", this, "ViewerRedraw()");
588}
589
590////////////////////////////////////////////////////////////////////////////////
591/// Create Extra Tab controls - camera rotator and stereo.
592
594{
595 Int_t labw = 80;
596
597 TGCompositeFrame *tab = CreateEditorTabSubFrame("Extras"), *p = 0;
598
599 // ----- Auto rotator -----
600
601 p = new TGGroupFrame(tab, "Auto rotator", kVerticalFrame);
602
603 //
604 fRotateSceneOn = new TGCheckButton(p, "Rotate all objects");
605 fRotateSceneOn->SetToolTipText("This covers a very specific use-case and is most likely not what you need.\nProceed at your own risk. Sorry about that.");
606 p->AddFrame(fRotateSceneOn, new TGLayoutHints(kLHintsLeft, 4, 1, 1, 1));
607
610
613
614 fARotWPhi = MakeLabeledNEntry(p, "Omega Phi:", labw, 5, TGNumberFormat::kNESRealTwo);
616
619
620 fARotWTheta = MakeLabeledNEntry(p, "Omega Theta:", labw, 5, TGNumberFormat::kNESRealTwo);
622
625
626 fARotWDolly = MakeLabeledNEntry(p, "Omega Dolly:", labw, 5, TGNumberFormat::kNESRealTwo);
628
629 {
631
632 TGTextButton *b = new TGTextButton(l, "Start");
633 b->Connect("Clicked()", "TGLViewerEditor", this, "DoRotatorStart()");
634 l->AddFrame(b, new TGLayoutHints(kLHintsLeft | kLHintsExpandX));
635
636 b = new TGTextButton(l, "Stop");
637 b->Connect("Clicked()", "TGLViewerEditor", this, "DoRotatorStop()");
638 l->AddFrame(b, new TGLayoutHints(kLHintsLeft | kLHintsExpandX));
639
640 p->AddFrame(l, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 4, 0));
641 }
642
644
645 // ----- Auto Save Images -----
646
647 p = new TGGroupFrame(tab, "Auto save images", kVerticalFrame);
648
651 p->AddFrame(fASavImageGUIBaseName, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 4, 0));
652
655 new TGRadioButton(fASavImageGUIOutMode, "PNG set ");
658
659 {
661
662 TGTextButton *b = new TGTextButton(l, "Start");
663 b->Connect("Clicked()", "TGLViewerEditor", this, "DoASavImageStart()");
664 l->AddFrame(b, new TGLayoutHints(kLHintsLeft | kLHintsExpandX));
665
666 b = new TGTextButton(l, "Stop");
667 b->Connect("Clicked()", "TGLViewerEditor", this, "DoASavImageStop()");
668 l->AddFrame(b, new TGLayoutHints(kLHintsLeft | kLHintsExpandX));
669
670 p->AddFrame(l, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 4, 0));
671 }
672
674
675 // ----- Stereo -----
676
677 fStereoFrame = p = new TGGroupFrame(tab, "Stereo", kVerticalFrame);
678
679 // Int_t labw = 80;
680
683
686
689
691}
692
693
694////////////////////////////////////////////////////////////////////////////////
695/// Enable/disable reference position (x/y/z) number edits based on
696/// reference check box.
697
699{
703}
704
705////////////////////////////////////////////////////////////////////////////////
706/// Configuration of guides GUI called from SetModel().
707
709{
710 Bool_t axesDepthTest = kFALSE;
711 Bool_t referenceOn = kFALSE;
712 Double_t referencePos[3] = {0.};
713 fViewer->GetGuideState(fAxesType, axesDepthTest, referenceOn, referencePos);
714
715 for (Int_t i = 1; i < 4; i++) {
717 if (fAxesType+1 == i)
718 btn->SetDown(kTRUE);
719 else
720 btn->SetDown(kFALSE);
721 }
722 fAxesContainer->GetButton(4)->SetOn(axesDepthTest, kFALSE);
723
724 fReferenceOn->SetDown(referenceOn);
725 fReferencePosX->SetNumber(referencePos[0]);
726 fReferencePosY->SetNumber(referencePos[1]);
727 fReferencePosZ->SetNumber(referencePos[2]);
729
730 // overlay
733
735 {
737 fr->ShowFrame(fCamMode);
738
739
740 if (! fr->IsMapped()) {
741 fr->MapSubwindows();
742 fr->MapWindow();
746 }
747 }
748 else
749 {
751
752 // only mode implemented for perspective camera
754 fr->HideFrame(fCamMode);
755 if (fr->IsMapped())
756 fr->UnmapWindow();
757 }
758}
759
760////////////////////////////////////////////////////////////////////////////////
761
763{
764 if (TGLAutoRotator * const r = fViewer->GetAutoRotator()) {
765 r->Stop();
766
767 if (fRotateSceneOn->IsOn()) {
768 r->SetDeltaPhi(fSceneRotDt->GetNumber());
769
770 SetLabeledNEntryState(fSceneRotDt, kTRUE);
771 SetLabeledNEntryState(fARotDt, kFALSE);
772 SetLabeledNEntryState(fARotWPhi, kFALSE);
773 SetLabeledNEntryState(fARotATheta, kFALSE);
774 SetLabeledNEntryState(fARotWTheta, kFALSE);
775 SetLabeledNEntryState(fARotADolly, kFALSE);
776 SetLabeledNEntryState(fARotWDolly, kFALSE);
777 } else {
778 SetLabeledNEntryState(fSceneRotDt, kFALSE);
779 SetLabeledNEntryState(fARotDt, kTRUE);
780 SetLabeledNEntryState(fARotWPhi, kTRUE);
781 SetLabeledNEntryState(fARotATheta, kTRUE);
782 SetLabeledNEntryState(fARotWTheta, kTRUE);
783 SetLabeledNEntryState(fARotADolly, kTRUE);
784 SetLabeledNEntryState(fARotWDolly, kTRUE);
785 }
786
787 r->SetRotateScene(fRotateSceneOn->IsOn());
788 }
789}
790
791////////////////////////////////////////////////////////////////////////////////
792/// Update rotator related variables.
793
795{
797 if (fRotateSceneOn->IsOn()) {
798 r->SetDeltaPhi(fSceneRotDt->GetNumber());
799 } else {
800 r->SetDt (fARotDt->GetNumber());
801 r->SetWPhi (fARotWPhi->GetNumber());
802 r->SetATheta(fARotATheta->GetNumber());
803 r->SetWTheta(fARotWTheta->GetNumber());
804 r->SetADolly(fARotADolly->GetNumber());
805 r->SetWDolly(fARotWDolly->GetNumber());
806 }
807}
808
809////////////////////////////////////////////////////////////////////////////////
810/// Start auto-rotator.
811
813{
815 if (!r->IsRunning())
816 r->SetRotateScene(fRotateSceneOn->IsOn());
817
818 r->Start();
819}
820
821////////////////////////////////////////////////////////////////////////////////
822/// Stop auto-rotator.
823
825{
827}
828
829////////////////////////////////////////////////////////////////////////////////
830/// Update base-name.
831
833{
835 r->SetImageGUIBaseName(t);
836}
837
838////////////////////////////////////////////////////////////////////////////////
839/// Update output mode.
840
842{
844 r->SetImageGUIOutMode(m);
845}
846
847////////////////////////////////////////////////////////////////////////////////
848/// Start auto-rotator image auto-save.
849
851{
853 if (r->GetImageAutoSave())
854 {
855 Warning("DoASavImageStart", "AutoSave in progress.");
856 return;
857 }
858
859 r->StartImageAutoSaveWithGUISettings();
860}
861
862////////////////////////////////////////////////////////////////////////////////
863/// Stop auto-rotator image auto-save.
864
866{
868 if (!r->GetImageAutoSave())
869 {
870 Warning("DoASavImageStop", "AutoSave not in progress.");
871 return;
872 }
873
874 r->StopImageAutoSave();
875}
876
877////////////////////////////////////////////////////////////////////////////////
878/// Update stereo related variables.
879
881{
885 ViewerRedraw();
886}
887
888//Aux. functions that do not have to be members.
889
890namespace {
891
892//Here's how we create a number entry and its label:
893
894// TGHorizontalFrame *rfr = new TGHorizontalFrame(p);
895// TGHorizontalFrame *labfr = new TGHorizontalFrame(rfr, labelw, 20, kFixedSize);
896// TGLabel *lab = new TGLabel(labfr, name);
897// labfr->AddFrame(lab, new TGLayoutHints(kLHintsLeft | kLHintsBottom, 0, 0, 0) );
898// rfr->AddFrame(labfr, new TGLayoutHints(kLHintsLeft | kLHintsBottom, 0, 0, 0));
899//
900// TGNumberEntry* ne = new TGNumberEntry(rfr, 0.0f, nd, -1, (TGNumberFormat::EStyle)style);
901// rfr->AddFrame(ne, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsBottom, 2, 0, 0));
902//
903// p->AddFrame(rfr, new TGLayoutHints(kLHintsLeft, 0, 0, 1, 0));
904
905////////////////////////////////////////////////////////////////////////////////
906
907TGLabel *FindLabelForNEntry(TGNumberEntry *entry)
908{
909 if (!entry) {
910 //I would prefer an assert here.
911 ::Error("FindLabelForNEntry", "parameter 'entry' is null");
912 return 0;
913 }
914
915 TGLabel *label = 0;
916
917 if (const TGHorizontalFrame * const grandpa = dynamic_cast<const TGHorizontalFrame *>(entry->GetParent())) {
918 if (TList * const parents = grandpa->GetList()) {
919 TIter next1(parents);
920 while (TGFrameElement * const frameElement = dynamic_cast<TGFrameElement *>(next1())) {
921 if (TGHorizontalFrame * const parent = dynamic_cast<TGHorizontalFrame *>(frameElement->fFrame)) {
922 if (TList * const children = parent->GetList()) {
923 TIter next2(children);
924 while (TGFrameElement * const candidate = dynamic_cast<TGFrameElement *>(next2())) {
925 if ((label = dynamic_cast<TGLabel *>(candidate->fFrame)))
926 break;
927 }
928 }
929 }
930
931 if (label)
932 break;
933 }
934 }
935 }
936
937 return label;
938}
939
940////////////////////////////////////////////////////////////////////////////////
941///This is quite an ugly hack but still not as ugly as having 5-6 additional
942///TGLabels as data members.
943
944void SetLabeledNEntryState(TGNumberEntry *entry, Bool_t enabled)
945{
946 if (!entry) {
947 //I would prefer an assert here.
948 ::Error("SetLabeledNEntryState", "parameter 'entry' is null");
949 return;
950 }
951
952 entry->SetState(enabled);
953 if (TGLabel * const label = FindLabelForNEntry(entry))
954 //Wah!
955 label->Disable(!enabled);
956}
957
958}
@ kChildFrame
Definition: GuiTypes.h:379
@ kVerticalFrame
Definition: GuiTypes.h:381
@ kHorizontalFrame
Definition: GuiTypes.h:382
@ kFixedSize
Definition: GuiTypes.h:390
ULong_t Pixel_t
Definition: GuiTypes.h:39
ROOT::R::TRInterface & r
Definition: Object.C:4
#define b(i)
Definition: RSha256.hxx:100
const Bool_t kFALSE
Definition: RtypesCore.h:90
bool Bool_t
Definition: RtypesCore.h:61
double Double_t
Definition: RtypesCore.h:57
short Color_t
Definition: RtypesCore.h:81
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
void Error(const char *location, const char *msgfmt,...)
@ kButtonDown
Definition: TGButton.h:54
@ kButtonUp
Definition: TGButton.h:53
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsNormal
Definition: TGLayout.h:39
@ kLHintsCenterX
Definition: TGLayout.h:32
@ kLHintsBottom
Definition: TGLayout.h:36
@ kLHintsTop
Definition: TGLayout.h:34
@ kLHintsExpandX
Definition: TGLayout.h:37
char name[80]
Definition: TGX11.cxx:109
#define gGLManager
Definition: TVirtualGL.h:162
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition: TColor.cxx:2016
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition: TColor.cxx:1769
virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button=0)
Set layout hints for the specified button or if button=0 for all buttons.
virtual void SetButton(Int_t id, Bool_t down=kTRUE)
Sets the button with id to be on/down, and if this is an exclusive group, all other button in the gro...
virtual TGButton * GetButton(Int_t id) const
Definition: TGButtonGroup.h:93
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:397
virtual void SetOn(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition: TGButton.h:120
virtual void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition: TGButton.cxx:262
virtual Bool_t IsDown() const
Definition: TGButton.cxx:253
virtual Bool_t IsOn() const
Definition: TGButton.h:311
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1202
virtual Bool_t IsDown() const
Definition: TGButton.h:312
void SetColor(Pixel_t color, Bool_t emit=kTRUE)
Set color.
void Enable(Bool_t on=kTRUE)
Set state of widget as enabled.
virtual Int_t GetSelected() const
Definition: TGComboBox.h:134
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:106
virtual TGListBox * GetListBox() const
Definition: TGComboBox.h:130
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
Definition: TGComboBox.cxx:451
virtual TList * GetList() const
Definition: TGFrame.h:347
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1101
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1148
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition: TGFrame.cxx:1188
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1174
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:589
virtual void MapWindow()
map window
Definition: TGFrame.h:229
UInt_t GetWidth() const
Definition: TGFrame.h:249
virtual void UnmapWindow()
unmap window
Definition: TGFrame.h:231
Automatically rotates GL camera.
void Stop()
Stop the auto-rotator.
Bool_t GetRotateScene() const
A GL overlay element which displays camera furstum.
void SetShowPerspective(Bool_t x)
Int_t GetPerspectiveMode() const
void SetShowOrthographic(Bool_t x)
Int_t GetOrthographicMode() const
Bool_t GetShowPerspective() const
Bool_t GetShowOrthographic() const
void SetPerspectiveMode(EMode m)
void SetOrthographicMode(EMode m)
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Definition: TGLCamera.h:43
virtual Bool_t IsPerspective() const
Definition: TGLCamera.h:118
Double_t * GetCenterVec()
Definition: TGLCamera.h:156
Bool_t GetExternalCenter()
Definition: TGLCamera.h:152
void SetExternalCenter(Bool_t x)
Set camera center diffrent than scene center, if enable is kTRUE.
Definition: TGLCamera.cxx:825
void SetCenterVec(Double_t x, Double_t y, Double_t z)
Set camera center vector.
Definition: TGLCamera.cxx:847
virtual Bool_t IsOrthographic() const
Definition: TGLCamera.h:117
GUI sub-editor for TGLClipSet.
void SetModel(TGLClipSet *m)
Set model object.
TGLColor & Background()
Definition: TGLUtil.h:850
void SetColor(Int_t r, Int_t g, Int_t b, Int_t a=255)
Set color with Int_t values.
Definition: TGLUtil.cxx:1236
Color_t GetColorIndex() const
Returns color-index representing the color.
Definition: TGLUtil.cxx:1218
Sub-editor for TGLLightSet.
void SetModel(TGLLightSet *m)
New model was set, refresh data.
TGLColorSet & ColorSet()
Return reference to current color-set (top of the stack).
Definition: TGLRnrCtx.cxx:278
void SetOLLineW(Float_t w)
Float_t OLLineW() const
Float_t WFLineW() const
TGLRnrCtx & RnrCtx() const
void SetWFLineW(Float_t w)
GUI editor for TGLViewer.
TGButtonGroup * fAxesContainer
void DoDrawCameraCenter()
Draw camera center.
void DoUpdateScene()
UpdateScene was clicked.
TGCompositeFrame * fGuidesFrame
void DoCameraHome()
CameraHome was clicked.
void DoCaptureCenter()
Capture camera-center via picking.
void DoCameraCenterExt()
Set external camera center.
void DoASavImageGUIBaseName(const char *t)
Update base-name.
TGLLightSetSubEditor * fLightSet
static TGNumberEntry * MakeLabeledNEntry(TGCompositeFrame *p, const char *name, Int_t labelw, Int_t nd=7, Int_t s=5)
Helper function to create fixed width TGLabel and TGNumberEntry in same row.
void UpdateCameraCenter()
Update current camera with GUI state.
TGLViewer * fViewer
TGNumberEntry * fPointSizeScale
void DoClearColor(Pixel_t color)
Clear-color was changed.
void UpdatePointLineStuff()
Slot for point-sizes and line-widths.
TGCompositeFrame * fClipFrame
TGCheckButton * fPointSmooth
TGCheckButton * fReferenceOn
TGComboBox * fCamMode
TGNumberEntry * fARotWDolly
TGNumberEntry * fCameraCenterY
void SetGuides()
Configuration of guides GUI called from SetModel().
void DoRotatorStart()
Start auto-rotator.
TGNumberEntry * fStereoEyeOffsetFac
void UpdateViewerReference()
Update viewer with GUI state.
void CreateClippingTab()
Create GUI controls - clip type (none/plane/box) and plane/box properties.
TGCheckButton * fLineSmooth
TGNumberEntry * fMaxSceneDrawTimeLQ
TGCheckButton * fRotateSceneOn
void DoRotatorStop()
Stop auto-rotator.
TGNumberEntry * fARotATheta
TGCheckButton * fDrawCameraCenter
TGNumberEntry * fSceneRotDt
void UpdateStereo()
Update stereo related variables.
void UpdateMaxDrawTimes()
Slot for fMaxSceneDrawTimeHQ and fMaxSceneDrawTimeLQ.
TGNumberEntry * fReferencePosY
TGGroupFrame * fRefContainer
void UpdateReferencePosState()
Enable/disable reference position (x/y/z) number edits based on reference check box.
TGCheckButton * fResetCamerasOnUpdate
TGLClipSetSubEditor * fClipSet
TGCheckButton * fIgnoreSizesOnUpdate
TGCheckButton * fCameraCenterExt
TGNumberEntry * fCameraCenterX
TGNumberEntry * fReferencePosZ
TGRadioButton * fAxesEdge
virtual void SetModel(TObject *obj)
Sets model or disables/hides viewer.
TGNumberEntry * fCameraCenterZ
void DoIgnoreSizesOnUpdate()
ResetCamerasOnUpdate was toggled.
void DoASavImageGUIOutMode(Int_t m)
Update output mode.
TGNumberEntry * fARotADolly
TGLViewerEditor(const TGLViewerEditor &)
TGCheckButton * fCamOverlayOn
TGTextButton * fUpdateScene
void CreateExtrasTab()
Create Extra Tab controls - camera rotator and stereo.
TGCompositeFrame * fStereoFrame
void DoASavImageStop()
Stop auto-rotator image auto-save.
void CreateGuidesTab()
Create "Guides" tab.
void CreateStyleTab()
Creates "Style" tab.
TGButtonGroup * fASavImageGUIOutMode
TGNumberEntry * fReferencePosX
TGRadioButton * fAxesOrigin
void DoAnnotation()
Create annotation via picking.
virtual void ViewerRedraw()
Initiate redraw of the viewer.
TGNumberEntry * fOLLineWidth
TGNumberEntry * fARotWPhi
TGRadioButton * fAxesNone
void DoCameraOverlay()
Update viewer with GUI state.
TGColorSelect * fClearColor
TGNumberEntry * fARotDt
TGNumberEntry * fMaxSceneDrawTimeHQ
TGCheckButton * fCaptureAnnotate
TGNumberEntry * fWFLineWidth
void DoASavImageStart()
Start auto-rotator image auto-save.
void DoResetCamerasOnUpdate()
ResetCamerasOnUpdate was toggled.
TGGroupFrame * fCamContainer
TGNumberEntry * fStereoFrustumAsymFac
TGTextButton * fCameraHome
TGNumberEntry * fARotWTheta
void UpdateViewerAxes(Int_t id)
Update viewer with GUI state.
TGNumberEntry * fLineWidthScale
TGCheckButton * fAxesDepthTest
TGTextEntry * fASavImageGUIBaseName
TGNumberEntry * fStereoZeroParallax
void UpdateRotator()
Update rotator related variables.
void ConnectSignals2Slots()
Connect signals to slots.
TGTextButton * fCaptureCenter
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:57
void SetDrawCameraCenter(Bool_t x)
Draw camera look at and rotation point.
Definition: TGLViewer.cxx:2074
void SetMaxSceneDrawTimeLQ(Float_t t)
Definition: TGLViewer.h:312
void SetStereoFrustumAsymFac(Float_t f)
Definition: TGLViewer.h:297
Float_t GetStereoEyeOffsetFac() const
Definition: TGLViewer.h:291
EPushAction GetPushAction() const
Definition: TGLViewer.h:300
Bool_t GetSmoothPoints() const
Definition: TGLViewer.h:258
TGLCameraOverlay * GetCameraOverlay() const
Definition: TGLViewer.h:283
Bool_t GetSmoothLines() const
Definition: TGLViewer.h:259
Int_t GetDev() const
Definition: TGLViewer.h:230
Float_t GetStereoZeroParallax() const
Definition: TGLViewer.h:290
Float_t GetMaxSceneDrawTimeLQ() const
Definition: TGLViewer.h:310
Bool_t GetDrawCameraCenter()
Definition: TGLViewer.h:280
@ kPushCamCenter
Definition: TGLViewer.h:128
@ kPushAnnotate
Definition: TGLViewer.h:128
Float_t GetPointScale() const
Definition: TGLViewer.h:254
void RequestDraw(Short_t LOD=TGLRnrCtx::kLODMed)
Post request for redraw of viewer at level of detail 'LOD' Request is directed via cross thread gVirt...
Definition: TGLViewer.cxx:438
void SetGuideState(Int_t axesType, Bool_t axesDepthTest, Bool_t referenceOn, const Double_t *referencePos)
Set the state of guides (axes & reference markers) from arguments.
Definition: TGLViewer.cxx:2059
TGLLightSet * GetLightSet() const
Definition: TGLViewer.h:263
void SetIgnoreSizesOnUpdate(Bool_t v)
Definition: TGLViewer.h:357
TGLCamera & CurrentCamera() const
Definition: TGLViewer.h:269
Float_t GetStereoFrustumAsymFac() const
Definition: TGLViewer.h:292
void SetStereoEyeOffsetFac(Float_t f)
Definition: TGLViewer.h:296
TGLClipSet * GetClipSet() const
Definition: TGLViewer.h:264
Bool_t IsUsingDefaultColorSet() const
Check if the viewer is using the default color set.
Definition: TGLViewer.cxx:1663
void SetSmoothPoints(Bool_t s)
Definition: TGLViewer.h:260
void UpdateScene(Bool_t redraw=kTRUE)
Force update of pad-scenes.
Definition: TGLViewer.cxx:336
void SetLineScale(Float_t s)
Definition: TGLViewer.h:257
Bool_t GetStereo() const
Definition: TGLViewer.h:289
void SetMaxSceneDrawTimeHQ(Float_t t)
Definition: TGLViewer.h:311
void SetPointScale(Float_t s)
Definition: TGLViewer.h:256
void SetStereoZeroParallax(Float_t f)
Definition: TGLViewer.h:295
void SetSmoothLines(Bool_t s)
Definition: TGLViewer.h:261
Float_t GetLineScale() const
Definition: TGLViewer.h:255
Bool_t GetIgnoreSizesOnUpdate() const
Definition: TGLViewer.h:356
TGLAutoRotator * GetAutoRotator()
Get the auto-rotator for this viewer.
Definition: TGLViewer.cxx:1999
Bool_t GetResetCamerasOnUpdate() const
Definition: TGLViewer.h:359
void PickCameraCenter()
Definition: TGLViewer.h:281
Float_t GetMaxSceneDrawTimeHQ() const
Definition: TGLViewer.h:309
void GetGuideState(Int_t &axesType, Bool_t &axesDepthTest, Bool_t &referenceOn, Double_t *referencePos) const
Fetch the state of guides (axes & reference markers) into arguments.
Definition: TGLViewer.cxx:2045
void PickAnnotate()
Definition: TGLViewer.h:282
void SetResetCamerasOnUpdate(Bool_t v)
Definition: TGLViewer.h:360
void ResetCurrentCamera()
Resets position/rotation of current camera to default values.
Definition: TGLViewer.cxx:358
virtual void Disable(Bool_t on=kTRUE)
Definition: TGLabel.h:97
virtual void Resize(UInt_t w, UInt_t h)
Resize the listbox widget.
Definition: TGListBox.cxx:1420
virtual void SetNumber(Double_t val)
TGNumberEntryField * GetNumberEntry() const
virtual void SetLimits(ELimit limits=TGNumberFormat::kNELNoLimits, Double_t min=0, Double_t max=1)
virtual void SetState(Bool_t enable=kTRUE)
Set the active state.
virtual Double_t GetNumber() const
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGButton.cxx:870
virtual void SetDefaultSize(UInt_t w, UInt_t h)
Set the default / minimal size of the widget.
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line.
const TGWindow * GetParent() const
Definition: TGWindow.h:84
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:285
virtual TGVerticalFrame * CreateEditorTabSubFrame(const char *name)
Create a vertical frame to be used by 'owner' in extra tab 'name'.
Definition: TGedFrame.cxx:123
Bool_t fInit
Definition: TGedFrame.h:53
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
A doubly linked list.
Definition: TList.h:44
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition: TList.cxx:692
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:877
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition: TQObject.cxx:866
TCanvas * style()
Definition: style.C:1
auto * m
Definition: textangle.C:8
auto * l
Definition: textangle.C:4