2 // Category: interfaces
5 //==============================================================
7 //----------------TG4GeometryGUI.cxx--------------------------//
8 //----------------AG4 Geometry Browser----------------------//
10 //=================================================================
14 #include "TG4GeometryGUI.h"
15 #include "TG4GuiVolume.h"
16 #include "TG4MainFrame.h"
17 #include "TG4VolumesFrames.h"
18 #include "TG4MaterialsFrames.h"
19 #include "TG4Globals.h"
21 #include <G4LogicalVolume.hh>
22 #include <G4VPhysicalVolume.hh>
23 #include <G4LogicalVolumeStore.hh>
24 #include <TGListTree.h>
25 #include <TObjArray.h>
29 ClassImp(TG4GeometryGUI)
31 TG4GeometryGUI::TG4GeometryGUI()
34 fPanel = new TG4MainFrame(gClient->GetRoot(), 650, 500);
36 G4cout << "\n***********************************************" << G4endl;
37 G4cout << "***********************************************" << G4endl;
38 G4cout << " Welcome to the Geometry Browser for AliGeant4 " << G4endl;
39 G4cout << "\n***********************************************" << G4endl;
40 G4cout << "***********************************************\n" << G4endl;
48 TG4GeometryGUI::TG4GeometryGUI(const TG4GeometryGUI& gg)
50 // Dummy copy constructor
51 TG4Globals::Exception(
52 "Attempt to use TG4GeometryGUI copy constructor.");
55 TG4GeometryGUI& TG4GeometryGUI::operator=(const TG4GeometryGUI& gg)
57 // check assignement to self
58 if (this == &gg) return *this;
60 TG4Globals::Exception(
61 "Attempt to assign TG4GeometryGUI singleton.");
66 TG4GeometryGUI::~TG4GeometryGUI(){
69 G4cout << "\n Now in TG4GeometryGUI destructor \n" << G4endl;
71 // ----> guiVolumes not taken care of yet
75 void TG4GeometryGUI::ReadGeometryTree()
77 //--->Linking logical volumes to gui volumes
80 const TGPicture* kFolder = gClient->GetPicture("folder_t.xpm");
81 const TGPicture* kOpenFolder = gClient->GetPicture("ofolder_t.xpm");
82 const TGPicture* kDocument = gClient->GetPicture("doc_t.xpm");
85 G4LogicalVolumeStore* volumeStore;
88 TGListTreeItem* itemi;
90 volumeStore = G4LogicalVolumeStore::GetInstance();
91 top = (*volumeStore )[0];
93 G4String vname = top->GetName();
94 volume = new TG4GuiVolume( vname, top);//--->TObject
95 itemi = fPanel->AddItem(volume,0,vname, kOpenFolder, kFolder);
97 RegisterLogicalVolume( top, itemi);
99 // delete volume; ---> inactivated to get UserData for the
100 // ---> ListTree items in the MainFrame
104 void TG4GeometryGUI::RegisterLogicalVolume(G4LogicalVolume* lv,
105 TGListTreeItem* itemv)
107 //--->Filling up gui volumes objArray
109 typedef G4std::set <G4String, G4std::less<G4String> > TG4StringSet;
110 TG4StringSet lVolumeNames; //set of names of solids
113 const TGPicture* kFolder = gClient->GetPicture("folder_t.xpm");
114 const TGPicture* kOpenFolder = gClient->GetPicture("ofolder_t.xpm");
116 TG4GuiVolume* volume;
117 G4LogicalVolume* lDaughter;
118 G4VPhysicalVolume* pDaughter;
119 TGListTreeItem* itemi;
121 G4int nofDaughters = lv->GetNoDaughters();
122 if (nofDaughters == 0) return;
124 //---------->only for nofDaughters > 0
126 G4String lvName = lv->GetName();
127 TObjArray* guiVolumes = new TObjArray();
131 for (ii=0; ii<nofDaughters; ii++) {
133 pDaughter = lv->GetDaughter(ii);
134 lDaughter = pDaughter->GetLogicalVolume();
135 G4String vname = lDaughter->GetName();
137 //-------> process lv only if it was not yet processed
138 if ( (lVolumeNames.find(vname)) == (lVolumeNames.end()) ) {
140 volume = new TG4GuiVolume( vname, lDaughter);
141 itemi = fPanel->AddItem(volume, itemv, vname, kOpenFolder, kFolder);
143 itemi->SetUserData(volume);
145 volume->SetItem( itemi);
147 //-----> store the name of logical volume in the set
148 lVolumeNames.insert(lVolumeNames.begin(),vname);
149 guiVolumes->AddLast( volume );
155 //-----> process daughters
156 for (ii=0; ii<guiVolumes->GetEntriesFast(); ii++) {
158 TG4GuiVolume* guiVolume = (TG4GuiVolume*)(guiVolumes->At(ii));
159 G4LogicalVolume* lvd = guiVolume->GetLogicalVolume();
160 TGListTreeItem* itemvd = guiVolume->GetItem();
161 RegisterLogicalVolume(lvd, itemvd);
165 // delete volume;---> if deleted, wrong logical volumes assigned
166 // ---> to the ListTree items in the MainFrame display
169 void TG4GeometryGUI::ReadMaterials() const
171 //-----> Puts logical volumes and materials names
172 //-----> into ComboBoxes
173 TG4VolumesFrames* vFrame = fPanel->GetVolumesFrames();
174 vFrame->SetVolumesComboEntries();
176 TG4MaterialsFrames* mFrame = fPanel->GetMaterialsFrames();
177 mFrame->SetMaterialsComboEntries();