2 // Category: interfaces
5 //========================================================
7 //------------TG4ListTreeFrame.cxx--------------------------------//
8 //--------- Frame for the ListTree container---//
10 //=========================================================
12 #include "TG4ListTreeFrame.h"
13 #include "TG4GuiVolume.h"
14 #include "TG4Globals.h"
16 #include <TGListTree.h>
19 #include <G4LogicalVolume.hh>
20 #include <G4UImanager.hh>
22 ClassImp(TG4ListTreeFrame)
24 TG4ListTreeFrame::TG4ListTreeFrame( TGCompositeFrame* Parent, TGMainFrame* ActionFrame)
26 //------>canvas for the ListTree
27 fCanvasWindow = new TGCanvas( Parent, 400, 240);
28 ULong_t back= TGFrame::GetWhitePixel();
29 fCanvasWindow->ChangeBackground(back);
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);
37 TGLayoutHints *lCanvasLayout = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
38 Parent->AddFrame(fCanvasWindow, lCanvasLayout);
42 TG4ListTreeFrame::TG4ListTreeFrame(const TG4ListTreeFrame& ltf)
44 // Dummy copy constructor
45 TG4Globals::Exception(
46 "Attempt to use TG4ListTreeFrame copy constructor.");
49 TG4ListTreeFrame& TG4ListTreeFrame::operator=(const TG4ListTreeFrame& ltf)
51 // check assignement to self
52 if (this == <f) return *this;
54 TG4Globals::Exception(
55 "Attempt to assign singleton.");
60 TG4ListTreeFrame::~TG4ListTreeFrame()
64 G4cout << "\n Now in TG4ListTreeFrame destructor \n" << G4endl;
66 delete fVolumesListTree;
71 TGListTree* TG4ListTreeFrame::GetVolumesListTree() const
73 //---> get VolumesListTree for use in the MainFrame
74 return fVolumesListTree;
77 void TG4ListTreeFrame::DrawSelectedVolume(TGListTreeItem* item)
79 //---> draw the volume belonging to the item
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();
87 G4String parentName, lName;
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
97 //------->>>>inserted for getting no on copies
100 if ( lvParent->GetDaughter(ii)->GetLogicalVolume() == lvolume )
105 //------>>>> end of getting no of copies
107 lName = lvolume->GetName();
109 //------->>>>> case of iParent = 0
115 G4cout << "For logical volume " << lName << " "
116 << "the number of copies is :! " << icopy << endl;
117 //------> looping over number of copies
119 while ( ii < icopy) {
120 G4String lCommand = "/vis/scene/add/volume " ;
123 TG4Globals::AppendNumberToString( lCommand, ii);
125 G4cout << "!!!!ADD VOLUME COMMAND IS!!!! " << lCommand << G4endl;
126 G4UImanager::GetUIpointer()->ApplyCommand( lCommand );
127 G4UImanager::GetUIpointer()->ApplyCommand(
128 "/control/execute vis_cont.mac");