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