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