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

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