Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "TGComboBox.h"
26#include "TError.h"
27
28#include "TGLViewerEditor.h"
29#include "TGLViewer.h"
30#include "TGLLightSetEditor.h"
31#include "TGLClipSetEditor.h"
32#include "TGLUtil.h"
33#include "TGLCameraOverlay.h"
34#include "TGLAutoRotator.h"
35
36/** \class TGLViewerEditor
37\ingroup opengl
38GUI editor for TGLViewer.
39*/
40
41namespace {
42
43void SetLabeledNEntryState(TGNumberEntry *entry, Bool_t enabled);
44
45}
46
48
50 TGedFrame(p, width, height, options | kVerticalFrame, back),
51 fGuidesFrame(0),
52 fClipFrame(0),
53 fClearColor(0),
54 fIgnoreSizesOnUpdate(0),
55 fResetCamerasOnUpdate(0),
56 fUpdateScene(0),
57 fCameraHome(0),
58 fMaxSceneDrawTimeHQ(0),
59 fMaxSceneDrawTimeLQ(0),
60 fPointSizeScale(0), fLineWidthScale(0),
61 fPointSmooth(0), fLineSmooth(0),
62 fWFLineWidth(0), fOLLineWidth(0),
63
64 fCameraCenterExt(0),
65 fCaptureCenter(0),
66 fCameraCenterX(0),
67 fCameraCenterY(0),
68 fCameraCenterZ(0),
69 fCaptureAnnotate(),
70 fAxesType(0),
71 fAxesContainer(0),
72 fAxesNone(0),
73 fAxesEdge(0),
74 fAxesOrigin(0),
75 fAxesDepthTest(0),
76 fRefContainer(0),
77 fReferenceOn(0),
78 fReferencePosX(0),
79 fReferencePosY(0),
80 fReferencePosZ(0),
81 fCamContainer(0),
82 fCamMode(0),
83 fCamOverlayOn(0),
84 fClipSet(0),
85 fARotDt(0), fARotWPhi(0), fARotATheta(0), fARotWTheta(0), fARotADolly(0), fARotWDolly(0),
86 fASavImageGUIBaseName(0), fASavImageGUIOutMode(0),
87 fStereoZeroParallax(0), fStereoEyeOffsetFac(0), fStereoFrustumAsymFac(0),
88 fViewer(0),
89 fIsInPad(kTRUE)
90{
91 // Constructor.
92
97}
98
99//______________________________________________________________________________
100
102{
103 // Destructor.
104
105}
106
107////////////////////////////////////////////////////////////////////////////////
108/// Connect signals to slots.
109
111{
112 fClearColor->Connect("ColorSelected(Pixel_t)", "TGLViewerEditor", this, "DoClearColor(Pixel_t)");
113 fIgnoreSizesOnUpdate->Connect("Toggled(Bool_t)", "TGLViewerEditor", this, "DoIgnoreSizesOnUpdate()");
114 fResetCamerasOnUpdate->Connect("Toggled(Bool_t)", "TGLViewerEditor", this, "DoResetCamerasOnUpdate()");
115 fUpdateScene->Connect("Pressed()", "TGLViewerEditor", this, "DoUpdateScene()");
116 fCameraHome->Connect("Pressed()", "TGLViewerEditor", this, "DoCameraHome()");
117 fMaxSceneDrawTimeHQ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateMaxDrawTimes()");
118 fMaxSceneDrawTimeLQ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateMaxDrawTimes()");
119 fPointSizeScale->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdatePointLineStuff()");
120 fLineWidthScale->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdatePointLineStuff()");
121 fPointSmooth->Connect("Clicked()", "TGLViewerEditor", this, "UpdatePointLineStuff()");
122 fLineSmooth ->Connect("Clicked()", "TGLViewerEditor", this, "UpdatePointLineStuff()");
123 fWFLineWidth->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdatePointLineStuff()");
124 fOLLineWidth->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdatePointLineStuff()");
125
126 fCameraCenterExt->Connect("Clicked()", "TGLViewerEditor", this, "DoCameraCenterExt()");
127 fCaptureCenter->Connect("Clicked()", "TGLViewerEditor", this, "DoCaptureCenter()");
128 fDrawCameraCenter->Connect("Clicked()", "TGLViewerEditor", this, "DoDrawCameraCenter()");
129 fCameraCenterX->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateCameraCenter()");
130 fCameraCenterY->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateCameraCenter()");
131 fCameraCenterZ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateCameraCenter()");
132
133 fCaptureAnnotate->Connect("Clicked()", "TGLViewerEditor", this, "DoAnnotation()");
134
135 fAxesContainer->Connect("Clicked(Int_t)", "TGLViewerEditor", this, "UpdateViewerAxes(Int_t)");
136
137 fReferenceOn->Connect("Clicked()", "TGLViewerEditor", this, "UpdateViewerReference()");
138 fReferencePosX->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateViewerReference()");
139 fReferencePosY->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateViewerReference()");
140 fReferencePosZ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateViewerReference()");
141
142 fCamMode->Connect("Selected(Int_t)", "TGLViewerEditor", this, "DoCameraOverlay()");
143 fCamOverlayOn->Connect("Clicked()", "TGLViewerEditor", this, "DoCameraOverlay()");
144
145 //
146 fRotateSceneOn->Connect("Clicked()", "TGLViewerEditor", this, "SetRotatorMode()");
147
148 fSceneRotDt->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateRotator()");
149 fARotDt ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateRotator()");
150 fARotWPhi ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateRotator()");
151 fARotATheta->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateRotator()");
152 fARotWTheta->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateRotator()");
153 fARotADolly->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateRotator()");
154 fARotWDolly->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateRotator()");
155
156 fASavImageGUIBaseName->Connect("TextChanged(char*", "TGLViewerEditor", this, "DoASavImageGUIBaseName(char*)");
157 fASavImageGUIOutMode->Connect("Clicked(Int_t)", "TGLViewerEditor", this, "DoASavImageGUIOutMode(Int_t)");
158
159 fStereoZeroParallax ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateStereo()");
160 fStereoEyeOffsetFac ->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateStereo()");
161 fStereoFrustumAsymFac->Connect("ValueSet(Long_t)", "TGLViewerEditor", this, "UpdateStereo()");
162 fStereoZeroParallax ->Connect("ValueChanged(Long_t)", "TGLViewerEditor", this, "UpdateStereo()");
163 fStereoEyeOffsetFac ->Connect("ValueChanged(Long_t)", "TGLViewerEditor", this, "UpdateStereo()");
164 fStereoFrustumAsymFac->Connect("ValueChanged(Long_t)", "TGLViewerEditor", this, "UpdateStereo()");
165
166 fInit = kFALSE;
167}
168
169////////////////////////////////////////////////////////////////////////////////
170/// Initiate redraw of the viewer.
171
173{
174 if (gGLManager && fIsInPad)
175 gGLManager->MarkForDirectCopy(fViewer->GetDev(), kTRUE);
177}
178
179////////////////////////////////////////////////////////////////////////////////
180/// Sets model or disables/hides viewer.
181
183{
184 fViewer = 0;
185
186 fViewer = static_cast<TGLViewer *>(obj);
187 fIsInPad = (fViewer->GetDev() != -1);
188
189 SetGuides();
190
191 if (fInit)
193
196
197 // style tab
210 //camera look at
214 Double_t* la = cam.GetCenterVec();
221
222 // push action
225
226 {
228
229 fSceneRotDt->SetNumber(r->GetDeltaPhi());
230 fARotDt ->SetNumber(r->GetDt());
231 fARotWPhi ->SetNumber(r->GetWPhi());
232 fARotATheta->SetNumber(r->GetATheta());
233 fARotWTheta->SetNumber(r->GetWTheta());
234 fARotADolly->SetNumber(r->GetADolly());
235 fARotWDolly->SetNumber(r->GetWDolly());
236
237 fASavImageGUIBaseName->SetText(r->GetImageGUIBaseName());
238 fASavImageGUIOutMode ->SetButton(r->GetImageGUIOutMode());
239
240 Bool_t rotate_standard = ! fViewer->GetAutoRotator()->GetRotateScene();
241 fRotateSceneOn->SetState(rotate_standard ? kButtonUp : kButtonDown);
242 SetLabeledNEntryState(fSceneRotDt, ! rotate_standard);
243 SetLabeledNEntryState(fARotDt, rotate_standard);
244 SetLabeledNEntryState(fARotWPhi, rotate_standard);
245 SetLabeledNEntryState(fARotATheta, rotate_standard);
246 SetLabeledNEntryState(fARotWTheta, rotate_standard);
247 SetLabeledNEntryState(fARotADolly, rotate_standard);
248 SetLabeledNEntryState(fARotWDolly, rotate_standard);
249 }
250
251 if (fViewer->GetStereo())
252 {
257 }
258 else
259 {
261 }
262}
263
264////////////////////////////////////////////////////////////////////////////////
265/// Clear-color was changed.
266
268{
270 ViewerRedraw();
271}
272
273////////////////////////////////////////////////////////////////////////////////
274/// ResetCamerasOnUpdate was toggled.
275
277{
281}
282
283////////////////////////////////////////////////////////////////////////////////
284/// ResetCamerasOnUpdate was toggled.
285
287{
289}
290
291////////////////////////////////////////////////////////////////////////////////
292/// UpdateScene was clicked.
293
295{
297}
298
299////////////////////////////////////////////////////////////////////////////////
300/// CameraHome was clicked.
301
303{
305 ViewerRedraw();
306}
307
308////////////////////////////////////////////////////////////////////////////////
309/// Slot for fMaxSceneDrawTimeHQ and fMaxSceneDrawTimeLQ.
310
312{
315}
316
317////////////////////////////////////////////////////////////////////////////////
318/// Slot for point-sizes and line-widths.
319
321{
328 ViewerRedraw();
329}
330
331////////////////////////////////////////////////////////////////////////////////
332/// Update viewer with GUI state.
333
335{
337
339 {
342 }
343 else
344 {
347 }
348 ViewerRedraw();
349}
350
351////////////////////////////////////////////////////////////////////////////////
352/// Set external camera center.
353
355{
358
362
363 ViewerRedraw();
364}
365
366////////////////////////////////////////////////////////////////////////////////
367/// Capture camera-center via picking.
368
370{
372 ViewerRedraw();
373}
374
375////////////////////////////////////////////////////////////////////////////////
376/// Draw camera center.
377
379{
381 ViewerRedraw();
382}
383
384////////////////////////////////////////////////////////////////////////////////
385/// Update current camera with GUI state.
386
388{
391 ViewerRedraw();
392}
393
394////////////////////////////////////////////////////////////////////////////////
395/// Create annotation via picking.
396
398{
400}
401
402////////////////////////////////////////////////////////////////////////////////
403/// Update viewer with GUI state.
404
406{
407 if(id < 4)
408 {
409 fAxesType = id -1;
410 for (Int_t i = 1; i < 4; i++) {
411 TGButton * button = fAxesContainer->GetButton(i);
412 if (i == id)
413 button->SetDown(kTRUE);
414 else
415 button->SetDown(kFALSE);
416 }
417 }
422}
423
424////////////////////////////////////////////////////////////////////////////////
425/// Update viewer with GUI state.
426
428{
432}
433
434////////////////////////////////////////////////////////////////////////////////
435/// Helper function to create fixed width TGLabel and TGNumberEntry in same row.
436
438 Int_t labelw,Int_t nd, Int_t style)
439{
441 TGHorizontalFrame *labfr = new TGHorizontalFrame(rfr, labelw, 20, kFixedSize);
442 TGLabel *lab = new TGLabel(labfr, name);
443 labfr->AddFrame(lab, new TGLayoutHints(kLHintsLeft | kLHintsBottom, 0, 0, 0) );
444 rfr->AddFrame(labfr, new TGLayoutHints(kLHintsLeft | kLHintsBottom, 0, 0, 0));
445
446 TGNumberEntry* ne = new TGNumberEntry(rfr, 0.0f, nd, -1, (TGNumberFormat::EStyle)style);
448
449 p->AddFrame(rfr, new TGLayoutHints(kLHintsLeft, 0, 0, 1, 0));
450 return ne;
451}
452
453////////////////////////////////////////////////////////////////////////////////
454/// Creates "Style" tab.
455
457{
458 MakeTitle("Update behaviour");
459 fIgnoreSizesOnUpdate = new TGCheckButton(this, "Ignore sizes");
460 fIgnoreSizesOnUpdate->SetToolTipText("Ignore bounding-box sizes on scene update");
462 fResetCamerasOnUpdate = new TGCheckButton(this, "Reset on update");
463 fResetCamerasOnUpdate->SetToolTipText("Reset camera on scene update");
465
466 TGCompositeFrame* af = this;
467 fUpdateScene = new TGTextButton(af, "Update Scene", 130);
469 fCameraHome = new TGTextButton(af, "Camera Home", 130);
471 fMaxSceneDrawTimeHQ = MakeLabeledNEntry(af, "Max HQ draw time:", 120, 6, TGNumberFormat::kNESInteger);
473 fMaxSceneDrawTimeHQ->GetNumberEntry()->SetToolTipText("Maximum time spent in scene drawing\nin high-quality mode [ms].");
474 fMaxSceneDrawTimeLQ = MakeLabeledNEntry(af, "Max LQ draw time:", 120, 6, TGNumberFormat::kNESInteger);
476 fMaxSceneDrawTimeLQ->GetNumberEntry()->SetToolTipText("Maximum time spent in scene drawing\nin low-quality mode (during rotation etc).");
477
478 TGHorizontalFrame* hf = new TGHorizontalFrame(this);
479 TGLabel* lab = new TGLabel(hf, "Clear Color");
480 hf->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 4, 8, 3));
481 fClearColor = new TGColorSelect(hf, 0, -1);
482 hf->AddFrame(fClearColor, new TGLayoutHints(kLHintsLeft, 1, 1, 8, 1));
483 AddFrame(hf, new TGLayoutHints(kLHintsLeft, 2, 1, 1, 1));
484
485 // LightSet
487 fLightSet->Connect("Changed()", "TGLViewerEditor", this, "ViewerRedraw()");
489
490 // Point-sizes / line-widths.
491 hf = new TGHorizontalFrame(af);
492 fPointSizeScale = MakeLabeledNEntry(hf, "Point-size scale:", 116, 4, TGNumberFormat::kNESRealOne);
494 fPointSmooth = new TGCheckButton(hf);
495 fPointSmooth->SetToolTipText("Use smooth points.");
496 hf->AddFrame(fPointSmooth, new TGLayoutHints(kLHintsNormal, 3, 0, 3, 0));
497 af->AddFrame(hf);
498 hf = new TGHorizontalFrame(af);
499 fLineWidthScale = MakeLabeledNEntry(hf, "Line-width scale:", 116, 4, TGNumberFormat::kNESRealOne);
501 fLineSmooth = new TGCheckButton(hf);
502 fLineSmooth->SetToolTipText("Use smooth lines.");
503 hf->AddFrame(fLineSmooth, new TGLayoutHints(kLHintsNormal, 3, 0, 3, 0));
504 af->AddFrame(hf);
505 fWFLineWidth = MakeLabeledNEntry(af, "Wireframe line-width:", 116, 4, TGNumberFormat::kNESRealOne);
507 fOLLineWidth = MakeLabeledNEntry(af, "Outline line-width:", 116, 4, TGNumberFormat::kNESRealOne);
509}
510
511////////////////////////////////////////////////////////////////////////////////
512/// Create "Guides" tab.
513
515{
517
518 // external camera look at point
519 TGGroupFrame* grf = new TGGroupFrame(fGuidesFrame, "Camera center:", kVerticalFrame);
520 fDrawCameraCenter = new TGCheckButton(grf, "Show", 50);
522 fCameraCenterExt = new TGCheckButton(grf, "External", 50);
523 grf->AddFrame(fCameraCenterExt, new TGLayoutHints(kLHintsLeft, 0, 0, 1, 0));
525 Int_t labw = 20;
529 fCaptureCenter = new TGTextButton(grf, " Pick center ");
530 grf->AddFrame(fCaptureCenter, new TGLayoutHints(kLHintsNormal, labw + 2, 0, 2, 0));
531
532 // annotate
533 TGGroupFrame* annf = new TGGroupFrame(fGuidesFrame, "Annotation");
535 fCaptureAnnotate = new TGCheckButton(annf, "Pick annotation");
537
538 // reference container
539 fRefContainer = new TGGroupFrame(fGuidesFrame, "Reference marker");
546
547 // axes
549 fAxesNone = new TGRadioButton(fAxesContainer, "None", 1);
550 fAxesEdge = new TGRadioButton(fAxesContainer, "Edge", 2);
551 fAxesOrigin = new TGRadioButton(fAxesContainer, "Origin", 3);
552 fAxesDepthTest = new TGCheckButton(fAxesContainer, "DepthTest",4);
554
555 // camera overlay
556 fCamContainer = new TGGroupFrame(fGuidesFrame, "Camera overlay");
561 TGLabel* lab = new TGLabel(chf, "Mode");
562 chf->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 4, 1, 2));
563 fCamMode = new TGComboBox(chf);
570 lb->Resize(lb->GetWidth(), 5*18);
571 fCamMode->Resize(90, 20);
572 chf->AddFrame(fCamMode, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
574}
575
576////////////////////////////////////////////////////////////////////////////////
577/// Create GUI controls - clip type (none/plane/box) and plane/box properties.
578
580{
582
584 fClipSet->Connect("Changed()", "TGLViewerEditor", this, "ViewerRedraw()");
586}
587
588////////////////////////////////////////////////////////////////////////////////
589/// Create Extra Tab controls - camera rotator and stereo.
590
592{
593 Int_t labw = 80;
594
595 TGCompositeFrame *tab = CreateEditorTabSubFrame("Extras"), *p = 0;
596
597 // ----- Auto rotator -----
598
599 p = new TGGroupFrame(tab, "Auto rotator", kVerticalFrame);
600
601 //
602 fRotateSceneOn = new TGCheckButton(p, "Rotate all objects");
603 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.");
604 p->AddFrame(fRotateSceneOn, new TGLayoutHints(kLHintsLeft, 4, 1, 1, 1));
605
608
611
612 fARotWPhi = MakeLabeledNEntry(p, "Omega Phi:", labw, 5, TGNumberFormat::kNESRealTwo);
614
617
618 fARotWTheta = MakeLabeledNEntry(p, "Omega Theta:", labw, 5, TGNumberFormat::kNESRealTwo);
620
623
624 fARotWDolly = MakeLabeledNEntry(p, "Omega Dolly:", labw, 5, TGNumberFormat::kNESRealTwo);
626
627 {
629
630 TGTextButton *b = new TGTextButton(l, "Start");
631 b->Connect("Clicked()", "TGLViewerEditor", this, "DoRotatorStart()");
632 l->AddFrame(b, new TGLayoutHints(kLHintsLeft | kLHintsExpandX));
633
634 b = new TGTextButton(l, "Stop");
635 b->Connect("Clicked()", "TGLViewerEditor", this, "DoRotatorStop()");
636 l->AddFrame(b, new TGLayoutHints(kLHintsLeft | kLHintsExpandX));
637
638 p->AddFrame(l, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 4, 0));
639 }
640
642
643 // ----- Auto Save Images -----
644
645 p = new TGGroupFrame(tab, "Auto save images", kVerticalFrame);
646
649 p->AddFrame(fASavImageGUIBaseName, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 4, 0));
650
653 new TGRadioButton(fASavImageGUIOutMode, "PNG set ");
656
657 {
659
660 TGTextButton *b = new TGTextButton(l, "Start");
661 b->Connect("Clicked()", "TGLViewerEditor", this, "DoASavImageStart()");
662 l->AddFrame(b, new TGLayoutHints(kLHintsLeft | kLHintsExpandX));
663
664 b = new TGTextButton(l, "Stop");
665 b->Connect("Clicked()", "TGLViewerEditor", this, "DoASavImageStop()");
666 l->AddFrame(b, new TGLayoutHints(kLHintsLeft | kLHintsExpandX));
667
668 p->AddFrame(l, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 4, 0));
669 }
670
672
673 // ----- Stereo -----
674
675 fStereoFrame = p = new TGGroupFrame(tab, "Stereo", kVerticalFrame);
676
677 // Int_t labw = 80;
678
681
684
687
689}
690
691
692////////////////////////////////////////////////////////////////////////////////
693/// Enable/disable reference position (x/y/z) number edits based on
694/// reference check box.
695
697{
701}
702
703////////////////////////////////////////////////////////////////////////////////
704/// Configuration of guides GUI called from SetModel().
705
707{
708 Bool_t axesDepthTest = kFALSE;
709 Bool_t referenceOn = kFALSE;
710 Double_t referencePos[3] = {0.};
711 fViewer->GetGuideState(fAxesType, axesDepthTest, referenceOn, referencePos);
712
713 for (Int_t i = 1; i < 4; i++) {
715 if (fAxesType+1 == i)
716 btn->SetDown(kTRUE);
717 else
718 btn->SetDown(kFALSE);
719 }
720 fAxesContainer->GetButton(4)->SetOn(axesDepthTest, kFALSE);
721
722 fReferenceOn->SetDown(referenceOn);
723 fReferencePosX->SetNumber(referencePos[0]);
724 fReferencePosY->SetNumber(referencePos[1]);
725 fReferencePosZ->SetNumber(referencePos[2]);
727
728 // overlay
731
733 {
735 fr->ShowFrame(fCamMode);
736
737
738 if (! fr->IsMapped()) {
739 fr->MapSubwindows();
740 fr->MapWindow();
744 }
745 }
746 else
747 {
749
750 // only mode implemented for perspective camera
752 fr->HideFrame(fCamMode);
753 if (fr->IsMapped())
754 fr->UnmapWindow();
755 }
756}
757
758////////////////////////////////////////////////////////////////////////////////
759
761{
762 if (TGLAutoRotator * const r = fViewer->GetAutoRotator()) {
763 r->Stop();
764
765 if (fRotateSceneOn->IsOn()) {
766 r->SetDeltaPhi(fSceneRotDt->GetNumber());
767
768 SetLabeledNEntryState(fSceneRotDt, kTRUE);
769 SetLabeledNEntryState(fARotDt, kFALSE);
770 SetLabeledNEntryState(fARotWPhi, kFALSE);
771 SetLabeledNEntryState(fARotATheta, kFALSE);
772 SetLabeledNEntryState(fARotWTheta, kFALSE);
773 SetLabeledNEntryState(fARotADolly, kFALSE);
774 SetLabeledNEntryState(fARotWDolly, kFALSE);
775 } else {
776 SetLabeledNEntryState(fSceneRotDt, kFALSE);
777 SetLabeledNEntryState(fARotDt, kTRUE);
778 SetLabeledNEntryState(fARotWPhi, kTRUE);
779 SetLabeledNEntryState(fARotATheta, kTRUE);
780 SetLabeledNEntryState(fARotWTheta, kTRUE);
781 SetLabeledNEntryState(fARotADolly, kTRUE);
782 SetLabeledNEntryState(fARotWDolly, kTRUE);
783 }
784
785 r->SetRotateScene(fRotateSceneOn->IsOn());
786 }
787}
788
789////////////////////////////////////////////////////////////////////////////////
790/// Update rotator related variables.
791
793{
795 if (fRotateSceneOn->IsOn()) {
796 r->SetDeltaPhi(fSceneRotDt->GetNumber());
797 } else {
798 r->SetDt (fARotDt->GetNumber());
799 r->SetWPhi (fARotWPhi->GetNumber());
800 r->SetATheta(fARotATheta->GetNumber());
801 r->SetWTheta(fARotWTheta->GetNumber());
802 r->SetADolly(fARotADolly->GetNumber());
803 r->SetWDolly(fARotWDolly->GetNumber());
804 }
805}
806
807////////////////////////////////////////////////////////////////////////////////
808/// Start auto-rotator.
809
811{
813 if (!r->IsRunning())
814 r->SetRotateScene(fRotateSceneOn->IsOn());
815
816 r->Start();
817}
818
819////////////////////////////////////////////////////////////////////////////////
820/// Stop auto-rotator.
821
823{
825}
826
827////////////////////////////////////////////////////////////////////////////////
828/// Update base-name.
829
831{
833 r->SetImageGUIBaseName(t);
834}
835
836////////////////////////////////////////////////////////////////////////////////
837/// Update output mode.
838
840{
842 r->SetImageGUIOutMode(m);
843}
844
845////////////////////////////////////////////////////////////////////////////////
846/// Start auto-rotator image auto-save.
847
849{
851 if (r->GetImageAutoSave())
852 {
853 Warning("DoASavImageStart", "AutoSave in progress.");
854 return;
855 }
856
857 r->StartImageAutoSaveWithGUISettings();
858}
859
860////////////////////////////////////////////////////////////////////////////////
861/// Stop auto-rotator image auto-save.
862
864{
866 if (!r->GetImageAutoSave())
867 {
868 Warning("DoASavImageStop", "AutoSave not in progress.");
869 return;
870 }
871
872 r->StopImageAutoSave();
873}
874
875////////////////////////////////////////////////////////////////////////////////
876/// Update stereo related variables.
877
879{
883 ViewerRedraw();
884}
885
886//Aux. functions that do not have to be members.
887
888namespace {
889
890//Here's how we create a number entry and its label:
891
892// TGHorizontalFrame *rfr = new TGHorizontalFrame(p);
893// TGHorizontalFrame *labfr = new TGHorizontalFrame(rfr, labelw, 20, kFixedSize);
894// TGLabel *lab = new TGLabel(labfr, name);
895// labfr->AddFrame(lab, new TGLayoutHints(kLHintsLeft | kLHintsBottom, 0, 0, 0) );
896// rfr->AddFrame(labfr, new TGLayoutHints(kLHintsLeft | kLHintsBottom, 0, 0, 0));
897//
898// TGNumberEntry* ne = new TGNumberEntry(rfr, 0.0f, nd, -1, (TGNumberFormat::EStyle)style);
899// rfr->AddFrame(ne, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsBottom, 2, 0, 0));
900//
901// p->AddFrame(rfr, new TGLayoutHints(kLHintsLeft, 0, 0, 1, 0));
902
903////////////////////////////////////////////////////////////////////////////////
904
905TGLabel *FindLabelForNEntry(TGNumberEntry *entry)
906{
907 if (!entry) {
908 //I would prefer an assert here.
909 ::Error("FindLabelForNEntry", "parameter 'entry' is null");
910 return 0;
911 }
912
913 TGLabel *label = 0;
914
915 if (const TGHorizontalFrame * const grandpa = dynamic_cast<const TGHorizontalFrame *>(entry->GetParent())) {
916 if (TList * const parents = grandpa->GetList()) {
917 TIter next1(parents);
918 while (TGFrameElement * const frameElement = dynamic_cast<TGFrameElement *>(next1())) {
919 if (TGHorizontalFrame * const parent = dynamic_cast<TGHorizontalFrame *>(frameElement->fFrame)) {
920 if (TList * const children = parent->GetList()) {
921 TIter next2(children);
922 while (TGFrameElement * const candidate = dynamic_cast<TGFrameElement *>(next2())) {
923 if ((label = dynamic_cast<TGLabel *>(candidate->fFrame)))
924 break;
925 }
926 }
927 }
928
929 if (label)
930 break;
931 }
932 }
933 }
934
935 return label;
936}
937
938////////////////////////////////////////////////////////////////////////////////
939///This is quite an ugly hack but still not as ugly as having 5-6 additional
940///TGLabels as data members.
941
942void SetLabeledNEntryState(TGNumberEntry *entry, Bool_t enabled)
943{
944 if (!entry) {
945 //I would prefer an assert here.
946 ::Error("SetLabeledNEntryState", "parameter 'entry' is null");
947 return;
948 }
949
950 entry->SetState(enabled);
951 if (TGLabel * const label = FindLabelForNEntry(entry))
952 //Wah!
953 label->Disable(!enabled);
954}
955
956}
@ kChildFrame
Definition GuiTypes.h:379
@ kVerticalFrame
Definition GuiTypes.h:381
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kFixedSize
Definition GuiTypes.h:390
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
ROOT::R::TRInterface & r
Definition Object.C:4
#define b(i)
Definition RSha256.hxx:100
const Bool_t kFALSE
Definition RtypesCore.h:101
bool Bool_t
Definition RtypesCore.h:63
double Double_t
Definition RtypesCore.h:59
short Color_t
Definition RtypesCore.h:92
const Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:187
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:231
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsNormal
Definition TGLayout.h:32
@ kLHintsCenterX
Definition TGLayout.h:25
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
char name[80]
Definition TGX11.cxx:110
#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:2069
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:1822
Organizes TGButton widgets in a group.
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
A button abstract base class.
Definition TGButton.h:68
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:445
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:310
virtual Bool_t IsDown() const
Definition TGButton.cxx:301
Selects different options.
Definition TGButton.h:264
virtual Bool_t IsOn() const
Definition TGButton.h:311
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
virtual Bool_t IsDown() const
Definition TGButton.h:312
Like a checkbutton but instead of the check mark there is color area with a little down arrow.
void SetColor(Pixel_t color, Bool_t emit=kTRUE)
Set color.
void Enable(Bool_t on=kTRUE)
Set state of widget as enabled.
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition TGComboBox.h:47
virtual Int_t GetSelected() const
Definition TGComboBox.h:114
virtual void AddEntry(TGString *s, Int_t id)
Definition TGComboBox.h:86
virtual TGListBox * GetListBox() const
Definition TGComboBox.h:110
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...
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual TList * GetList() const
Definition TGFrame.h:310
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1204
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1190
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:605
virtual void MapWindow()
map window
Definition TGFrame.h:204
UInt_t GetWidth() const
Definition TGFrame.h:224
virtual void UnmapWindow()
unmap window
Definition TGFrame.h:206
A composite frame with a border and a title.
Definition TGFrame.h:523
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:386
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:44
virtual Bool_t IsPerspective() const
Definition TGLCamera.h:119
Double_t * GetCenterVec()
Definition TGLCamera.h:157
Bool_t GetExternalCenter()
Definition TGLCamera.h:153
void SetExternalCenter(Bool_t x)
Set camera center diffrent than scene center, if enable is kTRUE.
void SetCenterVec(Double_t x, Double_t y, Double_t z)
Set camera center vector.
virtual Bool_t IsOrthographic() const
Definition TGLCamera.h:118
GUI sub-editor for TGLClipSet.
void SetModel(TGLClipSet *m)
Set model object.
TGLColor & Background()
Definition TGLUtil.h:851
void SetColor(Int_t r, Int_t g, Int_t b, Int_t a=255)
Set color with Int_t values.
Definition TGLUtil.cxx:1235
Color_t GetColorIndex() const
Returns color-index representing the color.
Definition TGLUtil.cxx:1217
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).
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:55
void SetDrawCameraCenter(Bool_t x)
Draw camera look at and rotation point.
void SetMaxSceneDrawTimeLQ(Float_t t)
Definition TGLViewer.h:310
void SetStereoFrustumAsymFac(Float_t f)
Definition TGLViewer.h:295
Float_t GetStereoEyeOffsetFac() const
Definition TGLViewer.h:289
EPushAction GetPushAction() const
Definition TGLViewer.h:298
Bool_t GetSmoothPoints() const
Definition TGLViewer.h:256
TGLCameraOverlay * GetCameraOverlay() const
Definition TGLViewer.h:281
Bool_t GetSmoothLines() const
Definition TGLViewer.h:257
Int_t GetDev() const
Definition TGLViewer.h:228
Float_t GetStereoZeroParallax() const
Definition TGLViewer.h:288
Float_t GetMaxSceneDrawTimeLQ() const
Definition TGLViewer.h:308
Bool_t GetDrawCameraCenter()
Definition TGLViewer.h:278
@ kPushCamCenter
Definition TGLViewer.h:126
@ kPushAnnotate
Definition TGLViewer.h:126
Float_t GetPointScale() const
Definition TGLViewer.h:252
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...
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.
TGLLightSet * GetLightSet() const
Definition TGLViewer.h:261
void SetIgnoreSizesOnUpdate(Bool_t v)
Definition TGLViewer.h:355
TGLCamera & CurrentCamera() const
Definition TGLViewer.h:267
Float_t GetStereoFrustumAsymFac() const
Definition TGLViewer.h:290
void SetStereoEyeOffsetFac(Float_t f)
Definition TGLViewer.h:294
TGLClipSet * GetClipSet() const
Definition TGLViewer.h:262
Bool_t IsUsingDefaultColorSet() const
Check if the viewer is using the default color set.
void SetSmoothPoints(Bool_t s)
Definition TGLViewer.h:258
void UpdateScene(Bool_t redraw=kTRUE)
Force update of pad-scenes.
void SetLineScale(Float_t s)
Definition TGLViewer.h:255
Bool_t GetStereo() const
Definition TGLViewer.h:287
void SetMaxSceneDrawTimeHQ(Float_t t)
Definition TGLViewer.h:309
void SetPointScale(Float_t s)
Definition TGLViewer.h:254
void SetStereoZeroParallax(Float_t f)
Definition TGLViewer.h:293
void SetSmoothLines(Bool_t s)
Definition TGLViewer.h:259
Float_t GetLineScale() const
Definition TGLViewer.h:253
Bool_t GetIgnoreSizesOnUpdate() const
Definition TGLViewer.h:354
TGLAutoRotator * GetAutoRotator()
Get the auto-rotator for this viewer.
Bool_t GetResetCamerasOnUpdate() const
Definition TGLViewer.h:357
void PickCameraCenter()
Definition TGLViewer.h:279
Float_t GetMaxSceneDrawTimeHQ() const
Definition TGLViewer.h:307
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.
void PickAnnotate()
Definition TGLViewer.h:280
void SetResetCamerasOnUpdate(Bool_t v)
Definition TGLViewer.h:358
void ResetCurrentCamera()
Resets position/rotation of current camera to default values.
This class handles GUI labels.
Definition TGLabel.h:24
virtual void Disable(Bool_t on=kTRUE)
Definition TGLabel.h:89
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
A listbox is a box, possibly with scrollbar, containing entries.
Definition TGListBox.h:221
virtual void Resize(UInt_t w, UInt_t h)
Resize the listbox widget.
TGNumberEntry is a number entry input widget with up/down buttons.
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 SetNumber(Double_t val, Bool_t emit=kTRUE)
@ kNESRealOne
Fixed fraction real, one digit.
@ kNESRealThree
Fixed fraction real, three digit.
@ kNESInteger
Style of number entry field.
@ kNESRealTwo
Fixed fraction real, two digit.
@ kNELLimitMin
Lower limit only.
@ kNELLimitMinMax
Both lower and upper limits.
Selects different options.
Definition TGButton.h:322
Yield an action as soon as it is clicked.
Definition TGButton.h:142
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition TGButton.cxx:918
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
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.
ROOT GUI Window base class.
Definition TGWindow.h:23
const TGWindow * GetParent() const
Definition TGWindow.h:76
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:295
Base frame for implementing GUI - a service class.
Definition TGedFrame.h:27
virtual TGVerticalFrame * CreateEditorTabSubFrame(const char *name)
Create a vertical frame to be used by 'owner' in extra tab 'name'.
Bool_t fInit
init flag for setting signals/slots
Definition TGedFrame.h:47
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:95
A doubly linked list.
Definition TList.h:38
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition TList.cxx:693
Mother of all ROOT objects.
Definition TObject.h:41
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:869
TCanvas * style()
Definition style.C:1
auto * m
Definition textangle.C:8
auto * l
Definition textangle.C:4