]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/NLTProjectorEditor.cxx
44905b3b67e8ad0b9292015ae6a64541ec1ec297
[u/mrichter/AliRoot.git] / EVE / Reve / NLTProjectorEditor.cxx
1 // $Header$
2
3 #include "NLTProjectorEditor.h"
4 #include <Reve/NLTProjector.h>
5
6 #include <Reve/RGValuators.h>
7
8 #include <TColor.h>
9 #include <TGNumberEntry.h>
10 #include <TGColorSelect.h>
11 #include <TGComboBox.h>
12 #include <TGLabel.h>
13 #include <TG3DLine.h>
14
15 using namespace Reve;
16
17 //______________________________________________________________________
18 // NLTProjectorEditor
19 //
20 // GUI editor for class NLTProjector.
21 //
22
23 ClassImp(NLTProjectorEditor)
24
25 NLTProjectorEditor::NLTProjectorEditor(const TGWindow *p,
26                                          Int_t width, Int_t height,
27                                          UInt_t options, Pixel_t back) :
28     TGedFrame(p, width, height, options | kVerticalFrame, back),
29     fM(0),
30
31     fType(0),
32     fDistortion(0),
33     fFixedRadius(0),
34     fCurrentDepth(0),
35
36     fCenterFrame(0),
37     fDrawCenter(0),
38     fCenterX(0),
39     fCenterY(0),
40     fCenterZ(0),
41
42     fAxisColor(0),
43     fSIMode(0),
44     fSILevel(0)
45 {
46   // Constructor.
47
48   MakeTitle("NLTProjection");
49   {
50     TGHorizontalFrame* f = new TGHorizontalFrame(this);
51     TGLabel* lab = new TGLabel(f, "Type");
52     f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 31, 1, 2));
53     fType = new TGComboBox(f);
54     fType->AddEntry("CFishEye", NLTProjection::PT_CFishEye);
55     fType->AddEntry("RhoZ",     NLTProjection::PT_RhoZ);
56     TGListBox* lb = fType->GetListBox();
57     lb->Resize(lb->GetWidth(), 2*18);
58     fType->Resize(80, 20);
59     fType->Connect("Selected(Int_t)", "Reve::NLTProjectorEditor",
60                    this, "DoType(Int_t)");
61     f->AddFrame(fType, new TGLayoutHints(kLHintsTop, 1, 1, 2, 4));
62     AddFrame(f);
63   }
64
65   Int_t labelW = 60;
66   fDistortion = new RGValuator(this, "Distortion:", 90, 0);
67   fDistortion->SetNELength(5);
68   fDistortion->SetLabelWidth(labelW);
69   fDistortion->Build();
70   fDistortion->SetLimits(0, 50, 101, TGNumberFormat::kNESRealTwo);
71   fDistortion->Connect("ValueSet(Double_t)", "Reve::NLTProjectorEditor",
72                        this, "DoDistortion()");
73   AddFrame(fDistortion, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
74
75
76   fFixedRadius = new RGValuator(this, "FixedR:", 90, 0);
77   fFixedRadius->SetNELength(5);
78   fFixedRadius->SetLabelWidth(labelW);
79   fFixedRadius->Build();
80   fFixedRadius->SetLimits(0, 1000, 101, TGNumberFormat::kNESRealOne);
81   fFixedRadius->SetToolTip("Radius not scaled by distotion.");
82   fFixedRadius->Connect("ValueSet(Double_t)", "Reve::NLTProjectorEditor",
83                         this, "DoFixedRadius()");
84   AddFrame(fFixedRadius, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
85
86
87   fCurrentDepth = new RGValuator(this, "CurrentZ:", 90, 0);
88   fCurrentDepth->SetNELength(5);
89   fCurrentDepth->SetLabelWidth(labelW);
90   fCurrentDepth->Build();
91   fCurrentDepth->SetLimits(-300, 300, 601, TGNumberFormat::kNESRealOne);
92   fCurrentDepth->SetToolTip("Z coordinate of incoming projected object.");
93   fCurrentDepth->Connect("ValueSet(Double_t)", "Reve::NLTProjectorEditor",
94                          this, "DoCurrentDepth()");
95   AddFrame(fCurrentDepth, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
96
97   /**************************************************************************/
98   MakeTitle("Axis");
99   {
100     TGHorizontalFrame* hf1 = new TGHorizontalFrame(this);
101
102     TGCompositeFrame *labfr =
103       new TGHorizontalFrame(hf1, 60, 15, kFixedSize);
104     TGLabel* l = new TGLabel(labfr, "Color");
105     labfr->AddFrame(l, new TGLayoutHints(kLHintsLeft|kLHintsBottom));
106     hf1->AddFrame(labfr, new TGLayoutHints(kLHintsLeft|kLHintsBottom));
107
108
109     fAxisColor = new TGColorSelect(hf1, 0, -1);
110     hf1->AddFrame(fAxisColor, new TGLayoutHints(kLHintsLeft, 2, 0, 1, 1));
111     fAxisColor->Connect
112       ("ColorSelected(Pixel_t)",
113        "Reve::NLTProjectorEditor", this, "DoAxisColor(Pixel_t)");
114
115     AddFrame(hf1);
116   }
117   {
118     TGHorizontalFrame* f = new TGHorizontalFrame(this);
119     TGLabel* lab = new TGLabel(f, "StepMode");
120     f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 6, 1, 2));
121     fSIMode = new TGComboBox(f, "Position");
122     fSIMode->AddEntry("Value", 1);
123     fSIMode->AddEntry("Position", 0);
124     fSIMode->GetTextEntry()->SetToolTipText("Set tick-marks on equidistant values/screen position.");
125     TGListBox* lb = fSIMode->GetListBox();
126     lb->Resize(lb->GetWidth(), 2*18);
127     fSIMode->Resize(80, 20);
128     fSIMode->Connect("Selected(Int_t)", "Reve::NLTProjectorEditor",
129                      this, "DoSplitInfoMode(Int_t)");
130     f->AddFrame(fSIMode, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
131     AddFrame(f);
132   }
133   {
134     TGHorizontalFrame* f = new TGHorizontalFrame(this);
135     TGLabel* lab = new TGLabel(f, "SplitLevel");
136     f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 8, 1, 2));
137
138     fSILevel = new TGNumberEntry(f, 0, 3, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
139                                  TGNumberFormat::kNELLimitMinMax, 0, 7);
140     fSILevel->GetNumberEntry()->SetToolTipText("Number of tick-marks TMath::Power(2, level).");
141     fSILevel->Connect("ValueSet(Long_t)", "Reve::NLTProjectorEditor", this, "DoSplitInfoLevel()");
142     f->AddFrame(fSILevel, new TGLayoutHints(kLHintsTop, 1, 1, 1, 2));
143     AddFrame(f, new TGLayoutHints(kLHintsTop, 0, 0, 0, 3) );
144   }
145
146   /**************************************************************************/
147   // center tab
148   fCenterFrame = CreateEditorTabSubFrame("Center");
149
150   TGCompositeFrame *title1 = new TGCompositeFrame(fCenterFrame, 180, 10,
151                                                   kHorizontalFrame |
152                                                   kLHintsExpandX   |
153                                                   kFixedWidth      |
154                                                   kOwnBackground);
155   title1->AddFrame(new TGLabel(title1, "Distortion Center"),
156                    new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
157   title1->AddFrame(new TGHorizontal3DLine(title1),
158                    new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
159   fCenterFrame->AddFrame(title1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
160
161
162   {
163
164     TGHorizontalFrame* hf1 = new TGHorizontalFrame(fCenterFrame);
165
166     fDrawOrigin = new TGCheckButton(hf1, "DrawOrigin");
167     hf1->AddFrame(fDrawOrigin, new TGLayoutHints(kLHintsLeft, 2,1,0,4));
168     fDrawOrigin->Connect("Toggled(Bool_t)"," Reve::NLTProjectorEditor", this, "DoDrawOrigin()");
169
170
171     fDrawCenter = new TGCheckButton(hf1, "DrawCenter");
172     hf1->AddFrame(fDrawCenter, new TGLayoutHints(kLHintsLeft, 2,1,0,4));
173     fDrawCenter->Connect("Toggled(Bool_t)"," Reve::NLTProjectorEditor", this, "DoDrawCenter()");
174
175     fCenterFrame->AddFrame(hf1, new TGLayoutHints(kLHintsTop, 0,0,0,0));
176
177   }
178
179   Int_t nel = 8;
180   fCenterX = new RGValuator(fCenterFrame, "CenterX:", 90, 0);
181   fCenterX->SetNELength(nel);
182   fCenterX->SetLabelWidth(labelW);
183   fCenterX->Build();
184   fCenterX->SetLimits(-5, 5, 501, TGNumberFormat::kNESRealThree);
185   fCenterX->SetToolTip("Origin of the projection.");
186   fCenterX->Connect("ValueSet(Double_t)", "Reve::NLTProjectorEditor",
187                     this, "DoCenter()");
188   fCenterFrame->AddFrame(fCenterX, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
189
190   fCenterY = new RGValuator(fCenterFrame, "CenterY:", 90, 0);
191   fCenterY->SetNELength(nel);
192   fCenterY->SetLabelWidth(labelW);
193   fCenterY->Build();
194   fCenterY->SetLimits(-5, 5, 501, TGNumberFormat::kNESRealThree);
195   fCenterY->SetToolTip("Origin of the projection.");
196   fCenterY->Connect("ValueSet(Double_t)", "Reve::NLTProjectorEditor",
197                     this, "DoCenter()");
198   fCenterFrame->AddFrame(fCenterY, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
199
200   fCenterZ = new RGValuator(fCenterFrame, "CenterZ:", 90, 0);
201   fCenterZ->SetNELength(nel);
202   fCenterZ->SetLabelWidth(labelW);
203   fCenterZ->Build();
204   fCenterZ->SetLimits(-25, 25, 501, TGNumberFormat::kNESRealThree);
205   fCenterZ->SetToolTip("Origin of the projection.");
206   fCenterZ->Connect("ValueSet(Double_t)", "Reve::NLTProjectorEditor",
207                     this, "DoCenter()");
208   fCenterFrame->AddFrame(fCenterZ, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
209 }
210
211 //______________________________________________________________________________
212 void NLTProjectorEditor::SetModel(TObject* obj)
213 {
214   // Set model object.
215
216   fM = dynamic_cast<NLTProjector*>(obj);
217
218   fAxisColor->SetColor(TColor::Number2Pixel(fM->GetAxisColor()), kFALSE);
219   fSIMode->Select(fM->GetSplitInfoMode(), kFALSE);
220   fSILevel->SetNumber(fM->GetSplitInfoLevel());
221
222   fType->Select(fM->GetProjection()->GetType(), kFALSE);
223   fDistortion->SetValue(1000.0f * fM->GetProjection()->GetDistortion());
224   fFixedRadius->SetValue(fM->GetProjection()->GetFixedRadius());
225   fCurrentDepth->SetValue(fM->GetCurrentDepth());
226
227   fDrawCenter->SetState(fM->GetDrawCenter()  ? kButtonDown : kButtonUp);
228   fDrawOrigin->SetState(fM->GetDrawOrigin()  ? kButtonDown : kButtonUp);
229   fCenterX->SetValue(fM->GetCenter().x);
230   fCenterY->SetValue(fM->GetCenter().y);
231   fCenterZ->SetValue(fM->GetCenter().z);
232 }
233
234 //______________________________________________________________________________
235 void NLTProjectorEditor::DoType(Int_t type)
236 {
237   // Slot for setting of projection type.
238
239   fM->SetProjection((NLTProjection::PType_e)type, 0.001f * fDistortion->GetValue());
240   fM->ProjectChildren();
241   Update();
242 }
243
244 //______________________________________________________________________________
245 void NLTProjectorEditor::DoDistortion()
246 {
247   // Slot for setting distortion.
248
249   fM->GetProjection()->SetDistortion(0.001f * fDistortion->GetValue());
250   fM->UpdateName();
251   fM->ProjectChildren();
252   Update();
253 }
254
255 //______________________________________________________________________________
256  void NLTProjectorEditor::DoFixedRadius()
257 {
258   // Slot for setting fixed radius.
259
260   fM->GetProjection()->SetFixedRadius(fFixedRadius->GetValue());
261   fM->ProjectChildren();
262   Update();
263 }
264
265 //______________________________________________________________________________
266 void NLTProjectorEditor::DoCurrentDepth()
267 {
268   // Slot for setting current depth.
269
270   fM->SetCurrentDepth(fCurrentDepth->GetValue());
271   fM->ProjectChildren();
272   Update();
273 }
274
275 //______________________________________________________________________________
276 void NLTProjectorEditor::DoCenter()
277 {
278   // Slot for setting center of distortion.
279  
280   fM->SetCenter(fCenterX->GetValue(), fCenterY->GetValue(), fCenterZ->GetValue());
281   Update();
282 }
283
284 //______________________________________________________________________________
285 void NLTProjectorEditor::DoDrawOrigin()
286 {
287   // Slot for setting draw of origin.
288
289   fM->SetDrawOrigin(fDrawOrigin->IsOn());
290   Update();
291 }
292
293 //______________________________________________________________________________
294 void NLTProjectorEditor::DoDrawCenter()
295 {
296   // Slot for setting draw of center.
297
298   fM->SetDrawCenter(fDrawCenter->IsOn());
299   Update();
300 }
301
302 //______________________________________________________________________________
303 void NLTProjectorEditor::DoSplitInfoMode(Int_t type)
304 {
305   // Slot for setting split info mode.
306
307   fM->SetSplitInfoMode(type);
308   Update();
309 }
310
311 //______________________________________________________________________________
312 void NLTProjectorEditor::DoSplitInfoLevel()
313 {
314   // Slot for setting tick-mark density.
315
316   fM->SetSplitInfoLevel((Int_t)fSILevel->GetNumber());
317   Update();
318 }
319
320 //______________________________________________________________________________
321 void NLTProjectorEditor::DoAxisColor(Pixel_t pixel)
322 {
323   // Slot for setting axis color.
324
325   fM->SetAxisColor(Color_t(TColor::GetColor(pixel)));
326   Update();
327 }