1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
|
---|
19 | ! Author(s): Thomas Bretz 12/2000 (tbretz@uni-sw.gwdg.de)
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2001
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | #include "MGDisplayAdc.h"
|
---|
27 |
|
---|
28 | #include <iostream.h> // cout for debugging
|
---|
29 |
|
---|
30 | #include <TGButton.h> // TGTextButton
|
---|
31 | #include <TCanvas.h> // TCanvas.h
|
---|
32 | #include <TGMsgBox.h> // TGMsgBox
|
---|
33 | #include <TGListBox.h> // TGListBox
|
---|
34 | #include <TGSlider.h> // TGVSlider
|
---|
35 | #include <TGButtonGroup.h> // TGVButtonGroup
|
---|
36 | #include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
|
---|
37 |
|
---|
38 | #include "MHFadcCam.h"
|
---|
39 |
|
---|
40 | enum ComIdentDisplayAdc
|
---|
41 | {
|
---|
42 | M_BUTTON_SAVE,
|
---|
43 | M_BUTTON_PRINT,
|
---|
44 | M_BUTTON_PRINTALL,
|
---|
45 | M_BUTTON_CLOSE,
|
---|
46 |
|
---|
47 | M_BUTTON_PREV,
|
---|
48 | M_BUTTON_NEXT,
|
---|
49 |
|
---|
50 | M_LIST_HISTO,
|
---|
51 | M_RADIO_HI,
|
---|
52 | M_RADIO_LO,
|
---|
53 | M_RADIO_LH,
|
---|
54 | M_BUTTON_RESET,
|
---|
55 | M_VSId1
|
---|
56 | };
|
---|
57 |
|
---|
58 | void MGDisplayAdc::AddFrameTop(TGHorizontalFrame *frame)
|
---|
59 | {
|
---|
60 | //
|
---|
61 | // left part of top frame
|
---|
62 | //
|
---|
63 | TGVerticalFrame *left = new TGVerticalFrame(frame, 80, 300, kFitWidth);
|
---|
64 | fList->Add(left);
|
---|
65 |
|
---|
66 | fHistoList = new TGListBox (left, M_LIST_HISTO);
|
---|
67 | fHistoList->Associate(this);
|
---|
68 | fHistoList->Resize(80, 405);
|
---|
69 |
|
---|
70 | fList->Add(fHistoList);
|
---|
71 |
|
---|
72 | TGLayoutHints *laylist = new TGLayoutHints(kLHintsNormal, 10, 10, 10, 10);
|
---|
73 | fList->Add(laylist);
|
---|
74 |
|
---|
75 | left->AddFrame(fHistoList, laylist);
|
---|
76 |
|
---|
77 | //
|
---|
78 | // middle part of top frame
|
---|
79 | //
|
---|
80 | TGVerticalFrame *mid = new TGVerticalFrame(frame, 80, 20, kFitWidth);
|
---|
81 | fList->Add(mid);
|
---|
82 |
|
---|
83 | // ---
|
---|
84 |
|
---|
85 | TGTextButton *prev = new TGTextButton(mid, "Prev Histo", M_BUTTON_PREV);
|
---|
86 | TGTextButton *next = new TGTextButton(mid, "Next Histo", M_BUTTON_NEXT);
|
---|
87 | prev->Associate(this);
|
---|
88 | next->Associate(this);
|
---|
89 |
|
---|
90 | fList->Add(prev);
|
---|
91 | fList->Add(next);
|
---|
92 |
|
---|
93 | // ---
|
---|
94 |
|
---|
95 | fSlider = new TGVSlider(mid, 250, kSlider1|kScaleBoth, M_VSId1);
|
---|
96 | fSlider->Associate(this);
|
---|
97 | fSlider->SetRange(1, 577);
|
---|
98 |
|
---|
99 | fList->Add(fSlider);
|
---|
100 |
|
---|
101 | // ---
|
---|
102 |
|
---|
103 | TGVButtonGroup *group = new TGVButtonGroup(mid);
|
---|
104 | fList->Add(group);
|
---|
105 |
|
---|
106 | TGRadioButton *radio1 = new TGRadioButton(group, "&High Gain", M_RADIO_HI);
|
---|
107 | TGRadioButton *radio2 = new TGRadioButton(group, "&Low Gain", M_RADIO_LO);
|
---|
108 | TGRadioButton *radio3 = new TGRadioButton(group, "H&igh/Low Gain", M_RADIO_LH);
|
---|
109 |
|
---|
110 | /* FIXME:
|
---|
111 |
|
---|
112 | ~TGRadioButton calls TGRadioButton::TGFrame::GetMainFrame
|
---|
113 | which calles fParent->GetFrame()
|
---|
114 |
|
---|
115 | fList->Add(radio1);
|
---|
116 | fList->Add(radio2);
|
---|
117 | fList->Add(radio3);
|
---|
118 | */
|
---|
119 |
|
---|
120 | radio1->SetState(kButtonDown);
|
---|
121 |
|
---|
122 | radio1->Associate(this);
|
---|
123 | radio2->Associate(this);
|
---|
124 | radio3->Associate(this);
|
---|
125 |
|
---|
126 | // ---
|
---|
127 |
|
---|
128 | TGLayoutHints *laybut1 = new TGLayoutHints(kLHintsNormal, 10, 10, 0, 10);
|
---|
129 | TGLayoutHints *laybut2 = new TGLayoutHints(kLHintsNormal, 10, 10, 10, 5);
|
---|
130 |
|
---|
131 | fList->Add(laybut1);
|
---|
132 | fList->Add(laybut2);
|
---|
133 |
|
---|
134 | mid->AddFrame(prev, laybut1);
|
---|
135 | mid->AddFrame(fSlider);
|
---|
136 | mid->AddFrame(next, laybut2);
|
---|
137 | mid->AddFrame(group, laybut2);
|
---|
138 |
|
---|
139 | //
|
---|
140 | // right part of top frame
|
---|
141 | //
|
---|
142 | TGVerticalFrame *right = new TGVerticalFrame(frame, 60, 60, kFitWidth);
|
---|
143 | fList->Add(right);
|
---|
144 |
|
---|
145 | TRootEmbeddedCanvas *canvas = new TRootEmbeddedCanvas("fECanv", right, 800, 400);
|
---|
146 | fList->Add(canvas);
|
---|
147 |
|
---|
148 | TGLayoutHints *laycanv = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY|kLHintsExpandX|kLHintsExpandY, 10, 10, 10, 10);
|
---|
149 | fList->Add(laycanv);
|
---|
150 |
|
---|
151 | right->AddFrame(canvas, laycanv);
|
---|
152 |
|
---|
153 |
|
---|
154 | TGTextButton *reset = new TGTextButton(right, "Reset histo", M_BUTTON_RESET);
|
---|
155 | reset->Associate(this);
|
---|
156 | fList->Add(reset);
|
---|
157 |
|
---|
158 | TGLayoutHints *layreset = new TGLayoutHints(kLHintsCenterX|kLHintsTop,10, 10, 0, 10);
|
---|
159 | fList->Add(layreset);
|
---|
160 |
|
---|
161 | right->AddFrame(reset, layreset);
|
---|
162 |
|
---|
163 | // ---
|
---|
164 |
|
---|
165 | fCanvas = canvas->GetCanvas();
|
---|
166 |
|
---|
167 | //
|
---|
168 | // layout the three subframes
|
---|
169 | //
|
---|
170 | TGLayoutHints *layframe1 = new TGLayoutHints(kLHintsTop, 10, 10, 10, 10);
|
---|
171 | TGLayoutHints *layframe2 = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY|kLHintsExpandX|kLHintsExpandY, 10, 10, 10, 10);
|
---|
172 | fList->Add(layframe1);
|
---|
173 | fList->Add(layframe2);
|
---|
174 |
|
---|
175 | frame->AddFrame(left, layframe1);
|
---|
176 | frame->AddFrame(mid, layframe1);
|
---|
177 | frame->AddFrame(right, layframe2);
|
---|
178 | }
|
---|
179 |
|
---|
180 | void MGDisplayAdc::AddFrameLow(TGHorizontalFrame *frame)
|
---|
181 | {
|
---|
182 | //
|
---|
183 | // the low frame for the control buttons
|
---|
184 | //
|
---|
185 | TGTextButton *but1 = new TGTextButton(frame, "Save", M_BUTTON_SAVE);
|
---|
186 | TGTextButton *but2 = new TGTextButton(frame, "Print", M_BUTTON_PRINT);
|
---|
187 | TGTextButton *but3 = new TGTextButton(frame, "PrintAll", M_BUTTON_PRINTALL);
|
---|
188 | TGTextButton *but4 = new TGTextButton(frame, "Close", M_BUTTON_CLOSE);
|
---|
189 |
|
---|
190 | but1->Associate(this);
|
---|
191 | but2->Associate(this);
|
---|
192 | but3->Associate(this);
|
---|
193 | but4->Associate(this);
|
---|
194 |
|
---|
195 | fList->Add(but1);
|
---|
196 | fList->Add(but2);
|
---|
197 | fList->Add(but3);
|
---|
198 | fList->Add(but4);
|
---|
199 |
|
---|
200 | TGLayoutHints *laybut = new TGLayoutHints(kLHintsNormal, 10, 10, 5, 5);
|
---|
201 | fList->Add(laybut);
|
---|
202 |
|
---|
203 | frame->AddFrame(but1, laybut);
|
---|
204 | frame->AddFrame(but2, laybut);
|
---|
205 | frame->AddFrame(but3, laybut);
|
---|
206 | frame->AddFrame(but4, laybut);
|
---|
207 | }
|
---|
208 |
|
---|
209 | MGDisplayAdc::MGDisplayAdc(MHFadcCam *histos,
|
---|
210 | const TGWindow *p, const TGWindow *main,
|
---|
211 | UInt_t w, UInt_t h,
|
---|
212 | UInt_t options)
|
---|
213 | : TGTransientFrame(p, main, w, h, options), fHists(histos), fHistoType(M_RADIO_HI)
|
---|
214 | {
|
---|
215 | fList = new TList;
|
---|
216 | fList->SetOwner();
|
---|
217 |
|
---|
218 | //
|
---|
219 | // Create the to frames
|
---|
220 | //
|
---|
221 | TGHorizontalFrame *frametop = new TGHorizontalFrame(this, 60, 20, kFitWidth);
|
---|
222 | TGHorizontalFrame *framelow = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
|
---|
223 |
|
---|
224 | //
|
---|
225 | // Add frames to 'autodel'
|
---|
226 | //
|
---|
227 | fList->Add(frametop);
|
---|
228 | fList->Add(framelow);
|
---|
229 |
|
---|
230 | //
|
---|
231 | // Add the gui elements to the two frames
|
---|
232 | //
|
---|
233 | AddFrameTop(frametop);
|
---|
234 | AddFrameLow(framelow);
|
---|
235 |
|
---|
236 | //
|
---|
237 | // layout the two frames in this frame
|
---|
238 | //
|
---|
239 | TGLayoutHints *laytop = new TGLayoutHints(kLHintsTop|kLHintsExpandX, 10, 10, 10, 10);
|
---|
240 | TGLayoutHints *laylow = new TGLayoutHints(kLHintsBottom|kLHintsExpandX, 10, 10, 10, 10);
|
---|
241 |
|
---|
242 | AddFrame(frametop, laytop);
|
---|
243 | AddFrame(framelow, laylow);
|
---|
244 |
|
---|
245 | //
|
---|
246 | // Setup interieur
|
---|
247 | //
|
---|
248 | BuildHistoList();
|
---|
249 |
|
---|
250 | //
|
---|
251 | // Here the initial display is set to hitogram 0
|
---|
252 | //
|
---|
253 | fHistoList->Select(1);
|
---|
254 | UpdateHist();
|
---|
255 |
|
---|
256 | //
|
---|
257 | // Setup frame
|
---|
258 | //
|
---|
259 | MapSubwindows();
|
---|
260 |
|
---|
261 | Layout();
|
---|
262 |
|
---|
263 | SetWindowName("ADC Spectra");
|
---|
264 | SetIconName("ADC Spectra");
|
---|
265 |
|
---|
266 | MapWindow();
|
---|
267 | SetWMSizeHints(550, 550, 1000, 1000, 1, 1);
|
---|
268 | }
|
---|
269 |
|
---|
270 | MGDisplayAdc::~MGDisplayAdc()
|
---|
271 | {
|
---|
272 | delete fList;
|
---|
273 | }
|
---|
274 |
|
---|
275 | // ======================================================================
|
---|
276 |
|
---|
277 | void MGDisplayAdc::CloseWindow()
|
---|
278 | {
|
---|
279 | // Got close message for this MainFrame. Calls parent CloseWindow()
|
---|
280 | // (which destroys the window) and terminate the application.
|
---|
281 | // The close message is generated by the window manager when its close
|
---|
282 | // window menu item is selected.
|
---|
283 | //
|
---|
284 | delete this;
|
---|
285 | }
|
---|
286 |
|
---|
287 |
|
---|
288 |
|
---|
289 | // ======================================================================
|
---|
290 | // ======================================================================
|
---|
291 |
|
---|
292 | Bool_t MGDisplayAdc::BuildHistoList()
|
---|
293 | {
|
---|
294 | //
|
---|
295 | // looks in the container of the AdcSpectra and reads in the
|
---|
296 | // Histogramms in there.
|
---|
297 | //
|
---|
298 | // In the class MHFadcCam are in fact two lists. One for the high and
|
---|
299 | // one for the low gain. Here we will use only the high gain list!!!
|
---|
300 | // With some special options (settings in the gui) we will also be able
|
---|
301 | // to plot the low gain
|
---|
302 | //
|
---|
303 | const Int_t nhi = fHists->GetEntries();
|
---|
304 | for (Int_t i=0 ; i<nhi; i++)
|
---|
305 | fHistoList->AddEntry(fHists->GetHistHi(i)->GetName(), i+1);
|
---|
306 |
|
---|
307 | fHistoList->MapSubwindows();
|
---|
308 | fHistoList->Layout();
|
---|
309 |
|
---|
310 | return kTRUE;
|
---|
311 | }
|
---|
312 |
|
---|
313 | // ======================================================================
|
---|
314 | // ======================================================================
|
---|
315 | void MGDisplayAdc::UpdateHist()
|
---|
316 | {
|
---|
317 | const Int_t selected = fHistoList->GetSelected();
|
---|
318 |
|
---|
319 | fHistoList->Select(selected); // ???
|
---|
320 |
|
---|
321 | fCanvas->Clear();
|
---|
322 |
|
---|
323 | switch (fHistoType)
|
---|
324 | {
|
---|
325 | case M_RADIO_HI:
|
---|
326 | case M_RADIO_LO:
|
---|
327 | fCanvas->Divide(1, 1);
|
---|
328 |
|
---|
329 | fCanvas->cd();
|
---|
330 | if (fHistoType==M_RADIO_HI)
|
---|
331 | fHists->DrawHi(selected-1);
|
---|
332 | else
|
---|
333 | fHists->DrawLo(selected-1);
|
---|
334 | break;
|
---|
335 |
|
---|
336 | case M_RADIO_LH:
|
---|
337 | fCanvas->Divide(1, 2);
|
---|
338 |
|
---|
339 | fCanvas->cd(1);
|
---|
340 | fHists->DrawHi(selected-1);
|
---|
341 |
|
---|
342 | fCanvas->cd(2);
|
---|
343 | fHists->DrawLo(selected-1);
|
---|
344 | break;
|
---|
345 | }
|
---|
346 |
|
---|
347 | fHistoList->SetTopEntry(selected);
|
---|
348 |
|
---|
349 | fCanvas->Modified();
|
---|
350 | fCanvas->Update();
|
---|
351 |
|
---|
352 | fSlider->SetPosition(selected);
|
---|
353 | }
|
---|
354 |
|
---|
355 | Bool_t MGDisplayAdc::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
|
---|
356 | {
|
---|
357 | //
|
---|
358 | // Process events generated by the buttons in the frame.
|
---|
359 | //
|
---|
360 | switch (GET_MSG(msg))
|
---|
361 | {
|
---|
362 | case kC_COMMAND:
|
---|
363 | switch (GET_SUBMSG(msg))
|
---|
364 | {
|
---|
365 | case kCM_BUTTON:
|
---|
366 | switch (parm1)
|
---|
367 | {
|
---|
368 | case M_BUTTON_SAVE:
|
---|
369 | cout << "Sorry, not yet implemented!" << endl;
|
---|
370 | return kTRUE;
|
---|
371 |
|
---|
372 | case M_BUTTON_PRINT:
|
---|
373 | cout << "Sorry, not yet implemented!" << endl;
|
---|
374 | return kTRUE;
|
---|
375 |
|
---|
376 | case M_BUTTON_RESET:
|
---|
377 | cout << "Sorry, not yet implemented!" << endl;
|
---|
378 | return kTRUE;
|
---|
379 |
|
---|
380 | case M_BUTTON_CLOSE:
|
---|
381 | CloseWindow();
|
---|
382 | return kTRUE;
|
---|
383 |
|
---|
384 | case M_BUTTON_PREV:
|
---|
385 | case M_BUTTON_NEXT:
|
---|
386 | {
|
---|
387 | const Int_t selected = fHistoList->GetSelected();
|
---|
388 |
|
---|
389 | if ((parm1==M_BUTTON_PREV && selected==1) ||
|
---|
390 | (parm1==M_BUTTON_NEXT && selected==577))
|
---|
391 | return kTRUE;
|
---|
392 |
|
---|
393 | fHistoList->Select(parm1==M_BUTTON_PREV ? selected-1 : selected+1);
|
---|
394 | UpdateHist();
|
---|
395 | }
|
---|
396 | return kTRUE;
|
---|
397 | }
|
---|
398 | return kTRUE;
|
---|
399 |
|
---|
400 | case kCM_RADIOBUTTON:
|
---|
401 | switch(parm1)
|
---|
402 | {
|
---|
403 | case M_RADIO_HI:
|
---|
404 | case M_RADIO_LO:
|
---|
405 | case M_RADIO_LH:
|
---|
406 | fHistoType = parm1;
|
---|
407 | UpdateHist();
|
---|
408 | return kTRUE;
|
---|
409 | }
|
---|
410 | return kTRUE;
|
---|
411 | }
|
---|
412 |
|
---|
413 | case kCM_LISTBOX:
|
---|
414 | if (GET_SUBMSG(msg) == M_LIST_HISTO)
|
---|
415 | UpdateHist();
|
---|
416 |
|
---|
417 | return kTRUE;
|
---|
418 |
|
---|
419 | case kC_VSLIDER:
|
---|
420 | if (GET_SUBMSG(msg)!=kSL_POS || parm1!=M_VSId1)
|
---|
421 | return kTRUE;
|
---|
422 |
|
---|
423 | // Check for the slider movement and sicronise with TGListBox
|
---|
424 | if (parm2<1 || parm2>577)
|
---|
425 | return kTRUE;
|
---|
426 |
|
---|
427 | fHistoList->Select(parm2);
|
---|
428 | UpdateHist();
|
---|
429 | return kTRUE;
|
---|
430 | }
|
---|
431 |
|
---|
432 | return kTRUE;
|
---|
433 | }
|
---|