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