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