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