]>
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" | |
39dd4871 | 14 | #include "TG4MaterialsFrames.h" |
65b5af58 | 15 | #include "TG4MainFrame.h" |
39dd4871 | 16 | #include "TG4Editor.h" |
4b1d6659 | 17 | #include "TG4Globals.h" |
39dd4871 | 18 | #include "TG4Limits.h" |
19 | #include "TG4G3CutVector.h" | |
65b5af58 | 20 | #include "TG4G3ControlVector.h" |
4b1d6659 | 21 | |
22 | #include <TGTextBuffer.h> | |
23 | #include <TGTextEntry.h> | |
24 | #include <TGComboBox.h> | |
25 | #include <TGLabel.h> | |
f9ea40e1 | 26 | #include <TGTab.h> |
39dd4871 | 27 | //#include <TGFrame.h> |
28 | //#include <TGButton.h> | |
4b1d6659 | 29 | |
30 | #include <G4LogicalVolumeStore.hh> | |
31 | #include <G4LogicalVolume.hh> | |
32 | #include <G4Material.hh> | |
33 | #include <G4VSolid.hh> | |
39dd4871 | 34 | #include <G4UserLimits.hh> |
35 | #include <G4Track.hh> | |
4b1d6659 | 36 | |
37 | ||
38 | ClassImp(TG4VolumesFrames) | |
39 | ||
65b5af58 | 40 | TG4VolumesFrames::TG4VolumesFrames( TGTab* Tab, TG4MainFrame* ActionFrame) |
41 | : fPanel(ActionFrame) | |
4b1d6659 | 42 | { |
43 | //---> creates the volumes properties display frame | |
44 | //---> and plunges it into the main frame | |
fb348a11 | 45 | TGCompositeFrame* parent = Tab->AddTab("Volumes Properties"); |
46 | fCapFrame = new TGCompositeFrame(parent, 60, 20, kHorizontalFrame); | |
cd912ca8 | 47 | ULong_t back= TGFrame::GetBlackPixel(); |
48 | fCapFrame->ChangeBackground(back); | |
4b1d6659 | 49 | fVolSubframe1 = new TGCompositeFrame(fCapFrame, 60, 20, kVerticalFrame); |
50 | fVolFrameLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5); | |
51 | ||
52 | // ComboBox for lvolumes | |
53 | fVolumesCombo = new TGComboBox(fVolSubframe1, 100); | |
54 | TGLayoutHints* lLayoutHints3 = | |
55 | new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, | |
56 | 2, 2, 2, 2); | |
57 | Text_t* lComboLabelText = " Pick up a volume here "; | |
58 | fComboLabel = new TGLabel( fVolSubframe1, lComboLabelText); | |
59 | fVolSubframe1->AddFrame(fComboLabel, lLayoutHints3); | |
60 | fVolSubframe1->AddFrame(fVolumesCombo, fVolFrameLayout); | |
61 | ||
39dd4871 | 62 | fVolumesCombo->Resize(200, 30); |
4b1d6659 | 63 | fVolumesCombo->Associate(ActionFrame); |
64 | ||
65 | ||
66 | // text labels with lvolumes properties | |
67 | ||
68 | Text_t* labelText[3] = | |
69 | {"Shape's Name", | |
70 | "Material ", | |
71 | "User Limits " }; | |
72 | ||
73 | // Entries for lvolumes properties | |
74 | TGLayoutHints* lLayoutHints4 = | |
75 | new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5); | |
76 | TGLayoutHints* lLayoutHints5 = | |
77 | new TGLayoutHints(kLHintsLeft | kLHintsExpandX ); | |
78 | fVolSubframe2 = new TGCompositeFrame(fCapFrame, 60, 20, kVerticalFrame); | |
79 | ||
80 | { // local scope for i | |
39dd4871 | 81 | for (Int_t i=0; i<2; i++) { |
4b1d6659 | 82 | Int_t idT=i+1; |
83 | fHframe[i] = new TGHorizontalFrame(fVolSubframe2, 500, 100, kFixedWidth); | |
84 | fVolSubframe2->AddFrame(fHframe[i], lLayoutHints4); | |
85 | fVolTextBuff[i] = new TGTextBuffer(200); | |
86 | fVolTextEntry[i] = new TGTextEntry(fHframe[i], fVolTextBuff[i], 300); | |
87 | fLabel[i] = new TGLabel(fHframe[i], labelText[i]); | |
88 | fHframe[i]->AddFrame(fLabel[i], lLayoutHints5); | |
89 | fHframe[i]->AddFrame(fVolTextEntry[i], lLayoutHints5); | |
90 | fVolTextEntry[i]->Associate(ActionFrame); | |
91 | } | |
39dd4871 | 92 | } |
93 | ||
94 | // --->a group frame for displaying user's limits with a text entry added | |
95 | ||
96 | fGrFrame = | |
97 | new TGGroupFrame(fVolSubframe2, "----- User Limits Showcase -----", kVerticalFrame); | |
98 | fHframe[2] = new TGHorizontalFrame( fGrFrame, 410, 100, kFixedWidth); | |
99 | TGLayoutHints* lLayoutHints6 = new TGLayoutHints(kLHintsTop | kLHintsLeft , | |
100 | 4, 0, 20, 2); | |
101 | fLabel[2] = new TGLabel(fHframe[2], labelText[2]); | |
102 | fHframe[2]->AddFrame(fLabel[2],lLayoutHints6); | |
103 | fVolTextBuff[2] = new TGTextBuffer(200); | |
104 | fVolTextEntry[2] = new TGTextEntry(fHframe[2], fVolTextBuff[2], 300); | |
105 | fVolTextEntry[2]->Resize(1000, fVolTextEntry[2]->GetDefaultHeight()); | |
106 | fHframe[2]->AddFrame(fVolTextEntry[2], lLayoutHints6); | |
107 | fVolTextEntry[2]->Associate(ActionFrame); | |
108 | ||
109 | fGrFrame->AddFrame(fHframe[2], lLayoutHints4); | |
110 | ||
111 | // ---> adding to the group frame another frame with text buttons | |
112 | // for calling up a full display of user's limits properties | |
4b1d6659 | 113 | |
39dd4871 | 114 | fGrHFrame= new TGHorizontalFrame( fGrFrame, 500, 100); |
115 | fbtsumm = new TGTextButton(fGrHFrame, "&User Limits", 301); | |
116 | fbtcuts = new TGTextButton(fGrHFrame, "&Show Cuts", 302); | |
117 | fbtcontrols = new TGTextButton(fGrHFrame, "&Show Controls", 303); | |
118 | TGLayoutHints* lLayoutHints7 = | |
119 | new TGLayoutHints(kLHintsTop | kLHintsLeft, 50, 0, 5, 5); | |
120 | fGrHFrame->SetLayoutManager(new TGMatrixLayout(fGrHFrame, 0, 3, 15)); | |
121 | fGrHFrame->AddFrame( fbtsumm ); | |
122 | fbtsumm->Resize(90, fbtsumm->GetDefaultHeight()); | |
123 | fGrHFrame->AddFrame( fbtcuts ); | |
124 | fbtcuts->Resize(90, fbtcuts->GetDefaultHeight()); | |
125 | fGrHFrame->AddFrame( fbtcontrols ); | |
126 | fbtcontrols->Resize(90, fbtcontrols->GetDefaultHeight()); | |
127 | ||
128 | fbtsumm->Associate(ActionFrame); | |
129 | fbtcuts->Associate(ActionFrame); | |
130 | fbtcontrols->Associate(ActionFrame); | |
131 | ||
132 | fGrFrame->AddFrame(fGrHFrame, lLayoutHints4); | |
133 | ||
134 | //---> adding the group frame to the subrame 2 | |
135 | fVolSubframe2->AddFrame( fGrFrame, lLayoutHints7); | |
136 | fGrFrame->Resize(fGrFrame->GetDefaultSize()); | |
137 | ||
138 | // ---> text for the user's limits display window when no volume specified yet | |
65b5af58 | 139 | fDisplBuffLimits = new TGTextBuffer(1000); |
140 | fDisplBuffLimits->Clear(); | |
141 | fDisplBuffLimits->AddText(0, "\n\n*** No volume specified, " | |
39dd4871 | 142 | "no limits displayed *** "); |
143 | ||
65b5af58 | 144 | // ---> text for the user's cuts display window when no volume specified yet |
145 | fDisplBuffCuts = new TGTextBuffer(1000); | |
146 | fDisplBuffCuts->Clear(); | |
147 | fDisplBuffCuts->AddText(0, "\n\n*** No volume specified, " | |
148 | "no cuts displayed *** "); | |
149 | ||
150 | // ---> text for the user's controls display window when no volume specified yet | |
151 | fDisplBuffControls = new TGTextBuffer(1000); | |
152 | fDisplBuffControls->Clear(); | |
153 | fDisplBuffControls->AddText(0, "\n\n*** No volume specified, " | |
154 | "no controls displayed *** "); | |
155 | ||
39dd4871 | 156 | |
157 | // ---> making up the Volumes frame | |
4b1d6659 | 158 | fCapFrame->AddFrame(fVolSubframe1,fVolFrameLayout); |
159 | fCapFrame->AddFrame(fVolSubframe2,fVolFrameLayout); | |
39dd4871 | 160 | |
161 | // ---> going to the main frame | |
fb348a11 | 162 | parent->AddFrame(fCapFrame, fVolFrameLayout); |
4b1d6659 | 163 | } |
164 | ||
165 | TG4VolumesFrames::TG4VolumesFrames(const TG4VolumesFrames& vf) | |
166 | { | |
167 | // Dummy copy constructor | |
168 | TG4Globals::Exception( | |
169 | "Attempt to use TG4VolumesFrames copy constructor."); | |
170 | } | |
171 | ||
172 | TG4VolumesFrames& TG4VolumesFrames::operator=(const TG4VolumesFrames& vf) | |
173 | { | |
174 | // check assignement to self | |
175 | if (this == &vf) return *this; | |
176 | ||
177 | TG4Globals::Exception( | |
178 | "Attempt to assign singleton."); | |
179 | ||
180 | return *this; | |
181 | } | |
182 | ||
183 | TG4VolumesFrames::~TG4VolumesFrames() | |
184 | { | |
185 | //---> liquidator | |
186 | ||
187 | G4cout << "\n Now in TG4VolumesFrames destructor \n" << G4endl; | |
188 | delete fVolSubframe1; | |
189 | delete fVolFrameLayout; | |
190 | delete fVolumesCombo; | |
191 | delete fComboLabel; | |
192 | delete fVolSubframe2; | |
193 | delete fCapFrame; | |
39dd4871 | 194 | delete fGrFrame; |
195 | delete fGrHFrame; | |
196 | delete fbtsumm; | |
197 | delete fbtcuts; | |
198 | delete fbtcontrols; | |
4b1d6659 | 199 | |
200 | Int_t i; | |
201 | for (i=0; i<3; i++) { | |
202 | delete fHframe[i]; | |
203 | delete fVolTextBuff[i]; | |
204 | delete fVolTextEntry[i]; | |
205 | delete fLabel[i]; | |
206 | } | |
65b5af58 | 207 | delete fDisplBuffLimits; |
208 | delete fDisplBuffCuts; | |
209 | delete fDisplBuffControls; | |
210 | ||
4b1d6659 | 211 | } |
212 | ||
213 | void TG4VolumesFrames::SetVolumesComboEntries() | |
214 | { | |
215 | //--->//---> puts names of lvolumes into the combo box entries | |
216 | ||
217 | G4LogicalVolumeStore* lComboEntries = G4LogicalVolumeStore::GetInstance(); | |
218 | ||
cd912ca8 | 219 | G4int ig = lComboEntries->size(); |
4b1d6659 | 220 | G4String name; |
221 | ||
222 | for (int ii=0; ii < ig; ii++) | |
223 | { name = ((*lComboEntries )[ii])->GetName() ; | |
224 | AddLogicalVolumeName( name, ii+1); | |
225 | }; | |
226 | ||
227 | name = " " ; | |
228 | AddLogicalVolumeName( name, ig+1); | |
229 | ||
230 | ||
231 | } | |
232 | ||
233 | void TG4VolumesFrames::AddLogicalVolumeName( const char* name, Int_t index) const | |
234 | { | |
235 | //-----> adds an lvolume name to the combo box | |
236 | ||
237 | fVolumesCombo->AddEntry( name, index); | |
238 | fVolumesCombo->Select(index); | |
239 | fVolumesCombo->Resize(200, 20); | |
240 | } | |
241 | ||
242 | void TG4VolumesFrames::DisplayVolumeCharacteristics() | |
243 | { | |
244 | //-----> shows informations about a logical volume | |
245 | ||
246 | G4LogicalVolumeStore* lComboEntries = G4LogicalVolumeStore::GetInstance(); | |
cd912ca8 | 247 | G4int ientr = lComboEntries->size(); |
4b1d6659 | 248 | G4int index = fVolumesCombo->GetSelected(); |
39dd4871 | 249 | G4int imat = 0; |
4b1d6659 | 250 | |
251 | G4cout << "\nThe clicked-on volumes entry has the index: " << index << G4endl; | |
39dd4871 | 252 | |
253 | TG4Limits* lLimits; | |
254 | ||
4b1d6659 | 255 | if( index < ientr+1 ) { |
256 | ||
257 | G4int ii = index-1; | |
258 | G4LogicalVolume* lVolume = (*lComboEntries )[ii]; | |
259 | G4Material* lvMaterial = ((*lComboEntries )[ii])->GetMaterial(); | |
39dd4871 | 260 | lLimits = (TG4Limits*)lVolume->GetUserLimits(); |
65b5af58 | 261 | TString lDisplayLimits = GetLimitsDisplay(lLimits); |
262 | TString lDisplayCuts = GetCutsDisplay(lLimits); | |
263 | TString lDisplayControls = GetControlsDisplay(lLimits); | |
264 | ||
39dd4871 | 265 | //---> fills up the buffer for popup frame display |
65b5af58 | 266 | fDisplBuffLimits->Clear(); |
267 | fDisplBuffLimits->AddText(0,lDisplayLimits); | |
268 | ||
269 | fDisplBuffCuts->Clear(); | |
270 | fDisplBuffCuts->AddText(0,lDisplayCuts); | |
271 | ||
272 | fDisplBuffControls->Clear(); | |
273 | fDisplBuffControls->AddText(0,lDisplayControls); | |
274 | ||
4b1d6659 | 275 | |
276 | G4cout << lVolume->GetName() << " " | |
277 | << lVolume->GetSolid()->GetEntityType() << " " | |
278 | << lvMaterial->GetName() << " " | |
39dd4871 | 279 | << lVolume->GetUserLimits()->GetType() << G4endl; |
280 | ||
281 | //---> putting text in the text entries | |
282 | char buff[100]; | |
283 | ||
4b1d6659 | 284 | sprintf(buff, lVolume->GetSolid()->GetEntityType()); |
285 | fVolTextBuff[0]->Clear(); | |
286 | fVolTextBuff[0]->AddText(0, buff); | |
287 | gClient->NeedRedraw(fVolTextEntry[0]); | |
288 | ||
289 | sprintf(buff, lvMaterial->GetName()); | |
290 | fVolTextBuff[1]->Clear(); | |
291 | fVolTextBuff[1]->AddText(0, buff); | |
292 | gClient->NeedRedraw(fVolTextEntry[1]); | |
293 | ||
294 | ||
295 | sprintf(buff, "User limits undefined" ); | |
296 | if (lVolume->GetUserLimits()) | |
39dd4871 | 297 | sprintf(buff, lLimits->GetName()); |
4b1d6659 | 298 | fVolTextBuff[2]->Clear(); |
299 | fVolTextBuff[2]->AddText(0, buff); | |
300 | gClient->NeedRedraw(fVolTextEntry[2]); | |
39dd4871 | 301 | |
302 | imat = lvMaterial->GetIndex(); | |
303 | ||
4b1d6659 | 304 | }; |
305 | ||
306 | if( index == ientr+1 ) { | |
307 | ||
308 | for ( G4int ii=0; ii<3; ii++) { | |
309 | fVolTextBuff[ii]->Clear(); | |
310 | gClient->NeedRedraw(fVolTextEntry[ii]); | |
311 | }; | |
65b5af58 | 312 | fDisplBuffLimits->Clear(); |
313 | fDisplBuffLimits->AddText(0, "\n\n*** No volume specified, " | |
39dd4871 | 314 | "no limits displayed *** "); |
65b5af58 | 315 | |
316 | fDisplBuffCuts->Clear(); | |
317 | fDisplBuffCuts->AddText(0, "\n\n*** No volume specified, " | |
318 | "no cuts displayed *** "); | |
319 | ||
320 | fDisplBuffControls->Clear(); | |
321 | fDisplBuffControls->AddText(0, "\n\n*** No volume specified, " | |
322 | "no controls displayed *** "); | |
323 | ||
39dd4871 | 324 | |
4b1d6659 | 325 | }; |
39dd4871 | 326 | |
327 | //---> setting appropriate display in the MaterialsFrames | |
328 | TG4MaterialsFrames* mFrames = fPanel->GetMaterialsFrames(); | |
329 | mFrames->DisplayMaterialCharacteristics( imat + 1 ); | |
330 | ||
331 | } | |
332 | ||
333 | void TG4VolumesFrames::DisplayUserLimits() | |
334 | { | |
335 | //-----> displays User Limits associated with the logical volume | |
336 | ||
65b5af58 | 337 | const char* cdisplay = fDisplBuffLimits->GetString(); |
338 | TG4Editor* ed = new TG4Editor( fCapFrame, 450, 300); | |
339 | ed->LoadBuffer(cdisplay); | |
340 | ed->Popup(); | |
341 | ||
342 | } | |
343 | ||
344 | void TG4VolumesFrames::DisplayCuts() | |
345 | { | |
346 | //-----> displays Cuts associated with the logical volume | |
347 | ||
348 | const char* cdisplay = fDisplBuffCuts->GetString(); | |
349 | TG4Editor* ed = new TG4Editor( fCapFrame, 450, 300); | |
350 | ed->LoadBuffer(cdisplay); | |
351 | ed->Popup(); | |
352 | ||
353 | } | |
354 | ||
355 | void TG4VolumesFrames::DisplayControls() | |
356 | { | |
357 | //-----> displays Controls associated with the logical volume | |
358 | ||
359 | const char* cdisplay = fDisplBuffControls->GetString(); | |
39dd4871 | 360 | TG4Editor* ed = new TG4Editor( fCapFrame, 450, 300); |
361 | ed->LoadBuffer(cdisplay); | |
362 | ed->Popup(); | |
363 | ||
364 | } | |
365 | ||
65b5af58 | 366 | //_______________________________________________________________________ |
367 | TString TG4VolumesFrames::GetLimitsDisplay(G4UserLimits* limits) const | |
39dd4871 | 368 | { |
369 | // Returns text for the user limits display in a separate frame | |
370 | // --- | |
371 | G4String display; | |
372 | G4Track dummy; | |
373 | char buff[200]; | |
374 | ||
375 | display = "\n\n**************************************"; | |
376 | display += "\n**************************************\n\n"; | |
65b5af58 | 377 | |
378 | const char* lname = ((TG4Limits*)limits)->GetName(); | |
379 | sprintf( buff, "\" %s \" limits: \n\n Max step length (mm): %g ", | |
380 | lname, limits->GetMaxAllowedStep(dummy)/mm ); | |
39dd4871 | 381 | display += buff; |
65b5af58 | 382 | |
383 | sprintf( buff, "\n\n Max track length (mm): %g \n\n Max time (s) : %g ", | |
384 | limits->GetUserMaxTrackLength(dummy)/mm, limits->GetUserMaxTime(dummy)/s); | |
385 | display += buff; | |
386 | ||
387 | sprintf( buff, "\n\n Min kin. energy (MeV): %g \n\n Min range (mm): %g ", | |
388 | limits->GetUserMinEkine(dummy)/MeV, limits->GetUserMinRange(dummy)/mm ); | |
39dd4871 | 389 | display += buff; |
65b5af58 | 390 | |
39dd4871 | 391 | display += "\n\n**************************************"; |
65b5af58 | 392 | display += "\n**************************************\n\n"; |
393 | ||
394 | const char* tmp = display; | |
395 | ||
396 | return TString(tmp); | |
397 | ||
398 | } | |
399 | //===================inserted================================================ | |
400 | //_______________________________________________________________________ | |
401 | TString TG4VolumesFrames::GetCutsDisplay(G4UserLimits* limits) const | |
402 | { | |
403 | // Returns text for the cuts display in a separate frame | |
404 | // --- | |
405 | G4String display; | |
406 | ||
407 | const TG4G3CutVector* lCutVector = ((TG4Limits*)limits) -> GetCutVector(); | |
408 | ||
409 | if ( ((TG4Limits*)limits) -> IsCut() ) | |
410 | display = lCutVector -> Format(); | |
411 | else | |
412 | display = "\n\n**** No special cuts. **** "; | |
413 | ||
414 | const char* tmp = display; | |
39dd4871 | 415 | |
65b5af58 | 416 | return TString(tmp); |
417 | ||
418 | } | |
419 | //_________________________________________________________________________ | |
420 | TString TG4VolumesFrames::GetControlsDisplay(G4UserLimits* limits) const | |
421 | { | |
422 | // Returns text for the controls display in a separate frame | |
423 | ||
424 | G4String display; | |
425 | ||
426 | const TG4G3ControlVector* lControlVector = ((TG4Limits*)limits) -> GetControlVector(); | |
427 | ||
428 | if ( ((TG4Limits*)limits) -> IsControl() ) | |
429 | display = lControlVector -> Format(); | |
430 | else | |
431 | display = "\n\n**** No special controls. **** "; | |
432 | ||
39dd4871 | 433 | const char* tmp = display; |
434 | ||
435 | return TString(tmp); | |
436 | ||
4b1d6659 | 437 | } |
438 | ||
65b5af58 | 439 | //================end of inserted================================================== |