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"
23 #include <TApplication.h>
25 #include <TGTextBuffer.h>
27 #include <G4LogicalVolume.hh>
29 ClassImp(TG4MainFrame)
31 TG4MainFrame::TG4MainFrame(const TGWindow* p, UInt_t w, UInt_t h)
32 : TGMainFrame(p, w, h)
34 //---> Creates the main frame
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);
40 fPopupMenu= new TGPopupMenu(gClient->GetRoot());
41 fPopupMenu->AddEntry("&Close Window", 1);
42 fPopupMenu->AddEntry("&Exit Root", 2);
44 fPopupMenuTest = new TGPopupMenu(this);
45 fPopupMenuTest->AddEntry("&Message", 3);
47 fPopupMenuHelp = new TGPopupMenu(gClient->GetRoot());
48 fPopupMenuHelp->AddEntry("&About", 4);
50 fPopupMenu->Associate(this);
51 fPopupMenuTest->Associate(this);
52 fPopupMenuHelp->Associate(this);
54 fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
55 fMenuBar->AddPopup("&Main Window",fPopupMenu, fMenuBarItemLayout);
56 fMenuBar->AddPopup("&Draw Control", fPopupMenuTest, fMenuBarItemLayout);
57 fMenuBar->AddPopup("&Report", fPopupMenuHelp, fMenuBarHelpLayout);
59 AddFrame(fMenuBar, fMenuBarLayout);
62 fTab = new TGTab(this, 400, 400);
63 TGLayoutHints* lTabLayout = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
64 kLHintsExpandY, 2, 2, 5, 1);
65 AddFrame(fTab, lTabLayout);
67 //------->Frame for ListTree of logical volumes
68 flistTreeFrame = new TG4ListTreeFrame( fTab, this);
70 //----->Frame for volumes properties
71 fvolumesFrames = new TG4VolumesFrames( fTab, this);
74 //----->Frame for materials properties
75 fmaterialsFrames = new TG4MaterialsFrames( fTab, this);
77 //----->Window name and final mapping
78 SetWindowName("ALICE Geant4 Browser");
80 Resize(GetDefaultSize());
86 TG4MainFrame::TG4MainFrame(const TG4MainFrame& mf)
87 : TGMainFrame( (const TGMainFrame&) mf)
89 // Dummy copy constructor
90 TG4Globals::Exception(
91 "Attempt to use TG4MainFrame copy constructor.");
94 TG4MainFrame& TG4MainFrame::operator=(const TG4MainFrame& mf)
96 // check assignement to self
97 if (this == &mf) return *this;
99 TG4Globals::Exception(
100 "Attempt to assign TG4MainFrame singleton.");
105 TG4MainFrame::~TG4MainFrame()
107 //----> Delete created widgets.
108 G4cout << "\n Now in the TG4MainFrame destructor\n" << G4endl;
109 delete fMenuBarLayout;
110 delete fMenuBarItemLayout;
111 delete fMenuBarHelpLayout;
114 delete fPopupMenuTest;
115 delete fPopupMenuHelp;
120 delete flistTreeFrame;
121 delete fvolumesFrames;
122 delete fmaterialsFrames;
125 TG4VolumesFrames* TG4MainFrame::GetVolumesFrames() const
127 //---> For use in TG4GeometryGUI
128 return fvolumesFrames;
131 TG4MaterialsFrames* TG4MainFrame::GetMaterialsFrames() const
133 //---> For use in TG4GeometryGUI
134 return fmaterialsFrames;
137 TG4ListTreeFrame* TG4MainFrame::GetListTreeFrame() const
139 //---> For use in TG4GeometryGUI
140 return flistTreeFrame;
143 void TG4MainFrame::CloseWindow()
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.
150 TGMainFrame::CloseWindow();
151 gApplication->Terminate(0);
154 Bool_t TG4MainFrame::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
156 //---> Processes events generated by the widgets in the frame
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");
164 lMsgBAnnBf1->AddText(0, "Volumes drawing almost completed !");
165 lMsgBAnnBf2->AddText(0, "YOU'RE CLOSING THE MAIN WINDOW!");
168 //=================================================================
172 EMsgBoxIcon icontype = kMBIconExclamation;
174 //===================================================================
175 //----->Editor window text
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**********************************************";
184 //=================================================================
185 //----->Process messages from widgets
186 switch (GET_MSG(msg)) {
189 switch (GET_SUBMSG(msg)) {
190 case kTE_TEXTCHANGED:
193 G4cout <<" Acting in TextEntry !!! " << G4endl;
206 //---->case Handle Popup menus
208 switch (GET_SUBMSG(msg)) {
211 G4cout << "!!!!CLICKING IN A TAB no. "
212 << fTab->GetCurrent() << " !!!" << G4endl;
220 flistTreeFrame->SendCloseMessage();
222 // for (Int_t i=1; i<3; i++)
224 new TGMsgBox(fClient->GetRoot(), this,
225 lMsgBTtleBf->GetString(), lMsgBAnnBf2->GetString(),
226 icontype, buttons, &retval);
227 // if not here, produces
228 // Error in <RootX11ErrorHandler>: BadWindow
229 // (invalid Window parameter) (XID: 100663461)
230 TGMainFrame::CloseWindow();
234 G4cout << "\n\n!!!!EXITING. BYE!!!\n\n" << G4endl;
235 CloseWindow(); //-->and exit root
240 buttons = kMBDismiss;
241 new TGMsgBox(fClient->GetRoot(), this,
242 lMsgBTtleBf->GetString(), lMsgBAnnBf1->GetString(),
243 icontype, buttons, &retval);
249 TG4Editor* ed = new TG4Editor(this, 400, 150);
250 ed->LoadBuffer(editortxt);
263 fvolumesFrames->DisplayVolumeCharacteristics();
267 fmaterialsFrames->DisplayMaterialCharacteristics( 0 );
278 fvolumesFrames->DisplayUserLimits();
282 fvolumesFrames->DisplayCuts();
286 fvolumesFrames->DisplayControls();
298 //----->case Handle volumes ListTree
300 flistTreeFrame->ProcessSubMessage( msg, parm1);
303 //---->default for GET_MSG