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

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