]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4MainFrame.cxx
removed not used includes
[u/mrichter/AliRoot.git] / TGeant4 / TG4MainFrame.cxx
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"
15 #include "TG4ListTreeFrame.h"
16 #include "TG4VolumesFrames.h"
17 #include "TG4MaterialsFrames.h"
18 #include "TG4Globals.h"
19
20 #include <TGTab.h>
21 #include <TGMenu.h>
22 #include <TApplication.h>
23 #include <TGMsgBox.h>
24 #include <TGTextBuffer.h>
25
26 #include <G4LogicalVolume.hh>
27
28 ClassImp(TG4MainFrame)
29
30 TG4MainFrame::TG4MainFrame(const TGWindow* p, UInt_t w, UInt_t h)
31     : TGMainFrame(p, w, h)
32 {
33 //---> Creates the main frame 
34
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);
38
39   fPopupMenu= new TGPopupMenu(gClient->GetRoot());
40   fPopupMenu->AddEntry("&Close Window", 1);
41   fPopupMenu->AddEntry("&Exit Root", 2);
42   
43   fPopupMenuTest = new TGPopupMenu(this);
44   fPopupMenuTest->AddEntry("&Message", 3);
45     
46   fPopupMenuHelp = new TGPopupMenu(gClient->GetRoot());
47   fPopupMenuHelp->AddEntry("&About", 4);
48
49    fPopupMenu->Associate(this);
50    fPopupMenuTest->Associate(this);
51    fPopupMenuHelp->Associate(this);
52  
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);
57
58    AddFrame(fMenuBar, fMenuBarLayout);
59  
60 //------>Adding a tab
61    fTab = new TGTab(this, 400, 400);
62    TGLayoutHints* lTabLayout = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
63                                           kLHintsExpandY, 2, 2, 5, 1);
64    AddFrame(fTab, lTabLayout);
65
66 //------->Frame for ListTree of logical volumes
67    flistTreeFrame = new TG4ListTreeFrame( fTab, this);
68
69 //----->Frame for volumes properties
70    fvolumesFrames = new TG4VolumesFrames( fTab, this);
71
72
73 //----->Frame for materials properties
74    fmaterialsFrames = new TG4MaterialsFrames( fTab, this);
75
76 //----->Window name and final mapping
77    SetWindowName("ALICE Geant4 Browser");
78    MapSubwindows();
79    Resize(GetDefaultSize());
80  
81    MapWindow();
82    
83 }
84
85 TG4MainFrame::TG4MainFrame(const TG4MainFrame& mf)
86    : TGMainFrame( (const TGMainFrame&) mf)
87 {
88 // Dummy copy constructor 
89   TG4Globals::Exception(
90     "Attempt to use TG4MainFrame copy constructor.");
91 }
92
93 TG4MainFrame& TG4MainFrame::operator=(const TG4MainFrame& mf)
94 {
95   // check assignement to self
96   if (this == &mf) return *this;
97
98   TG4Globals::Exception(
99     "Attempt to assign TG4MainFrame singleton.");
100     
101   return *this;  
102 }
103
104 TG4MainFrame::~TG4MainFrame()
105 {
106 //----> Delete created widgets.
107    G4cout << "\n Now in the TG4MainFrame destructor\n" << G4endl;  
108    delete fMenuBarLayout;
109    delete fMenuBarItemLayout;
110    delete fMenuBarHelpLayout;
111
112    delete fPopupMenu;
113    delete fPopupMenuTest;
114    delete fPopupMenuHelp;
115  
116    delete fMenuBar;
117    delete fTab;
118
119    delete flistTreeFrame;
120    delete fvolumesFrames;   
121    delete fmaterialsFrames;
122 }
123
124 TG4VolumesFrames* TG4MainFrame::GetVolumesFrames() const
125 {
126 //---> For use in TG4GeometryGUI
127    return fvolumesFrames;
128 }
129
130 TG4MaterialsFrames* TG4MainFrame::GetMaterialsFrames() const
131 {
132 //---> For use in TG4GeometryGUI
133    return fmaterialsFrames;
134 }
135
136 TG4ListTreeFrame* TG4MainFrame::GetListTreeFrame() const
137 {
138 //---> For use in TG4GeometryGUI
139    return flistTreeFrame;
140 }
141
142 void TG4MainFrame::CloseWindow()
143 {
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.
148
149    TGMainFrame::CloseWindow();
150    gApplication->Terminate(0);
151 }
152
153 Bool_t TG4MainFrame::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
154 {
155 //---> Processes events generated by the widgets in the frame
156
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!");
165
166
167 //=================================================================
168 //----->Message Box
169
170    int  retval;
171    EMsgBoxIcon icontype = kMBIconExclamation;
172    Int_t buttons;
173 //===================================================================
174 //----->Editor window text
175 G4String editortxt =
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)) {
186     
187     case kC_TEXTENTRY:
188         switch (GET_SUBMSG(msg)) {
189         case kTE_TEXTCHANGED:
190             switch (parm1) {
191             case 300:
192                 G4cout <<" Acting in TextEntry !!! " << G4endl;
193                 
194                 break;
195                 
196              default:
197                  break;
198             };
199             
200          default:
201             break;
202          }
203         break;
204
205 //---->case Handle Popup menus    
206     case kC_COMMAND:
207         switch (GET_SUBMSG(msg)) {
208             case kCM_MENU:
209                switch (parm1) {
210
211                    case 1:
212                    
213                      buttons = kMBOk;
214                     // for (Int_t i=1; i<3; i++)
215                     //      buttons |= 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();
223                              break;  
224
225                   case 2:
226                      G4cout << "\n\n!!!!EXITING. BYE!!!\n\n" << G4endl; 
227                      CloseWindow();   //-->and exit root
228                      break;
229                      
230                    case 3:
231                       //-->popup Message 
232                       buttons = kMBDismiss;
233                       new TGMsgBox(fClient->GetRoot(), this,
234                                   lMsgBTtleBf->GetString(), lMsgBAnnBf1->GetString(),
235                                   icontype, buttons, &retval);
236                       break;
237                       
238                   case 4:
239                      //-->editor window
240                      {
241                       TG4Editor* ed = new TG4Editor(this, 400, 150);
242                       ed->LoadBuffer(editortxt);
243                       ed->Popup();
244                       };
245                       break;
246                   
247                   default:    
248                      break;
249                 };
250                 
251             case kCM_COMBOBOX: 
252                 switch(parm1) {
253                 
254                     case 100:
255                       fvolumesFrames->DisplayVolumeCharacteristics();
256                       break;
257                       
258                     case 200:
259                       fmaterialsFrames->DisplayMaterialCharacteristics( 0 );
260                       break;
261                      
262                     default:
263                       break;
264                };
265                
266            case kCM_BUTTON:
267                switch(parm1) {
268                
269                    case 301:
270                      cout << "\n User Limits Summary button pressed " << endl;    
271                      fvolumesFrames->DisplayUserLimits();
272                      break;
273                      
274                    case 302:
275                       cout << "\n Cuts button pressed " << endl;
276                       break;
277                       
278                    case 303:
279                       cout << "\n Controls button pressed " << endl;
280                       break;
281                       
282                    default:
283                       break;
284                };
285                
286             default:
287                break;
288          }
289          break;    
290
291 //----->case Handle volumes ListTree
292     case kC_LISTTREE:
293         flistTreeFrame->ProcessSubMessage( msg, parm1);    
294         break;
295
296 //---->default for GET_MSG      
297     default:
298         break;
299     }
300
301     delete lMsgBTtleBf;
302     delete lMsgBAnnBf1;
303     delete lMsgBAnnBf2; 
304    
305     return kTRUE;
306 }
307