2 // Category: interfaces
6 //========================================================
8 //------------TG4ListTreeFrame.cxx--------------------------------//
9 //--------- Frame for the ListTree container---//
11 //=========================================================
13 #include "TG4ListTreeFrame.h"
14 #include "TG4GuiVolume.h"
15 #include "TG4Globals.h"
17 #include <TGListTree.h>
21 #include <G4LogicalVolume.hh>
22 #include <G4UImanager.hh>
24 ClassImp(TG4ListTreeFrame)
26 TG4ListTreeFrame::TG4ListTreeFrame( TGTab* Tab, TGMainFrame* ActionFrame)
28 //------>canvas for the ListTree
29 TGCompositeFrame* parent= Tab->AddTab("Volumes");
30 fCanvasWindow = new TGCanvas( parent, 400, 240);
31 ULong_t back= TGFrame::GetWhitePixel();
32 fCanvasWindow->ChangeBackground(back);
34 //----->ListTree for the logical volumes
35 fVolumesListTree= new TGListTree(fCanvasWindow->GetViewPort(), 10, 10, kHorizontalFrame);
36 fVolumesListTree->Associate(ActionFrame);
37 //------->container for the ListTree
38 fCanvasWindow->SetContainer(fVolumesListTree);
40 TGLayoutHints *lCanvasLayout = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
41 parent->AddFrame(fCanvasWindow, lCanvasLayout);
45 TG4ListTreeFrame::TG4ListTreeFrame(const TG4ListTreeFrame& ltf)
47 // Dummy copy constructor
48 TG4Globals::Exception(
49 "Attempt to use TG4ListTreeFrame copy constructor.");
52 TG4ListTreeFrame& TG4ListTreeFrame::operator=(const TG4ListTreeFrame& ltf)
54 // check assignement to self
55 if (this == <f) return *this;
57 TG4Globals::Exception(
58 "Attempt to assign singleton.");
63 TG4ListTreeFrame::~TG4ListTreeFrame()
67 G4cout << "\n Now in TG4ListTreeFrame destructor \n" << G4endl;
69 delete fVolumesListTree;
73 TGListTreeItem* TG4ListTreeFrame::
74 AddItem(TObject* obj, TGListTreeItem* parent, const char* name,
75 const TGPicture* open, const TGPicture* closed)
77 //----->Add item to the list tree
78 return fVolumesListTree->AddItem(parent, name, obj, open, closed);
81 Bool_t TG4ListTreeFrame::ProcessSubMessage(Long_t msg, Long_t parm1)
83 //---> Processes events generated by the ListTree widget
85 switch (GET_SUBMSG(msg)) {
87 //----->Cases to Handle mouse click
90 //---> Button 1: Select volume
91 if (parm1 == kButton1){
92 TGListTreeItem* item = fVolumesListTree->GetSelected();
95 TG4GuiVolume* volume=((TG4GuiVolume*) item->GetUserData());
96 G4LogicalVolume* lvolume = volume->GetLogicalVolume();
99 G4cout << "The selected logical volume name is "
100 << lvolume->GetName() << G4endl;
105 //---> Button 3: Draw Volume
106 if (parm1 == kButton3){
107 TGListTreeItem* item = fVolumesListTree->GetSelected();
109 DrawSelectedVolume(item);};
115 case kCT_ITEMDBLCLICK:
116 if (parm1 == kButton1) {
117 if (fVolumesListTree->GetSelected() != 0) {
118 gClient->NeedRedraw(fVolumesListTree);
122 //-->default for GET_SUBMSG
130 void TG4ListTreeFrame::DrawSelectedVolume(TGListTreeItem* item)
132 //---> draw the volume belonging to the item
134 TG4GuiVolume* volume=((TG4GuiVolume*) item->GetUserData());
135 G4LogicalVolume* lvolume = volume->GetLogicalVolume();
136 //-------->>>>>>inserted part for getting parent and number of daughters
137 TGListTreeItem* iParent = item -> GetParent();
140 G4String parentName, lName;
144 TG4GuiVolume* vParent = ((TG4GuiVolume*) iParent->GetUserData());
145 G4LogicalVolume* lvParent = vParent->GetLogicalVolume();
146 parentName = lvParent->GetName();
147 noDght = lvParent->GetNoDaughters();
148 //------>>>> end of getting parent and number of daughters
150 //------->>>>inserted for getting no on copies
152 while ( ii < noDght){
153 if ( lvParent->GetDaughter(ii)->GetLogicalVolume() == lvolume )
158 //------>>>> end of getting no of copies
160 lName = lvolume->GetName();
162 //------->>>>> case of iParent = 0
168 G4cout << "For logical volume " << lName << " "
169 << "the number of copies is :! " << icopy << endl;
170 //------> looping over number of copies
172 while ( ii < icopy) {
173 G4String lCommand = "/vis/scene/add/volume " ;
176 TG4Globals::AppendNumberToString( lCommand, ii);
178 G4cout << "!!!!ADD VOLUME COMMAND IS!!!! " << lCommand << G4endl;
179 G4UImanager::GetUIpointer()->ApplyCommand( lCommand );
180 G4UImanager::GetUIpointer()->ApplyCommand("/vis/sceneHandler/attach");
181 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
184 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
187 //________________________________________________________________________________
188 void TG4ListTreeFrame::SendCloseMessage()
190 //---> Supposed to brighten up the "Volumes" panel
191 //---> plus close the Volumes tree to the ALICE icon
193 TGListTreeItem* first = fVolumesListTree->GetFirstItem();
194 Int_t btn = kButton1;
195 fVolumesListTree->Clicked( first, btn);
196 fVolumesListTree->DoubleClicked( first, btn);
197 gClient->NeedRedraw(fVolumesListTree);
201 //__________________________________________________________________________________