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

Last change on this file since 956 was 949, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 7.8 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
37#include "MEvtDisp.h"
38#include "MAnalysis.h"
39#include "MDataCheck.h"
40#include "MMonteCarlo.h"
41
42#include "MGPrototyp.h"
43
44ClassImp(MMars)
45
46enum {
47 M_FILE_EXIT,
48 M_FILE_ABOUT,
49
50 M_PICTURE_MAGIC,
51 M_PICTURE_MARS,
52
53 M_BUTTON_EVTDISP,
54 M_BUTTON_DATACHECK,
55 M_BUTTON_ANALYSE,
56 M_BUTTON_MONTECARLO
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("Exit", M_FILE_EXIT);
71 //fFileMenu->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, M_PICTURE_MAGIC);
91 TGPictureButton *mars = new TGPictureButton(top, fPic2, M_PICTURE_MARS);
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(kLHintsLeft, 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::CreateBottomFrame(TGHorizontalFrame *low)
110{
111 //
112 // Create Tab Container
113 //
114 TGLayoutHints *laytabs = new TGLayoutHints(kLHintsBottom|kLHintsExpandX|kLHintsExpandY, 5, 5, 5, 5);
115 fList->Add(laytabs);
116
117 TGTab *tabs = new TGTab(low, 400, 400);
118 fList->Add(tabs);
119 low->AddFrame(tabs, laytabs);
120
121 //
122 // Create Tab1
123 //
124 TGCompositeFrame *tf = tabs->AddTab("Control");
125
126 TGVerticalFrame *tab1 = new TGVerticalFrame(tf, 300, 100);
127 TGVerticalFrame *tab2 = new TGVerticalFrame(tf, 300, 100);
128
129 fList->Add(tab1);
130 fList->Add(tab2);
131
132 TGLayoutHints *laytabx = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
133 fList->Add(laytabx);
134
135 tf->AddFrame(tab1, laytabx);
136 tf->AddFrame(tab2, laytabx);
137
138 TGTextButton *evtdisp = new TGTextButton(tab2, "EventDisplay", M_BUTTON_EVTDISP);
139 TGTextButton *datacheck = new TGTextButton(tab2, "Data Check", M_BUTTON_DATACHECK);
140 TGTextButton *analysis = new TGTextButton(tab2, "Analysis", M_BUTTON_ANALYSE);
141 TGTextButton *montecarlo = new TGTextButton(tab2, "MonteCarlo", M_BUTTON_MONTECARLO);
142
143 fList->Add(evtdisp);
144 fList->Add(datacheck);
145 fList->Add(analysis);
146 fList->Add(montecarlo);
147
148 evtdisp ->Associate(this);
149 datacheck ->Associate(this);
150 analysis ->Associate(this);
151 montecarlo->Associate(this);
152
153 TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsCenterX , 10, 10, 10, 10);
154 fList->Add(laybut);
155
156 tab2->AddFrame(evtdisp, laybut);
157 tab2->AddFrame(datacheck, laybut);
158 tab2->AddFrame(analysis, laybut);
159 tab2->AddFrame(montecarlo, laybut);
160}
161
162MMars::MMars(/*const TGWindow *p,*/ UInt_t w, UInt_t h)
163 : TGMainFrame(gClient->GetRoot(), w, h)
164{
165 //
166 // Create the deletion list
167 //
168 fList = new TList;
169 fList->SetOwner();
170
171 //
172 // Create the MenuBar
173 //
174 CreateMenuBar();
175
176 //
177 // create and layout the frame/contents
178 //
179 TGHorizontalFrame *top = new TGHorizontalFrame(this, 300, 100);
180 TGHorizontalFrame *low = new TGHorizontalFrame(this, 300, 100);
181
182 TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
183
184 fList->Add(top);
185 fList->Add(low);
186 fList->Add(linesep);
187
188 CreateTopFrame(top);
189 CreateBottomFrame(low);
190
191 TGLayoutHints *layout = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
192 fList->Add(layout);
193
194 AddFrame(top, layout);
195 AddFrame(linesep, layout);
196 AddFrame(low, layout);
197
198 //
199 // Map the window, set up the layout, etc.
200 //
201 SetWMSizeHints(400, 380, 400, 380, 10, 10); // set the smallest and biggest size of the Main frame
202
203 MapSubwindows();
204
205 Layout();
206
207 SetWindowName("MARS Main Window");
208 SetIconName("MARS");
209
210 MapWindow();
211}
212
213// ======================================================================
214
215MMars::~MMars()
216{
217 gClient->FreePicture(fPic1);
218 gClient->FreePicture(fPic2);
219
220 delete fList;
221}
222// ======================================================================
223
224void MMars::CloseWindow()
225{
226 // Got close message for this MainFrame. Calls parent CloseWindow()
227 // (which destroys the window) and terminate the application.
228 // The close message is generated by the window manager when its close
229 // window menu item is selected.
230
231 TGMainFrame::CloseWindow();
232 gROOT->GetApplication()->Terminate(0);
233}
234
235void MMars::DisplWarning(const char *txt)
236{
237 Int_t retval;
238 new TGMsgBox(fClient->GetRoot(), this,
239 "WARNING!", txt,
240 kMBIconExclamation, 4, &retval);
241}
242
243Bool_t MMars::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
244{
245 // Process events generated by the buttons in the frame.
246
247 switch (GET_MSG(msg))
248 {
249 case kC_COMMAND:
250 switch (GET_SUBMSG(msg))
251 {
252 case kCM_BUTTON:
253
254 switch (parm1)
255 {
256
257 case M_BUTTON_EVTDISP:
258 new MEvtDisp(this);
259 return kTRUE;
260
261 case M_BUTTON_DATACHECK:
262 new MDataCheck(this);
263 return kTRUE;
264
265 case M_BUTTON_ANALYSE:
266 new MAnalysis(this);
267 return kTRUE;
268
269 case M_BUTTON_MONTECARLO:
270 new MMonteCarlo(this);
271 return kTRUE;
272
273 case M_PICTURE_MAGIC:
274 DisplWarning("Please open a Netscape to the MAGIC homepage");
275 return kTRUE;
276
277 case M_PICTURE_MARS:
278 DisplWarning("Please open a Netscape to the MARS homepage");
279 return kTRUE;
280
281 }
282
283 case kCM_MENU:
284 if (parm1!=M_FILE_EXIT)
285 return kTRUE;
286
287 CloseWindow();
288 return kTRUE;
289 }
290 }
291
292 return kTRUE;
293}
Note: See TracBrowser for help on using the repository browser.