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): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
|
---|
19 | ! Author(s): Thomas Bretz 12/2000 (tbretz@uni-sw.gwdg.de)
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2001
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | #include "MMars.h"
|
---|
27 |
|
---|
28 | #include <TApplication.h> // gROOT->GetApplication()->...
|
---|
29 |
|
---|
30 | #include <TGTab.h> // TGTab
|
---|
31 | #include <TGMenu.h> // TGPopupMenu
|
---|
32 | #include <TSystem.h> // gSystem->Exec
|
---|
33 | #include <TGMsgBox.h> // TGMsgBox
|
---|
34 | #include <TGButton.h> // TGPictureButton
|
---|
35 | #include <TG3DLine.h> // TGHorizontal3DLine
|
---|
36 |
|
---|
37 | #include "MEvtDisp.h"
|
---|
38 | #include "MAnalysis.h"
|
---|
39 | #include "MDataCheck.h"
|
---|
40 | #include "MMonteCarlo.h"
|
---|
41 | #include "MCameraDisplay.h"
|
---|
42 |
|
---|
43 | ClassImp(MMars)
|
---|
44 |
|
---|
45 | enum {
|
---|
46 | M_FILE_EXIT,
|
---|
47 | M_FILE_ABOUT,
|
---|
48 |
|
---|
49 | M_PICTURE_MAGIC,
|
---|
50 | M_PICTURE_MARS,
|
---|
51 |
|
---|
52 | M_BUTTON_EVTDISP,
|
---|
53 | M_BUTTON_DATACHECK,
|
---|
54 | M_BUTTON_ANALYSE,
|
---|
55 | M_BUTTON_MONTECARLO,
|
---|
56 | M_BUTTON_CAMDISPLAY
|
---|
57 | };
|
---|
58 |
|
---|
59 | void MMars::CreateMenuBar()
|
---|
60 | {
|
---|
61 | TGLayoutHints *laymenubar = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX, 2, 2, 2, 2);
|
---|
62 | TGLayoutHints *laymenuitem = new TGLayoutHints(kLHintsTop|kLHintsLeft, 0, 4, 0, 0);
|
---|
63 | TGLayoutHints *laylinesep = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
|
---|
64 |
|
---|
65 | fList->Add(laymenubar);
|
---|
66 | fList->Add(laymenuitem);
|
---|
67 | fList->Add(laylinesep);
|
---|
68 |
|
---|
69 | TGPopupMenu *filemenu = new TGPopupMenu(gClient->GetRoot());
|
---|
70 | filemenu->AddEntry("Exit", M_FILE_EXIT);
|
---|
71 | //fFileMenu->Associate(this);
|
---|
72 |
|
---|
73 | TGMenuBar *menubar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
|
---|
74 | menubar->AddPopup("File", filemenu, laymenuitem);
|
---|
75 | AddFrame(menubar, laymenubar);
|
---|
76 |
|
---|
77 | TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
|
---|
78 | AddFrame(linesep, laylinesep);
|
---|
79 |
|
---|
80 | fList->Add(filemenu);
|
---|
81 | fList->Add(menubar);
|
---|
82 | fList->Add(linesep);
|
---|
83 | }
|
---|
84 |
|
---|
85 | void MMars::CreateTopFrame(TGHorizontalFrame *top)
|
---|
86 | {
|
---|
87 | fPic1 = gClient->GetPicture("magiclogo.xpm");
|
---|
88 | fPic2 = gClient->GetPicture("marslogo.xpm");
|
---|
89 |
|
---|
90 | TGPictureButton *magic = new TGPictureButton(top, fPic1, M_PICTURE_MAGIC);
|
---|
91 | TGPictureButton *mars = new TGPictureButton(top, fPic2, M_PICTURE_MARS);
|
---|
92 |
|
---|
93 | fList->Add(magic);
|
---|
94 | fList->Add(mars);
|
---|
95 |
|
---|
96 | magic->Associate(this);
|
---|
97 | mars->Associate(this);
|
---|
98 |
|
---|
99 | TGLayoutHints *lay1 = new TGLayoutHints(kLHintsLeft, 10., 10., 20., 10.);
|
---|
100 | TGLayoutHints *lay2 = new TGLayoutHints(kLHintsRight, 10., 10., 10., 10.);
|
---|
101 |
|
---|
102 | fList->Add(lay1);
|
---|
103 | fList->Add(lay2);
|
---|
104 |
|
---|
105 | top->AddFrame(magic, lay1);
|
---|
106 | top->AddFrame(mars, lay2);
|
---|
107 | }
|
---|
108 |
|
---|
109 | void MMars::CreateTextButton(TGVerticalFrame *tab, const char *text,
|
---|
110 | const UInt_t id, TGLayoutHints *hints) const
|
---|
111 | {
|
---|
112 | //
|
---|
113 | // Create the button
|
---|
114 | //
|
---|
115 | TGTextButton *button = new TGTextButton(tab, text, id);
|
---|
116 |
|
---|
117 | //
|
---|
118 | // Add button for 'auto-delete'
|
---|
119 | //
|
---|
120 | fList->Add(button);
|
---|
121 |
|
---|
122 | //
|
---|
123 | // Send button events (meesages) to this object (s. ProcessMessage)
|
---|
124 | //
|
---|
125 | button->Associate(this);
|
---|
126 |
|
---|
127 | //
|
---|
128 | // Add button with corresponding layout to containing frame
|
---|
129 | //
|
---|
130 | tab->AddFrame(button, hints);
|
---|
131 | }
|
---|
132 |
|
---|
133 | void MMars::CreateBottomFrame(TGHorizontalFrame *low)
|
---|
134 | {
|
---|
135 | //
|
---|
136 | // Create Tab Container
|
---|
137 | //
|
---|
138 | TGLayoutHints *laytabs = new TGLayoutHints(kLHintsBottom|kLHintsExpandX|kLHintsExpandY, 5, 5, 5, 5);
|
---|
139 | fList->Add(laytabs);
|
---|
140 |
|
---|
141 | TGTab *tabs = new TGTab(low, 400, 400);
|
---|
142 | fList->Add(tabs);
|
---|
143 | low->AddFrame(tabs, laytabs);
|
---|
144 |
|
---|
145 | //
|
---|
146 | // Create Tab1
|
---|
147 | //
|
---|
148 | TGCompositeFrame *tf = tabs->AddTab("Control");
|
---|
149 |
|
---|
150 | TGVerticalFrame *tab1 = new TGVerticalFrame(tf, 300, 100);
|
---|
151 | TGVerticalFrame *tab2 = new TGVerticalFrame(tf, 300, 100);
|
---|
152 |
|
---|
153 | fList->Add(tab1);
|
---|
154 | fList->Add(tab2);
|
---|
155 |
|
---|
156 | TGLayoutHints *laytabx = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
|
---|
157 | fList->Add(laytabx);
|
---|
158 |
|
---|
159 | tf->AddFrame(tab1, laytabx);
|
---|
160 | tf->AddFrame(tab2, laytabx);
|
---|
161 |
|
---|
162 | TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsCenterX, 10, 10, 10, 10);
|
---|
163 | fList->Add(laybut);
|
---|
164 |
|
---|
165 | CreateTextButton(tab2, "Event Display", M_BUTTON_EVTDISP, laybut);
|
---|
166 | CreateTextButton(tab2, "Data Check", M_BUTTON_DATACHECK, laybut);
|
---|
167 | CreateTextButton(tab2, "Analysis", M_BUTTON_ANALYSE, laybut);
|
---|
168 | CreateTextButton(tab2, "Monte Carlo", M_BUTTON_MONTECARLO, laybut);
|
---|
169 | CreateTextButton(tab2, "Camera Display", M_BUTTON_CAMDISPLAY, laybut);
|
---|
170 | }
|
---|
171 |
|
---|
172 | MMars::MMars(/*const TGWindow *p,*/ UInt_t w, UInt_t h)
|
---|
173 | : TGMainFrame(gClient->GetRoot(), w, h)
|
---|
174 | //: MBrowser (gClient->GetRoot(), gClient->GetRoot(), w, h)
|
---|
175 | {
|
---|
176 | //
|
---|
177 | // Create the deletion list
|
---|
178 | //
|
---|
179 | fList = new TList;
|
---|
180 | fList->SetOwner();
|
---|
181 |
|
---|
182 | //
|
---|
183 | // Create the MenuBar
|
---|
184 | //
|
---|
185 | CreateMenuBar();
|
---|
186 |
|
---|
187 | //
|
---|
188 | // create and layout the frame/contents
|
---|
189 | //
|
---|
190 | TGHorizontalFrame *top = new TGHorizontalFrame(this, 300, 100);
|
---|
191 | TGHorizontalFrame *low = new TGHorizontalFrame(this, 300, 100);
|
---|
192 |
|
---|
193 | TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
|
---|
194 |
|
---|
195 | fList->Add(top);
|
---|
196 | fList->Add(low);
|
---|
197 | fList->Add(linesep);
|
---|
198 |
|
---|
199 | CreateTopFrame(top);
|
---|
200 | CreateBottomFrame(low);
|
---|
201 |
|
---|
202 | TGLayoutHints *layout = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
|
---|
203 | fList->Add(layout);
|
---|
204 |
|
---|
205 | AddFrame(top, layout);
|
---|
206 | AddFrame(linesep, layout);
|
---|
207 | AddFrame(low, layout);
|
---|
208 |
|
---|
209 | // CreateTopFrame(fTop2);
|
---|
210 | // CreateBottomFrame(fTop3);
|
---|
211 |
|
---|
212 | //
|
---|
213 | // Map the window, set up the layout, etc.
|
---|
214 | //
|
---|
215 | SetWMSizeHints(330, 410, 330, 410, 10, 10); // set the smallest and biggest size of the Main frame
|
---|
216 |
|
---|
217 | MapSubwindows();
|
---|
218 |
|
---|
219 | Layout();
|
---|
220 |
|
---|
221 | SetWindowName("MARS Main Window");
|
---|
222 | SetIconName("MARS");
|
---|
223 |
|
---|
224 | MapWindow();
|
---|
225 | }
|
---|
226 |
|
---|
227 | // ======================================================================
|
---|
228 |
|
---|
229 | MMars::~MMars()
|
---|
230 | {
|
---|
231 | gClient->FreePicture(fPic1);
|
---|
232 | gClient->FreePicture(fPic2);
|
---|
233 |
|
---|
234 | delete fList;
|
---|
235 | }
|
---|
236 | // ======================================================================
|
---|
237 |
|
---|
238 | void MMars::CloseWindow()
|
---|
239 | {
|
---|
240 | // Got close message for this MainFrame. Calls parent CloseWindow()
|
---|
241 | // (which destroys the window) and terminate the application.
|
---|
242 | // The close message is generated by the window manager when its close
|
---|
243 | // window menu item is selected.
|
---|
244 |
|
---|
245 | TGMainFrame::CloseWindow();
|
---|
246 | gROOT->GetApplication()->Terminate(0);
|
---|
247 | }
|
---|
248 |
|
---|
249 | void MMars::DisplWarning(const char *txt)
|
---|
250 | {
|
---|
251 | Int_t retval;
|
---|
252 | new TGMsgBox(fClient->GetRoot(), this,
|
---|
253 | "WARNING!", txt,
|
---|
254 | kMBIconExclamation, 4, &retval);
|
---|
255 | }
|
---|
256 |
|
---|
257 | Bool_t MMars::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
|
---|
258 | {
|
---|
259 | // Process events generated by the buttons in the frame.
|
---|
260 |
|
---|
261 | switch (GET_MSG(msg))
|
---|
262 | {
|
---|
263 | case kC_COMMAND:
|
---|
264 | switch (GET_SUBMSG(msg))
|
---|
265 | {
|
---|
266 | case kCM_BUTTON:
|
---|
267 |
|
---|
268 | switch (parm1)
|
---|
269 | {
|
---|
270 |
|
---|
271 | case M_BUTTON_EVTDISP:
|
---|
272 | new MEvtDisp(this);
|
---|
273 | return kTRUE;
|
---|
274 |
|
---|
275 | case M_BUTTON_DATACHECK:
|
---|
276 | new MDataCheck(this);
|
---|
277 | return kTRUE;
|
---|
278 |
|
---|
279 | case M_BUTTON_ANALYSE:
|
---|
280 | new MAnalysis(this);
|
---|
281 | return kTRUE;
|
---|
282 |
|
---|
283 | case M_BUTTON_MONTECARLO:
|
---|
284 | new MMonteCarlo(this);
|
---|
285 | return kTRUE;
|
---|
286 |
|
---|
287 | case M_BUTTON_CAMDISPLAY:
|
---|
288 | new MCameraDisplay(this);
|
---|
289 | return kTRUE;
|
---|
290 |
|
---|
291 | case M_PICTURE_MAGIC:
|
---|
292 | gSystem->Exec("netscape http://hegra1.mppmu.mpg.de/MAGICWeb/ &");
|
---|
293 | return kTRUE;
|
---|
294 |
|
---|
295 | case M_PICTURE_MARS:
|
---|
296 | gSystem->Exec("netscape http://magic.uni-sw.gwdg.de/mars/ &");
|
---|
297 | return kTRUE;
|
---|
298 | }
|
---|
299 |
|
---|
300 | case kCM_MENU:
|
---|
301 | if (parm1!=M_FILE_EXIT)
|
---|
302 | return kTRUE;
|
---|
303 |
|
---|
304 | CloseWindow();
|
---|
305 | return kTRUE;
|
---|
306 | }
|
---|
307 | }
|
---|
308 |
|
---|
309 | return kTRUE;
|
---|
310 | }
|
---|