source: trunk/MagicSoft/Mars/mmain/MMars.cc@ 2314

Last change on this file since 2314 was 2173, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 8.7 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de>
19! Author(s): Harald Kornmayer 1/2001
20!
21! Copyright: MAGIC Software Development, 2000-2002
22!
23!
24\* ======================================================================== */
25
26#include "MMars.h"
27
28#include <iostream>
29
30#include <TApplication.h> // gROOT->GetApplication()->...
31
32#include <TGTab.h> // TGTab
33#include <TGMenu.h> // TGPopupMenu
34#include <TSystem.h> // gSystem->Exec
35#include <TGMsgBox.h> // TGMsgBox
36#include <TGButton.h> // TGPictureButton
37#include <TG3DLine.h> // TGHorizontal3DLine
38
39#include "MGList.h"
40#include "MEvtDisp.h"
41#include "MAnalysis.h"
42#include "MDataCheck.h"
43#include "MMonteCarlo.h"
44#include "MCameraDisplay.h"
45
46ClassImp(MMars);
47
48using namespace std;
49
50enum {
51 kFileExit,
52 kFileAbout,
53
54 kPicMagic,
55 kPicMars,
56
57 kButEvtDisplay,
58 kButDataCheck,
59 kButAnalysis,
60 kButMonteCarlo,
61 kButCameraDisplay
62};
63
64void MMars::CreateMenuBar()
65{
66 TGLayoutHints *laymenubar = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX, 2, 2, 2, 2);
67 TGLayoutHints *laymenuitem = new TGLayoutHints(kLHintsTop|kLHintsLeft, 0, 4, 0, 0);
68 TGLayoutHints *laylinesep = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
69
70 fList->Add(laymenubar);
71 fList->Add(laymenuitem);
72 fList->Add(laylinesep);
73
74 TGPopupMenu *filemenu = new TGPopupMenu(gClient->GetRoot());
75 filemenu->AddEntry("E&xit", kFileExit);
76 filemenu->Associate(this);
77
78 TGMenuBar *menubar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
79 menubar->AddPopup("&File", filemenu, laymenuitem);
80 AddFrame(menubar, laymenubar);
81
82 TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
83 AddFrame(linesep, laylinesep);
84
85 fList->Add(filemenu);
86 fList->Add(menubar);
87 fList->Add(linesep);
88}
89
90void MMars::CreateTopFrame(TGHorizontalFrame *top)
91{
92 const TGPicture *pic1 = fList->GetPicture("magiclogo.xpm");
93 if (pic1)
94 {
95 TGPictureButton *magic = new TGPictureButton(top, pic1, kPicMagic);
96 fList->Add(magic);
97 magic->Associate(this);
98 TGLayoutHints *lay1 = new TGLayoutHints(kLHintsLeft, 10, 10, 20, 10);
99 fList->Add(lay1);
100 top->AddFrame(magic, lay1);
101 }
102
103 const TGPicture *pic2 = fList->GetPicture("marslogo.xpm");
104 if (pic2)
105 {
106 TGPictureButton *mars = new TGPictureButton(top, pic2, kPicMars);
107 fList->Add(mars);
108 mars->Associate(this);
109 TGLayoutHints *lay2 = new TGLayoutHints(kLHintsRight, 10, 10, 10, 10);
110 fList->Add(lay2);
111 top->AddFrame(mars, lay2);
112 }
113}
114
115#include <TGLabel.h>
116
117void MMars::CreateTextButton(TGVerticalFrame *tab,
118 const char *text, const char *descr,
119 const UInt_t id) const
120{
121 //
122 // Create the button
123 //
124 TGHorizontalFrame *frame = new TGHorizontalFrame(tab, 1, 1);
125 TGTextButton *button = new TGTextButton(frame, text, id);
126 TGLabel *label = new TGLabel(frame, descr);
127 TGLayoutHints *hints1 = new TGLayoutHints(kLHintsLeft|kLHintsCenterY|kLHintsExpandX, 5, 5, 2, 2);
128
129 //
130 // Add button for 'auto-delete'
131 //
132 fList->Add(hints1);
133 fList->Add(button);
134 fList->Add(label);
135 fList->Add(frame);
136
137 //
138 // Send button events (meesages) to this object (s. ProcessMessage)
139 //
140 button->Associate(this);
141
142 //
143 // Add button with corresponding layout to containing frame
144 //
145 tab->AddFrame(frame, hints1);
146 frame->AddFrame(button, hints1);
147 frame->AddFrame(label, hints1);
148}
149
150void MMars::CreateBottomFrame(TGHorizontalFrame *low)
151{
152 //
153 // Create Tab Container
154 //
155 TGLayoutHints *laytabs = new TGLayoutHints(kLHintsBottom|kLHintsExpandX|kLHintsExpandY, 5, 5, 5, 5);
156 fList->Add(laytabs);
157
158 TGTab *tabs = new TGTab(low, 1, 1);
159 fList->Add(tabs);
160 low->AddFrame(tabs, laytabs);
161
162 //
163 // Create Tab1
164 //
165 TGCompositeFrame *tf = tabs->AddTab("Control");
166
167 TGLayoutHints *laytab = new TGLayoutHints(kLHintsCenterY|kLHintsExpandX);
168 TGVerticalFrame *tab = new TGVerticalFrame(tf, 1, 1);
169 fList->Add(laytab);
170 fList->Add(tab);
171
172 CreateTextButton(tab, "Event Display", "Histograms: Pix per Event",
173 kButEvtDisplay);
174 CreateTextButton(tab, "Data Check", "Histograms: Pix per Run",
175 kButDataCheck);
176 CreateTextButton(tab, "Analysis", "Calculate image parameters",
177 kButAnalysis);
178 CreateTextButton(tab, "Monte Carlo", "Calculate MC stuff",
179 kButMonteCarlo);
180 CreateTextButton(tab, "Camera Display", "Display Cerenkov Photons",
181 kButCameraDisplay);
182
183 tf->AddFrame(tab, laytab);
184}
185
186MMars::MMars()
187: TGMainFrame(gClient->GetRoot(), 400, 400, kVerticalFrame)
188{
189 //
190 // Create the deletion list
191 //
192 fList = new MGList;
193 fList->SetOwner();
194
195 //
196 // Create the MenuBar
197 //
198 CreateMenuBar();
199
200 //
201 // create and layout the frame/contents
202 //
203 TGHorizontalFrame *top = new TGHorizontalFrame(this, 1, 1);
204 TGHorizontalFrame *low = new TGHorizontalFrame(this, 1, 1);
205
206 TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
207
208 fList->Add(top);
209 fList->Add(low);
210 fList->Add(linesep);
211
212 CreateTopFrame(top);
213 CreateBottomFrame(low);
214
215 TGLayoutHints *layout1 = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
216 TGLayoutHints *layout2 = new TGLayoutHints(kLHintsTop|kLHintsExpandX|kLHintsExpandY);
217 fList->Add(layout1);
218 fList->Add(layout2);
219
220 AddFrame(top, layout1);
221 AddFrame(linesep, layout1);
222 AddFrame(low, layout2);
223
224 //
225 // Map the window, set up the layout, etc.
226 //
227 Move(rand()%100, rand()%100);
228
229 Layout();
230
231 MapSubwindows();
232
233 SetWindowName("MARS Main Window");
234 SetIconName("MARS");
235
236 MapWindow();
237}
238
239// ======================================================================
240
241MMars::~MMars()
242{
243 delete fList;
244}
245// ======================================================================
246
247void MMars::CloseWindow()
248{
249 // Got close message for this MainFrame. Calls parent CloseWindow()
250 // (which destroys the window) and terminate the application.
251 // The close message is generated by the window manager when its close
252 // window menu item is selected.
253
254 TGMainFrame::CloseWindow();
255 gROOT->GetApplication()->Terminate(0);
256}
257
258void MMars::DisplWarning(const char *txt)
259{
260 Int_t retval;
261 new TGMsgBox(fClient->GetRoot(), this,
262 "WARNING!", txt,
263 kMBIconExclamation, 4, &retval);
264}
265
266Bool_t MMars::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
267{
268 // Process events generated by the buttons in the frame.
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 kButEvtDisplay:
281 new MEvtDisp(/*this*/);
282 return kTRUE;
283
284 case kButDataCheck:
285 new MDataCheck(/*this*/);
286 return kTRUE;
287
288 case kButAnalysis:
289 new MAnalysis(/*this*/);
290 return kTRUE;
291
292 case kButMonteCarlo:
293 new MMonteCarlo(/*this*/);
294 return kTRUE;
295
296 case kButCameraDisplay:
297 new MCameraDisplay(/*this*/);
298 return kTRUE;
299
300 case kPicMagic:
301 cout << "Trying to start 'netscape http://hegra1.mppmu.mpg.de/MAGICWeb/'..." << endl;
302 gSystem->Exec("netscape http://hegra1.mppmu.mpg.de/MAGICWeb/ &");
303 return kTRUE;
304
305 case kPicMars:
306 cout << "Trying to start 'netscape http://magic.astro.uni-wuerzburg.de/mars/'..." << endl;
307 gSystem->Exec("netscape http://magic.astro.uni-wuerzburg.de/mars/ &");
308 return kTRUE;
309 }
310
311 case kCM_MENU:
312 if (parm1!=kFileExit)
313 return kTRUE;
314
315 CloseWindow();
316 return kTRUE;
317 }
318 }
319
320 return kTRUE;
321}
Note: See TracBrowser for help on using the repository browser.