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

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