]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant4/TG4MainFrame.cxx
Made a new abstract base class; AliL3HoughBaseTransformer for different implementations
[u/mrichter/AliRoot.git] / TGeant4 / TG4MainFrame.cxx
CommitLineData
c26cc566 1// $Id$
2// Category: interfaces
3//
4// Author: D. Adamova
5//
6//========================================================
7//
8//------------TG4MainFrame.cxx--------------------------------//
9//---------Main Window for the AG4 Geometry Browser---//
10//
11//=========================================================
12
13#include "TG4MainFrame.h"
14#include "TG4Editor.h"
ab33f4bc 15#include "TG4ListTreeFrame.h"
c26cc566 16#include "TG4VolumesFrames.h"
17#include "TG4MaterialsFrames.h"
c26cc566 18#include "TG4Globals.h"
19
65b5af58 20
c26cc566 21#include <TGTab.h>
22#include <TGMenu.h>
23#include <TApplication.h>
24#include <TGMsgBox.h>
25#include <TGTextBuffer.h>
26
27#include <G4LogicalVolume.hh>
28
c26cc566 29ClassImp(TG4MainFrame)
30
31TG4MainFrame::TG4MainFrame(const TGWindow* p, UInt_t w, UInt_t h)
32 : TGMainFrame(p, w, h)
33{
34//---> Creates the main frame
35
36 fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 1, 1);
37 fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
38 fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight);
39
40 fPopupMenu= new TGPopupMenu(gClient->GetRoot());
41 fPopupMenu->AddEntry("&Close Window", 1);
42 fPopupMenu->AddEntry("&Exit Root", 2);
43
44 fPopupMenuTest = new TGPopupMenu(this);
45 fPopupMenuTest->AddEntry("&Message", 3);
46
47 fPopupMenuHelp = new TGPopupMenu(gClient->GetRoot());
48 fPopupMenuHelp->AddEntry("&About", 4);
49
50 fPopupMenu->Associate(this);
51 fPopupMenuTest->Associate(this);
52 fPopupMenuHelp->Associate(this);
53
54 fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
65b5af58 55 fMenuBar->AddPopup("&Main Window",fPopupMenu, fMenuBarItemLayout);
c26cc566 56 fMenuBar->AddPopup("&Draw Control", fPopupMenuTest, fMenuBarItemLayout);
57 fMenuBar->AddPopup("&Report", fPopupMenuHelp, fMenuBarHelpLayout);
58
59 AddFrame(fMenuBar, fMenuBarLayout);
60
ab33f4bc 61//------>Adding a tab
c26cc566 62 fTab = new TGTab(this, 400, 400);
c26cc566 63 TGLayoutHints* lTabLayout = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
64 kLHintsExpandY, 2, 2, 5, 1);
65 AddFrame(fTab, lTabLayout);
66
ab33f4bc 67//------->Frame for ListTree of logical volumes
208c9539 68 flistTreeFrame = new TG4ListTreeFrame( fTab, this);
c26cc566 69
ab33f4bc 70//----->Frame for volumes properties
208c9539 71 fvolumesFrames = new TG4VolumesFrames( fTab, this);
c26cc566 72
73
ab33f4bc 74//----->Frame for materials properties
208c9539 75 fmaterialsFrames = new TG4MaterialsFrames( fTab, this);
c26cc566 76
77//----->Window name and final mapping
78 SetWindowName("ALICE Geant4 Browser");
79 MapSubwindows();
80 Resize(GetDefaultSize());
81
82 MapWindow();
83
84}
85
86TG4MainFrame::TG4MainFrame(const TG4MainFrame& mf)
87 : TGMainFrame( (const TGMainFrame&) mf)
88{
89// Dummy copy constructor
90 TG4Globals::Exception(
91 "Attempt to use TG4MainFrame copy constructor.");
92}
93
94TG4MainFrame& TG4MainFrame::operator=(const TG4MainFrame& mf)
95{
96 // check assignement to self
97 if (this == &mf) return *this;
98
99 TG4Globals::Exception(
100 "Attempt to assign TG4MainFrame singleton.");
101
102 return *this;
103}
104
105TG4MainFrame::~TG4MainFrame()
106{
107//----> Delete created widgets.
108 G4cout << "\n Now in the TG4MainFrame destructor\n" << G4endl;
109 delete fMenuBarLayout;
110 delete fMenuBarItemLayout;
111 delete fMenuBarHelpLayout;
112
113 delete fPopupMenu;
114 delete fPopupMenuTest;
115 delete fPopupMenuHelp;
116
117 delete fMenuBar;
118 delete fTab;
119
ab33f4bc 120 delete flistTreeFrame;
c26cc566 121 delete fvolumesFrames;
122 delete fmaterialsFrames;
123}
124
125TG4VolumesFrames* TG4MainFrame::GetVolumesFrames() const
126{
127//---> For use in TG4GeometryGUI
128 return fvolumesFrames;
129}
130
131TG4MaterialsFrames* TG4MainFrame::GetMaterialsFrames() const
132{
133//---> For use in TG4GeometryGUI
134 return fmaterialsFrames;
135}
136
208c9539 137TG4ListTreeFrame* TG4MainFrame::GetListTreeFrame() const
c26cc566 138{
208c9539 139//---> For use in TG4GeometryGUI
140 return flistTreeFrame;
c26cc566 141}
142
143void TG4MainFrame::CloseWindow()
144{
145 // Got close message for this MainFrame. Calls parent CloseWindow()
146 // (which destroys the window) ((//and terminate the application)).
147 // The close message is generated by the window manager when its close
148 // window menu item is selected.
149
150 TGMainFrame::CloseWindow();
151 gApplication->Terminate(0);
152}
153
154Bool_t TG4MainFrame::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
155{
156//---> Processes events generated by the widgets in the frame
157
158//=============================================================
159//-----> text buffers for Message Boxes
160 TGTextBuffer* lMsgBTtleBf = new TGTextBuffer(100);
161 TGTextBuffer* lMsgBAnnBf1 = new TGTextBuffer(100);
162 TGTextBuffer* lMsgBAnnBf2 = new TGTextBuffer(100);
163 lMsgBTtleBf->AddText(0, "MsgBox");
ab33f4bc 164 lMsgBAnnBf1->AddText(0, "Volumes drawing almost completed !");
c26cc566 165 lMsgBAnnBf2->AddText(0, "YOU'RE CLOSING THE MAIN WINDOW!");
166
167
168//=================================================================
169//----->Message Box
170
171 int retval;
172 EMsgBoxIcon icontype = kMBIconExclamation;
173 Int_t buttons;
174//===================================================================
175//----->Editor window text
39dd4871 176G4String editortxt =
177"\n**********************************************"
178"\n**********************************************"
179"\nWelcome to ALICE Geant4 Geometry Browser. \n"
180"Clicking with the right button on a volume icon\n"
181"will produce the volume's image. "
182"\n\n**********************************************"
183"\n**********************************************";
c26cc566 184//=================================================================
208c9539 185//----->Process messages from widgets
c26cc566 186 switch (GET_MSG(msg)) {
187
188 case kC_TEXTENTRY:
189 switch (GET_SUBMSG(msg)) {
190 case kTE_TEXTCHANGED:
191 switch (parm1) {
192 case 300:
193 G4cout <<" Acting in TextEntry !!! " << G4endl;
194
195 break;
196
197 default:
198 break;
199 };
200
201 default:
202 break;
203 }
204 break;
205
206//---->case Handle Popup menus
207 case kC_COMMAND:
208 switch (GET_SUBMSG(msg)) {
65b5af58 209
210 case kCM_TAB:
211 G4cout << "!!!!CLICKING IN A TAB no. "
212 << fTab->GetCurrent() << " !!!" << G4endl;
213 break;
214
c26cc566 215 case kCM_MENU:
216 switch (parm1) {
217
218 case 1:
65b5af58 219 fTab->SetTab(0);
220 flistTreeFrame->SendCloseMessage();
c26cc566 221 buttons = kMBOk;
222 // for (Int_t i=1; i<3; i++)
223 // buttons |= i;
65b5af58 224 new TGMsgBox(fClient->GetRoot(), this,
225 lMsgBTtleBf->GetString(), lMsgBAnnBf2->GetString(),
226 icontype, buttons, &retval);
c26cc566 227 // if not here, produces
228 // Error in <RootX11ErrorHandler>: BadWindow
65b5af58 229 // (invalid Window parameter) (XID: 100663461)
c26cc566 230 TGMainFrame::CloseWindow();
231 break;
232
233 case 2:
234 G4cout << "\n\n!!!!EXITING. BYE!!!\n\n" << G4endl;
235 CloseWindow(); //-->and exit root
236 break;
237
238 case 3:
239 //-->popup Message
240 buttons = kMBDismiss;
241 new TGMsgBox(fClient->GetRoot(), this,
242 lMsgBTtleBf->GetString(), lMsgBAnnBf1->GetString(),
243 icontype, buttons, &retval);
244 break;
245
246 case 4:
247 //-->editor window
248 {
249 TG4Editor* ed = new TG4Editor(this, 400, 150);
250 ed->LoadBuffer(editortxt);
251 ed->Popup();
252 };
253 break;
254
255 default:
256 break;
257 };
258
259 case kCM_COMBOBOX:
260 switch(parm1) {
261
262 case 100:
263 fvolumesFrames->DisplayVolumeCharacteristics();
264 break;
265
266 case 200:
39dd4871 267 fmaterialsFrames->DisplayMaterialCharacteristics( 0 );
c26cc566 268 break;
269
270 default:
271 break;
272 };
273
39dd4871 274 case kCM_BUTTON:
275 switch(parm1) {
276
65b5af58 277 case 301:
39dd4871 278 fvolumesFrames->DisplayUserLimits();
279 break;
280
281 case 302:
65b5af58 282 fvolumesFrames->DisplayCuts();
39dd4871 283 break;
284
285 case 303:
65b5af58 286 fvolumesFrames->DisplayControls();
39dd4871 287 break;
288
289 default:
290 break;
291 };
292
c26cc566 293 default:
294 break;
295 }
296 break;
297
298//----->case Handle volumes ListTree
299 case kC_LISTTREE:
208c9539 300 flistTreeFrame->ProcessSubMessage( msg, parm1);
c26cc566 301 break;
208c9539 302
c26cc566 303//---->default for GET_MSG
304 default:
305 break;
306 }
307
308 delete lMsgBTtleBf;
309 delete lMsgBAnnBf1;
310 delete lMsgBAnnBf2;
311
312 return kTRUE;
313}
314