]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant4/TG4GeometryGUI.cxx
Corrected bug in constructor (fIshunt has to be =1)
[u/mrichter/AliRoot.git] / TGeant4 / TG4GeometryGUI.cxx
CommitLineData
b8c9c0a3 1// $Id$
2// Category: interfaces
3//
4// Author: D. Adamova, I. Hrivnacova
5//==============================================================
6//
7//----------------TG4GeometryGUI.cxx--------------------------//
8//----------------AG4 Geometry Browser----------------------//
9//
10//=================================================================
11
12
13
14#include "TG4GeometryGUI.h"
15#include "TG4GuiVolume.h"
16#include "TG4GUI.h"
17#include <G4LogicalVolume.hh>
18#include <G4VPhysicalVolume.hh>
19#include <G4LogicalVolumeStore.hh>
20#include <TGListTree.h>
21#include <TObjArray.h>
22
23ClassImp(TG4GeometryGUI)
24
25TG4GeometryGUI::TG4GeometryGUI()
26{
27 // Constructor
28 fPanel = new TG4GUI(gClient->GetRoot(), 650, 500);
29
30 ReadGeometryTree();
31
32}
33
34void TG4GeometryGUI::ReadGeometryTree()
35{
36// Linking logical volumes to gui volumes
37
38// Icons for folders
39 const TGPicture* kFolder = gClient->GetPicture("folder_t.xpm");
40 const TGPicture* kOpenFolder = gClient->GetPicture("ofolder_t.xpm");
41
42 TG4GuiVolume* volume;
43 G4LogicalVolumeStore* volumeStore;
44 G4LogicalVolume* top;
45
46 TGListTreeItem* itemi;
47
48 volumeStore = G4LogicalVolumeStore::GetInstance();
49 top = (*volumeStore )[0];
50
51 G4String vname = top->GetName();
52 volume = new TG4GuiVolume( vname, top);//--->TObject
53 itemi = fPanel->AddItem(volume,0,vname, kOpenFolder, kFolder);
54
55 RegisterLogicalVolume( top, itemi);
56
57}
58
59void TG4GeometryGUI::RegisterLogicalVolume(G4LogicalVolume* lv,
60 TGListTreeItem* itemv)
61{
62// Filling up gui volumes objArray
63
64typedef G4std::set <G4String, G4std::less<G4String> > TG4StringSet;
65TG4StringSet lVolumeNames; //set of names of solids
66
67// Icons for folders
68 const TGPicture* kFolder = gClient->GetPicture("folder_t.xpm");
69 const TGPicture* kOpenFolder = gClient->GetPicture("ofolder_t.xpm");
70
71 TG4GuiVolume* volume;
72 G4LogicalVolume* lDaughter;
73 G4VPhysicalVolume* pDaughter;
74 TGListTreeItem* itemi;
75
76 G4int nofDaughters = lv->GetNoDaughters();
77 if (nofDaughters == 0) return;
78
79//---------->only for nofDaughters > 0
80 // open composition
81 G4String lvName = lv->GetName();
82 TObjArray* guiVolumes = new TObjArray();
83
84
85 G4int ii;
86 for (ii=0; ii<nofDaughters; ii++) {
87
88 pDaughter = lv->GetDaughter(ii);
89 lDaughter = pDaughter->GetLogicalVolume();
90 G4String vname = lDaughter->GetName();
91
92//-------> process lv only if it was not yet processed
93 if ( (lVolumeNames.find(vname)) == (lVolumeNames.end()) ) {
94
95 volume = new TG4GuiVolume( vname, lDaughter);
96 itemi = fPanel->AddItem(volume, itemv, vname, kOpenFolder, kFolder);
97 volume->SetItem( itemi);
98
99//-----> store the name of logical volume in the set
100 lVolumeNames.insert(lVolumeNames.begin(),vname);
101 guiVolumes->AddLast( volume );
102 };
103
104 };
105
106
107//-----> process daughters
108 for (ii=0; ii<guiVolumes->GetEntriesFast(); ii++) {
109
110 TG4GuiVolume* guiVolume = (TG4GuiVolume*)(guiVolumes->At(ii));
111 G4LogicalVolume* lvd = guiVolume->GetLogicalVolume();
112 TGListTreeItem* itemvd = guiVolume->GetItem();
113 RegisterLogicalVolume(lvd, itemvd);
114 }
115
116 delete guiVolumes;
117}
118