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

Last change on this file since 1329 was 1108, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 8.2 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 <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
113void MMars::CreateTextButton(TGVerticalFrame *tab, const char *text,
114 const UInt_t id, TGLayoutHints *hints) const
115{
116 //
117 // Create the button
118 //
119 TGTextButton *button = new TGTextButton(tab, text, id);
120
121 //
122 // Add button for 'auto-delete'
123 //
124 fList->Add(button);
125
126 //
127 // Send button events (meesages) to this object (s. ProcessMessage)
128 //
129 button->Associate(this);
130
131 //
132 // Add button with corresponding layout to containing frame
133 //
134 tab->AddFrame(button, hints);
135}
136
137void MMars::CreateBottomFrame(TGHorizontalFrame *low)
138{
139 //
140 // Create Tab Container
141 //
142 TGLayoutHints *laytabs = new TGLayoutHints(kLHintsBottom|kLHintsExpandX|kLHintsExpandY, 5, 5, 5, 5);
143 fList->Add(laytabs);
144
145 TGTab *tabs = new TGTab(low, 400, 400);
146 fList->Add(tabs);
147 low->AddFrame(tabs, laytabs);
148
149 //
150 // Create Tab1
151 //
152 TGCompositeFrame *tf = tabs->AddTab("Control");
153
154 TGVerticalFrame *tab1 = new TGVerticalFrame(tf, 300, 100);
155 TGVerticalFrame *tab2 = new TGVerticalFrame(tf, 300, 100);
156
157 fList->Add(tab1);
158 fList->Add(tab2);
159
160 TGLayoutHints *laytabx = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
161 fList->Add(laytabx);
162
163 tf->AddFrame(tab1, laytabx);
164 tf->AddFrame(tab2, laytabx);
165
166 TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsCenterX, 10, 10, 10, 10);
167 fList->Add(laybut);
168
169 CreateTextButton(tab2, "Event Display", kButEvtDisplay, laybut);
170 CreateTextButton(tab2, "Data Check", kButDataCheck, laybut);
171 CreateTextButton(tab2, "Analysis", kButAnalysis, laybut);
172 CreateTextButton(tab2, "Monte Carlo", kButMonteCarlo, laybut);
173 CreateTextButton(tab2, "Camera Display", kButCameraDisplay, laybut);
174}
175
176MMars::MMars()
177: TGMainFrame(gClient->GetRoot(), 330, 400, kVerticalFrame|kFixedSize)
178{
179 //
180 // Create the deletion list
181 //
182 fList = new MGList;
183 fList->SetOwner();
184
185 //
186 // Create the MenuBar
187 //
188 CreateMenuBar();
189
190 //
191 // create and layout the frame/contents
192 //
193 TGHorizontalFrame *top = new TGHorizontalFrame(this, 300, 100);
194 TGHorizontalFrame *low = new TGHorizontalFrame(this, 300, 100);
195
196 TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
197
198 fList->Add(top);
199 fList->Add(low);
200 fList->Add(linesep);
201
202 CreateTopFrame(top);
203 CreateBottomFrame(low);
204
205 TGLayoutHints *layout = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
206 fList->Add(layout);
207
208 AddFrame(top, layout);
209 AddFrame(linesep, layout);
210 AddFrame(low, layout);
211
212 // CreateTopFrame(fTop2);
213 // CreateBottomFrame(fTop3);
214
215 //
216 // Map the window, set up the layout, etc.
217 // kFixedSize seems to be ignored
218 //
219 SetWMSizeHints(GetWidth(), GetHeight(), GetWidth(), GetHeight(), 0, 0); // set the smallest and biggest size of the Main frame
220 Move(rand()%100, rand()%100);
221
222 MapSubwindows();
223
224 Layout();
225
226 SetWindowName("MARS Main Window");
227 SetIconName("MARS");
228
229 MapWindow();
230}
231
232// ======================================================================
233
234MMars::~MMars()
235{
236 delete fList;
237}
238// ======================================================================
239
240void MMars::CloseWindow()
241{
242 // Got close message for this MainFrame. Calls parent CloseWindow()
243 // (which destroys the window) and terminate the application.
244 // The close message is generated by the window manager when its close
245 // window menu item is selected.
246
247 TGMainFrame::CloseWindow();
248 gROOT->GetApplication()->Terminate(0);
249}
250
251void MMars::DisplWarning(const char *txt)
252{
253 Int_t retval;
254 new TGMsgBox(fClient->GetRoot(), this,
255 "WARNING!", txt,
256 kMBIconExclamation, 4, &retval);
257}
258
259Bool_t MMars::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
260{
261 // Process events generated by the buttons in the frame.
262
263 switch (GET_MSG(msg))
264 {
265 case kC_COMMAND:
266 switch (GET_SUBMSG(msg))
267 {
268 case kCM_BUTTON:
269
270 switch (parm1)
271 {
272
273 case kButEvtDisplay:
274 new MEvtDisp(this);
275 return kTRUE;
276
277 case kButDataCheck:
278 new MDataCheck(this);
279 return kTRUE;
280
281 case kButAnalysis:
282 new MAnalysis(this);
283 return kTRUE;
284
285 case kButMonteCarlo:
286 new MMonteCarlo(this);
287 return kTRUE;
288
289 case kButCameraDisplay:
290 new MCameraDisplay(this);
291 return kTRUE;
292
293 case kPicMagic:
294 gSystem->Exec("netscape http://hegra1.mppmu.mpg.de/MAGICWeb/ &");
295 return kTRUE;
296
297 case kPicMars:
298 gSystem->Exec("netscape http://magic.uni-sw.gwdg.de/mars/ &");
299 return kTRUE;
300 }
301
302 case kCM_MENU:
303 if (parm1!=kFileExit)
304 return kTRUE;
305
306 CloseWindow();
307 return kTRUE;
308 }
309 }
310
311 return kTRUE;
312}
Note: See TracBrowser for help on using the repository browser.