source: trunk/MagicSoft/MarsOctober/mocttest/MGDisplayAdc.cc@ 9488

Last change on this file since 9488 was 452, checked in by harald, 24 years ago
Further improvements in the layout of some guiclasses. Know the fundament for calculating the pedestals is created with the first implementation of the classes MPixPedest and MPedest. A first task for calculating the pedestals is set up (MCalcPed1).
File size: 7.5 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, 300 ) ;
27
28 fFrameTop->AddFrame (fFT1, new TGLayoutHints ( kLHintsTop , 10, 10, 10, 10 ) ) ;
29
30 // middle part of top frame
31 //
32
33 fFT2 = new TGVerticalFrame (fFrameTop, 80,20, kFitWidth ) ;
34
35 fButtonPrev = new TGTextButton ( fFT2, "Prev Histo", M_BUTTON_PREV ) ;
36 fButtonPrev->Associate (this) ;
37 fFT2->AddFrame ( fButtonPrev, new TGLayoutHints (kLHintsLeft | kLHintsTop,10, 10, 0, 10 ) ) ;
38
39
40 fVslider1 = new TGVSlider (fFT2, 250, kSlider1 | kScaleBoth, VSId1);
41
42 fVslider1->Associate(this);
43 fVslider1->SetRange(0, 576);
44 fFT2->AddFrame(fVslider1);
45
46 fButtonNext = new TGTextButton ( fFT2, "Next Histo", M_BUTTON_NEXT ) ;
47 fButtonNext->Associate (this) ;
48 fFT2->AddFrame ( fButtonNext, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 5 ) ) ;
49
50 fFrameTop->AddFrame (fFT2, new TGLayoutHints ( kLHintsTop , 10, 10, 10, 10 ) ) ;
51
52
53 // right part of top frame
54 //
55 fFT3 = new TGVerticalFrame (fFrameTop, 60, 60, kFitWidth ) ;
56
57 fECanv = new TRootEmbeddedCanvas("fECanv", fFT3, 400, 400 ) ;
58 fFT3->AddFrame( fECanv, new TGLayoutHints ( kLHintsCenterX | kLHintsCenterY | kLHintsExpandX | kLHintsExpandY , 10, 10, 10, 10 ) ) ;
59
60 fCanv = fECanv->GetCanvas() ;
61
62 fFrameTop->AddFrame (fFT3, new TGLayoutHints ( kLHintsCenterX | kLHintsCenterY | kLHintsExpandX | kLHintsExpandY , 10, 10, 10, 10 ) ) ;
63
64 AddFrame ( fFrameTop, new TGLayoutHints ( kLHintsTop | kLHintsExpandX , 10, 10, 10, 10 ) ) ;
65
66 //
67 // the low frame for the control buttons
68 //
69 fFrameLow = new TGHorizontalFrame (this, 60,20, kFixedWidth ) ;
70
71 fButtonSave = new TGTextButton ( fFrameLow, "Save", M_BUTTON_SAVE ) ;
72 fButtonSave->Associate (this) ;
73 fFrameLow->AddFrame ( fButtonSave, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) ) ;
74
75 fButtonPrint = new TGTextButton ( fFrameLow, "Print", M_BUTTON_PRINT ) ;
76 fButtonPrint->Associate (this) ;
77 fFrameLow->AddFrame ( fButtonPrint, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) ) ;
78
79 fButtonPrintAll = new TGTextButton ( fFrameLow, "PrintAll", M_BUTTON_PRINTALL ) ;
80 fButtonPrintAll->Associate (this) ;
81 fFrameLow->AddFrame ( fButtonPrintAll, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) ) ;
82
83
84
85 fButtonClose = new TGTextButton ( fFrameLow, "Close", M_BUTTON_CLOSE ) ;
86 fButtonClose->Associate (this) ;
87 fFrameLow->AddFrame ( fButtonClose, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) ) ;
88 AddFrame ( fFrameLow, new TGLayoutHints ( kLHintsBottom | kLHintsExpandX , 10, 10, 10, 10 ) ) ;
89
90 //
91 //
92 //
93 BuildHistoList() ;
94
95 MapSubwindows();
96
97 Layout();
98
99 SetWindowName("ADC Spectra");
100 SetIconName("ADC Spectra");
101
102 MapWindow();
103
104 SetWMSizeHints(400, 470, 1000, 1000, 10, 10);
105}
106
107// ======================================================================
108// ======================================================================
109//
110//
111
112MGDisplayAdc::~MGDisplayAdc ()
113{
114 delete fButtonSave ;
115 delete fButtonPrint ;
116 delete fButtonPrintAll ;
117 delete fButtonClose ;
118
119 delete fButtonPrev;
120 delete fButtonNext ;
121
122 delete fECanv ;
123 delete fHistoList ;
124 delete fFT1 ;
125 delete fFT2 ;
126 delete fFT3 ;
127 delete fFrameLow ;
128 delete fFrameTop ;
129
130}
131
132// ======================================================================
133// ======================================================================
134
135void MGDisplayAdc::CloseWindow()
136{
137 // Got close message for this MainFrame. Calls parent CloseWindow()
138 // (which destroys the window) and terminate the application.
139 // The close message is generated by the window manager when its close
140 // window menu item is selected.
141 //
142 delete this ;
143 // TGTransientFrame::CloseWindow();
144 // TGMainFrame::CloseWindow();
145 // gROOT->GetApplication()->Terminate(0) ;
146}
147
148
149// ======================================================================
150// ======================================================================
151
152Bool_t MGDisplayAdc::BuildHistoList()
153{
154 // looks in the container of the AdcSpectra and reads in the
155 // Histogramms in there.
156 //
157 // In the class MHistosAdc are in fact two lists. One for the high and
158 // one for the low gain. Here we will use only the high gain list!!!
159 // With some special options (settings in the gui) we will also be able
160 // to plot the low gain
161 //
162 for ( Int_t i=0 ; i < fHists->GetHighEntries(); i++ ) {
163
164 fHistoList->AddEntry(fHists->GetHighList()->At(i)->GetName(), i+1) ;
165 }
166
167 fHistoList->MapSubwindows() ;
168 fHistoList->Layout() ;
169
170 return (kTRUE) ;
171}
172
173// ======================================================================
174// ======================================================================
175
176Bool_t MGDisplayAdc::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
177{
178
179// cout <<"Entering process method." << endl;
180 // Process events generated by the buttons in the frame.
181 //
182 Int_t buttons = 4, retval = 0 ;
183 Char_t wort[100] ;
184 Char_t extens[5] ;
185 Char_t command[110] ;
186
187 TGFileItem *item ; // to process items in the file view container
188 void *np = NULL ; // null pointer
189
190 switch (GET_MSG(msg))
191 {
192 case kC_COMMAND:
193 switch (GET_SUBMSG(msg))
194 {
195 case kCM_BUTTON:
196
197 switch (parm1)
198 {
199
200 case M_BUTTON_SAVE:
201 new TGMsgBox(fClient->GetRoot(), this,
202 "WARNING!",
203 "Not implemented yet.",
204 kMBIconExclamation, buttons, &retval);
205
206 break ;
207
208 case M_BUTTON_PRINT:
209 break;
210
211 case M_BUTTON_CLOSE:
212 CloseWindow() ;
213 break ;
214 case M_BUTTON_PREV:
215 fCanv->cd() ;
216
217 fHists->GetHighList()->At( fHistoList->GetSelected()-1-1)->Draw() ;
218
219 fCanv->Modified() ;
220 fCanv->Update() ;
221 fVslider1->SetPosition( fHistoList->GetSelected()-1);
222
223
224
225 break;
226
227 default:
228 break ;
229 }
230
231 case kCM_MENU:
232 switch (parm1)
233 {
234 }
235 break ;
236
237 default:
238 break ;
239
240 }
241
242 case kCM_LISTBOX:
243 switch (GET_SUBMSG(msg))
244 {
245 case M_LIST_HISTO:
246 fCanv->cd() ;
247
248 fHists->GetHighList()->At( fHistoList->GetSelected()-1)->Draw() ;
249
250 fCanv->Modified() ;
251 fCanv->Update() ;
252 fVslider1->SetPosition( fHistoList->GetSelected()-1);
253
254
255
256 default:
257 break ;
258 }
259
260
261 case kC_CONTAINER:
262 switch (GET_SUBMSG(msg))
263 {
264
265 case kCT_ITEMDBLCLICK:
266
267 break;
268
269 default:
270 break ;
271 }
272
273
274
275 default:
276 break;
277
278 case kC_VSLIDER:
279 switch(GET_SUBMSG(msg))
280 {
281 case kSL_POS:
282 {
283 switch(parm1)
284 {
285 case VSId1:
286 fCanv->cd() ;
287
288 fHists->GetHighList()->At(parm2)->Draw() ;
289
290 fCanv->Modified() ;
291 fCanv->Update() ;
292
293 break;
294 }
295 break;
296 }
297 break;
298 }
299 break;
300
301 }
302 return kTRUE;
303}
Note: See TracBrowser for help on using the repository browser.