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

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