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

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