2 // Category: interfaces
6 //========================================================
8 //------------TG4VolumesFrames.cxx--------------------------------//
9 //--------- Frames for the the display of volumes properties---//
11 //=========================================================
13 #include "TG4VolumesFrames.h"
14 #include "TG4Globals.h"
16 #include <TGTextBuffer.h>
17 #include <TGTextEntry.h>
18 #include <TGComboBox.h>
23 #include <G4LogicalVolumeStore.hh>
24 #include <G4LogicalVolume.hh>
25 #include <G4Material.hh>
26 #include <G4VSolid.hh>
29 ClassImp(TG4VolumesFrames)
31 TG4VolumesFrames::TG4VolumesFrames( TGTab* Tab, TGMainFrame* ActionFrame)
33 //---> creates the volumes properties display frame
34 //---> and plunges it into the main frame
35 TGCompositeFrame* parent = Tab->AddTab("Volumes Properties");
36 fCapFrame = new TGCompositeFrame(parent, 60, 20, kHorizontalFrame);
37 ULong_t back= TGFrame::GetBlackPixel();
38 fCapFrame->ChangeBackground(back);
39 fVolSubframe1 = new TGCompositeFrame(fCapFrame, 60, 20, kVerticalFrame);
40 fVolFrameLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
42 // ComboBox for lvolumes
43 fVolumesCombo = new TGComboBox(fVolSubframe1, 100);
44 TGLayoutHints* lLayoutHints3 =
45 new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
47 Text_t* lComboLabelText = " Pick up a volume here ";
48 fComboLabel = new TGLabel( fVolSubframe1, lComboLabelText);
49 fVolSubframe1->AddFrame(fComboLabel, lLayoutHints3);
50 fVolSubframe1->AddFrame(fVolumesCombo, fVolFrameLayout);
52 fVolumesCombo->Resize(200, 20);
53 fVolumesCombo->Associate(ActionFrame);
56 // text labels with lvolumes properties
58 Text_t* labelText[3] =
63 // Entries for lvolumes properties
64 TGLayoutHints* lLayoutHints4 =
65 new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5);
66 TGLayoutHints* lLayoutHints5 =
67 new TGLayoutHints(kLHintsLeft | kLHintsExpandX );
68 fVolSubframe2 = new TGCompositeFrame(fCapFrame, 60, 20, kVerticalFrame);
70 { // local scope for i
71 for (Int_t i=0; i<3; i++) {
73 fHframe[i] = new TGHorizontalFrame(fVolSubframe2, 500, 100, kFixedWidth);
74 fVolSubframe2->AddFrame(fHframe[i], lLayoutHints4);
75 fVolTextBuff[i] = new TGTextBuffer(200);
76 fVolTextEntry[i] = new TGTextEntry(fHframe[i], fVolTextBuff[i], 300);
77 fLabel[i] = new TGLabel(fHframe[i], labelText[i]);
78 fHframe[i]->AddFrame(fLabel[i], lLayoutHints5);
79 fHframe[i]->AddFrame(fVolTextEntry[i], lLayoutHints5);
80 fVolTextEntry[i]->Associate(ActionFrame);
84 // making up the Volumes frame
85 fCapFrame->AddFrame(fVolSubframe1,fVolFrameLayout);
86 fCapFrame->AddFrame(fVolSubframe2,fVolFrameLayout);
87 // going to the main frame
88 parent->AddFrame(fCapFrame, fVolFrameLayout);
91 TG4VolumesFrames::TG4VolumesFrames(const TG4VolumesFrames& vf)
93 // Dummy copy constructor
94 TG4Globals::Exception(
95 "Attempt to use TG4VolumesFrames copy constructor.");
98 TG4VolumesFrames& TG4VolumesFrames::operator=(const TG4VolumesFrames& vf)
100 // check assignement to self
101 if (this == &vf) return *this;
103 TG4Globals::Exception(
104 "Attempt to assign singleton.");
109 TG4VolumesFrames::~TG4VolumesFrames()
113 G4cout << "\n Now in TG4VolumesFrames destructor \n" << G4endl;
114 delete fVolSubframe1;
115 delete fVolFrameLayout;
116 delete fVolumesCombo;
118 delete fVolSubframe2;
122 for (i=0; i<3; i++) {
124 delete fVolTextBuff[i];
125 delete fVolTextEntry[i];
131 void TG4VolumesFrames::SetVolumesComboEntries()
133 //--->//---> puts names of lvolumes into the combo box entries
135 G4LogicalVolumeStore* lComboEntries = G4LogicalVolumeStore::GetInstance();
137 G4int ig = lComboEntries->size();
140 for (int ii=0; ii < ig; ii++)
141 { name = ((*lComboEntries )[ii])->GetName() ;
142 AddLogicalVolumeName( name, ii+1);
146 AddLogicalVolumeName( name, ig+1);
151 void TG4VolumesFrames::AddLogicalVolumeName( const char* name, Int_t index) const
153 //-----> adds an lvolume name to the combo box
155 fVolumesCombo->AddEntry( name, index);
156 fVolumesCombo->Select(index);
157 fVolumesCombo->Resize(200, 20);
160 void TG4VolumesFrames::DisplayVolumeCharacteristics()
162 //-----> shows informations about a logical volume
164 G4LogicalVolumeStore* lComboEntries = G4LogicalVolumeStore::GetInstance();
165 G4int ientr = lComboEntries->size();
166 G4int index = fVolumesCombo->GetSelected();
168 G4cout << "\nThe clicked-on volumes entry has the index: " << index << G4endl;
170 if( index < ientr+1 ) {
173 G4LogicalVolume* lVolume = (*lComboEntries )[ii];
174 G4Material* lvMaterial = ((*lComboEntries )[ii])->GetMaterial();
176 G4cout << lVolume->GetName() << " "
177 << lVolume->GetSolid()->GetEntityType() << " "
178 << lvMaterial->GetName() << " "
179 << lVolume->GetUserLimits() << " "
185 sprintf(buff, lVolume->GetSolid()->GetEntityType());
186 fVolTextBuff[0]->Clear();
187 fVolTextBuff[0]->AddText(0, buff);
188 gClient->NeedRedraw(fVolTextEntry[0]);
190 sprintf(buff, lvMaterial->GetName());
191 fVolTextBuff[1]->Clear();
192 fVolTextBuff[1]->AddText(0, buff);
193 gClient->NeedRedraw(fVolTextEntry[1]);
196 sprintf(buff, "User limits undefined" );
197 if (lVolume->GetUserLimits())
198 sprintf(buff, "User limits defined" );
199 fVolTextBuff[2]->Clear();
200 fVolTextBuff[2]->AddText(0, buff);
201 gClient->NeedRedraw(fVolTextEntry[2]);
204 if( index == ientr+1 ) {
206 for ( G4int ii=0; ii<3; ii++) {
207 fVolTextBuff[ii]->Clear();
208 gClient->NeedRedraw(fVolTextEntry[ii]);