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