Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEveCaloVizEditor.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Author: Matevz Tadel 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 "TEveCaloVizEditor.h"
13 #include "TEveCalo.h"
14 #include "TEveGValuators.h"
15 #include "TEveRGBAPaletteEditor.h"
16 #include "TEveCaloData.h"
17 
18 #include "TGClient.h"
19 #include "TGFont.h"
20 #include "TGedEditor.h"
21 
22 #include "TGLabel.h"
23 #include "TGNumberEntry.h"
24 #include "TGDoubleSlider.h"
25 #include "TGNumberEntry.h"
26 #include "TG3DLine.h"
27 #include "TGButtonGroup.h"
28 #include "TColor.h"
29 #include "TGColorSelect.h"
30 
31 #include "TMathBase.h"
32 #include "TMath.h"
33 
34 /** \class TEveCaloVizEditor
35 \ingroup TEve
36 GUI editor for TEveCaloEditor.
37 */
38 
39 ClassImp(TEveCaloVizEditor);
40 
41 ////////////////////////////////////////////////////////////////////////////////
42 /// Constructor.
43 
44 TEveCaloVizEditor::TEveCaloVizEditor(const TGWindow *p, Int_t width, Int_t height,
45  UInt_t options, Pixel_t back) :
46  TGedFrame(p, width, height, options | kVerticalFrame, back),
47  fM(0),
48 
49  fPlotE(0),
50  fPlotEt(0),
51 
52  fScaleAbs(0),
53  fMaxValAbs(0),
54  fMaxTowerH(0),
55 
56  fEtaRng(0),
57  fPhi(0),
58  fPhiOffset(0),
59  fDataFrame(0),
60  fSliceFrame(0)
61 {
62  MakeTitle("TEveCaloViz");
63 
64  TGLabel* label = 0;
65  Int_t labelW = 45;
66 
67  // scaling
68  TGHorizontalFrame* scf = new TGHorizontalFrame(this);
69 
70  label = new TGLabel(scf, "ScaleAbsolute:");
71  scf->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsBottom));
72 
73  fScaleAbs = new TGCheckButton(scf);
74  scf->AddFrame(fScaleAbs, new TGLayoutHints(kLHintsLeft, 3, 5, 3, 0));
75  fScaleAbs->Connect("Toggled(Bool_t)", "TEveCaloVizEditor", this, "DoScaleAbs()");
76 
77 
78  fMaxValAbs = new TEveGValuator(scf, "MaxEVal:", 70, 0);
79  fMaxValAbs->SetLabelWidth(56);
80  fMaxValAbs->SetNELength(5);
81  fMaxValAbs->SetShowSlider(kFALSE);
82  fMaxValAbs->Build();
83  fMaxValAbs->SetLimits(0, 1000);
84  fMaxValAbs->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoMaxValAbs()");
85  scf->AddFrame(fMaxValAbs, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
86 
87  AddFrame(scf, new TGLayoutHints(kLHintsTop, 4, 1, 1, 0));
88 
89 
90  // tower height
91  fMaxTowerH = new TEveGValuator(this, "MaxTowerH:", 96, 0);
92  fMaxTowerH->SetLabelWidth(71);
93  fMaxTowerH->SetNELength(5);
94  fMaxTowerH->SetShowSlider(kFALSE);
95  fMaxTowerH->Build();
96  fMaxTowerH->SetLimits(0.1, 500, 501, TGNumberFormat::kNESRealOne);
97  fMaxTowerH->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoMaxTowerH()");
98  AddFrame(fMaxTowerH, new TGLayoutHints(kLHintsTop, 4, 1, 1, 1));
99 
100 
101  //______________________________________________________________________________
102 
103  fDataFrame = CreateEditorTabSubFrame("Data");
104 
105  // E/Et Plot
106  {
107  TGHorizontalFrame *group = new TGHorizontalFrame(fDataFrame);
108  TGCompositeFrame *labfr = new TGHorizontalFrame(group, 28, 20, kFixedSize);
109 
110  TGFont *myfont = gClient->GetFont("-adobe-times-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
111  label = new TGLabel(labfr, "Plot:");
112  label->SetTextFont(myfont);
113  labfr->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsBottom));
114  group->AddFrame(labfr, new TGLayoutHints(kLHintsLeft));
115 
116  fPlotE = new TGRadioButton(group, new TGHotString("E"), 11);
117  fPlotE->Connect("Clicked()", "TEveCaloVizEditor", this, "DoPlot()");
118  group->AddFrame(fPlotE, new TGLayoutHints(kLHintsLeft | kLHintsBottom, 2, 2, 0, 0));
119 
120  fPlotEt = new TGRadioButton(group, new TGHotString("Et"), 22);
121  fPlotEt->Connect("Clicked()", "TEveCaloVizEditor", this, "DoPlot()");
122  group->AddFrame(fPlotEt, new TGLayoutHints(kLHintsLeft | kLHintsBottom, 2, 2, 0, 0));
123 
124  fDataFrame->AddFrame(group, new TGLayoutHints(kLHintsTop, 4, 1, 1, 0));
125  }
126 
127  // eta
128  fEtaRng = new TEveGDoubleValuator(fDataFrame,"Eta rng:", 40, 0);
129  fEtaRng->SetNELength(6);
130  fEtaRng->SetLabelWidth(labelW);
131  fEtaRng->Build();
132  fEtaRng->GetSlider()->SetWidth(195);
133  fEtaRng->SetLimits(-5.5, 5.5, TGNumberFormat::kNESRealTwo);
134  fEtaRng->Connect("ValueSet()", "TEveCaloVizEditor", this, "DoEtaRange()");
135  fDataFrame->AddFrame(fEtaRng, new TGLayoutHints(kLHintsTop, 1, 1, 4, 5));
136 
137  // phi
138  fPhi = new TEveGValuator(fDataFrame, "Phi:", 90, 0);
139  fPhi->SetLabelWidth(labelW);
140  fPhi->SetNELength(6);
141  fPhi->Build();
142  fPhi->SetLimits(-TMath::Pi(), TMath::Pi(), TGNumberFormat::kNESRealTwo);
143  fPhi->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoPhi()");
144  fDataFrame->AddFrame(fPhi, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
145 
146  fPhiOffset = new TEveGValuator(fDataFrame, "PhiOff:", 90, 0);
147  fPhiOffset->SetLabelWidth(labelW);
148  fPhiOffset->SetNELength(6);
149  fPhiOffset->Build();
150  fPhiOffset->SetLimits(0, TMath::Pi(), TGNumberFormat::kNESRealTwo);
151  fPhiOffset->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoPhi()");
152  fDataFrame->AddFrame(fPhiOffset, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
153 
154  fSliceFrame = new TGVerticalFrame(fDataFrame);
155  fDataFrame->AddFrame(fSliceFrame);
156 }
157 
158 ////////////////////////////////////////////////////////////////////////////////
159 /// Create slice info gui.
160 
161 void TEveCaloVizEditor::MakeSliceInfo()
162 {
163  Int_t ns = fM->GetData()->GetNSlices();
164  Int_t nf = fSliceFrame->GetList()->GetSize();
165 
166  if (ns > nf)
167  {
168  for (Int_t i=nf; i<ns; ++i)
169  {
170  TGHorizontalFrame* f = new TGHorizontalFrame(fSliceFrame);
171 
172  TEveGValuator* threshold = new TEveGValuator(f,"", 90, 0, i);
173  threshold->SetLabelWidth(50);
174  threshold->SetNELength(6);
175  threshold->SetShowSlider(kFALSE);
176  threshold->Build();
177  threshold->SetLimits(0, 1000, TGNumberFormat::kNESRealTwo);
178  threshold->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoSliceThreshold()");
179  f->AddFrame(threshold, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
180 
181  TGColorSelect* color = new TGColorSelect(f, 0, i);
182  f->AddFrame(color, new TGLayoutHints(kLHintsLeft|kLHintsTop, 3, 1, 0, 1));
183  color->Connect("ColorSelected(Pixel_t)", "TEveCaloVizEditor", this, "DoSliceColor(Pixel_t)");
184 
185  TGNumberEntry* transparency = new TGNumberEntry(f, 0., 2, i,
186  TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
187  TGNumberFormat::kNELLimitMinMax, 0, 100);
188  transparency->SetHeight(18);
189  transparency->GetNumberEntry()->SetToolTipText("Transparency: 0 is opaque, 100 fully transparent.");
190  f->AddFrame(transparency, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
191  transparency->Connect("ValueSet(Long_t)", "TEveCaloVizEditor", this, "DoSliceTransparency(Long_t)");
192 
193 
194  fSliceFrame->AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
195  }
196  nf = ns;
197  }
198 
199  TIter frame_iterator(fSliceFrame->GetList());
200  for (Int_t i=0; i<nf; ++i)
201  {
202  TGFrameElement *el = (TGFrameElement*) frame_iterator();
203  TGHorizontalFrame *fr = (TGHorizontalFrame*) el->fFrame;
204  if (i < ns)
205  {
206  TEveCaloData::SliceInfo_t &si = fM->GetData()->RefSliceInfo(i);
207 
208  TEveGValuator *threshold = (TEveGValuator*) ((TGFrameElement*) fr->GetList()->At(0))->fFrame;
209  TGColorSelect *color = (TGColorSelect*) ((TGFrameElement*) fr->GetList()->At(1) )->fFrame;
210  TGNumberEntry *transp = (TGNumberEntry*) ((TGFrameElement*) fr->GetList()->At(2))->fFrame;
211 
212  threshold->GetLabel()->SetText(si.fName);
213  threshold->SetValue(si.fThreshold);
214  color->SetColor(TColor::Number2Pixel(si.fColor), kFALSE);
215  transp->SetNumber(si.fTransparency);
216 
217  if (! fr->IsMapped()) {
218  fr->MapSubwindows();
219  fr->MapWindow();
220  }
221  }
222  else
223  {
224  if (fr->IsMapped()) {
225  fr->UnmapWindow();
226  }
227  }
228  }
229 }
230 
231 ////////////////////////////////////////////////////////////////////////////////
232 /// Set model object.
233 
234 void TEveCaloVizEditor::SetModel(TObject* obj)
235 {
236  fM = dynamic_cast<TEveCaloViz*>(obj);
237  if (fM->GetPlotEt())
238  {
239  fPlotEt->SetState(kButtonDown, kFALSE);
240  fPlotE->SetState(kButtonUp, kFALSE);
241  }
242  else
243  {
244  fPlotE->SetState(kButtonDown, kFALSE);
245  fPlotEt->SetState(kButtonUp, kFALSE);
246  }
247 
248  if (fM->fData)
249  {
250  TGCompositeFrame* p = GetGedEditor()->GetEditorTab("Data");
251  if (p->GetList()->IsEmpty())
252  {
253  p->MapWindow();
254  p->MapSubwindows();
255  }
256 
257  fScaleAbs->SetState(fM->GetScaleAbs() ? kButtonDown : kButtonUp);
258  fMaxValAbs->SetValue(fM->GetMaxValAbs());
259  fMaxTowerH->SetValue(fM->GetMaxTowerH());
260 
261  Double_t min, max;
262  fM->GetData()->GetEtaLimits(min, max);
263  fEtaRng->SetLimits((Float_t)min, (Float_t)max);
264  fEtaRng->SetValues(fM->fEtaMin, fM->fEtaMax);
265 
266  fM->GetData()->GetPhiLimits(min, max);
267  fPhi->SetLimits(min, max, 101, TGNumberFormat::kNESRealTwo);
268  fPhi->SetValue(fM->fPhi);
269  if ( fM->GetData()->GetWrapTwoPi())
270  {
271  fPhi->SetToolTip("Center angle in radians");
272  fPhiOffset->SetLimits(1e-3, TMath::Pi(), 101, TGNumberFormat::kNESRealTwo);
273  }
274  else
275  {
276  Float_t d = (max-min)*0.5;
277  fPhiOffset->SetLimits(1e-3, d, 101, TGNumberFormat::kNESRealTwo);
278  }
279  fPhiOffset->SetValue(fM->fPhiOffset);
280  fPhiOffset->SetToolTip("Phi range in radians");
281 
282  MakeSliceInfo();
283  }
284  else
285  {
286 
287  fDataFrame->UnmapWindow();
288  }
289 }
290 
291 ////////////////////////////////////////////////////////////////////////////////
292 /// Slot for setting max tower height.
293 
294 void TEveCaloVizEditor::DoMaxTowerH()
295 {
296  fM->SetMaxTowerH(fMaxTowerH->GetValue());
297  Update();
298 }
299 
300 ////////////////////////////////////////////////////////////////////////////////
301 /// Slot for enabling/disabling absolute scale.
302 
303 void TEveCaloVizEditor::DoScaleAbs()
304 {
305  fM->SetScaleAbs(fScaleAbs->IsOn());
306  Update();
307 }
308 
309 ////////////////////////////////////////////////////////////////////////////////
310 /// Slot for setting max E in for absolute scale.
311 
312 void TEveCaloVizEditor::DoMaxValAbs()
313 {
314  fM->SetMaxValAbs(fMaxValAbs->GetValue());
315  Update();
316 }
317 
318 ////////////////////////////////////////////////////////////////////////////////
319 /// Slot for setting E/Et plot.
320 
321 void TEveCaloVizEditor::DoPlot()
322 {
323  TGButton *btn = (TGButton *) gTQSender;
324  Int_t id = btn->WidgetId();
325 
326  if (id == fPlotE->WidgetId())
327  fPlotEt->SetState(kButtonUp);
328  else
329  fPlotE->SetState(kButtonUp);
330 
331  fM->SetPlotEt(fPlotEt->IsDown());
332  Update();
333 }
334 
335 ////////////////////////////////////////////////////////////////////////////////
336 /// Slot for setting eta range.
337 
338 void TEveCaloVizEditor::DoEtaRange()
339 {
340  fM->SetEta(fEtaRng->GetMin(), fEtaRng->GetMax());
341  Update();
342 }
343 
344 ////////////////////////////////////////////////////////////////////////////////
345 /// Slot for setting phi range.
346 
347 void TEveCaloVizEditor::DoPhi()
348 {
349  fM->SetPhiWithRng(fPhi->GetValue(), fPhiOffset->GetValue());
350  Update();
351 }
352 
353 ////////////////////////////////////////////////////////////////////////////////
354 /// Slot for SliceThreshold.
355 
356 void TEveCaloVizEditor::DoSliceThreshold()
357 {
358  TEveGValuator *st = (TEveGValuator *) gTQSender;
359  fM->SetDataSliceThreshold(st->WidgetId(), st->GetValue());
360  Update();
361 }
362 
363 ////////////////////////////////////////////////////////////////////////////////
364 /// Slot for slice info Color.
365 
366 void TEveCaloVizEditor::DoSliceColor(Pixel_t pixel)
367 {
368  TGColorSelect *cs = (TGColorSelect *) gTQSender;
369  fM->SetDataSliceColor(cs->WidgetId(), Color_t(TColor::GetColor(pixel)));
370  Update();
371 }
372 
373 ////////////////////////////////////////////////////////////////////////////////
374 /// Slot for slice transparency.
375 
376 void TEveCaloVizEditor::DoSliceTransparency(Long_t t)
377 {
378  TGNumberEntry *cs = (TGNumberEntry*) gTQSender;
379  fM->GetData()->SetSliceTransparency(cs->WidgetId(), t);
380  Update();
381 }
382 
383 /** \class TEveCalo3DEditor
384 \ingroup TEve
385 GUI editor for TEveCalo3D.
386 */
387 
388 ClassImp(TEveCalo3DEditor);
389 
390 ////////////////////////////////////////////////////////////////////////////////
391 /// Constructor.
392 
393 TEveCalo3DEditor::TEveCalo3DEditor(const TGWindow *p, Int_t width, Int_t height,
394  UInt_t options, Pixel_t back) :
395  TGedFrame(p, width, height, options | kVerticalFrame, back),
396  fM(0),
397  fFrameTransparency(0)
398 {
399  MakeTitle("TEveCalo3D");
400 
401  TGHorizontalFrame* f = new TGHorizontalFrame(this);
402  TGLabel* lab = new TGLabel(f, "Frame transparency: ");
403  f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 1, 1, 1));
404 
405  fFrameTransparency = new TGNumberEntry(f, 0., 2, -1,
406  TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
407  TGNumberFormat::kNELLimitMinMax, 0, 100);
408 
409  fFrameTransparency->SetHeight(18);
410  fFrameTransparency->GetNumberEntry()->SetToolTipText("Transparency: 0 is opaque, 100 fully transparent.");
411  f->AddFrame(fFrameTransparency, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
412  fFrameTransparency->Connect("ValueSet(Long_t)","TEveCalo3DEditor", this, "DoFrameTransparency()");
413 
414  AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
415 }
416 
417 ////////////////////////////////////////////////////////////////////////////////
418 /// Set model object.
419 
420 void TEveCalo3DEditor::SetModel(TObject* obj)
421 {
422  fM = dynamic_cast<TEveCalo3D*>(obj);
423  fFrameTransparency->SetNumber(fM->GetFrameTransparency());
424 }
425 
426 ////////////////////////////////////////////////////////////////////////////////
427 /// Slot for frame transparency.
428 
429 void TEveCalo3DEditor::DoFrameTransparency()
430 {
431  fM->SetFrameTransparency((Char_t)(fFrameTransparency->GetNumber()));
432  Update();
433 }