source: trunk/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc@ 801

Last change on this file since 801 was 749, checked in by tbretz, 24 years ago
*** empty log message ***
File size: 13.9 KB
Line 
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 <TGButton.h> // TGTextButton
29#include <TCanvas.h> // TCanvas.h
30#include <TGMsgBox.h> // TGMsgBox
31#include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
32
33enum ComIdentDisplayAdc {
34 M_BUTTON_SAVE,
35 M_BUTTON_PRINT,
36 M_BUTTON_PRINTALL,
37 M_BUTTON_CLOSE ,
38
39 M_BUTTON_PREV,
40 M_BUTTON_NEXT,
41
42 M_LIST_HISTO,
43 M_RADIO_HIGH,
44 M_RADIO_LOW,
45 M_RADIO_LH,
46 M_BUTTON_RESET,
47 M_VSId1
48} ;
49
50MGDisplayAdc::MGDisplayAdc ( MHFadcCam *histos,
51 const TGWindow *p, const TGWindow *main,
52 UInt_t w, UInt_t h,
53 UInt_t options)
54 : TGTransientFrame(p, main, w, h, options )
55{
56 //
57 // default constructor
58 //
59
60 //
61 // NEVER try to delete them in the destructor!
62 //
63 fHists = histos ;
64
65 //
66 // the top frame for the list and some buttons and the Canvas
67 //
68 fFrameTop = new TGHorizontalFrame (this, 60,20, kFitWidth ) ;
69
70 //
71 // left part of top frame
72 //
73 fFT1 = new TGVerticalFrame (fFrameTop, 80,300, kFitWidth ) ;
74
75 fHistoList = new TGListBox ( fFT1, M_LIST_HISTO ) ;
76 fHistoList->Associate( this ) ;
77 fFT1->AddFrame ( fHistoList, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 10 ) ) ;
78
79 fHistoList->Resize(80, 405 ) ;
80
81 fFrameTop->AddFrame (fFT1, new TGLayoutHints ( kLHintsTop , 10, 10, 10, 10 ) ) ;
82
83 //
84 // middle part of top frame
85 //
86 fFT2 = new TGVerticalFrame (fFrameTop, 80,20, kFitWidth ) ;
87
88 fButtonPrev = new TGTextButton ( fFT2, "Prev Histo", M_BUTTON_PREV ) ;
89 fButtonPrev->Associate (this) ;
90 fFT2->AddFrame ( fButtonPrev, new TGLayoutHints (kLHintsLeft | kLHintsTop,10, 10, 0, 10 ) ) ;
91
92
93 fVslider1 = new TGVSlider (fFT2, 250, kSlider1 | kScaleBoth, M_VSId1);
94
95 fVslider1->Associate(this);
96 fVslider1->SetRange(0, 576);
97 fFT2->AddFrame(fVslider1);
98
99 fButtonNext = new TGTextButton ( fFT2, "Next Histo", M_BUTTON_NEXT ) ;
100 fButtonNext->Associate (this) ;
101 fFT2->AddFrame ( fButtonNext, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 5 ) ) ;
102
103 fFrameTop->AddFrame (fFT2, new TGLayoutHints ( kLHintsTop , 10, 10, 10, 10 ) ) ;
104
105 //
106 // Radio buttons, used to select the high, low anh high/low display
107 //
108 fRadio[0] = new TGRadioButton(fFT2, "&High Gain", M_RADIO_HIGH);
109 fFT2->AddFrame ( fRadio[0], new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 5 ) ) ;
110 fRadio[0]->Associate(this);
111 fRadio[0]->SetState(kButtonDown);
112 fHistoLock = kFALSE;
113 fHistoType=1;
114
115 fRadio[1] = new TGRadioButton(fFT2, "&Low Gain", M_RADIO_LOW);
116 fFT2->AddFrame ( fRadio[1], new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 5 ) ) ;
117 fRadio[1]->Associate(this);
118
119 fRadio[2] = new TGRadioButton(fFT2, "H&igh/Low Gain", M_RADIO_LH);
120 fFT2->AddFrame ( fRadio[2], new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 5 ) ) ;
121 fRadio[2]->Associate(this);
122
123 //
124 // right part of top frame
125 //
126 fFT3 = new TGVerticalFrame (fFrameTop, 60, 60, kFitWidth ) ;
127
128 fECanv = new TRootEmbeddedCanvas("fECanv", fFT3, 400, 400 ) ;
129
130 fFT3->AddFrame( fECanv, new TGLayoutHints ( kLHintsCenterX | kLHintsCenterY | kLHintsExpandX | kLHintsExpandY , 10, 10, 10, 10 ) ) ;
131
132 //
133 //the button for reseting the histogram
134 //
135 fButtonReset = new TGTextButton ( fFT3, "Reset histo", M_BUTTON_RESET ) ;
136 fButtonReset->Associate (this) ;
137 fFT3->AddFrame ( fButtonReset, new TGLayoutHints (kLHintsCenterX | kLHintsTop,10, 10, 0, 10 ) ) ;
138
139 fCanv = fECanv->GetCanvas() ;
140
141 fFrameTop->AddFrame (fFT3, new TGLayoutHints ( kLHintsCenterX | kLHintsCenterY | kLHintsExpandX | kLHintsExpandY , 10, 10, 10, 10 ) ) ;
142
143 AddFrame ( fFrameTop, new TGLayoutHints ( kLHintsTop | kLHintsExpandX , 10, 10, 10, 10 ) ) ;
144
145 //
146 // the low frame for the control buttons
147 //
148 fFrameLow = new TGHorizontalFrame (this, 60,20, kFixedWidth ) ;
149
150 fButtonSave = new TGTextButton ( fFrameLow, "Save", M_BUTTON_SAVE ) ;
151 fButtonSave->Associate (this) ;
152 fFrameLow->AddFrame ( fButtonSave, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) ) ;
153
154 fButtonPrint = new TGTextButton ( fFrameLow, "Print", M_BUTTON_PRINT ) ;
155 fButtonPrint->Associate (this) ;
156 fFrameLow->AddFrame ( fButtonPrint, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) ) ;
157
158 fButtonPrintAll = new TGTextButton ( fFrameLow, "PrintAll", M_BUTTON_PRINTALL ) ;
159 fButtonPrintAll->Associate (this) ;
160 fFrameLow->AddFrame ( fButtonPrintAll, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) ) ;
161
162 fButtonClose = new TGTextButton ( fFrameLow, "Close", M_BUTTON_CLOSE ) ;
163 fButtonClose->Associate (this) ;
164 fFrameLow->AddFrame ( fButtonClose, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) ) ;
165 AddFrame ( fFrameLow, new TGLayoutHints ( kLHintsBottom | kLHintsExpandX , 10, 10, 10, 10 ) ) ;
166
167 //
168 //
169 //
170 BuildHistoList() ;
171
172 MapSubwindows();
173
174 Layout();
175
176 SetWindowName("ADC Spectra");
177 SetIconName("ADC Spectra");
178
179 //
180 // Here the initial display is set to hitogram 0
181 //
182 fHistoList->Select(1, kTRUE);
183 DrawSelectedHi() ;
184 SetSelectedTopEntry();
185 fCanv->Modified() ;
186 fCanv->Update() ;
187 SetSelectedPos();
188
189 MapWindow();
190 SetWMSizeHints(550, 550, 1000, 1000, 1, 1);
191}
192
193MGDisplayAdc::~MGDisplayAdc ()
194{
195 delete fButtonSave ;
196 delete fButtonPrint ;
197 delete fButtonPrintAll ;
198 delete fButtonClose ;
199
200 delete fButtonPrev;
201 delete fButtonNext ;
202 delete fButtonReset ;
203
204 delete fVslider1;
205 delete fECanv ;
206
207 delete fHistoList ;
208 delete fRadio[2];
209 delete fRadio[1];
210 delete fRadio[0];
211 delete fFT1 ;
212 delete fFT2 ;
213 delete fFT3 ;
214 delete fFrameLow ;
215 delete fFrameTop ;
216}
217
218// ======================================================================
219// ======================================================================
220
221void MGDisplayAdc::CloseWindow()
222{
223 // Got close message for this MainFrame. Calls parent CloseWindow()
224 // (which destroys the window) and terminate the application.
225 // The close message is generated by the window manager when its close
226 // window menu item is selected.
227 //
228 delete this ;
229 // TGTransientFrame::CloseWindow();
230 // TGMainFrame::CloseWindow();
231 // gROOT->GetApplication()->Terminate(0) ;
232}
233
234
235
236// ======================================================================
237// ======================================================================
238
239Bool_t MGDisplayAdc::BuildHistoList(Int_t type )
240{
241 //
242 // looks in the container of the AdcSpectra and reads in the
243 // Histogramms in there.
244 //
245 // In the class MHFadcCam are in fact two lists. One for the high and
246 // one for the low gain. Here we will use only the high gain list!!!
247 // With some special options (settings in the gui) we will also be able
248 // to plot the low gain
249 //
250
251 const Int_t nhi = fHists->GetEntries();
252 for ( Int_t i=0 ; i < nhi; i++ ) {
253 fHistoList->AddEntry(fHists->GetHistHi(i)->GetName(), i+1) ;
254 }
255
256 fHistoList->MapSubwindows() ;
257 fHistoList->Layout() ;
258 return kTRUE ;
259}
260
261// ======================================================================
262// ======================================================================
263
264Bool_t MGDisplayAdc::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
265{
266 //
267 // Process events generated by the buttons in the frame.
268 //
269 Int_t buttons = 4, retval = 0 ;
270 //Char_t wort[100] ;
271 //Char_t extens[5] ;
272 //Char_t command[110] ;
273
274 //TGFileItem *item ; // to process items in the file view container
275 //void *np = NULL ; // null pointer
276
277 switch (GET_MSG(msg))
278 {
279 case kC_COMMAND:
280 switch (GET_SUBMSG(msg))
281 {
282 case kCM_BUTTON:
283
284 switch (parm1)
285 {
286 case M_BUTTON_SAVE:
287 new TGMsgBox(fClient->GetRoot(), this,
288 "WARNING!",
289 "Not implemented yet.",
290 kMBIconExclamation, buttons, &retval);
291 break ;
292
293 case M_BUTTON_PRINT:
294 break;
295
296 case M_BUTTON_RESET:
297 new TGMsgBox(fClient->GetRoot(), this,
298 "WARNING!",
299 "Not implemented yet.",
300 kMBIconExclamation, buttons, &retval);
301 break;
302
303 case M_BUTTON_CLOSE:
304 CloseWindow() ;
305 break ;
306
307 // The selection for "Next Histogram".
308 // There is also a link for the sicronisation with the slider
309 //
310 case M_BUTTON_PREV:
311 case M_BUTTON_NEXT:
312 if ((parm1==M_BUTTON_PREV && GetSelected()-1 > 0) ||
313 (parm2==M_BUTTON_NEXT && GetSelected()-1 < 576))
314 {
315 if (fHistoLock == kTRUE )
316 {
317 fCanvas->cd(1);
318 SelectSelected();
319 DrawSelectedHi() ;
320 fCanvas->cd(2);
321 DrawSelectedLo() ;
322 }
323 else
324 {
325 fCanv->cd();
326 SelectSelected();
327 DrawSelectedHi() ;
328
329 }
330 SetSelectedTopEntry();
331 fCanv->Modified() ;
332 fCanv->Update() ;
333 SetSelectedPos();
334
335 }
336 if (fRadio[1]->GetState() != kButtonDown)
337 break;
338
339 fRadio[0]->SetState(kButtonDown);
340 fRadio[1]->SetState(kButtonUp);
341 break;
342
343 default:
344 break ;
345 }
346 break;
347
348 case kCM_RADIOBUTTON:
349
350 switch(parm1)
351 {
352 case M_RADIO_HIGH:
353 case M_RADIO_LOW:
354 if (parm1 == M_RADIO_HIGH)
355 {
356 fRadio[1]->SetState(kButtonUp);
357 fRadio[2]->SetState(kButtonUp);
358 fHistoType=1;
359 }
360 else
361 {
362 fRadio[0]->SetState(kButtonUp);
363 fRadio[2]->SetState(kButtonUp);
364 fHistoType = 2;
365 }
366 fHistoLock = kFALSE;
367
368 fCanv->cd();
369 SelectSelected();
370 parm1 == M_RADIO_HIGH ? DrawSelectedHi() : DrawSelectedLo();
371
372 SetSelectedTopEntry();
373 fCanv->Modified() ;
374 fCanv->Update() ;
375 SetSelectedPos();
376 break;
377
378 case M_RADIO_LH:
379 fRadio[0]->SetState(kButtonUp);
380 fRadio[1]->SetState(kButtonUp);
381
382 if (fHistoLock == kFALSE)
383 {
384 fCanvas = fECanv->GetCanvas();
385 fCanvas->Divide(1,2, 0, 0 ,0);
386
387 fCanv->Modified() ;
388 fCanv->Update() ;
389 fHistoLock = kTRUE;
390 fHistoType = 3;
391 }
392
393 fCanvas->cd(1);
394
395 SelectSelected();
396 DrawSelectedHi() ;
397 SetSelectedTopEntry();
398
399 fCanvas->cd(2);
400 SelectSelected();
401 DrawSelectedLo() ;
402 SetSelectedTopEntry();
403
404 fCanv->Modified() ;
405 fCanv->Update();
406
407 default:
408 break;
409 }
410 break;
411 }
412
413 case kCM_LISTBOX:
414 if (GET_SUBMSG(msg) != M_LIST_HISTO)
415 break;
416
417 if (fHistoLock == kTRUE )
418 {
419 fCanvas->cd(1);
420 DrawSelectedHi() ;
421 fCanvas->cd(2);
422 DrawSelectedLo() ;
423 }
424 else
425 {
426 fCanv->cd() ;
427 DrawSelectedHi() ;
428 }
429 fCanv->Modified() ;
430 fCanv->Update() ;
431 SetSelectedPos();
432 break ;
433
434/*
435 case kC_CONTAINER:
436 switch (GET_SUBMSG(msg))
437 {
438
439 case kCT_ITEMDBLCLICK:
440 break;
441
442 default:
443 break ;
444 }
445*/
446
447 case kC_VSLIDER:
448 if (GET_SUBMSG(msg)!=kSL_POS || parm1!=M_VSId1)
449 break;
450
451 // Check for the slider movement and sicronise with TGListBox
452 if (parm2<0 || parm2>576)
453 break;
454
455 if (fHistoLock==kTRUE)
456 {
457 fCanvas->cd(1) ;
458 DrawHi(parm2) ;
459 fHistoList->Select(parm2+1, kTRUE);
460
461 fCanvas->cd(2) ;
462 DrawLo(parm2) ;
463 }
464 else
465 {
466 fCanv->cd() ;
467 DrawHi(parm2) ;
468 }
469
470 fHistoList->Select(parm2+1, kTRUE);
471 SetSelectedTopEntry();
472
473 fCanv->Modified() ;
474 fCanv->Update() ;
475
476 if (fRadio[1]->GetState() != kButtonDown)
477 break;
478
479 fRadio[0]->SetState(kButtonDown);
480 fRadio[1]->SetState(kButtonUp);
481
482 break;
483
484 }
485 return kTRUE;
486}
Note: See TracBrowser for help on using the repository browser.