2 // Category: interfaces
6 //========================================================
8 //------------TG4MainFrame.cxx--------------------------------//
9 //---------Main Window for the AG4 Geometry Browser---//
11 //=========================================================
13 #include "TG4MainFrame.h"
14 #include "TG4Editor.h"
15 #include "TG4ListTreeFrame.h"
16 #include "TG4VolumesFrames.h"
17 #include "TG4MaterialsFrames.h"
18 #include "TG4Globals.h"
22 #include <TApplication.h>
24 #include <TGTextBuffer.h>
26 #include <G4LogicalVolume.hh>
28 ClassImp(TG4MainFrame)
30 TG4MainFrame::TG4MainFrame(const TGWindow* p, UInt_t w, UInt_t h)
31 : TGMainFrame(p, w, h)
33 //---> Creates the main frame
35 fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 1, 1);
36 fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
37 fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight);
39 fPopupMenu= new TGPopupMenu(gClient->GetRoot());
40 fPopupMenu->AddEntry("&Close Window", 1);
41 fPopupMenu->AddEntry("&Exit Root", 2);
43 fPopupMenuTest = new TGPopupMenu(this);
44 fPopupMenuTest->AddEntry("&Message", 3);
46 fPopupMenuHelp = new TGPopupMenu(gClient->GetRoot());
47 fPopupMenuHelp->AddEntry("&About", 4);
49 fPopupMenu->Associate(this);
50 fPopupMenuTest->Associate(this);
51 fPopupMenuHelp->Associate(this);
53 fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
54 fMenuBar->AddPopup("&CloseWindow/ExitRoot",fPopupMenu, fMenuBarItemLayout);
55 fMenuBar->AddPopup("&Draw Control", fPopupMenuTest, fMenuBarItemLayout);
56 fMenuBar->AddPopup("&Report", fPopupMenuHelp, fMenuBarHelpLayout);
58 AddFrame(fMenuBar, fMenuBarLayout);
61 fTab = new TGTab(this, 400, 400);
62 TGLayoutHints* lTabLayout = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
63 kLHintsExpandY, 2, 2, 5, 1);
64 AddFrame(fTab, lTabLayout);
66 //------->Frame for ListTree of logical volumes
67 flistTreeFrame = new TG4ListTreeFrame( fTab, this);
69 //----->Frame for volumes properties
70 fvolumesFrames = new TG4VolumesFrames( fTab, this);
73 //----->Frame for materials properties
74 fmaterialsFrames = new TG4MaterialsFrames( fTab, this);
76 //----->Window name and final mapping
77 SetWindowName("ALICE Geant4 Browser");
79 Resize(GetDefaultSize());
85 TG4MainFrame::TG4MainFrame(const TG4MainFrame& mf)
86 : TGMainFrame( (const TGMainFrame&) mf)
88 // Dummy copy constructor
89 TG4Globals::Exception(
90 "Attempt to use TG4MainFrame copy constructor.");
93 TG4MainFrame& TG4MainFrame::operator=(const TG4MainFrame& mf)
95 // check assignement to self
96 if (this == &mf) return *this;
98 TG4Globals::Exception(
99 "Attempt to assign TG4MainFrame singleton.");
104 TG4MainFrame::~TG4MainFrame()
106 //----> Delete created widgets.
107 G4cout << "\n Now in the TG4MainFrame destructor\n" << G4endl;
108 delete fMenuBarLayout;
109 delete fMenuBarItemLayout;
110 delete fMenuBarHelpLayout;
113 delete fPopupMenuTest;
114 delete fPopupMenuHelp;
119 delete flistTreeFrame;
120 delete fvolumesFrames;
121 delete fmaterialsFrames;
124 TG4VolumesFrames* TG4MainFrame::GetVolumesFrames() const
126 //---> For use in TG4GeometryGUI
127 return fvolumesFrames;
130 TG4MaterialsFrames* TG4MainFrame::GetMaterialsFrames() const
132 //---> For use in TG4GeometryGUI
133 return fmaterialsFrames;
136 TG4ListTreeFrame* TG4MainFrame::GetListTreeFrame() const
138 //---> For use in TG4GeometryGUI
139 return flistTreeFrame;
142 void TG4MainFrame::CloseWindow()
144 // Got close message for this MainFrame. Calls parent CloseWindow()
145 // (which destroys the window) ((//and terminate the application)).
146 // The close message is generated by the window manager when its close
147 // window menu item is selected.
149 TGMainFrame::CloseWindow();
150 gApplication->Terminate(0);
153 Bool_t TG4MainFrame::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
155 //---> Processes events generated by the widgets in the frame
157 //=============================================================
158 //-----> text buffers for Message Boxes
159 TGTextBuffer* lMsgBTtleBf = new TGTextBuffer(100);
160 TGTextBuffer* lMsgBAnnBf1 = new TGTextBuffer(100);
161 TGTextBuffer* lMsgBAnnBf2 = new TGTextBuffer(100);
162 lMsgBTtleBf->AddText(0, "MsgBox");
163 lMsgBAnnBf1->AddText(0, "Volumes drawing almost completed !");
164 lMsgBAnnBf2->AddText(0, "YOU'RE CLOSING THE MAIN WINDOW!");
167 //=================================================================
171 EMsgBoxIcon icontype = kMBIconExclamation;
173 //===================================================================
174 //----->Editor window text
176 "\n**********************************************"
177 "\n**********************************************"
178 "\nWelcome to ALICE Geant4 Geometry Browser. \n"
179 "Clicking with the right button on a volume icon\n"
180 "will produce the volume's image. "
181 "\n\n**********************************************"
182 "\n**********************************************";
183 //=================================================================
184 //----->Process messages from widgets
185 switch (GET_MSG(msg)) {
188 switch (GET_SUBMSG(msg)) {
189 case kTE_TEXTCHANGED:
192 G4cout <<" Acting in TextEntry !!! " << G4endl;
205 //---->case Handle Popup menus
207 switch (GET_SUBMSG(msg)) {
214 // for (Int_t i=1; i<3; i++)
216 new TGMsgBox(fClient->GetRoot(), this,
217 lMsgBTtleBf->GetString(), lMsgBAnnBf2->GetString(),
218 icontype, buttons, &retval);
219 // if not here, produces
220 // Error in <RootX11ErrorHandler>: BadWindow
221 // (invalid Window parameter) (XID: 100663461)
222 TGMainFrame::CloseWindow();
226 G4cout << "\n\n!!!!EXITING. BYE!!!\n\n" << G4endl;
227 CloseWindow(); //-->and exit root
232 buttons = kMBDismiss;
233 new TGMsgBox(fClient->GetRoot(), this,
234 lMsgBTtleBf->GetString(), lMsgBAnnBf1->GetString(),
235 icontype, buttons, &retval);
241 TG4Editor* ed = new TG4Editor(this, 400, 150);
242 ed->LoadBuffer(editortxt);
255 fvolumesFrames->DisplayVolumeCharacteristics();
259 fmaterialsFrames->DisplayMaterialCharacteristics( 0 );
270 cout << "\n User Limits Summary button pressed " << endl;
271 fvolumesFrames->DisplayUserLimits();
275 cout << "\n Cuts button pressed " << endl;
279 cout << "\n Controls button pressed " << endl;
291 //----->case Handle volumes ListTree
293 flistTreeFrame->ProcessSubMessage( msg, parm1);
296 //---->default for GET_MSG