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

Last change on this file since 1103 was 1082, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 8.1 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-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
43ClassImp(MMars)
44
45enum {
46 kFileExit,
47 kFileAbout,
48
49 kPicMagic,
50 kPicMars,
51
52 kButEvtDisplay,
53 kButDataCheck,
54 kButAnalysis,
55 kButMonteCarlo,
56 kButCameraDisplay
57};
58
59void 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("E&xit", kFileExit);
71 filemenu->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
85void 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, kPicMagic);
91 TGPictureButton *mars = new TGPictureButton(top, fPic2, kPicMars);
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
109void 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
133void 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", kButEvtDisplay, laybut);
166 CreateTextButton(tab2, "Data Check", kButDataCheck, laybut);
167 CreateTextButton(tab2, "Analysis", kButAnalysis, laybut);
168 CreateTextButton(tab2, "Monte Carlo", kButMonteCarlo, laybut);
169 CreateTextButton(tab2, "Camera Display", kButCameraDisplay, laybut);
170}
171
172MMars::MMars()
173: TGMainFrame(gClient->GetRoot(), 330, 400, kVerticalFrame|kFixedSize)
174{
175 //
176 // Create the deletion list
177 //
178 fList = new TList;
179 fList->SetOwner();
180
181 //
182 // Create the MenuBar
183 //
184 CreateMenuBar();
185
186 //
187 // create and layout the frame/contents
188 //
189 TGHorizontalFrame *top = new TGHorizontalFrame(this, 300, 100);
190 TGHorizontalFrame *low = new TGHorizontalFrame(this, 300, 100);
191
192 TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
193
194 fList->Add(top);
195 fList->Add(low);
196 fList->Add(linesep);
197
198 CreateTopFrame(top);
199 CreateBottomFrame(low);
200
201 TGLayoutHints *layout = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
202 fList->Add(layout);
203
204 AddFrame(top, layout);
205 AddFrame(linesep, layout);
206 AddFrame(low, layout);
207
208 // CreateTopFrame(fTop2);
209 // CreateBottomFrame(fTop3);
210
211 //
212 // Map the window, set up the layout, etc.
213 // kFixedSize seems to be ignored
214 //
215 SetWMSizeHints(GetWidth(), GetHeight(), GetWidth(), GetHeight(), 0, 0); // set the smallest and biggest size of the Main frame
216 Move(rand()%100, rand()%100);
217
218 MapSubwindows();
219
220 Layout();
221
222 SetWindowName("MARS Main Window");
223 SetIconName("MARS");
224
225 MapWindow();
226}
227
228// ======================================================================
229
230MMars::~MMars()
231{
232 gClient->FreePicture(fPic1);
233 gClient->FreePicture(fPic2);
234
235 delete fList;
236}
237// ======================================================================
238
239void MMars::CloseWindow()
240{
241 // Got close message for this MainFrame. Calls parent CloseWindow()
242 // (which destroys the window) and terminate the application.
243 // The close message is generated by the window manager when its close
244 // window menu item is selected.
245
246 TGMainFrame::CloseWindow();
247 gROOT->GetApplication()->Terminate(0);
248}
249
250void MMars::DisplWarning(const char *txt)
251{
252 Int_t retval;
253 new TGMsgBox(fClient->GetRoot(), this,
254 "WARNING!", txt,
255 kMBIconExclamation, 4, &retval);
256}
257
258Bool_t MMars::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
259{
260 // Process events generated by the buttons in the frame.
261
262 switch (GET_MSG(msg))
263 {
264 case kC_COMMAND:
265 switch (GET_SUBMSG(msg))
266 {
267 case kCM_BUTTON:
268
269 switch (parm1)
270 {
271
272 case kButEvtDisplay:
273 new MEvtDisp(this);
274 return kTRUE;
275
276 case kButDataCheck:
277 new MDataCheck(this);
278 return kTRUE;
279
280 case kButAnalysis:
281 new MAnalysis(this);
282 return kTRUE;
283
284 case kButMonteCarlo:
285 new MMonteCarlo(this);
286 return kTRUE;
287
288 case kButCameraDisplay:
289 new MCameraDisplay(this);
290 return kTRUE;
291
292 case kPicMagic:
293 gSystem->Exec("netscape http://hegra1.mppmu.mpg.de/MAGICWeb/ &");
294 return kTRUE;
295
296 case kPicMars:
297 gSystem->Exec("netscape http://magic.uni-sw.gwdg.de/mars/ &");
298 return kTRUE;
299 }
300
301 case kCM_MENU:
302 if (parm1!=kFileExit)
303 return kTRUE;
304
305 CloseWindow();
306 return kTRUE;
307 }
308 }
309
310 return kTRUE;
311}
Note: See TracBrowser for help on using the repository browser.