forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveCaloLegoEditor.cxx
297 lines (237 loc) · 10.4 KB
/
TEveCaloLegoEditor.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
// @(#)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 "TEveCaloLegoEditor.h"
#include "TEveCalo.h"
#include "TEveGValuators.h"
#include "TGComboBox.h"
#include "TColor.h"
#include "TGColorSelect.h"
#include "TGLabel.h"
#include "TG3DLine.h"
//______________________________________________________________________________
// GUI editor for TEveCaloLego.
//
ClassImp(TEveCaloLegoEditor);
//______________________________________________________________________________
TEveCaloLegoEditor::TEveCaloLegoEditor(const TGWindow *p, Int_t width, Int_t height,
UInt_t options, Pixel_t back) :
TGedFrame(p, width, height, options | kVerticalFrame, back),
fM(0),
fGridColor(0),
fFontColor(0),
fPlaneColor(0),
fTransparency(0),
fProjection(0),
f2DMode(0),
fBoxMode(0),
fCell2DTextMin(0),
fRebinFrame(0),
fAutoRebin(0),
fPixelsPerBin(0),
fNormalizeRebin(0)
{
// Constructor.
MakeTitle("TEveCaloLego");
{ // grid color
TGHorizontalFrame* f = new TGHorizontalFrame(this);
TGLabel* lab = new TGLabel(f, "GridColor:");
f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 10, 1, 1));
fGridColor = new TGColorSelect(f, 0, -1);
f->AddFrame(fGridColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 3, 1, 0, 1));
fGridColor->Connect("ColorSelected(Pixel_t)", "TEveCaloLegoEditor", this, "DoGridColor(Pixel_t)");
AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
}
// axis
{
// font color
TGHorizontalFrame* f = new TGHorizontalFrame(this);
TGLabel* lab = new TGLabel(f, "FontColor:");
f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 8, 1, 1));
fFontColor = new TGColorSelect(f, 0, -1);
f->AddFrame(fFontColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 3, 1, 0, 1));
fFontColor->Connect("ColorSelected(Pixel_t)", "TEveCaloLegoEditor", this, "DoFontColor(Pixel_t)");
AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
}
{
// plane color
TGHorizontalFrame* f = new TGHorizontalFrame(this);
TGLabel* lab = new TGLabel(f, "PlaneColor:");
f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 1, 1, 1));
fPlaneColor = new TGColorSelect(f, 0, -1);
f->AddFrame(fPlaneColor, new TGLayoutHints(kLHintsLeft|kLHintsTop, 3, 1, 0, 1));
fPlaneColor->Connect("ColorSelected(Pixel_t)", "TEveCaloLegoEditor", this, "DoPlaneColor(Pixel_t)");
fTransparency = new TGNumberEntry(f, 0., 2, -1,
TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
TGNumberFormat::kNELLimitMinMax, 0, 100);
fTransparency->SetHeight(18);
fTransparency->GetNumberEntry()->SetToolTipText("Transparency: 0 is opaque, 100 fully transparent.");
f->AddFrame(fTransparency, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
fTransparency->Connect("ValueSet(Long_t)","TEveCaloLegoEditor", this, "DoTransparency()");
AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
}
Int_t lw = 80;
fProjection = MakeLabeledCombo("Project:", 1);
fProjection->AddEntry("Auto", TEveCaloLego::kAuto);
fProjection->AddEntry("3D", TEveCaloLego::k3D);
fProjection->AddEntry("2D", TEveCaloLego::k2D);
fProjection->Connect("Selected(Int_t)", "TEveCaloLegoEditor", this, "DoProjection()");
f2DMode = MakeLabeledCombo("2DMode:", 4);
f2DMode->AddEntry("ValColor", TEveCaloLego::kValColor);
f2DMode->AddEntry("ValSize", TEveCaloLego::kValSize);
f2DMode->AddEntry("ValSizeOutline", TEveCaloLego::kValSizeOutline);
f2DMode->Connect("Selected(Int_t)", "TEveCaloLegoEditor", this, "Do2DMode()");
fBoxMode = MakeLabeledCombo("Box:", 4);
fBoxMode->AddEntry("None", TEveCaloLego::kNone);
fBoxMode->AddEntry("Back", TEveCaloLego::kBack);
fBoxMode->AddEntry("FrontBack", TEveCaloLego::kFrontBack);
fBoxMode->Connect("Selected(Int_t)", "TEveCaloLegoEditor", this, "DoBoxMode()");
fCell2DTextMin = new TEveGValuator(this, "Cell2DTexMin:", 90, 0);
fCell2DTextMin->SetLabelWidth(lw);
fCell2DTextMin->SetNELength(5);
fCell2DTextMin->SetShowSlider(kFALSE);
fCell2DTextMin->Build();
fCell2DTextMin->SetLimits(1, 1000);
fCell2DTextMin->SetToolTip("Draw cell values above N pixels.");
fCell2DTextMin->Connect("ValueSet(Double_t)", "TEveCaloLegoEditor", this, "DoCell2DTextMin()");
AddFrame(fCell2DTextMin, new TGLayoutHints(kLHintsTop, 1, 2, 1, 2));
MakeRebinFrame();
}
//______________________________________________________________________________
void TEveCaloLegoEditor::MakeRebinFrame()
{
fRebinFrame = CreateEditorTabSubFrame("Rebin");
fAutoRebin = new TGCheckButton(fRebinFrame, "AutoRebin");
fRebinFrame->AddFrame(fAutoRebin, new TGLayoutHints(kLHintsLeft, 3, 5, 3, 0));
fAutoRebin->Connect("Toggled(Bool_t)", "TEveCaloLegoEditor", this, "DoAutoRebin()");
fNormalizeRebin = new TGCheckButton(fRebinFrame, "NormalizeRebin");
fRebinFrame->AddFrame(fNormalizeRebin, new TGLayoutHints(kLHintsLeft, 3, 5, 3, 0));
fNormalizeRebin->Connect("Toggled(Bool_t)", "TEveCaloLegoEditor", this, "DoNormalize()");
fPixelsPerBin = new TEveGValuator(fRebinFrame, "PixelsPerBin:", 90, 0);
fPixelsPerBin->SetLabelWidth(80);
fPixelsPerBin->SetNELength(5);
fPixelsPerBin->SetShowSlider(kFALSE);
fPixelsPerBin->Build();
fPixelsPerBin->SetLimits(1, 50);
fPixelsPerBin->SetToolTip("Number of labels along the Z axis.");
fPixelsPerBin->Connect("ValueSet(Double_t)", "TEveCaloLegoEditor", this, "DoPixelsPerBin()");
fRebinFrame->AddFrame(fPixelsPerBin, new TGLayoutHints(kLHintsTop, 4, 2, 1, 2));
}
//______________________________________________________________________________
TGComboBox* TEveCaloLegoEditor::MakeLabeledCombo(const char* name, Int_t off)
{
// Helper function. Creates TGComboBox with fixed size TGLabel.
UInt_t labelW = 60;
UInt_t labelH = 20;
TGHorizontalFrame* hf = new TGHorizontalFrame(this);
// label
TGCompositeFrame *labfr = new TGHorizontalFrame(hf, labelW, labelH, kFixedSize);
TGLabel* label = new TGLabel(labfr, name);
labfr->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsBottom));
hf->AddFrame(labfr, new TGLayoutHints(kLHintsLeft));
// combo
TGLayoutHints* clh = new TGLayoutHints(kLHintsLeft, 0,0,0,0);
TGComboBox* combo = new TGComboBox(hf);
combo->Resize(90, 20);
hf->AddFrame(combo, clh);
AddFrame(hf, new TGLayoutHints(kLHintsTop, 1, 1, 1, off));
return combo;
}
//______________________________________________________________________________
void TEveCaloLegoEditor::SetModel(TObject* obj)
{
// Set model object.
fM = dynamic_cast<TEveCaloLego*>(obj);
fGridColor->SetColor(TColor::Number2Pixel(fM->GetGridColor() < 0 ? 0 : fM->GetGridColor()), kFALSE);
fFontColor->SetColor(TColor::Number2Pixel(fM->GetFontColor() < 0 ? 0 : fM->GetFontColor()), kFALSE);
fPlaneColor->SetColor(TColor::Number2Pixel(fM->GetPlaneColor()), kFALSE);
fTransparency->SetNumber(fM->GetPlaneTransparency());
fCell2DTextMin->SetValue(fM->GetDrawNumberCellPixels());
fProjection->Select(fM->GetProjection(), kFALSE);
f2DMode->Select(fM->Get2DMode(), kFALSE);
fBoxMode->Select(fM->GetBoxMode(), kFALSE);
fPixelsPerBin->SetValue(fM->GetPixelsPerBin());
fAutoRebin->SetState(fM->GetAutoRebin() ? kButtonDown : kButtonUp);
fNormalizeRebin->SetState(fM->GetNormalizeRebin() ? kButtonDown : kButtonUp);
}
//______________________________________________________________________________
void TEveCaloLegoEditor::DoGridColor(Pixel_t pixel)
{
// Slot for GridColor.
fM->SetGridColor(Color_t(TColor::GetColor(pixel)));
Update();
}
//______________________________________________________________________________
void TEveCaloLegoEditor::DoFontColor(Pixel_t pixel)
{
// Slot for FontColor.
fM->SetFontColor(Color_t(TColor::GetColor(pixel)));
Update();
}
//______________________________________________________________________________
void TEveCaloLegoEditor::DoPlaneColor(Pixel_t pixel)
{
// Slot for PlaneColor.
fM->SetPlaneColor(Color_t(TColor::GetColor(pixel)));
Update();
}
//______________________________________________________________________________
void TEveCaloLegoEditor::DoCell2DTextMin()
{
// Slot for setting limit in pixels in which cell value is rendered.
fM->SetDrawNumberCellPixels((Int_t)fCell2DTextMin->GetValue());
Update();
}
//______________________________________________________________________________
void TEveCaloLegoEditor::DoProjection()
{
// Slot for projection.
fM->SetProjection((TEveCaloLego::EProjection_e)fProjection->GetSelected());
Update();
}
//______________________________________________________________________________
void TEveCaloLegoEditor::Do2DMode()
{
// Slot for projection.
fM->Set2DMode((TEveCaloLego::E2DMode_e)f2DMode->GetSelected());
Update();
}
//______________________________________________________________________________
void TEveCaloLegoEditor::DoBoxMode()
{
// Slot for projection.
fM->SetBoxMode((TEveCaloLego::EBoxMode_e)fBoxMode->GetSelected());
Update();
}
//______________________________________________________________________________
void TEveCaloLegoEditor::DoTransparency()
{
// Slot for Transparency.
fM->SetPlaneTransparency((Char_t)(fTransparency->GetNumber()));
Update();
}
//______________________________________________________________________________
void TEveCaloLegoEditor::DoPixelsPerBin()
{
// Slot for PixelsPerBin.
fM->SetPixelsPerBin((Int_t)fPixelsPerBin->GetValue());
Update();
}
//______________________________________________________________________________
void TEveCaloLegoEditor::DoAutoRebin()
{
fM->SetAutoRebin(fAutoRebin->IsOn());
Update();
}
//______________________________________________________________________________
void TEveCaloLegoEditor::DoNormalize()
{
fM->SetNormalizeRebin(fNormalizeRebin->IsOn());
Update();
}