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

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