]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4ListTreeFrame.cxx
Initial version
[u/mrichter/AliRoot.git] / TGeant4 / TG4ListTreeFrame.cxx
1 // $Id$
2 // Category: interfaces
3 //
4 // Author: D. Adamova
5 //========================================================
6 //
7 //------------TG4ListTreeFrame.cxx--------------------------------//
8 //--------- Frame for the ListTree container---//
9 //
10 //========================================================= 
11  
12 #include "TG4ListTreeFrame.h"
13 #include "TG4GuiVolume.h"
14 #include "TG4Globals.h"
15
16 #include <TGListTree.h>
17 #include <TGCanvas.h>
18
19 #include <G4LogicalVolume.hh>
20 #include <G4UImanager.hh>
21
22 ClassImp(TG4ListTreeFrame)
23
24 TG4ListTreeFrame::TG4ListTreeFrame( TGCompositeFrame* Parent, TGMainFrame* ActionFrame)
25 {
26 //------>canvas for the ListTree
27    fCanvasWindow = new TGCanvas( Parent, 400, 240);   
28    ULong_t back= TGFrame::GetWhitePixel(); 
29    fCanvasWindow->ChangeBackground(back);
30  
31 //----->ListTree for the logical volumes
32    fVolumesListTree= new TGListTree(fCanvasWindow->GetViewPort(), 10, 10, kHorizontalFrame);
33    fVolumesListTree->Associate(ActionFrame);
34 //------->container for the ListTree
35    fCanvasWindow->SetContainer(fVolumesListTree);
36
37    TGLayoutHints *lCanvasLayout = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
38    Parent->AddFrame(fCanvasWindow, lCanvasLayout);
39    
40 }
41
42 TG4ListTreeFrame::TG4ListTreeFrame(const TG4ListTreeFrame& ltf) 
43 {
44 // Dummy copy constructor 
45   TG4Globals::Exception(
46     "Attempt to use TG4ListTreeFrame copy constructor.");
47 }
48
49 TG4ListTreeFrame& TG4ListTreeFrame::operator=(const TG4ListTreeFrame& ltf)
50 {
51   // check assignement to self
52   if (this == &ltf) return *this;
53
54   TG4Globals::Exception(
55     "Attempt to assign  singleton.");
56     
57   return *this;  
58 }    
59
60 TG4ListTreeFrame::~TG4ListTreeFrame()
61 {
62 //---> liquidator 
63
64    G4cout << "\n Now in  TG4ListTreeFrame destructor \n" << G4endl;
65    delete fCanvasWindow;
66    delete fVolumesListTree;   
67
68 }   
69
70
71 TGListTree* TG4ListTreeFrame::GetVolumesListTree() const
72 {
73 //---> get VolumesListTree for use in the MainFrame
74   return fVolumesListTree;
75 }
76
77 void  TG4ListTreeFrame::DrawSelectedVolume(TGListTreeItem* item)
78 {
79 //---> draw the volume belonging to the item
80
81   TG4GuiVolume* volume=((TG4GuiVolume*) item->GetUserData());
82   G4LogicalVolume* lvolume = volume->GetLogicalVolume();             
83 //-------->>>>>>inserted part for getting parent and number of daughters
84   TGListTreeItem* iParent = item -> GetParent();
85   G4int noDght, ii;
86   G4int icopy = 0;
87   G4String parentName, lName;
88     
89   if (iParent) {
90     
91       TG4GuiVolume* vParent   = ((TG4GuiVolume*) iParent->GetUserData());
92       G4LogicalVolume* lvParent = vParent->GetLogicalVolume();
93       parentName = lvParent->GetName();
94       noDght = lvParent->GetNoDaughters();
95 //------>>>> end of getting parent and number of daughters
96
97    //------->>>>inserted for getting no on copies
98       ii = 0;
99       while ( ii < noDght){
100          if ( lvParent->GetDaughter(ii)->GetLogicalVolume() ==  lvolume )
101               icopy++;  
102      
103              ii++;
104           };
105    //------>>>> end of getting no of copies
106
107       lName = lvolume->GetName();
108   }
109 //------->>>>> case of iParent = 0        
110   else {
111       lName = "ALIC";
112       icopy = 1;
113   };
114      
115   G4cout << "For logical volume   " << lName << "   "
116          << "the number of copies is :!   "  << icopy << endl;
117 //------> looping over number of copies
118    ii=0;              
119    while ( ii < icopy) { 
120       G4String lCommand = "/vis/scene/add/volume  " ;
121       lCommand += lName;
122       lCommand += "  ";
123       TG4Globals::AppendNumberToString( lCommand, ii);
124       lCommand += "  -1";
125       G4cout << "!!!!ADD VOLUME COMMAND IS!!!!   " << lCommand << G4endl;
126       G4UImanager::GetUIpointer()->ApplyCommand( lCommand );
127       G4UImanager::GetUIpointer()->ApplyCommand(
128                   "/control/execute vis_cont.mac");
129       ii++;
130       };
131       
132 }
133               
134  
135