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