Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEveGeoNodeEditor.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, 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 "TEveGeoNodeEditor.h"
13 #include "TEveGValuators.h"
14 
15 #include "TEveGeoNode.h"
16 #include "TGeoNode.h"
17 
18 #include "TVirtualPad.h"
19 #include "TColor.h"
20 
21 #include "TGLabel.h"
22 #include "TGButton.h"
23 #include "TGNumberEntry.h"
24 #include "TGColorSelect.h"
25 #include "TGDoubleSlider.h"
26 
27 /** \class TEveGeoNodeEditor
28 \ingroup TEve
29 Editor for TEveGeoNode class.
30 */
31 
32 ClassImp(TEveGeoNodeEditor);
33 
34 ////////////////////////////////////////////////////////////////////////////////
35 /// Constructor.
36 
37 TEveGeoNodeEditor::TEveGeoNodeEditor(const TGWindow *p,
38  Int_t width, Int_t height,
39  UInt_t options, Pixel_t back) :
40  TGedFrame(p,width, height, options | kVerticalFrame, back),
41 
42  fNodeRE (0),
43 
44  fVizNode(0),
45  fVizNodeDaughters(0),
46  fVizVolume(0),
47  fVizVolumeDaughters(0)
48 {
49  MakeTitle("GeoNode");
50 
51  // --- Visibility control
52 
53  fVizNode = new TGCheckButton(this, "VizNode");
54  AddFrame(fVizNode, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
55  fVizNode->Connect
56  ("Toggled(Bool_t)",
57  "TEveGeoNodeEditor", this, "DoVizNode()");
58 
59  fVizNodeDaughters = new TGCheckButton(this, "VizNodeDaughters");
60  AddFrame(fVizNodeDaughters, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
61  fVizNodeDaughters->Connect
62  ("Toggled(Bool_t)",
63  "TEveGeoNodeEditor", this, "DoVizNodeDaughters()");
64 
65  fVizVolume = new TGCheckButton(this, "VizVolume");
66  AddFrame(fVizVolume, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
67  fVizVolume->Connect
68  ("Toggled(Bool_t)",
69  "TEveGeoNodeEditor", this, "DoVizVolume()");
70 
71  fVizVolumeDaughters = new TGCheckButton(this, "VizVolumeDaughters");
72  AddFrame(fVizVolumeDaughters, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
73  fVizVolumeDaughters->Connect
74  ("Toggled(Bool_t)",
75  "TEveGeoNodeEditor", this, "DoVizVolumeDaughters()");
76 }
77 
78 ////////////////////////////////////////////////////////////////////////////////
79 /// Set model object.
80 
81 void TEveGeoNodeEditor::SetModel(TObject* obj)
82 {
83  fNodeRE = dynamic_cast<TEveGeoNode*>(obj);
84  TGeoNode* node = fNodeRE->fNode;
85  TGeoVolume* vol = node->GetVolume();
86 
87  fVizNode->SetState(node->TGeoAtt::IsVisible() ? kButtonDown : kButtonUp);
88  fVizNodeDaughters->SetState(node->TGeoAtt::IsVisDaughters() ? kButtonDown : kButtonUp);
89  fVizVolume->SetState(vol->IsVisible() ? kButtonDown : kButtonUp);
90  fVizVolumeDaughters->SetState(vol->IsVisDaughters() ? kButtonDown : kButtonUp);
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 /// Slot for VizNode.
95 
96 void TEveGeoNodeEditor::DoVizNode()
97 {
98  fNodeRE->SetRnrSelf(fVizNode->IsOn());
99  Update();
100 }
101 
102 ////////////////////////////////////////////////////////////////////////////////
103 /// Slot for VizNodeDaughters.
104 
105 void TEveGeoNodeEditor::DoVizNodeDaughters()
106 {
107  fNodeRE->SetRnrChildren(fVizNodeDaughters->IsOn());
108  Update();
109 }
110 
111 ////////////////////////////////////////////////////////////////////////////////
112 /// Slot for VizVolume.
113 
114 void TEveGeoNodeEditor::DoVizVolume()
115 {
116  fNodeRE->fNode->GetVolume()->SetVisibility(fVizVolume->IsOn());
117  Update();
118 }
119 
120 ////////////////////////////////////////////////////////////////////////////////
121 /// Slot for VizVolumeDaughters.
122 
123 void TEveGeoNodeEditor::DoVizVolumeDaughters()
124 {
125  fNodeRE->fNode->GetVolume()->VisibleDaughters(fVizVolumeDaughters->IsOn());
126  Update();
127 }
128 
129 /** \class TEveGeoTopNodeEditor
130 \ingroup TEve
131 Editor for TEveGeoTopNode class.
132 */
133 
134 ClassImp(TEveGeoTopNodeEditor);
135 
136 ////////////////////////////////////////////////////////////////////////////////
137 /// Constructor.
138 
139 TEveGeoTopNodeEditor::TEveGeoTopNodeEditor(const TGWindow *p,
140  Int_t width, Int_t height,
141  UInt_t options, Pixel_t back) :
142  TGedFrame(p, width, height, options | kVerticalFrame, back),
143 
144  fTopNodeRE (0),
145  fVisOption (0),
146  fVisLevel (0),
147  fMaxVisNodes (0)
148 {
149  MakeTitle("GeoTopNode");
150 
151  Int_t labelW = 64;
152 
153  fVisOption = new TEveGValuator(this, "VisOption:", 90, 0);
154  fVisOption->SetLabelWidth(labelW);
155  fVisOption->SetShowSlider(kFALSE);
156  fVisOption->SetNELength(4);
157  fVisOption->Build();
158  fVisOption->SetLimits(0, 2, 10, TGNumberFormat::kNESInteger);
159  fVisOption->SetToolTip("Visualization option passed to TGeoPainter.");
160  fVisOption->Connect("ValueSet(Double_t)", "TEveGeoTopNodeEditor", this, "DoVisOption()");
161  AddFrame(fVisOption, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
162 
163  fVisLevel = new TEveGValuator(this, "VisLevel:", 90, 0);
164  fVisLevel->SetLabelWidth(labelW);
165  fVisLevel->SetShowSlider(kFALSE);
166  fVisLevel->SetNELength(4);
167  fVisLevel->Build();
168  fVisLevel->SetLimits(0, 30, 31, TGNumberFormat::kNESInteger);
169  fVisLevel->SetToolTip("Level (depth) to which the geometry is traversed.\nWhen zero, maximum number of nodes to draw can be specified.");
170  fVisLevel->Connect("ValueSet(Double_t)", "TEveGeoTopNodeEditor", this, "DoVisLevel()");
171  AddFrame(fVisLevel, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
172 
173  fMaxVisNodes = new TEveGValuator(this, "MaxNodes:", 90, 0);
174  fMaxVisNodes->SetLabelWidth(labelW);
175  fMaxVisNodes->SetShowSlider(kFALSE);
176  fMaxVisNodes->SetNELength(6);
177  fMaxVisNodes->Build();
178  fMaxVisNodes->SetLimits(100, 999999, 0, TGNumberFormat::kNESInteger);
179  fMaxVisNodes->SetToolTip("Maximum number of nodes to draw.");
180  fMaxVisNodes->Connect("ValueSet(Double_t)", "TEveGeoTopNodeEditor", this, "DoMaxVisNodes()");
181  AddFrame(fMaxVisNodes, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
182 }
183 
184 ////////////////////////////////////////////////////////////////////////////////
185 /// Set model object.
186 
187 void TEveGeoTopNodeEditor::SetModel(TObject* obj)
188 {
189  fTopNodeRE = dynamic_cast<TEveGeoTopNode*>(obj);
190 
191  fVisOption ->SetValue(fTopNodeRE->GetVisOption());
192  fVisLevel ->SetValue(fTopNodeRE->GetVisLevel());
193  fMaxVisNodes->SetValue(fTopNodeRE->GetMaxVisNodes());
194  if (fTopNodeRE->GetVisLevel() > 0)
195  fMaxVisNodes->UnmapWindow();
196  else
197  fMaxVisNodes->MapWindow();
198 }
199 
200 ////////////////////////////////////////////////////////////////////////////////
201 /// Slot for VisOption.
202 
203 void TEveGeoTopNodeEditor::DoVisOption()
204 {
205  fTopNodeRE->SetVisOption(Int_t(fVisOption->GetValue()));
206  Update();
207 }
208 
209 ////////////////////////////////////////////////////////////////////////////////
210 /// Slot for VisLevel.
211 
212 void TEveGeoTopNodeEditor::DoVisLevel()
213 {
214  fTopNodeRE->SetVisLevel(Int_t(fVisLevel->GetValue()));
215  Update();
216 }
217 
218 ////////////////////////////////////////////////////////////////////////////////
219 /// Slot for MaxVisNodes.
220 
221 void TEveGeoTopNodeEditor::DoMaxVisNodes()
222 {
223  fTopNodeRE->SetMaxVisNodes(Int_t(fMaxVisNodes->GetValue()));
224  Update();
225 }