source: trunk/MagicSoft/MarsOctober/mocttest/MGOctMain.cc@ 525

Last change on this file since 525 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: 12.1 KB
Line 
1#include "MGOctMain.h"
2
3#define S_ISDIR(m) (((m)&(0170000)) == (0040000))
4
5MGOctMain::MGOctMain(const TGWindow *p, UInt_t w, UInt_t h)
6 : TGMainFrame(p, w, h)
7{
8 //
9 // Main window to controll the october test
10 //
11
12 // set non-gui members to starting values
13
14 sprintf ( fInputFile, "\n" ) ;
15
16 //
17 // First create the MenuBar.
18 //
19
20 // Layout objects for menue.
21
22 fLayMenuBar = new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2 ) ;
23 fLayMenuItem = new TGLayoutHints ( kLHintsTop | kLHintsLeft , 0, 4, 0, 0 ) ;
24
25 // crate the menu bar
26
27 fFileMenu = new TGPopupMenu ( fClient->GetRoot() ) ;
28 fFileMenu->AddEntry ("Exit", M_FILE_EXIT ) ;
29 fFileMenu->Associate(this) ;
30
31 // the button messages are handled by main frame (this)
32
33 fMenuBar = new TGMenuBar ( this, 1, 1, kHorizontalFrame ) ;
34 fMenuBar->AddPopup("File", fFileMenu, fLayMenuItem ) ;
35 AddFrame(fMenuBar, fLayMenuBar ) ;
36
37 //
38 // Create the top window with a lot of buttons
39 //
40
41 fFrameTop = new TGCompositeFrame (this, 300,100, kVerticalFrame ) ;
42
43 fTop1 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;
44
45 fButEvtDisp = new TGTextButton(fTop1, "EventDisplay", M_BUTTON_EVTDISP );
46 fButEvtDisp->Associate(this) ;
47 fTop1->AddFrame (fButEvtDisp, new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 5, 5) );
48
49 fFrameTop->AddFrame (fTop1, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) );
50
51 fTop2 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;
52
53 fButPedADC = new TGTextButton(fTop2, "ADC Spectra of Pedestals", M_BUTTON_PEDADC );
54 fButPedADC->Associate(this) ;
55 fTop2->AddFrame (fButPedADC, new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 5, 5) );
56
57 fButCrADC = new TGTextButton(fTop2, "ADC Specta of Cosmics", M_BUTTON_CRADC );
58 fButCrADC->Associate(this) ;
59 fTop2->AddFrame (fButCrADC, new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 5, 5) );
60
61 fFrameTop->AddFrame (fTop2, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) );
62
63 fTop3 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;
64
65 fButPedTDC = new TGTextButton(fTop3, "TDC Spectra of Pedestals", M_BUTTON_PEDTDC );
66 fButPedTDC->Associate(this) ;
67 fTop3->AddFrame (fButPedTDC, new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 5, 5) );
68
69 fButCrTDC = new TGTextButton(fTop3, "TDC Specta of Cosmics", M_BUTTON_CRTDC );
70 fButCrTDC->Associate(this) ;
71 fTop3->AddFrame (fButCrTDC, new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 5, 5) );
72
73 fFrameTop->AddFrame (fTop3, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) );
74
75 AddFrame(fFrameTop, new TGLayoutHints (kLHintsTop ) ) ;
76
77
78 //
79 // Create the low window with a tabs in it
80 //
81
82 fFrameLow = new TGCompositeFrame (this, 300,100, kHorizontalFrame ) ;
83
84 fLayTab = new TGLayoutHints ( kLHintsExpandX , 5, 5, 5, 5 ) ;
85
86 // create the first tab
87
88 fTab = new TGTab ( fFrameLow, 400, 400 ) ;
89
90 TGCompositeFrame *tf = fTab->AddTab("Input File") ;
91
92 fTabF1 = new TGCompositeFrame (tf, 100, 100, kHorizontalFrame) ;
93 // tf->AddFrame(fTabF1, fLayTab ) ;
94
95
96 fTabF1a = new TGCompositeFrame (tf, 100, 100, kHorizontalFrame) ;
97 tf->AddFrame(fTabF1a, new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ;
98
99 fTabF1b = new TGCompositeFrame (tf, 100, 100, kVerticalFrame) ;
100 // tf->AddFrame(fTabF1b, new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY , 5, 5, 5, 5 ) ) ;
101 tf->AddFrame(fTabF1b, new TGLayoutHints ( kLHintsExpandX | kLHintsExpandY , 5, 5, 5, 5 ) ) ;
102
103
104 fDir = new TGListBox(fTabF1a, -1) ;
105 fDir->Resize(350,20) ;
106 char temp[100] ;
107 // sprintf ( temp, "%s", START_DIRECTORY ) ;
108 sprintf ( temp, "%s", gSystem->WorkingDirectory() ) ;
109 fDir->AddEntry(temp, 1) ;
110 fTabF1a->AddFrame( fDir, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ;
111
112
113 fPicCdup = fClient->GetPicture("tb_uplevel.xpm") ;
114 fCdup = new TGPictureButton(fTabF1a, fPicCdup, M_PBUTTON_CDIR_UP ) ;
115 fCdup->SetToolTipText("One Level up!") ;
116 fCdup->Associate(this) ;
117 fTabF1a->AddFrame (fCdup, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ;
118
119 fPicList = fClient->GetPicture("tb_list.xpm") ;
120 fListMode = new TGPictureButton(fTabF1a, fPicList, M_PBUTTON_LIST_MODE ) ;
121 fListMode->SetToolTipText("List Mode") ;
122 fListMode->Associate(this) ;
123 fListMode->SetState(kButtonUp) ;
124 fListMode->AllowStayDown(kTRUE) ;
125 fTabF1a->AddFrame (fListMode, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ;
126
127 fPicDetail = fClient->GetPicture("tb_details.xpm") ;
128 fDetail = new TGPictureButton(fTabF1a, fPicDetail, M_PBUTTON_DETAIL_MODE ) ;
129 fDetail->SetToolTipText("Details Mode") ;
130 fDetail->Associate(this) ;
131 fDetail->SetState(kButtonEngaged) ;
132 fDetail->AllowStayDown(kTRUE) ;
133 fTabF1a->AddFrame (fDetail, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ;
134
135
136 fFileView = new TGListView(fTabF1b, 540, 380 ) ;
137 fFileCont = new TGFileContainer(fFileView->GetViewPort(), 100, 100,
138 kVerticalFrame, fgWhitePixel) ;
139
140 fFileCont->Associate(this) ;
141 fFileView->GetViewPort()->SetBackgroundColor(fgWhitePixel) ;
142 fFileView->SetContainer(fFileCont) ;
143 fFileCont->SetFilter("*") ;
144 // fFileCont->ChangeDirectory(START_DIRECTORY) ;
145 fFileCont->ChangeDirectory(gSystem->WorkingDirectory()) ;
146 fFileView->SetViewMode(kLVDetails);
147 fFileCont->Sort(kSortByName) ;
148
149 fTabF1b->AddFrame(fFileView, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5) ) ;
150
151 tf->AddFrame(fTabF1, fLayTab) ;
152
153 fFrameLow->AddFrame ( fTab, new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) );
154
155 AddFrame(fFrameLow, new TGLayoutHints (kLHintsExpandX|kLHintsExpandY) ) ;
156
157 //
158 // Map the window, set up the layout, etc.
159 //
160
161 SetWMSizeHints(400, 650, 1000, 1000, 10, 10 ) ; // set the smallest and biggest size of the Main frame
162
163 MapSubwindows();
164
165 Layout();
166
167 SetWindowName("MARS Main Window");
168 SetIconName("MARS");
169
170 MapWindow();
171
172}
173
174
175// ======================================================================
176// ======================================================================
177
178MGOctMain::~MGOctMain()
179{
180 delete fFrameTop, fFrameLow ;
181
182}
183
184
185// ======================================================================
186// ======================================================================
187
188void MGOctMain::CloseWindow()
189{
190 // Got close message for this MainFrame. Calls parent CloseWindow()
191 // (which destroys the window) and terminate the application.
192 // The close message is generated by the window manager when its close
193 // window menu item is selected.
194
195 TGMainFrame::CloseWindow();
196 gROOT->GetApplication()->Terminate(0) ;
197}
198
199
200// ======================================================================
201// ======================================================================
202
203Bool_t MGOctMain::InputFileSelected()
204{
205 // Checks if there is a selected input root file
206
207 if ( strcmp ( fInputFile, "\n") == 0 )
208 {
209 return ( kFALSE ) ;
210 }
211
212 return (kTRUE) ;
213}
214
215
216// ======================================================================
217// ======================================================================
218
219Bool_t MGOctMain::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
220{
221 // Process events generated by the buttons in the frame.
222
223 Int_t buttons = 4, retval = 0 ;
224 Char_t wort[100] ;
225 Char_t extens[5] ;
226 Char_t command[110] ;
227
228 TGFileItem *item ; // to process items in the file view container
229 void *np = NULL ; // null pointer
230
231 switch (GET_MSG(msg))
232 {
233 case kC_COMMAND:
234 switch (GET_SUBMSG(msg))
235 {
236 case kCM_BUTTON:
237
238 switch (parm1)
239 {
240
241 case M_BUTTON_EVTDISP:
242
243 if ( InputFileSelected() == kFALSE ) { // it is not selected
244
245 new TGMsgBox(fClient->GetRoot(), this,
246 "ERROR!",
247 "No Input (root) File selected!",
248 kMBIconExclamation, buttons, &retval);
249 break ;
250 }
251 // just a warning that the EventDisplay doesn't exist
252 new TGMsgBox(fClient->GetRoot(), this,
253 "WARNING!",
254 "EventDisplay not yet implemented! Gabi works on it!!",
255 kMBIconExclamation, buttons, &retval);
256
257 break ;
258
259 case M_BUTTON_PEDADC:
260
261 if ( InputFileSelected() == kFALSE ) { // it is not selected
262
263 new TGMsgBox(fClient->GetRoot(), this, "ERROR!",
264 "No Input (root) File selected!", kMBIconExclamation, buttons, &retval);
265 break ;
266 }
267
268 fOctober.PedAdcSpectra(fInputFile) ;
269
270 break ;
271
272
273 case M_BUTTON_CRADC:
274
275 if ( InputFileSelected() == kFALSE ) { // it is not selected
276
277 new TGMsgBox(fClient->GetRoot(), this, "ERROR!",
278 "No Input (root) File selected!", kMBIconExclamation, buttons, &retval);
279 break ;
280 }
281
282 fOctober.CrAdcSpectra(fInputFile) ;
283
284 break ;
285
286 case M_BUTTON_PEDTDC:
287
288 if ( InputFileSelected() == kFALSE ) { // it is not selected
289
290 new TGMsgBox(fClient->GetRoot(), this, "ERROR!",
291 "No Input (root) File selected!", kMBIconExclamation, buttons, &retval);
292 break ;
293 }
294
295 fOctober.PedTdcSpectra(fInputFile) ;
296
297 break ;
298
299 case M_BUTTON_CRTDC:
300
301 if ( InputFileSelected() == kFALSE ) { // it is not selected
302
303 new TGMsgBox(fClient->GetRoot(), this, "ERROR!",
304 "No Input (root) File selected!", kMBIconExclamation, buttons, &retval);
305 break ;
306 }
307
308 fOctober.CrTdcSpectra(fInputFile) ;
309
310 break ;
311
312 case M_PBUTTON_CDIR_UP :
313
314 // goto the parent directory
315
316 gSystem->ChangeDirectory("..") ;
317 fDir->RemoveEntry(1) ;
318 sprintf (wort, "%s", gSystem->WorkingDirectory() ) ;
319 fDir->AddEntry(wort,1) ;
320 fDir->MapSubwindows() ;
321 fDir->Layout() ;
322 fFileCont->ChangeDirectory( wort ) ;
323 fFileCont->DisplayDirectory() ;
324
325 break ;
326
327 case M_PBUTTON_LIST_MODE:
328 fFileView->SetViewMode(kLVList) ;
329 fDetail->SetState(kButtonUp) ;
330
331 break ;
332
333 case M_PBUTTON_DETAIL_MODE:
334 fFileView->SetViewMode(kLVDetails) ;
335 fListMode->SetState(kButtonUp) ;
336
337 break ;
338
339 default:
340 break ;
341 }
342
343 case kCM_MENU:
344 switch (parm1) {
345 case M_FILE_EXIT:
346 CloseWindow() ;
347 break;
348
349 }
350 break ;
351
352 default:
353 break ;
354
355 }
356
357 case kC_CONTAINER:
358 switch (GET_SUBMSG(msg)) {
359
360 // case kCT_ITEMCLICK:
361 // printf ("itemclick\n");
362 // break;
363
364
365 case kCT_ITEMDBLCLICK:
366 //
367 // process the double click in the file view container
368 //
369
370 if ( parm1 == kButton1) {
371 if ( fFileCont->NumSelected() == 1 ) {
372 //
373 // one file selected
374 //
375 item = (TGFileItem *) fFileCont->GetNextSelected(&np) ;
376
377 if ( S_ISDIR(item->GetType()) ) // file is directory
378 {
379 // goto directory
380
381 sprintf (wort, "%s", item->GetItemName()->GetString()) ;
382 fFileCont->ChangeDirectory ( wort ) ;
383 gSystem->ChangeDirectory( wort ) ;
384
385 sprintf (wort, "%s", gSystem->WorkingDirectory() ) ;
386 fDir->RemoveEntry(1) ;
387 fDir->AddEntry( wort, 1 ) ;
388 fDir->MapSubwindows() ;
389 fDir->Layout() ;
390 }
391 else // file is no directory, is a file
392 {
393 sprintf (wort, "%s", item->GetItemName()->GetString() ) ;
394
395 // determine the file type by extensions
396
397 for (Int_t i = 0 ; i<5; i++)
398 extens[i] = '\0' ;
399
400 for ( Int_t i=0; wort[i] != '\0'; i++) {
401 if ( wort[i] == '.') {
402 strncpy (extens, &wort[i+1], 4 ) ;
403 break ;
404 }
405 }
406
407 if ( ! strcmp(extens, "ps") ) { // postscript file
408 sprintf ( command, "gv %s/%s &",
409 gSystem->WorkingDirectory(),
410 wort ) ;
411 gSystem->Exec(command) ;
412 break ;
413 }
414 else if ( ! strcmp(extens, "root") ) { // root file
415 sprintf ( fInputFile, "%s/%s" , gSystem->WorkingDirectory(), wort ) ;
416
417 printf (" %s \n", fInputFile ) ;
418 break ;
419 }
420
421 }
422 }
423 }
424 break;
425
426 default:
427 break ;
428 }
429
430
431
432 default:
433 break;
434 }
435 return kTRUE;
436}
Note: See TracBrowser for help on using the repository browser.