]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveBase/AliEveJetPlaneEditor.cxx
Fix enums as reported by coverity
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveJetPlaneEditor.cxx
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 #include "AliEveJetPlaneEditor.h"
11 #include "AliEveJetPlane.h"
12
13 #include <TEveGValuators.h>
14
15 #include <TGButton.h>
16 #include <TGNumberEntry.h>
17 #include <TGFrame.h>
18 #include <TGTab.h>
19
20 //==============================================================================
21 //==============================================================================
22 // AliEveJetPlaneEditor
23 //==============================================================================
24
25 //______________________________________________________________________________
26 //
27 // GUI editor for AliEveJetPlane class.
28
29 AliEveJetPlaneEditor::StaticDataWindow* AliEveJetPlaneEditor::fgStaticWindow = 0;
30
31 ClassImp(AliEveJetPlaneEditor)
32
33 AliEveJetPlaneEditor::AliEveJetPlaneEditor(const TGWindow *p, Int_t width, Int_t height,
34                                UInt_t options, Pixel_t back) :
35   TGedFrame(p, width, height, options | kVerticalFrame, back),
36   fM(0),
37   fRnrJets(0),
38   fRnrTracks(0),
39   fEnergyScale(0),
40   fArrowJetScale(0),
41   fArrowTrackScale(0),
42   fOneSelection(0), fTwoSelection(0),
43   fInformationSetup(0)
44 {
45   // Constructor.
46
47   MakeTitle("AliEveJetPlane");
48   Int_t labelW = 67;
49
50   fRnrJets  = new TGCheckButton(this, "Rnr Jets");
51   AddFrame(fRnrJets, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
52   fRnrJets->Connect("Clicked()", "AliEveJetPlaneEditor", this, "DoRnrJets()");
53
54   fRnrTracks  = new TGCheckButton(this, "Rnr Tracks");
55   AddFrame(fRnrTracks, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
56   fRnrTracks->Connect("Clicked()", "AliEveJetPlaneEditor", this, "DoRnrTracks()");
57
58   fEnergyScale = new TEveGValuator(this, "Length scale:", 110, 0);
59   fEnergyScale->SetLabelWidth(labelW);
60   fEnergyScale->SetNELength(6);
61   fEnergyScale->Build();
62   fEnergyScale->SetLimits(1, 200, 200, TGNumberFormat::kNESRealOne);
63   fEnergyScale->SetToolTip("Energy mapped to length of arrow.");
64   fEnergyScale->Connect("ValueSet(Double_t)", "AliEveJetPlaneEditor", this, "DoEnergyScale()");
65   AddFrame(fEnergyScale, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
66
67   fArrowJetScale = new TEveGValuator(this, "Jet scale:", 110, 0);
68   fArrowJetScale->SetLabelWidth(labelW);
69   fArrowJetScale->SetNELength(6);
70   fArrowJetScale->Build();
71   fArrowJetScale->SetLimits(0.1, 3, 100, TGNumberFormat::kNESRealOne);
72   fArrowJetScale->SetToolTip("Scale for jet arrow dimensions.");
73   fArrowJetScale->Connect("ValueSet(Double_t)", "AliEveJetPlaneEditor", this, "DoArrowJetScale()");
74   AddFrame(fArrowJetScale, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
75
76   fArrowTrackScale = new TEveGValuator(this, "Track scale:", 110, 0);
77   fArrowTrackScale->SetLabelWidth(labelW);
78   fArrowTrackScale->SetNELength(6);
79   fArrowTrackScale->Build();
80   fArrowTrackScale->SetLimits(0.1, 3, 100, TGNumberFormat::kNESRealOne);
81   fArrowTrackScale->SetToolTip("Scale for track arrow dimensions.");
82   fArrowTrackScale->Connect("ValueSet(Double_t)", "AliEveJetPlaneEditor", this, "DoArrowTrackScale()");
83   AddFrame(fArrowTrackScale, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
84         
85         fOneSelection = new TGRadioButton(this, "&One AliEveTrack/Jet");
86   fTwoSelection = new TGRadioButton(this, "&Two AliEveTrack/Jet");
87   AddFrame(fOneSelection, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
88   AddFrame(fTwoSelection, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
89   fOneSelection->Connect("Clicked()", "AliEveJetPlaneEditor", this, "DoOneSelection()");
90   fTwoSelection->Connect("Clicked()", "AliEveJetPlaneEditor", this, "DoTwoSelection()");
91
92   // fInformationSetup = new TGTextButton(this, "AliEveTrack/Jet Print");
93   // AddFrame(fInformationSetup, new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 0, 2, 2));
94   // fInformationSetup->Connect("Clicked()", "AliEveJetPlaneEditor", this, "DoStaticDataWindow()");
95 }
96
97 /******************************************************************************/
98
99 void AliEveJetPlaneEditor::SetModel(TObject* obj)
100 {
101   // Set model object.
102
103   fM = static_cast<AliEveJetPlane*>(obj);
104
105   // Set values of widgets
106   // fXYZZ->SetValue(fM->GetXYZZ());
107   fRnrJets->SetState(fM->GetRnrJets() ? kButtonDown : kButtonUp);
108   fRnrTracks->SetState(fM->GetRnrTracks() ? kButtonDown : kButtonUp);
109   fEnergyScale->SetValue(fM->GetEnergyScale());
110   fArrowJetScale->SetValue(fM->GetArrowJetScale());
111   fArrowTrackScale->SetValue(fM->GetArrowTrackScale());
112         fOneSelection->SetState(fM->GetOneSelection() ? kButtonDown : kButtonUp);
113   fTwoSelection->SetState(fM->GetTwoSelection() ? kButtonDown : kButtonUp);
114 }
115
116 /******************************************************************************/
117
118 void AliEveJetPlaneEditor::DoRnrJets()
119 {
120   // Slot for RnrJets.
121
122   fM->SetRnrJets(fRnrJets->IsOn());
123   Update();
124 }
125
126 void AliEveJetPlaneEditor::DoRnrTracks()
127 {
128   // Slot for RnrTracks.
129
130   fM->SetRnrTracks(fRnrTracks->IsOn());
131   Update();
132 }
133
134 void AliEveJetPlaneEditor::DoArrowJetScale()
135 {
136   // Slot for JetScale.
137
138   fM->SetArrowJetScale(fArrowJetScale->GetValue());
139   Update();
140 }
141
142 void AliEveJetPlaneEditor::DoArrowTrackScale()
143 {
144   // Slot for TrackScale.
145
146   fM->SetArrowTrackScale(fArrowTrackScale->GetValue());
147   Update();
148 }
149
150 void AliEveJetPlaneEditor::DoEnergyScale()
151 {
152   // Slot for EnergyScale.
153
154   fM->SetEnergyScale(fEnergyScale->GetValue());
155   Update();
156 }
157
158 void AliEveJetPlaneEditor::DoOneSelection()
159 {
160   // Slot for OneSelection.
161
162   fTwoSelection->SetState(kButtonUp);
163   fM->SetOneSelection(fOneSelection->IsOn());
164   fM->SetTwoSelection(fTwoSelection->IsOn());
165   Update();
166 }
167
168 void AliEveJetPlaneEditor::DoTwoSelection()
169 {
170   // Slot for TwoSelection.
171
172   fOneSelection->SetState(kButtonUp);
173   fM->SetOneSelection(fOneSelection->IsOn());
174   fM->SetTwoSelection(fTwoSelection->IsOn());
175   Update();
176 }
177
178 void AliEveJetPlaneEditor::DoStaticDataWindow()
179 {
180   // Slot for StaticDataWindow.
181
182   printf("\n Soon available ... \n");
183   if (fgStaticWindow == 0)
184     fgStaticWindow = new StaticDataWindow(gClient->GetRoot(), this, 400, 200);
185
186   // call fgStaticWindow->ReadValues(); // like setmodel
187
188   // position relative to the parent's window
189   fgStaticWindow->MapWindow();
190   fgStaticWindow->RaiseWindow();
191   fgStaticWindow->CenterOnParent();
192 }
193
194
195 //==============================================================================
196 //==============================================================================
197 // AliEveJetPlaneEditor::StaticDataWindow
198 //==============================================================================
199
200 //______________________________________________________________________________
201 //
202 // Common settings for all AliEveJetPlane objects.
203 // Used as a pop-up from AliEveJetPlaneEditor.
204
205 ClassImp(AliEveJetPlaneEditor::StaticDataWindow)
206
207 AliEveJetPlaneEditor::StaticDataWindow::StaticDataWindow(const TGWindow *p, const TGWindow *main,
208                                                          UInt_t w, UInt_t h, UInt_t options) :
209   TGTransientFrame(p, main, w, h, options),
210   fFrame1(0), fF2(0),
211   fOkButton(0), fCancelButton(0),
212   fL1(0), fL2(0), fL3(0), fL5(0),
213   fTab(0),
214   fChk1(0), fChk2(0), fChk3(0), fChk4(0), fChk5(0)
215 {
216   // Constructor.
217   // Create a dialog window. A dialog window pops up with respect to its
218   // "main" window.
219
220   Connect("CloseWindow()", "AliEveJetPlaneEditor::StaticDataWindow", this, "DoClose()");
221   DontCallClose(); // to avoid double deletions.
222
223   // use hierarchical cleaning
224   SetCleanup(kDeepCleanup);
225
226   fFrame1 = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
227
228   fOkButton = new TGTextButton(fFrame1, "&Ok", 1);
229   fOkButton->Connect("Clicked()", "AliEveJetPlaneEditor::StaticDataWindow", this, "DoOK()");
230   fCancelButton = new TGTextButton(fFrame1, "&Cancel", 2);
231   fCancelButton->Connect("Clicked()", "AliEveJetPlaneEditor::StaticDataWindow", this, "DoCancel()");
232
233   fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,2, 2, 2, 2);
234   fL2 = new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1);
235
236   fFrame1->AddFrame(fOkButton, fL1);
237   fFrame1->AddFrame(fCancelButton, fL1);
238
239   fFrame1->Resize(150, fOkButton->GetDefaultHeight());
240   AddFrame(fFrame1, fL2);
241
242   // Tabs for one and two track information
243
244   fTab = new TGTab(this, 300, 300);
245   fTab->Connect("Selected(Int_t)", "AliEveJetPlaneEditor::StaticDataWindow", this, "DoTab(Int_t)");
246
247   fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
248
249   TGCompositeFrame *tf = fTab->AddTab("One AliEveTrack/Jet");
250
251   //    fF1 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
252   //    fF1->AddFrame(new TGTextButton(fF1, "&Test button", 0), fL3);
253   //    fF1->AddFrame(fTxt1 = new TGTextEntry(fF1, new TGTextBuffer(100)), fL3);
254   //    fF1->AddFrame(fTxt2 = new TGTextEntry(fF1, new TGTextBuffer(100)), fL3);
255   //    tf->AddFrame(fF1, fL3);
256   //    fTxt1->Resize(150, fTxt1->GetDefaultHeight());
257   //    fTxt2->Resize(150, fTxt2->GetDefaultHeight());
258   fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2);
259   fF2 = new TGCompositeFrame(tf, 60, 60, kVerticalFrame);
260   fF2->AddFrame(fChk1 = new TGCheckButton(fF2, "4-Momentum: {pt, px, py, pz} "), fL1);
261   fF2->AddFrame(fChk2 = new TGCheckButton(fF2, "4-Momentum: {pt, Phi, Theta}"), fL1);
262   fF2->AddFrame(fChk3 = new TGCheckButton(fF2, "Pseudorapidity: Eta"), fL1);
263   fF2->AddFrame(fChk4 = new TGCheckButton(fF2, "Energy: E"), fL1);
264   fF2->AddFrame(fChk5 = new TGCheckButton(fF2, "Charge and Mass"), fL1);
265
266   tf = fTab->AddTab("Two Tracks/Jets");
267
268   tf->AddFrame(fF2, fL3);
269
270   //    fBtn1->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
271   //    fBtn2->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
272   //    fChk1->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
273   //    fChk2->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
274   //    fRad1->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
275   //    fRad2->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
276
277
278   fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY, 2, 2, 5, 1);
279   AddFrame(fTab, fL5);
280
281   MapSubwindows();
282   Resize();
283
284   SetWindowName("AliEveTrack/Jet Common Setup");
285 }
286
287 AliEveJetPlaneEditor::StaticDataWindow::~StaticDataWindow()
288 {
289   // Destructor, deletes the window.
290
291   DeleteWindow();
292 }
293
294 void AliEveJetPlaneEditor::StaticDataWindow::DoClose()
295 {
296   // Close the window.
297
298   UnmapWindow();
299 }
300
301 void AliEveJetPlaneEditor::StaticDataWindow::DoOK()
302 {
303   // Read data from widgets, copy to static members of AliEveJetPlane
304
305   SendCloseMessage();
306 }
307
308 void AliEveJetPlaneEditor::StaticDataWindow::DoCancel()
309 {
310   // Cancel, close the window.
311
312   SendCloseMessage();
313 }
314
315 void AliEveJetPlaneEditor::StaticDataWindow::DoTab(Int_t /*id*/)
316 {
317   // Tab selected.
318
319   // printf("Tab item %d activated\n", id);
320 }
321
322