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

Last change on this file since 1912 was 1668, checked in by tbretz, 22 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.h>
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
48enum {
49 kFileExit,
50 kFileAbout,
51
52 kPicMagic,
53 kPicMars,
54
55 kButEvtDisplay,
56 kButDataCheck,
57 kButAnalysis,
58 kButMonteCarlo,
59 kButCameraDisplay
60};
61
62void MMars::CreateMenuBar()
63{
64 TGLayoutHints *laymenubar = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX, 2, 2, 2, 2);
65 TGLayoutHints *laymenuitem = new TGLayoutHints(kLHintsTop|kLHintsLeft, 0, 4, 0, 0);
66 TGLayoutHints *laylinesep = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
67
68 fList->Add(laymenubar);
69 fList->Add(laymenuitem);
70 fList->Add(laylinesep);
71
72 TGPopupMenu *filemenu = new TGPopupMenu(gClient->GetRoot());
73 filemenu->AddEntry("E&xit", kFileExit);
74 filemenu->Associate(this);
75
76 TGMenuBar *menubar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
77 menubar->AddPopup("&File", filemenu, laymenuitem);
78 AddFrame(menubar, laymenubar);
79
80 TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
81 AddFrame(linesep, laylinesep);
82
83 fList->Add(filemenu);
84 fList->Add(menubar);
85 fList->Add(linesep);
86}
87
88void MMars::CreateTopFrame(TGHorizontalFrame *top)
89{
90 const TGPicture *pic1 = fList->GetPicture("magiclogo.xpm");
91 if (pic1)
92 {
93 TGPictureButton *magic = new TGPictureButton(top, pic1, kPicMagic);
94 fList->Add(magic);
95 magic->Associate(this);
96 TGLayoutHints *lay1 = new TGLayoutHints(kLHintsLeft, 10., 10., 20., 10.);
97 fList->Add(lay1);
98 top->AddFrame(magic, lay1);
99 }
100
101 const TGPicture *pic2 = fList->GetPicture("marslogo.xpm");
102 if (pic2)
103 {
104 TGPictureButton *mars = new TGPictureButton(top, pic2, kPicMars);
105 fList->Add(mars);
106 mars->Associate(this);
107 TGLayoutHints *lay2 = new TGLayoutHints(kLHintsRight, 10., 10., 10., 10.);
108 fList->Add(lay2);
109 top->AddFrame(mars, lay2);
110 }
111}
112
113#include <TGLabel.h>
114
115void MMars::CreateTextButton(TGVerticalFrame *tab,
116 const char *text, const char *descr,
117 const UInt_t id) const
118{
119 //
120 // Create the button
121 //
122 TGHorizontalFrame *frame = new TGHorizontalFrame(tab, 1, 1);
123 TGTextButton *button = new TGTextButton(frame, text, id);
124 TGLabel *label = new TGLabel(frame, descr);
125 TGLayoutHints *hints1 = new TGLayoutHints(kLHintsLeft|kLHintsCenterY|kLHintsExpandX, 5, 5, 2, 2);
126
127 //
128 // Add button for 'auto-delete'
129 //
130 fList->Add(hints1);
131 fList->Add(button);
132 fList->Add(label);
133 fList->Add(frame);
134
135 //
136 // Send button events (meesages) to this object (s. ProcessMessage)
137 //
138 button->Associate(this);
139
140 //
141 // Add button with corresponding layout to containing frame
142 //
143 tab->AddFrame(frame, hints1);
144 frame->AddFrame(button, hints1);
145 frame->AddFrame(label, hints1);
146}
147
148void MMars::CreateBottomFrame(TGHorizontalFrame *low)
149{
150 //
151 // Create Tab Container
152 //
153 TGLayoutHints *laytabs = new TGLayoutHints(kLHintsBottom|kLHintsExpandX|kLHintsExpandY, 5, 5, 5, 5);
154 fList->Add(laytabs);
155
156 TGTab *tabs = new TGTab(low, 1, 1);
157 fList->Add(tabs);
158 low->AddFrame(tabs, laytabs);
159
160 //
161 // Create Tab1
162 //
163 TGCompositeFrame *tf = tabs->AddTab("Control");
164
165 TGLayoutHints *laytab = new TGLayoutHints(kLHintsCenterY|kLHintsExpandX);
166 TGVerticalFrame *tab = new TGVerticalFrame(tf, 1, 1);
167 fList->Add(laytab);
168 fList->Add(tab);
169
170 CreateTextButton(tab, "Event Display", "Histograms: Pix per Event",
171 kButEvtDisplay);
172 CreateTextButton(tab, "Data Check", "Histograms: Pix per Run",
173 kButDataCheck);
174 CreateTextButton(tab, "Analysis", "Calculate image parameters",
175 kButAnalysis);
176 CreateTextButton(tab, "Monte Carlo", "Calculate MC stuff",
177 kButMonteCarlo);
178 CreateTextButton(tab, "Camera Display", "Display Cerenkov Photons",
179 kButCameraDisplay);
180
181 tf->AddFrame(tab, laytab);
182}
183
184MMars::MMars()
185: TGMainFrame(gClient->GetRoot(), 400, 400, kVerticalFrame)
186{
187 //
188 // Create the deletion list
189 //
190 fList = new MGList;
191 fList->SetOwner();
192
193 //
194 // Create the MenuBar
195 //
196 CreateMenuBar();
197
198 //
199 // create and layout the frame/contents
200 //
201 TGHorizontalFrame *top = new TGHorizontalFrame(this, 1, 1);
202 TGHorizontalFrame *low = new TGHorizontalFrame(this, 1, 1);
203
204 TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
205
206 fList->Add(top);
207 fList->Add(low);
208 fList->Add(linesep);
209
210 CreateTopFrame(top);
211 CreateBottomFrame(low);
212
213 TGLayoutHints *layout1 = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
214 TGLayoutHints *layout2 = new TGLayoutHints(kLHintsTop|kLHintsExpandX|kLHintsExpandY);
215 fList->Add(layout1);
216 fList->Add(layout2);
217
218 AddFrame(top, layout1);
219 AddFrame(linesep, layout1);
220 AddFrame(low, layout2);
221
222 //
223 // Map the window, set up the layout, etc.
224 //
225 Move(rand()%100, rand()%100);
226
227 Layout();
228
229 MapSubwindows();
230
231 SetWindowName("MARS Main Window");
232 SetIconName("MARS");
233
234 MapWindow();
235}
236
237// ======================================================================
238
239MMars::~MMars()
240{
241 delete fList;
242}
243// ======================================================================
244
245void MMars::CloseWindow()
246{
247 // Got close message for this MainFrame. Calls parent CloseWindow()
248 // (which destroys the window) and terminate the application.
249 // The close message is generated by the window manager when its close
250 // window menu item is selected.
251
252 TGMainFrame::CloseWindow();
253 gROOT->GetApplication()->Terminate(0);
254}
255
256void MMars::DisplWarning(const char *txt)
257{
258 Int_t retval;
259 new TGMsgBox(fClient->GetRoot(), this,
260 "WARNING!", txt,
261 kMBIconExclamation, 4, &retval);
262}
263
264Bool_t MMars::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
265{
266 // Process events generated by the buttons in the frame.
267
268 switch (GET_MSG(msg))
269 {
270 case kC_COMMAND:
271 switch (GET_SUBMSG(msg))
272 {
273 case kCM_BUTTON:
274
275 switch (parm1)
276 {
277
278 case kButEvtDisplay:
279 new MEvtDisp(/*this*/);
280 return kTRUE;
281
282 case kButDataCheck:
283 new MDataCheck(/*this*/);
284 return kTRUE;
285
286 case kButAnalysis:
287 new MAnalysis(/*this*/);
288 return kTRUE;
289
290 case kButMonteCarlo:
291 new MMonteCarlo(/*this*/);
292 return kTRUE;
293
294 case kButCameraDisplay:
295 new MCameraDisplay(/*this*/);
296 return kTRUE;
297
298 case kPicMagic:
299 cout << "Trying to start 'netscape http://hegra1.mppmu.mpg.de/MAGICWeb/'..." << endl;
300 gSystem->Exec("netscape http://hegra1.mppmu.mpg.de/MAGICWeb/ &");
301 return kTRUE;
302
303 case kPicMars:
304 cout << "Trying to start 'netscape http://magic.astro.uni-wuerzburg.de/mars/'..." << endl;
305 gSystem->Exec("netscape http://magic.astro.uni-wuerzburg.de/mars/ &");
306 return kTRUE;
307 }
308
309 case kCM_MENU:
310 if (parm1!=kFileExit)
311 return kTRUE;
312
313 CloseWindow();
314 return kTRUE;
315 }
316 }
317
318 return kTRUE;
319}
Note: See TracBrowser for help on using the repository browser.