]>
Commit | Line | Data |
---|---|---|
32e219c2 | 1 | // $Header$ |
2 | ||
3 | #include "TrackRnrStyleEditor.h" | |
4 | #include <Reve/Track.h> | |
5 | ||
6 | #include <Reve/RGValuators.h> | |
7 | #include <Reve/ReveManager.h> | |
8 | ||
9 | #include <TVirtualPad.h> | |
10 | #include <TColor.h> | |
11 | ||
12 | #include <TGLabel.h> | |
13 | #include <TG3DLine.h> | |
14 | #include <TGButton.h> | |
15 | #include <TGNumberEntry.h> | |
16 | #include <TGColorSelect.h> | |
17 | #include <TGDoubleSlider.h> | |
18 | #include <TGComboBox.h> | |
19 | #include <TAttMarkerEditor.h> | |
20 | ||
21 | using namespace Reve; | |
22 | ||
23 | //______________________________________________________________________ | |
24 | // TrackRnrStyleSubEditor | |
25 | // | |
26 | // | |
27 | ||
28 | ClassImp(TrackRnrStyleSubEditor) | |
29 | ||
30 | TrackRnrStyleSubEditor::TrackRnrStyleSubEditor(const TGWindow *p): | |
31 | TGVerticalFrame(p), | |
32 | fM (0), | |
33 | ||
34 | fMaxR(0), | |
35 | fMaxZ(0), | |
36 | fMaxOrbits(0), | |
37 | fMinAng(0), | |
38 | fDelta(0), | |
39 | ||
40 | fRnrFV(0), | |
41 | ||
42 | fPMFrame(0), | |
43 | fFitDaughters(0), | |
44 | fFitReferences(0), | |
45 | fFitDecay(0), | |
46 | fRnrDaughters(0), | |
47 | fRnrReferences(0), | |
48 | fRnrDecay(0), | |
49 | ||
50 | fRefsCont(0), | |
51 | fPMAtt(0), | |
52 | fFVAtt(0) | |
53 | { | |
54 | Int_t labelW = 51; | |
55 | ||
56 | // --- Limits | |
57 | fMaxR = new RGValuator(this, "Max R:", 90, 0); | |
58 | fMaxR->SetLabelWidth(labelW); | |
59 | fMaxR->SetNELength(6); | |
60 | fMaxR->Build(); | |
61 | fMaxR->SetLimits(0.1, 1000, 101, TGNumberFormat::kNESRealOne); | |
62 | fMaxR->SetToolTip("Maximum radius to which the tracks will be drawn."); | |
63 | fMaxR->Connect("ValueSet(Double_t)", "Reve::TrackRnrStyleSubEditor", this, "DoMaxR()"); | |
64 | AddFrame(fMaxR, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); | |
65 | ||
66 | fMaxZ = new RGValuator(this, "Max Z:", 90, 0); | |
67 | fMaxZ->SetLabelWidth(labelW); | |
68 | fMaxZ->SetNELength(6); | |
69 | fMaxZ->Build(); | |
70 | fMaxZ->SetLimits(0.1, 2000, 101, TGNumberFormat::kNESRealOne); | |
71 | fMaxZ->SetToolTip("Maximum z-coordinate to which the tracks will be drawn."); | |
72 | fMaxZ->Connect("ValueSet(Double_t)", "Reve::TrackRnrStyleSubEditor", this, "DoMaxZ()"); | |
73 | AddFrame(fMaxZ, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); | |
74 | ||
75 | fMaxOrbits = new RGValuator(this, "Orbits:", 90, 0); | |
76 | fMaxOrbits->SetLabelWidth(labelW); | |
77 | fMaxOrbits->SetNELength(6); | |
78 | fMaxOrbits->Build(); | |
79 | fMaxOrbits->SetLimits(0.1, 10, 101, TGNumberFormat::kNESRealOne); | |
80 | fMaxOrbits->SetToolTip("Maximal angular path of tracks' orbits (1 ~ 2Pi)."); | |
81 | fMaxOrbits->Connect("ValueSet(Double_t)", "Reve::TrackRnrStyleSubEditor", this, "DoMaxOrbits()"); | |
82 | AddFrame(fMaxOrbits, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); | |
83 | ||
84 | fMinAng = new RGValuator(this, "Angle:", 90, 0); | |
85 | fMinAng->SetLabelWidth(labelW); | |
86 | fMinAng->SetNELength(6); | |
87 | fMinAng->Build(); | |
88 | fMinAng->SetLimits(1, 160, 81, TGNumberFormat::kNESRealOne); | |
89 | fMinAng->SetToolTip("Minimal angular step between two helix points."); | |
90 | fMinAng->Connect("ValueSet(Double_t)", "Reve::TrackRnrStyleSubEditor", this, "DoMinAng()"); | |
91 | AddFrame(fMinAng, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); | |
92 | ||
93 | fDelta = new RGValuator(this, "Delta:", 90, 0); | |
94 | fDelta->SetLabelWidth(labelW); | |
95 | fDelta->SetNELength(6); | |
96 | fDelta->Build(); | |
97 | fDelta->SetLimits(0.001, 10, 101, TGNumberFormat::kNESRealThree); | |
98 | fDelta->SetToolTip("Maximal error at the mid-point of the line connecting to helix points."); | |
99 | fDelta->Connect("ValueSet(Double_t)", "Reve::TrackRnrStyleSubEditor", this, "DoDelta()"); | |
100 | AddFrame(fDelta, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); | |
101 | } | |
102 | ||
4c1b64ab | 103 | //______________________________________________________________________________ |
32e219c2 | 104 | void TrackRnrStyleSubEditor::CreateRefsContainer(TGVerticalFrame* p) |
105 | { | |
4c1b64ab | 106 | // Create a frame containing track-reference controls under parent |
107 | // frame p. | |
108 | ||
32e219c2 | 109 | fRefsCont = new TGCompositeFrame(p, 80, 20, kVerticalFrame); |
110 | fPMFrame = new TGVerticalFrame(fRefsCont); | |
4c1b64ab | 111 | // Rendering control. |
32e219c2 | 112 | { |
32e219c2 | 113 | TGGroupFrame* fitPM = new TGGroupFrame(fPMFrame, "PathMarks:", kLHintsTop | kLHintsCenterX); |
114 | fitPM->SetTitlePos(TGGroupFrame::kLeft); | |
115 | fPMFrame->AddFrame( fitPM, new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3)); | |
116 | ||
117 | TGMatrixLayout *ml = new TGMatrixLayout(fitPM, 0,1,6); | |
118 | fitPM->SetLayoutManager(ml); | |
119 | ||
120 | fFitDaughters = new TGCheckButton(fitPM, "Fit Daughters", PathMark::Daughter); | |
121 | fFitReferences = new TGCheckButton(fitPM, "Fit Refs", PathMark::Reference); | |
122 | fFitDecay = new TGCheckButton(fitPM, "Fit Decay", PathMark::Decay); | |
123 | ||
124 | fitPM->AddFrame(fFitDaughters); | |
125 | fitPM->AddFrame(fFitReferences); | |
126 | fitPM->AddFrame(fFitDecay); | |
127 | ||
128 | fFitDecay->Connect("Clicked()","Reve::TrackRnrStyleSubEditor", this, "DoFitPM()"); | |
129 | fFitReferences->Connect("Clicked()","Reve::TrackRnrStyleSubEditor", this, "DoFitPM()"); | |
130 | fFitDaughters->Connect("Clicked()","Reve::TrackRnrStyleSubEditor", this, "DoFitPM()"); | |
131 | } | |
4c1b64ab | 132 | // Kinematics fitting. |
32e219c2 | 133 | { |
32e219c2 | 134 | TGGroupFrame* rnrPM = new TGGroupFrame(fPMFrame, "PathMarks:", kLHintsTop | kLHintsCenterX); |
135 | rnrPM->SetTitlePos(TGGroupFrame::kLeft); | |
136 | fPMFrame->AddFrame( rnrPM, new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3)); | |
137 | ||
138 | TGMatrixLayout *ml = new TGMatrixLayout(rnrPM, 0,1,6); | |
139 | rnrPM->SetLayoutManager(ml); | |
140 | ||
141 | fRnrDaughters = new TGCheckButton(rnrPM, "Rnr Daughters", PathMark::Daughter); | |
142 | fRnrReferences = new TGCheckButton(rnrPM, "Rnr Refs", PathMark::Reference); | |
143 | fRnrDecay = new TGCheckButton(rnrPM, "Rnr Decay", PathMark::Decay); | |
144 | ||
145 | rnrPM->AddFrame(fRnrDaughters); | |
146 | rnrPM->AddFrame(fRnrReferences); | |
147 | rnrPM->AddFrame(fRnrDecay); | |
148 | ||
149 | fRnrDecay->Connect("Clicked()","Reve::TrackRnrStyleSubEditor", this, "DoRnrPM()"); | |
150 | fRnrReferences->Connect("Clicked()","Reve::TrackRnrStyleSubEditor", this, "DoRnrPM()"); | |
151 | fRnrDaughters->Connect("Clicked()","Reve::TrackRnrStyleSubEditor", this, "DoRnrPM()"); | |
152 | ||
153 | fRefsCont->AddFrame(fPMFrame, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); | |
154 | } | |
4c1b64ab | 155 | // Marker attributes. |
32e219c2 | 156 | { |
157 | fPMAtt = new TAttMarkerEditor(fRefsCont); | |
158 | TGFrameElement *el = (TGFrameElement*) fPMAtt->GetList()->First(); | |
322ad047 | 159 | TGFrame *f = el->fFrame; fPMAtt->RemoveFrame(f); |
160 | f->DestroyWindow(); delete f; | |
32e219c2 | 161 | fRefsCont->AddFrame(fPMAtt, new TGLayoutHints(kLHintsTop, 1, 1, 3, 1)); |
162 | } | |
163 | ||
4c1b64ab | 164 | // First vertex. |
32e219c2 | 165 | TGCompositeFrame *title1 = new TGCompositeFrame(fRefsCont, 145, 10, |
166 | kHorizontalFrame | | |
167 | kLHintsExpandX | | |
168 | kFixedWidth | | |
169 | kOwnBackground); | |
170 | title1->AddFrame(new TGLabel(title1, "FirstVertex"), | |
171 | new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0)); | |
172 | title1->AddFrame(new TGHorizontal3DLine(title1), | |
173 | new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 5)); | |
174 | fRefsCont->AddFrame(title1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0)); | |
175 | ||
176 | fRnrFV = new TGCheckButton(fRefsCont, "Rnr"); | |
177 | fRnrFV->Connect("Clicked()","Reve::TrackRnrStyleSubEditor", this, "DoRnrFV()"); | |
178 | fRefsCont->AddFrame(fRnrFV, new TGLayoutHints(kLHintsTop, 5, 1, 2, 0)); | |
179 | { | |
180 | fFVAtt = new TAttMarkerEditor(fRefsCont); | |
181 | TGFrameElement *el = (TGFrameElement*) fFVAtt->GetList()->First(); | |
322ad047 | 182 | TGFrame *f = el->fFrame; fFVAtt->RemoveFrame(f); |
183 | f->DestroyWindow(); delete f; | |
32e219c2 | 184 | fRefsCont->AddFrame(fFVAtt, new TGLayoutHints(kLHintsTop, 1, 1, 3, 1)); |
185 | } | |
186 | p->AddFrame(fRefsCont,new TGLayoutHints(kLHintsTop| kLHintsExpandX)); | |
187 | } | |
188 | ||
4c1b64ab | 189 | //______________________________________________________________________________ |
32e219c2 | 190 | void TrackRnrStyleSubEditor::SetModel(TrackRnrStyle* m) |
191 | { | |
4c1b64ab | 192 | // Set model object. |
193 | ||
32e219c2 | 194 | fM = m; |
195 | ||
196 | fMaxR->SetValue(fM->fMaxR); | |
197 | fMaxZ->SetValue(fM->fMaxZ); | |
198 | fMaxOrbits->SetValue(fM->fMaxOrbs); | |
199 | fMinAng->SetValue(fM->fMinAng); | |
200 | fDelta->SetValue(fM->fDelta); | |
201 | ||
202 | if(fM->fEditPathMarks) | |
203 | { | |
204 | ShowFrame(fPMFrame); | |
205 | fRnrDaughters->SetState(fM->fRnrDaughters ? kButtonDown : kButtonUp); | |
206 | fRnrReferences->SetState(fM->fRnrReferences ? kButtonDown : kButtonUp); | |
207 | fRnrDecay->SetState(fM->fRnrDecay ? kButtonDown : kButtonUp); | |
208 | ||
209 | fFitDaughters->SetState(fM->fFitDaughters ? kButtonDown : kButtonUp); | |
210 | fFitReferences->SetState(fM->fFitReferences ? kButtonDown : kButtonUp); | |
211 | fFitDecay->SetState(fM->fFitDecay ? kButtonDown : kButtonUp); | |
212 | ||
213 | fPMAtt->SetModel(&fM->fPMAtt); | |
214 | } | |
215 | else | |
216 | { | |
217 | fRefsCont->HideFrame(fPMFrame); | |
218 | } | |
219 | ||
220 | fRnrFV->SetState(fM->fRnrFV ? kButtonDown : kButtonUp); | |
221 | fFVAtt->SetModel(&fM->fFVAtt); | |
222 | } | |
223 | ||
4c1b64ab | 224 | /******************************************************************************/ |
225 | ||
226 | //______________________________________________________________________________ | |
32e219c2 | 227 | void TrackRnrStyleSubEditor::Changed() |
228 | { | |
4c1b64ab | 229 | // Update registered tracks and emit "Changed()" signal. |
230 | ||
32e219c2 | 231 | fM->UpdateBackPtrItems(); |
232 | Emit("Changed()"); | |
233 | } | |
234 | ||
4c1b64ab | 235 | /******************************************************************************/ |
236 | ||
32e219c2 | 237 | void TrackRnrStyleSubEditor::DoMaxR() |
238 | { | |
239 | fM->SetMaxR(fMaxR->GetValue()); | |
240 | Changed(); | |
241 | } | |
242 | ||
243 | void TrackRnrStyleSubEditor::DoMaxZ() | |
244 | { | |
245 | fM->SetMaxZ(fMaxZ->GetValue()); | |
246 | Changed(); | |
247 | } | |
248 | ||
249 | void TrackRnrStyleSubEditor::DoMaxOrbits() | |
250 | { | |
251 | fM->SetMaxOrbs(fMaxOrbits->GetValue()); | |
252 | Changed(); | |
253 | } | |
254 | ||
255 | void TrackRnrStyleSubEditor::DoMinAng() | |
256 | { | |
257 | fM->SetMinAng(fMinAng->GetValue()); | |
258 | Changed(); | |
259 | } | |
260 | ||
261 | void TrackRnrStyleSubEditor::DoDelta() | |
262 | { | |
263 | fM->SetDelta(fDelta->GetValue()); | |
264 | Changed(); | |
265 | } | |
266 | ||
4c1b64ab | 267 | /******************************************************************************/ |
268 | ||
32e219c2 | 269 | void TrackRnrStyleSubEditor::DoFitPM() |
270 | { | |
271 | TGButton* b = (TGButton *) gTQSender; | |
272 | PathMark::Type_e type = PathMark::Type_e(b->WidgetId()); | |
273 | Bool_t on = b->IsOn(); | |
274 | ||
275 | switch(type) | |
276 | { | |
277 | case PathMark::Daughter: | |
278 | fM->SetFitDaughters(on); | |
279 | break; | |
280 | case PathMark::Reference: | |
281 | fM->SetFitReferences(on); | |
282 | break; | |
283 | case PathMark::Decay: | |
284 | fM->SetFitDecay(on); | |
285 | break; | |
286 | default: | |
287 | break; | |
288 | } | |
289 | Changed(); | |
290 | } | |
291 | ||
292 | void TrackRnrStyleSubEditor::DoRnrPM() | |
293 | { | |
294 | TGButton * b = (TGButton *) gTQSender; | |
295 | PathMark::Type_e type = PathMark::Type_e(b->WidgetId()); | |
296 | Bool_t on = b->IsOn(); | |
297 | switch(type){ | |
298 | case PathMark::Daughter: | |
299 | fM->SetRnrDaughters(on); | |
300 | break; | |
301 | case PathMark::Reference: | |
302 | fM->SetRnrReferences(on); | |
303 | break; | |
304 | case PathMark::Decay: | |
305 | fM->SetRnrDecay(on); | |
306 | break; | |
307 | ||
308 | default: | |
309 | break; | |
310 | } | |
311 | Changed(); | |
312 | } | |
313 | ||
314 | void TrackRnrStyleSubEditor::DoRnrFV() | |
315 | { | |
316 | fM->SetRnrFV(fRnrFV->IsOn()); | |
317 | Changed(); | |
318 | } | |
319 | ||
320 | ||
4c1b64ab | 321 | //______________________________________________________________________________ |
32e219c2 | 322 | // TrackRnrStyleEditor |
323 | // | |
4c1b64ab | 324 | // GUI editor for TrackRnrStyle. |
325 | // It's only a wrapper around a TrackRnrStyleSubEditor that holds actual | |
326 | // widgets. | |
32e219c2 | 327 | |
328 | ClassImp(TrackRnrStyleEditor) | |
329 | ||
4c1b64ab | 330 | //______________________________________________________________________________ |
32e219c2 | 331 | TrackRnrStyleEditor::TrackRnrStyleEditor(const TGWindow *p, |
332 | Int_t width, Int_t height, | |
333 | UInt_t options, Pixel_t back) : | |
334 | TGedFrame(p, width, height, options | kVerticalFrame, back), | |
4c1b64ab | 335 | fM(0), |
32e219c2 | 336 | fRSSubEditor(0) |
337 | { | |
4c1b64ab | 338 | // Constructor. |
339 | ||
32e219c2 | 340 | MakeTitle("RenderStyle"); |
341 | ||
342 | fRSSubEditor = new TrackRnrStyleSubEditor(this); | |
343 | fRSSubEditor->Connect("Changed()", "Reve::TrackRnrStyleEditor", this, "Update()"); | |
344 | AddFrame(fRSSubEditor, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0,0,0)); | |
345 | ||
346 | TGVerticalFrame* refsFrame = CreateEditorTabSubFrame("Refs"); | |
347 | TGCompositeFrame *title1 = new TGCompositeFrame(refsFrame, 145, 10, | |
348 | kHorizontalFrame | | |
349 | kLHintsExpandX | | |
350 | kFixedWidth | | |
351 | kOwnBackground); | |
352 | title1->AddFrame(new TGLabel(title1, "PathMarks"), | |
353 | new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0)); | |
354 | title1->AddFrame(new TGHorizontal3DLine(title1), | |
355 | new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7)); | |
356 | refsFrame->AddFrame(title1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0)); | |
4c1b64ab | 357 | |
32e219c2 | 358 | // path marks |
359 | fRSSubEditor->CreateRefsContainer(refsFrame); | |
360 | fRSSubEditor->fPMAtt->SetGedEditor((TGedEditor*)gReve->GetEditor()); | |
361 | fRSSubEditor->fFVAtt->SetGedEditor((TGedEditor*)gReve->GetEditor()); | |
362 | ||
4c1b64ab | 363 | fRSSubEditor->Connect("Changed()", "Reve::TrackRnrStyleEditor", this, "Update()"); |
32e219c2 | 364 | } |
365 | ||
4c1b64ab | 366 | //______________________________________________________________________________ |
32e219c2 | 367 | TrackRnrStyleEditor::~TrackRnrStyleEditor() |
368 | { | |
4c1b64ab | 369 | // Destructor. Noop. |
32e219c2 | 370 | } |
371 | ||
4c1b64ab | 372 | /******************************************************************************/ |
32e219c2 | 373 | |
4c1b64ab | 374 | //______________________________________________________________________________ |
32e219c2 | 375 | void TrackRnrStyleEditor::SetModel(TObject* obj) |
376 | { | |
4c1b64ab | 377 | // Set model object. |
378 | ||
32e219c2 | 379 | fM = dynamic_cast<TrackRnrStyle*>(obj); |
380 | fRSSubEditor->SetModel(fM); | |
381 | } |