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 "MDataCheck.h"
|
---|
39 | #include "MMonteCarlo.h"
|
---|
40 |
|
---|
41 | #include "MGPrototyp.h"
|
---|
42 |
|
---|
43 | ClassImp(MMars)
|
---|
44 |
|
---|
45 | enum {
|
---|
46 | M_FILE_EXIT ,
|
---|
47 | M_FILE_ABOUT ,
|
---|
48 |
|
---|
49 | M_PICTURE_MAGIC ,
|
---|
50 | M_PICTURE_MARS ,
|
---|
51 |
|
---|
52 | M_BUTTON_EVTDISP ,
|
---|
53 | M_BUTTON_DATACHECK ,
|
---|
54 | M_BUTTON_ANALYSE ,
|
---|
55 | M_BUTTON_MONTECARLO
|
---|
56 | } ;
|
---|
57 |
|
---|
58 |
|
---|
59 | MMars::MMars(/*const TGWindow *p,*/ UInt_t w, UInt_t h)
|
---|
60 | : TGMainFrame(gClient->GetRoot(), w, h)
|
---|
61 | {
|
---|
62 | // First create the MenuBar.
|
---|
63 |
|
---|
64 | // Layout objects for menue.
|
---|
65 |
|
---|
66 | fLayMenuBar = new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2 ) ;
|
---|
67 | fLayMenuItem = new TGLayoutHints ( kLHintsTop | kLHintsLeft , 0, 4, 0, 0 ) ;
|
---|
68 |
|
---|
69 | // crate the menu bar
|
---|
70 |
|
---|
71 | fFileMenu = new TGPopupMenu ( fClient->GetRoot() ) ;
|
---|
72 | fFileMenu->AddEntry ("Exit", M_FILE_EXIT ) ;
|
---|
73 | fFileMenu->Associate(this) ;
|
---|
74 |
|
---|
75 | // the button messages are handled by main frame (this)
|
---|
76 |
|
---|
77 | fMenuBar = new TGMenuBar ( this, 1, 1, kHorizontalFrame ) ;
|
---|
78 | fMenuBar->AddPopup("File", fFileMenu, fLayMenuItem ) ;
|
---|
79 | AddFrame(fMenuBar, fLayMenuBar ) ;
|
---|
80 |
|
---|
81 | fLineSep = new TGHorizontal3DLine(this) ;
|
---|
82 | AddFrame(fLineSep, new TGLayoutHints(kLHintsTop | kLHintsExpandX) );
|
---|
83 |
|
---|
84 | // set up the top part of the main window with the logos
|
---|
85 |
|
---|
86 | fTop = new TGHorizontalFrame (this, 300, 100 ) ;
|
---|
87 |
|
---|
88 | fPicMagic = new TGPictureButton(fTop,
|
---|
89 | gClient->GetPicture("magiclogo.xpm"), M_PICTURE_MAGIC );
|
---|
90 | fPicMagic->Associate(this) ;
|
---|
91 | fTop->AddFrame ( fPicMagic, new TGLayoutHints(kLHintsLeft, 10., 10., 20., 10.) ) ;
|
---|
92 |
|
---|
93 | fPicMars = new TGPictureButton(fTop,
|
---|
94 | gClient->GetPicture("marslogo.xpm"), M_PICTURE_MARS );
|
---|
95 | fPicMars->Associate(this) ;
|
---|
96 | fTop->AddFrame ( fPicMars, new TGLayoutHints(kLHintsLeft, 10., 10., 10., 10.) ) ;
|
---|
97 |
|
---|
98 | AddFrame(fTop, new TGLayoutHints(kLHintsTop | kLHintsExpandX ) );
|
---|
99 |
|
---|
100 | // a seperator
|
---|
101 |
|
---|
102 | fLineSep2 = new TGHorizontal3DLine(this) ;
|
---|
103 | AddFrame(fLineSep2, new TGLayoutHints(kLHintsTop | kLHintsExpandX) );
|
---|
104 |
|
---|
105 | // the low part of the frame
|
---|
106 |
|
---|
107 | fLow = new TGHorizontalFrame (this, 300, 100 ) ;
|
---|
108 |
|
---|
109 | // create the first tab
|
---|
110 |
|
---|
111 | fTab = new TGTab ( fLow, 400, 400 ) ;
|
---|
112 |
|
---|
113 | TGCompositeFrame *tf = fTab->AddTab("Control") ;
|
---|
114 |
|
---|
115 | fTabF1 = new TGVerticalFrame (tf, 300, 100) ;
|
---|
116 |
|
---|
117 | tf->AddFrame(fTabF1, new TGLayoutHints(kLHintsTop | kLHintsExpandX) ) ;
|
---|
118 |
|
---|
119 | // the buttons to go in the new window
|
---|
120 |
|
---|
121 | fTabF2 = new TGVerticalFrame (tf, 300, 100) ;
|
---|
122 |
|
---|
123 | fButLayout = new TGLayoutHints(kLHintsTop | kLHintsCenterX , 10, 10, 10, 10) ;
|
---|
124 |
|
---|
125 | fButEvtDisp = new TGTextButton(fTabF2, "EventDisplay", M_BUTTON_EVTDISP );
|
---|
126 | fButEvtDisp->Associate(this) ;
|
---|
127 | fTabF2->AddFrame(fButEvtDisp, fButLayout ) ;
|
---|
128 |
|
---|
129 | fButDataCheck = new TGTextButton(fTabF2, "Data Check", M_BUTTON_DATACHECK );
|
---|
130 | fButDataCheck->Associate(this) ;
|
---|
131 | fTabF2->AddFrame(fButDataCheck, fButLayout ) ;
|
---|
132 |
|
---|
133 | fButAnalys = new TGTextButton(fTabF2, "Analysis", M_BUTTON_ANALYSE );
|
---|
134 | fButAnalys->Associate(this) ;
|
---|
135 | fTabF2->AddFrame(fButAnalys, fButLayout ) ;
|
---|
136 |
|
---|
137 | fButMonteCarlo = new TGTextButton(fTabF2, "MonteCarlo", M_BUTTON_MONTECARLO );
|
---|
138 | fButMonteCarlo->Associate(this) ;
|
---|
139 | fTabF2->AddFrame(fButMonteCarlo, fButLayout ) ;
|
---|
140 |
|
---|
141 |
|
---|
142 |
|
---|
143 |
|
---|
144 | tf->AddFrame(fTabF2, new TGLayoutHints(kLHintsTop | kLHintsExpandX) ) ;
|
---|
145 |
|
---|
146 |
|
---|
147 |
|
---|
148 | fLow->AddFrame ( fTab, new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) );
|
---|
149 | AddFrame(fLow, new TGLayoutHints(kLHintsTop | kLHintsExpandX ) );
|
---|
150 |
|
---|
151 | // Map the window, set up the layout, etc.
|
---|
152 |
|
---|
153 | SetWMSizeHints(400, 650, 1000, 1000, 10, 10 ) ; // set the smallest and biggest size of the Main frame
|
---|
154 |
|
---|
155 | MapSubwindows();
|
---|
156 |
|
---|
157 | Layout();
|
---|
158 |
|
---|
159 | SetWindowName("MARS Main Window");
|
---|
160 | SetIconName("MARS");
|
---|
161 |
|
---|
162 | MapWindow();
|
---|
163 |
|
---|
164 | }
|
---|
165 |
|
---|
166 | // ======================================================================
|
---|
167 |
|
---|
168 | MMars::~MMars()
|
---|
169 | {
|
---|
170 |
|
---|
171 | delete fButLayout;
|
---|
172 | delete fLayMenuBar;
|
---|
173 | delete fLayMenuItem;
|
---|
174 | delete fButEvtDisp;
|
---|
175 | delete fButDataCheck;
|
---|
176 | delete fButAnalys;
|
---|
177 | delete fButMonteCarlo;
|
---|
178 | delete fPicMagic;
|
---|
179 | delete fPicMars;
|
---|
180 | delete fTabF1;
|
---|
181 | delete fTabF2;
|
---|
182 | delete fTab;
|
---|
183 | delete fLow;
|
---|
184 | delete fTop;
|
---|
185 | delete fLineSep2;
|
---|
186 | delete fLineSep;
|
---|
187 | delete fFileMenu;
|
---|
188 | delete fMenuBar;
|
---|
189 | }
|
---|
190 | // ======================================================================
|
---|
191 |
|
---|
192 | void MMars::CloseWindow()
|
---|
193 | {
|
---|
194 | // Got close message for this MainFrame. Calls parent CloseWindow()
|
---|
195 | // (which destroys the window) and terminate the application.
|
---|
196 | // The close message is generated by the window manager when its close
|
---|
197 | // window menu item is selected.
|
---|
198 |
|
---|
199 | TGMainFrame::CloseWindow();
|
---|
200 | gROOT->GetApplication()->Terminate(0) ;
|
---|
201 | }
|
---|
202 |
|
---|
203 | void MMars::DisplWarning(const char *txt)
|
---|
204 | {
|
---|
205 | Int_t retval;
|
---|
206 | new TGMsgBox(fClient->GetRoot(), this,
|
---|
207 | "WARNING!", txt,
|
---|
208 | kMBIconExclamation, 4, &retval);
|
---|
209 | }
|
---|
210 |
|
---|
211 | Bool_t MMars::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
|
---|
212 | {
|
---|
213 | // Process events generated by the buttons in the frame.
|
---|
214 |
|
---|
215 | switch (GET_MSG(msg))
|
---|
216 | {
|
---|
217 | case kC_COMMAND:
|
---|
218 | switch (GET_SUBMSG(msg))
|
---|
219 | {
|
---|
220 | case kCM_BUTTON:
|
---|
221 |
|
---|
222 | switch (parm1)
|
---|
223 | {
|
---|
224 |
|
---|
225 | case M_BUTTON_EVTDISP:
|
---|
226 | new MEvtDisp(this);
|
---|
227 | return kTRUE;
|
---|
228 |
|
---|
229 | case M_BUTTON_DATACHECK:
|
---|
230 | new MDataCheck(this);
|
---|
231 | return kTRUE;
|
---|
232 |
|
---|
233 | case M_BUTTON_ANALYSE:
|
---|
234 | DisplWarning("Analysis not yet implemented!");
|
---|
235 | return kTRUE;
|
---|
236 |
|
---|
237 | case M_BUTTON_MONTECARLO:
|
---|
238 | new MMonteCarlo(this);
|
---|
239 | return kTRUE;
|
---|
240 |
|
---|
241 | case M_PICTURE_MAGIC:
|
---|
242 | DisplWarning("Please open a Netscape to the MAGIC homepage");
|
---|
243 | return kTRUE;
|
---|
244 |
|
---|
245 | case M_PICTURE_MARS:
|
---|
246 | DisplWarning("Please open a Netscape to the MARS homepage");
|
---|
247 | return kTRUE;
|
---|
248 |
|
---|
249 | }
|
---|
250 |
|
---|
251 | case kCM_MENU:
|
---|
252 | if (parm1!=M_FILE_EXIT)
|
---|
253 | return kTRUE;
|
---|
254 |
|
---|
255 | CloseWindow() ;
|
---|
256 | return kTRUE;
|
---|
257 | }
|
---|
258 | }
|
---|
259 |
|
---|
260 | return kTRUE;
|
---|
261 | }
|
---|