]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant4/TG4VolumesFrames.cxx
upgrade: all volumes list tree related functions/data moved from TG4MainFrame to...
[u/mrichter/AliRoot.git] / TGeant4 / TG4VolumesFrames.cxx
CommitLineData
4b1d6659 1// $Id$
2// Category: interfaces
3//
4// Author: D. Adamova
5//
6//========================================================
7//
8//------------TG4VolumesFrames.cxx--------------------------------//
9//--------- Frames for the the display of volumes properties---//
10//
11//=========================================================
12
13#include "TG4VolumesFrames.h"
14#include "TG4Globals.h"
15
16#include <TGTextBuffer.h>
17#include <TGTextEntry.h>
18#include <TGComboBox.h>
19#include <TGLabel.h>
cd912ca8 20#include <TGFrame.h>
4b1d6659 21
22#include <G4LogicalVolumeStore.hh>
23#include <G4LogicalVolume.hh>
24#include <G4Material.hh>
25#include <G4VSolid.hh>
26
27
28 ClassImp(TG4VolumesFrames)
29
30TG4VolumesFrames::TG4VolumesFrames( TGCompositeFrame* Parent, TGMainFrame* ActionFrame)
31{
32//---> creates the volumes properties display frame
33//---> and plunges it into the main frame
34 fCapFrame = new TGCompositeFrame(Parent, 60, 20, kHorizontalFrame);
cd912ca8 35 ULong_t back= TGFrame::GetBlackPixel();
36 fCapFrame->ChangeBackground(back);
4b1d6659 37 fVolSubframe1 = new TGCompositeFrame(fCapFrame, 60, 20, kVerticalFrame);
38 fVolFrameLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
39
40// ComboBox for lvolumes
41 fVolumesCombo = new TGComboBox(fVolSubframe1, 100);
42 TGLayoutHints* lLayoutHints3 =
43 new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
44 2, 2, 2, 2);
45 Text_t* lComboLabelText = " Pick up a volume here ";
46 fComboLabel = new TGLabel( fVolSubframe1, lComboLabelText);
47 fVolSubframe1->AddFrame(fComboLabel, lLayoutHints3);
48 fVolSubframe1->AddFrame(fVolumesCombo, fVolFrameLayout);
49
50 fVolumesCombo->Resize(200, 20);
51 fVolumesCombo->Associate(ActionFrame);
52
53
54// text labels with lvolumes properties
55
56 Text_t* labelText[3] =
57 {"Shape's Name",
58 "Material ",
59 "User Limits " };
60
61// Entries for lvolumes properties
62 TGLayoutHints* lLayoutHints4 =
63 new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5);
64 TGLayoutHints* lLayoutHints5 =
65 new TGLayoutHints(kLHintsLeft | kLHintsExpandX );
66 fVolSubframe2 = new TGCompositeFrame(fCapFrame, 60, 20, kVerticalFrame);
67
68 { // local scope for i
69 for (Int_t i=0; i<3; i++) {
70 Int_t idT=i+1;
71 fHframe[i] = new TGHorizontalFrame(fVolSubframe2, 500, 100, kFixedWidth);
72 fVolSubframe2->AddFrame(fHframe[i], lLayoutHints4);
73 fVolTextBuff[i] = new TGTextBuffer(200);
74 fVolTextEntry[i] = new TGTextEntry(fHframe[i], fVolTextBuff[i], 300);
75 fLabel[i] = new TGLabel(fHframe[i], labelText[i]);
76 fHframe[i]->AddFrame(fLabel[i], lLayoutHints5);
77 fHframe[i]->AddFrame(fVolTextEntry[i], lLayoutHints5);
78 fVolTextEntry[i]->Associate(ActionFrame);
79 }
80 }
81
82// making up the Volumes frame
83 fCapFrame->AddFrame(fVolSubframe1,fVolFrameLayout);
84 fCapFrame->AddFrame(fVolSubframe2,fVolFrameLayout);
85// going to the main frame
86 Parent->AddFrame(fCapFrame, fVolFrameLayout);
87}
88
89TG4VolumesFrames::TG4VolumesFrames(const TG4VolumesFrames& vf)
90{
91// Dummy copy constructor
92 TG4Globals::Exception(
93 "Attempt to use TG4VolumesFrames copy constructor.");
94}
95
96TG4VolumesFrames& TG4VolumesFrames::operator=(const TG4VolumesFrames& vf)
97{
98 // check assignement to self
99 if (this == &vf) return *this;
100
101 TG4Globals::Exception(
102 "Attempt to assign singleton.");
103
104 return *this;
105}
106
107TG4VolumesFrames::~TG4VolumesFrames()
108{
109//---> liquidator
110
111 G4cout << "\n Now in TG4VolumesFrames destructor \n" << G4endl;
112 delete fVolSubframe1;
113 delete fVolFrameLayout;
114 delete fVolumesCombo;
115 delete fComboLabel;
116 delete fVolSubframe2;
117 delete fCapFrame;
118
119 Int_t i;
120 for (i=0; i<3; i++) {
121 delete fHframe[i];
122 delete fVolTextBuff[i];
123 delete fVolTextEntry[i];
124 delete fLabel[i];
125 }
126
127}
128
129void TG4VolumesFrames::SetVolumesComboEntries()
130{
131//--->//---> puts names of lvolumes into the combo box entries
132
133 G4LogicalVolumeStore* lComboEntries = G4LogicalVolumeStore::GetInstance();
134
cd912ca8 135 G4int ig = lComboEntries->size();
4b1d6659 136 G4String name;
137
138 for (int ii=0; ii < ig; ii++)
139 { name = ((*lComboEntries )[ii])->GetName() ;
140 AddLogicalVolumeName( name, ii+1);
141 };
142
143 name = " " ;
144 AddLogicalVolumeName( name, ig+1);
145
146
147}
148
149void TG4VolumesFrames::AddLogicalVolumeName( const char* name, Int_t index) const
150{
151//-----> adds an lvolume name to the combo box
152
153 fVolumesCombo->AddEntry( name, index);
154 fVolumesCombo->Select(index);
155 fVolumesCombo->Resize(200, 20);
156}
157
158void TG4VolumesFrames::DisplayVolumeCharacteristics()
159{
160//-----> shows informations about a logical volume
161
162 G4LogicalVolumeStore* lComboEntries = G4LogicalVolumeStore::GetInstance();
cd912ca8 163 G4int ientr = lComboEntries->size();
4b1d6659 164 G4int index = fVolumesCombo->GetSelected();
165
166 G4cout << "\nThe clicked-on volumes entry has the index: " << index << G4endl;
167
168 if( index < ientr+1 ) {
169
170 G4int ii = index-1;
171 G4LogicalVolume* lVolume = (*lComboEntries )[ii];
172 G4Material* lvMaterial = ((*lComboEntries )[ii])->GetMaterial();
173
174 G4cout << lVolume->GetName() << " "
175 << lVolume->GetSolid()->GetEntityType() << " "
176 << lvMaterial->GetName() << " "
177 << lVolume->GetUserLimits() << " "
178 << G4endl;
179
180
181 char buff[100];
182
183 sprintf(buff, lVolume->GetSolid()->GetEntityType());
184 fVolTextBuff[0]->Clear();
185 fVolTextBuff[0]->AddText(0, buff);
186 gClient->NeedRedraw(fVolTextEntry[0]);
187
188 sprintf(buff, lvMaterial->GetName());
189 fVolTextBuff[1]->Clear();
190 fVolTextBuff[1]->AddText(0, buff);
191 gClient->NeedRedraw(fVolTextEntry[1]);
192
193
194 sprintf(buff, "User limits undefined" );
195 if (lVolume->GetUserLimits())
196 sprintf(buff, "User limits defined" );
197 fVolTextBuff[2]->Clear();
198 fVolTextBuff[2]->AddText(0, buff);
199 gClient->NeedRedraw(fVolTextEntry[2]);
200 };
201
202 if( index == ientr+1 ) {
203
204 for ( G4int ii=0; ii<3; ii++) {
205 fVolTextBuff[ii]->Clear();
206 gClient->NeedRedraw(fVolTextEntry[ii]);
207 };
208 };
209}
210