]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant4/TG4GeometryGUI.cxx
update to geant4 3.2 - RW calls changed to STL
[u/mrichter/AliRoot.git] / TGeant4 / TG4GeometryGUI.cxx
CommitLineData
b8c9c0a3 1// $Id$
2// Category: interfaces
3//
66a8b12d 4// Author: D. Adamova
b8c9c0a3 5//==============================================================
6//
7//----------------TG4GeometryGUI.cxx--------------------------//
8//----------------AG4 Geometry Browser----------------------//
9//
10//=================================================================
11
12
13
14#include "TG4GeometryGUI.h"
15#include "TG4GuiVolume.h"
66a8b12d 16#include "TG4MainFrame.h"
17#include "TG4VolumesFrames.h"
18#include "TG4MaterialsFrames.h"
19#include "TG4Globals.h"
20
b8c9c0a3 21#include <G4LogicalVolume.hh>
22#include <G4VPhysicalVolume.hh>
23#include <G4LogicalVolumeStore.hh>
24#include <TGListTree.h>
25#include <TObjArray.h>
66a8b12d 26
27
b8c9c0a3 28
29ClassImp(TG4GeometryGUI)
30
31TG4GeometryGUI::TG4GeometryGUI()
32{
66a8b12d 33//---> Constructor
34 fPanel = new TG4MainFrame(gClient->GetRoot(), 650, 500);
35
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;
41
b8c9c0a3 42 ReadGeometryTree();
43
66a8b12d 44 ReadMaterials();
45
46 }
47
48TG4GeometryGUI::TG4GeometryGUI(const TG4GeometryGUI& gg)
49{
50// Dummy copy constructor
51 TG4Globals::Exception(
52 "Attempt to use TG4GeometryGUI copy constructor.");
53}
54
55TG4GeometryGUI& TG4GeometryGUI::operator=(const TG4GeometryGUI& gg)
56{
57 // check assignement to self
58 if (this == &gg) return *this;
59
60 TG4Globals::Exception(
61 "Attempt to assign TG4GeometryGUI singleton.");
62
63 return *this;
64}
65
66TG4GeometryGUI::~TG4GeometryGUI(){
67//---> liquidator
68
69 G4cout << "\n Now in TG4GeometryGUI destructor \n" << G4endl;
70 delete fPanel;
71// ----> guiVolumes not taken care of yet
72
b8c9c0a3 73}
74
75void TG4GeometryGUI::ReadGeometryTree()
76{
66a8b12d 77//--->Linking logical volumes to gui volumes
b8c9c0a3 78
79// Icons for folders
80 const TGPicture* kFolder = gClient->GetPicture("folder_t.xpm");
81 const TGPicture* kOpenFolder = gClient->GetPicture("ofolder_t.xpm");
66a8b12d 82 const TGPicture* kDocument = gClient->GetPicture("doc_t.xpm");
b8c9c0a3 83 TG4GuiVolume* volume;
66a8b12d 84
b8c9c0a3 85 G4LogicalVolumeStore* volumeStore;
86 G4LogicalVolume* top;
87
66a8b12d 88 TGListTreeItem* itemi;
b8c9c0a3 89
90 volumeStore = G4LogicalVolumeStore::GetInstance();
91 top = (*volumeStore )[0];
92
93 G4String vname = top->GetName();
94 volume = new TG4GuiVolume( vname, top);//--->TObject
95 itemi = fPanel->AddItem(volume,0,vname, kOpenFolder, kFolder);
96
97 RegisterLogicalVolume( top, itemi);
66a8b12d 98
99// delete volume; ---> inactivated to get UserData for the
100// ---> ListTree items in the MainFrame
b8c9c0a3 101
102}
103
104void TG4GeometryGUI::RegisterLogicalVolume(G4LogicalVolume* lv,
105 TGListTreeItem* itemv)
106{
66a8b12d 107//--->Filling up gui volumes objArray
b8c9c0a3 108
109typedef G4std::set <G4String, G4std::less<G4String> > TG4StringSet;
110TG4StringSet lVolumeNames; //set of names of solids
111
112// Icons for folders
113 const TGPicture* kFolder = gClient->GetPicture("folder_t.xpm");
114 const TGPicture* kOpenFolder = gClient->GetPicture("ofolder_t.xpm");
115
116 TG4GuiVolume* volume;
117 G4LogicalVolume* lDaughter;
118 G4VPhysicalVolume* pDaughter;
119 TGListTreeItem* itemi;
120
121 G4int nofDaughters = lv->GetNoDaughters();
122 if (nofDaughters == 0) return;
123
124//---------->only for nofDaughters > 0
125 // open composition
126 G4String lvName = lv->GetName();
127 TObjArray* guiVolumes = new TObjArray();
128
129
130 G4int ii;
131 for (ii=0; ii<nofDaughters; ii++) {
132
133 pDaughter = lv->GetDaughter(ii);
134 lDaughter = pDaughter->GetLogicalVolume();
135 G4String vname = lDaughter->GetName();
136
137//-------> process lv only if it was not yet processed
138 if ( (lVolumeNames.find(vname)) == (lVolumeNames.end()) ) {
139
140 volume = new TG4GuiVolume( vname, lDaughter);
141 itemi = fPanel->AddItem(volume, itemv, vname, kOpenFolder, kFolder);
66a8b12d 142
143 itemi->SetUserData(volume);
144
b8c9c0a3 145 volume->SetItem( itemi);
146
147//-----> store the name of logical volume in the set
148 lVolumeNames.insert(lVolumeNames.begin(),vname);
149 guiVolumes->AddLast( volume );
150 };
151
152 };
153
154
155//-----> process daughters
156 for (ii=0; ii<guiVolumes->GetEntriesFast(); ii++) {
157
158 TG4GuiVolume* guiVolume = (TG4GuiVolume*)(guiVolumes->At(ii));
159 G4LogicalVolume* lvd = guiVolume->GetLogicalVolume();
160 TGListTreeItem* itemvd = guiVolume->GetItem();
161 RegisterLogicalVolume(lvd, itemvd);
66a8b12d 162 };
b8c9c0a3 163
66a8b12d 164 delete guiVolumes;
165// delete volume;---> if deleted, wrong logical volumes assigned
166// ---> to the ListTree items in the MainFrame display
b8c9c0a3 167}
168
66a8b12d 169void TG4GeometryGUI::ReadMaterials() const
170{
171//-----> Puts logical volumes and materials names
172//-----> into ComboBoxes
173 TG4VolumesFrames* vFrame = fPanel->GetVolumesFrames();
174 vFrame->SetVolumesComboEntries();
175
176 TG4MaterialsFrames* mFrame = fPanel->GetMaterialsFrames();
177 mFrame->SetMaterialsComboEntries();
178
179}
180