source: branches/start/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc@ 9223

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