Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEveProjectionManagerEditor.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 
13 #include "TEveProjectionManager.h"
14 #include "TEveGValuators.h"
15 
16 #include "TGNumberEntry.h"
17 #include "TGComboBox.h"
18 #include "TGLabel.h"
19 
20 /** \class TEveProjectionManagerEditor
21 \ingroup TEve
22 GUI editor for TEveProjectionManager class.
23 */
24 
25 ClassImp(TEveProjectionManagerEditor);
26 
27 ////////////////////////////////////////////////////////////////////////////////
28 /// Constructor.
29 
30 TEveProjectionManagerEditor::TEveProjectionManagerEditor(const TGWindow *p,
31  Int_t width, Int_t height,
32  UInt_t options, Pixel_t back) :
33  TGedFrame(p, width, height, options | kVerticalFrame, back),
34  fM(0),
35 
36  fType(0),
37  fDistortion(0),
38  fFixR(0), fFixZ(0),
39  fPastFixRFac(0), fPastFixZFac(0),
40  fCurrentDepth(0),
41  fMaxTrackStep(0),
42 
43  fCenterX(0),
44  fCenterY(0),
45  fCenterZ(0)
46 {
47  MakeTitle("TEveProjection");
48  {
49  TGHorizontalFrame* f = new TGHorizontalFrame(this);
50  TGLabel* lab = new TGLabel(f, "Type");
51  f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 31, 1, 2));
52  fType = new TGComboBox(f);
53  fType->AddEntry("RPhi", TEveProjection::kPT_RPhi);
54  fType->AddEntry("RhoZ", TEveProjection::kPT_RhoZ);
55  fType->AddEntry("3D", TEveProjection::kPT_3D);
56  TGListBox* lb = fType->GetListBox();
57  lb->Resize(lb->GetWidth(), 2*18);
58  fType->Resize(80, 20);
59  fType->Connect("Selected(Int_t)", "TEveProjectionManagerEditor",
60  this, "DoType(Int_t)");
61  f->AddFrame(fType, new TGLayoutHints(kLHintsTop, 1, 1, 2, 4));
62  AddFrame(f);
63  }
64 
65  Int_t nel = 6;
66  Int_t labelW = 60;
67  fDistortion = new TEveGValuator(this, "Distortion:", 90, 0);
68  fDistortion->SetNELength(nel);
69  fDistortion->SetLabelWidth(labelW);
70  fDistortion->Build();
71  fDistortion->SetLimits(0, 50, 101, TGNumberFormat::kNESRealTwo);
72  fDistortion->Connect("ValueSet(Double_t)", "TEveProjectionManagerEditor",
73  this, "DoDistortion()");
74  AddFrame(fDistortion, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
75 
76 
77  fFixR = new TEveGValuator(this, "FixedR:", 90, 0);
78  fFixR->SetNELength(nel);
79  fFixR->SetLabelWidth(labelW);
80  fFixR->Build();
81  fFixR->SetLimits(0, 1000, 101, TGNumberFormat::kNESRealOne);
82  fFixR->SetToolTip("Radius after which scale is kept constant.");
83  fFixR->Connect("ValueSet(Double_t)", "TEveProjectionManagerEditor",
84  this, "DoFixR()");
85  AddFrame(fFixR, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
86 
87  fFixZ = new TEveGValuator(this, "FixedZ:", 90, 0);
88  fFixZ->SetNELength(nel);
89  fFixZ->SetLabelWidth(labelW);
90  fFixZ->Build();
91  fFixZ->SetLimits(0, 1000, 101, TGNumberFormat::kNESRealOne);
92  fFixZ->SetToolTip("Z-coordinate after which scale is kept constant.");
93  fFixZ->Connect("ValueSet(Double_t)", "TEveProjectionManagerEditor",
94  this, "DoFixZ()");
95  AddFrame(fFixZ, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
96 
97  fPastFixRFac = new TEveGValuator(this, "ScaleR:", 90, 0);
98  fPastFixRFac->SetNELength(nel);
99  fPastFixRFac->SetLabelWidth(labelW);
100  fPastFixRFac->Build();
101  fPastFixRFac->SetLimits(-2, 2, 101, TGNumberFormat::kNESRealTwo);
102  fPastFixRFac->SetToolTip("Relative R-scale beyond FixedR.\nExpressed as 10^x.");
103  fPastFixRFac->Connect("ValueSet(Double_t)", "TEveProjectionManagerEditor",
104  this, "DoPastFixRFac()");
105  AddFrame(fPastFixRFac, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
106 
107  fPastFixZFac = new TEveGValuator(this, "ScaleZ:", 90, 0);
108  fPastFixZFac->SetNELength(nel);
109  fPastFixZFac->SetLabelWidth(labelW);
110  fPastFixZFac->Build();
111  fPastFixZFac->SetLimits(-2, 2, 101, TGNumberFormat::kNESRealTwo);
112  fPastFixZFac->SetToolTip("Relative Z-scale beyond FixedZ.\nExpressed as 10^x.");
113  fPastFixZFac->Connect("ValueSet(Double_t)", "TEveProjectionManagerEditor",
114  this, "DoPastFixZFac()");
115  AddFrame(fPastFixZFac, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
116 
117  fCurrentDepth = new TEveGValuator(this, "CurrentZ:", 90, 0);
118  fCurrentDepth->SetNELength(nel);
119  fCurrentDepth->SetLabelWidth(labelW);
120  fCurrentDepth->Build();
121  fCurrentDepth->SetLimits(-300, 300, 601, TGNumberFormat::kNESRealTwo);
122  fCurrentDepth->SetToolTip("Z coordinate of incoming projected object.");
123  fCurrentDepth->Connect("ValueSet(Double_t)", "TEveProjectionManagerEditor",
124  this, "DoCurrentDepth()");
125  AddFrame(fCurrentDepth, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
126 
127  fMaxTrackStep = new TEveGValuator(this, "TrackStep:", 90, 0);
128  fMaxTrackStep->SetNELength(nel);
129  fMaxTrackStep->SetLabelWidth(labelW);
130  fMaxTrackStep->Build();
131  fMaxTrackStep->SetLimits(1, 100, 100, TGNumberFormat::kNESRealOne);
132  fMaxTrackStep->SetToolTip("Maximum step between two consecutive track-points to avoid artefacts due to projective distortions.\nTaken into account automatically during projection procedure.");
133  fMaxTrackStep->Connect("ValueSet(Double_t)", "TEveProjectionManagerEditor",
134  this, "DoMaxTrackStep()");
135  AddFrame(fMaxTrackStep, new TGLayoutHints(kLHintsTop, 1, 1, 1, 3));
136 
137  // --------------------------------
138 
139  MakeTitle("Distortion centre");
140  fCenterFrame = new TGVerticalFrame(this);
141 
142  fCenterX = new TEveGValuator(fCenterFrame, "CenterX:", 90, 0);
143  fCenterX->SetNELength(nel);
144  fCenterX->SetLabelWidth(labelW);
145  fCenterX->Build();
146  fCenterX->SetLimits(-5, 5, 501, TGNumberFormat::kNESRealThree);
147  fCenterX->SetToolTip("Origin of the projection.");
148  fCenterX->Connect("ValueSet(Double_t)", "TEveProjectionManagerEditor",
149  this, "DoCenter()");
150  fCenterFrame->AddFrame(fCenterX, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
151 
152  fCenterY = new TEveGValuator(fCenterFrame, "CenterY:", 90, 0);
153  fCenterY->SetNELength(nel);
154  fCenterY->SetLabelWidth(labelW);
155  fCenterY->Build();
156  fCenterY->SetLimits(-5, 5, 501, TGNumberFormat::kNESRealThree);
157  fCenterY->SetToolTip("Origin of the projection.");
158  fCenterY->Connect("ValueSet(Double_t)", "TEveProjectionManagerEditor",
159  this, "DoCenter()");
160  fCenterFrame->AddFrame(fCenterY, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
161 
162  fCenterZ = new TEveGValuator(fCenterFrame, "CenterZ:", 90, 0);
163  fCenterZ->SetNELength(nel);
164  fCenterZ->SetLabelWidth(labelW);
165  fCenterZ->Build();
166  fCenterZ->SetLimits(-25, 25, 501, TGNumberFormat::kNESRealThree);
167  fCenterZ->SetToolTip("Origin of the projection.");
168  fCenterZ->Connect("ValueSet(Double_t)", "TEveProjectionManagerEditor",
169  this, "DoCenter()");
170  fCenterFrame->AddFrame(fCenterZ, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
171 
172  AddFrame(fCenterFrame, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
173 }
174 
175 ////////////////////////////////////////////////////////////////////////////////
176 /// Set model object.
177 
178 void TEveProjectionManagerEditor::SetModel(TObject* obj)
179 {
180  fM = dynamic_cast<TEveProjectionManager*>(obj);
181 
182  fType->Select(fM->GetProjection()->GetType(), kFALSE);
183  fDistortion->SetValue(1000.0f * fM->GetProjection()->GetDistortion());
184  fFixR->SetValue(fM->GetProjection()->GetFixR());
185  fFixZ->SetValue(fM->GetProjection()->GetFixZ());
186  fPastFixRFac->SetValue(fM->GetProjection()->GetPastFixRFac());
187  fPastFixZFac->SetValue(fM->GetProjection()->GetPastFixZFac());
188  fCurrentDepth->SetValue(fM->GetCurrentDepth());
189  fMaxTrackStep->SetValue(fM->GetProjection()->GetMaxTrackStep());
190 
191  fCenterX->SetValue(fM->GetCenter().fX);
192  fCenterY->SetValue(fM->GetCenter().fY);
193  fCenterZ->SetValue(fM->GetCenter().fZ);
194 }
195 
196 ////////////////////////////////////////////////////////////////////////////////
197 /// Slot for setting of projection type.
198 
199 void TEveProjectionManagerEditor::DoType(Int_t type)
200 {
201  try
202  {
203  fM->SetProjection((TEveProjection::EPType_e)type);
204  fM->ProjectChildren();
205  Update();
206  }
207  catch (...)
208  {
209  SetModel(fM);
210  throw;
211  }
212 }
213 
214 ////////////////////////////////////////////////////////////////////////////////
215 /// Slot for setting distortion.
216 
217 void TEveProjectionManagerEditor::DoDistortion()
218 {
219  fM->GetProjection()->SetDistortion(0.001f * fDistortion->GetValue());
220  fM->UpdateName();
221  fM->ProjectChildren();
222  Update();
223 }
224 
225 ////////////////////////////////////////////////////////////////////////////////
226 /// Slot for setting fixed radius.
227 
228 void TEveProjectionManagerEditor::DoFixR()
229 {
230  fM->GetProjection()->SetFixR(fFixR->GetValue());
231  fM->ProjectChildren();
232  Update();
233 }
234 
235 ////////////////////////////////////////////////////////////////////////////////
236 /// Slot for setting fixed z-coordinate.
237 
238 void TEveProjectionManagerEditor::DoFixZ()
239 {
240  fM->GetProjection()->SetFixZ(fFixZ->GetValue());
241  fM->ProjectChildren();
242  Update();
243 }
244 
245 ////////////////////////////////////////////////////////////////////////////////
246 /// Slot for setting fixed radius.
247 
248 void TEveProjectionManagerEditor::DoPastFixRFac()
249 {
250  fM->GetProjection()->SetPastFixRFac(fPastFixRFac->GetValue());
251  fM->ProjectChildren();
252  Update();
253 }
254 
255 ////////////////////////////////////////////////////////////////////////////////
256 /// Slot for setting fixed z-coordinate.
257 
258 void TEveProjectionManagerEditor::DoPastFixZFac()
259 {
260  fM->GetProjection()->SetPastFixZFac(fPastFixZFac->GetValue());
261  fM->ProjectChildren();
262  Update();
263 }
264 
265 ////////////////////////////////////////////////////////////////////////////////
266 /// Slot for setting current depth.
267 
268 void TEveProjectionManagerEditor::DoCurrentDepth()
269 {
270  fM->SetCurrentDepth(fCurrentDepth->GetValue());
271  fM->ProjectChildren();
272  Update();
273 }
274 
275 ////////////////////////////////////////////////////////////////////////////////
276 /// Slot for setting fixed z-coordinate.
277 
278 void TEveProjectionManagerEditor::DoMaxTrackStep()
279 {
280  fM->GetProjection()->SetMaxTrackStep(fMaxTrackStep->GetValue());
281  fM->ProjectChildren();
282  Update();
283 }
284 
285 ////////////////////////////////////////////////////////////////////////////////
286 /// Slot for setting center of distortion.
287 
288 void TEveProjectionManagerEditor::DoCenter()
289 {
290  fM->SetCenter(fCenterX->GetValue(), fCenterY->GetValue(), fCenterZ->GetValue());
291  Update();
292 }
293