Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGeoVolumeEditor.cxx
Go to the documentation of this file.
1// @(#):$Id$
2// Author: M.Gheata
3
4/*************************************************************************
5 * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TGeoVolumeEditor
13\ingroup Geometry_builder
14
15Editor for geometry volumes and assemblies of volumes. Besides the volume
16name and line attributes, a TGeoVolume has the following editable categories
17split vertically by a shutter:
18
19 - Properties: one can edit the shape and medium components from here. It is
20 also possible to change the existing ones.
21 - Daughters: the main category allowing defining, editing, removing or
22 positioning daughter volumes inside the current edited volume. To add a
23 daughter, one needs to select first a volume and a matrix. Currently no check
24 is performed if the daughter volume creates an extrusion (illegal for tracking).
25 To remove or change the position of an existing daughter, one should simply
26 select the desired daughter from the combo box with the existing ones, then
27 simply click the appropriate button.
28 - Visualization: One can set the visibility of the volume and of its daughters,
29 set the visibility depth and the view type. Selecting "All" will draw the
30 volume and all visible daughters down to the selected level starting from the
31 edited volume. Selecting "Leaves" will draw just the deepest daughters within
32 the selected visibility level, without displaying the containers, while "Only"
33 will just draw the edited volume.
34 - Division: The category becomes active only if there are no daughters of the
35 edited volume added by normal positioning (e.g. from `<Daughters>` category). The
36 minimum allowed starting value for the selected division axis is automatically
37 selected, while the slicing step is set to 0 - meaning that only the number
38 of slices matter.
39*/
40
41#include "TGeoVolumeEditor.h"
42#include "TGeoVolume.h"
43#include "TGeoPatternFinder.h"
44#include "TGeoManager.h"
45#include "TGeoMatrix.h"
46#include "TGTab.h"
47#include "TGComboBox.h"
48#include "TGButton.h"
49#include "TGButtonGroup.h"
50#include "TGTextEntry.h"
51#include "TGNumberEntry.h"
52#include "TGLabel.h"
53#include "TGShutter.h"
54#include "TG3DLine.h"
55#include "TGeoTabManager.h"
56#include "TGedEditor.h"
57
58
84
85////////////////////////////////////////////////////////////////////////////////
86/// Constructor for volume editor.
87
89 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
90{
91 fGeometry = nullptr;
92 fVolume = nullptr;
93
97
98 // TGShutter for categories
101 Pixel_t color;
102 TGLabel *label;
103
104 // General settings
106 container = (TGCompositeFrame *)si->GetContainer();
107 container->SetBackgroundColor(GetDefaultFrameBackground());
109
110 // TextEntry for volume name
112 f1->AddFrame(label = new TGLabel(f1, "Volume name"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
113 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
114 gClient->GetColorByName("#ff0000", color);
115 label->SetTextColor(color);
116 container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
119 fVolumeName->SetToolTipText("Enter the volume name");
120 container->AddFrame(fVolumeName, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 3, 1, 2, 5));
121
122 // Current shape
124 f1->AddFrame(label = new TGLabel(f1, "Shape and medium"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
125 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
126 gClient->GetColorByName("#ff0000", color);
127 label->SetTextColor(color);
128 container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 10, 0));
130 fSelectedShape = nullptr;
131 fLSelShape = new TGLabel(f1, "Select shape");
132 gClient->GetColorByName("#0000ff", color);
133 fLSelShape->SetTextColor(color);
135 f1->AddFrame(fLSelShape, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
137 fBSelShape->SetToolTipText("Replace with one of the existing shapes");
138 fBSelShape->Associate(this);
139 f1->AddFrame(fBSelShape, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
140 fEditShape = new TGTextButton(f1, "Edit");
141 f1->AddFrame(fEditShape, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
142 fEditShape->SetToolTipText("Edit selected shape");
143 fEditShape->Associate(this);
144 container->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 0, 0));
145
146 // Current medium
148 fSelectedMedium = nullptr;
149 fLSelMedium = new TGLabel(f1, "Select medium");
150 gClient->GetColorByName("#0000ff", color);
153 f1->AddFrame(fLSelMedium, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
155 fBSelMedium->SetToolTipText("Replace with one of the existing media");
156 fBSelMedium->Associate(this);
157 f1->AddFrame(fBSelMedium, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
158 fEditMedium = new TGTextButton(f1, "Edit");
159 f1->AddFrame(fEditMedium, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
160 fEditMedium->SetToolTipText("Edit selected medium");
161 fEditMedium->Associate(this);
162 container->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 0, 0));
163
164 // List of daughters
165 si = new TGShutterItem(fCategories, new TGHotString("Daughters"), kCAT_DAUGHTERS);
166 container = (TGCompositeFrame *)si->GetContainer();
167 container->SetBackgroundColor(GetDefaultFrameBackground());
169
170 // Existing daughters
172 f1->AddFrame(label = new TGLabel(f1, "Existing daughters"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
173 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
174 gClient->GetColorByName("#ff0000", color);
175 label->SetTextColor(color);
176 container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
177
181 fNodeList->Associate(this);
182 f1->AddFrame(fNodeList, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
183 container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
184 // Buttons for editing matrix and removing node
186 fEditMatrix = new TGTextButton(f1, "Position");
187 f1->AddFrame(fEditMatrix, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
188 fEditMatrix->SetToolTipText("Edit the position of selected node");
189 fEditMatrix->Associate(this);
190 fRemoveNode = new TGTextButton(f1, "Remove");
191 f1->AddFrame(fRemoveNode, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
192 fRemoveNode->SetToolTipText("Remove the selected node. Cannot undo !)");
193 fRemoveNode->Associate(this);
194 container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
195
196 // Adding daughters
198 f1->AddFrame(label = new TGLabel(f1, "Add daughter"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
199 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
200 gClient->GetColorByName("#ff0000", color);
201 label->SetTextColor(color);
202 container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 10, 0));
203
204 // Select from existing volumes
206 fSelectedVolume = nullptr;
207 fLSelVolume = new TGLabel(f1, "Select volume");
208 gClient->GetColorByName("#0000ff", color);
211 f1->AddFrame(fLSelVolume, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
213 fBSelVolume->SetToolTipText("Select one of the existing volumes");
214 fBSelVolume->Associate(this);
215 f1->AddFrame(fBSelVolume, new TGLayoutHints(kLHintsRight, 1, 1, 2, 2));
216 container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
217
218 // Matrix selection for nodes
220 fSelectedMatrix = nullptr;
221 fLSelMatrix = new TGLabel(f1, "Select matrix");
222 gClient->GetColorByName("#0000ff", color);
225 f1->AddFrame(fLSelMatrix, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
227 fBSelMatrix->SetToolTipText("Select one of the existing matrices");
228 fBSelMatrix->Associate(this);
229 f1->AddFrame(fBSelMatrix, new TGLayoutHints(kLHintsRight, 1, 1, 2, 2));
230 container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
231
232 // Copy number
234 f1->AddFrame(new TGLabel(f1, "Node id"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
240 nef->SetToolTipText("Enter node copy number");
241 fCopyNumber->Associate(this);
242 f1->AddFrame(fCopyNumber, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
243 fAddNode = new TGTextButton(f1, "Add");
244 f1->AddFrame(fAddNode, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
245 fAddNode->Associate(this);
246 container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
247
248 // Visualization
249 si = new TGShutterItem(fCategories, new TGHotString("Visualization"), kCAT_VIS);
250 container = (TGCompositeFrame *)si->GetContainer();
251 container->SetBackgroundColor(GetDefaultFrameBackground());
253
255 f1->AddFrame(/* label = */ new TGLabel(f1, "Visibility"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
256 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
257 // gClient->GetColorByName("#ff0000", color);
258 // label->SetTextColor(color);
259 container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
260
262 fBVis[0] = new TGCheckButton(f1, "Volume");
263 fBVis[1] = new TGCheckButton(f1, "Nodes");
264 f1->AddFrame(fBVis[0], new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
265 f1->AddFrame(fBVis[1], new TGLayoutHints(kLHintsRight, 2, 2, 0, 0));
266 container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
267
269 f1->AddFrame(new TGLabel(f1, "Depth"), new TGLayoutHints(kLHintsLeft, 2, 2, 4, 0));
270 // gClient->GetColorByName("#0000ff", color);
271 // label->SetTextColor(color);
277 nef->SetToolTipText("Set visibility level here");
279 fEVisLevel->Associate(this);
280 f1->AddFrame(fEVisLevel, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
281 fBAuto = new TGCheckButton(f1, "Auto");
282 f1->AddFrame(fBAuto, new TGLayoutHints(kLHintsRight, 0, 0, 2, 0));
283 container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
284
285 TString stitle = "View";
287 fBView[0] = new TGRadioButton(bg, "All");
288 fBView[1] = new TGRadioButton(bg, "Leaves");
289 fBView[2] = new TGRadioButton(bg, "Only");
290 bg->SetRadioButtonExclusive();
291 bg->Show();
292 container->AddFrame(bg, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
293
295 fBRaytrace = new TGCheckButton(f1, "Raytrace");
296 f1->AddFrame(fBRaytrace, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
297 container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
298
299 // Division
300 si = new TGShutterItem(fCategories, new TGHotString("Division"), kCAT_DIVISION);
301 container = (TGCompositeFrame *)si->GetContainer();
302 container->SetBackgroundColor(GetDefaultFrameBackground());
304 // TextEntry for division name
306 f1->AddFrame(label = new TGLabel(f1, "Division name"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
307 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
308 gClient->GetColorByName("#ff0000", color);
309 label->SetTextColor(color);
310 container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
313 fDivName->SetToolTipText("Enter the volume name");
314 container->AddFrame(fDivName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
315 // Axis selection
316 stitle = "Axis";
318 bg = new TGVButtonGroup(f1, stitle);
319 fBDiv[0] = new TGRadioButton(bg, "Axis 1");
320 fBDiv[1] = new TGRadioButton(bg, "Axis 2");
321 fBDiv[2] = new TGRadioButton(bg, "Axis 3");
322 bg->Insert(fBDiv[0]);
323 bg->Insert(fBDiv[1]);
324 bg->Insert(fBDiv[2]);
325 bg->SetRadioButtonExclusive();
326 f1->AddFrame(bg, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
327 fApplyDiv = new TGTextButton(f1, "Apply");
328 fApplyDiv->SetToolTipText("Apply new division settings");
329 f1->AddFrame(fApplyDiv, new TGLayoutHints(kLHintsRight, 0, 2, 30, 0));
330 container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
331 // Division range
333 f1->AddFrame(/* label = */ new TGLabel(f1, "Division parameters"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
334 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
335 // gClient->GetColorByName("#ff0000", color);
336 // label->SetTextColor(color);
337 container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
339 f1->AddFrame(/* label = */ new TGLabel(f1, "From"), new TGLayoutHints(kLHintsLeft, 2, 2, 4, 0));
340 // gClient->GetColorByName("#0000ff", color);
341 // label->SetTextColor(color);
343 // fEDivFrom->SetNumStyle(TGNumberFormat::kNESInteger);
344 // fEDivFrom->SetNumAttr(TGNumberFormat::kNEAPositive);
347 nef->SetToolTipText("Set start value");
348 fEDivFrom->Associate(this);
349 f1->AddFrame(fEDivFrom, new TGLayoutHints(kLHintsRight, 2, 2, 0, 0));
350 container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
351
353 f1->AddFrame(/* label = */ new TGLabel(f1, "Step"), new TGLayoutHints(kLHintsLeft, 2, 2, 4, 0));
354 // gClient->GetColorByName("#0000ff", color);
355 // label->SetTextColor(color);
357 // fEDivFrom->SetNumStyle(TGNumberFormat::kNESInteger);
361 nef->SetToolTipText("Set division step");
362 fEDivStep->Associate(this);
363 f1->AddFrame(fEDivStep, new TGLayoutHints(kLHintsRight, 2, 2, 0, 0));
364 container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
365
367 f1->AddFrame(/* label = */ new TGLabel(f1, "Nslices"), new TGLayoutHints(kLHintsLeft, 2, 2, 4, 0));
368 // gClient->GetColorByName("#0000ff", color);
369 // label->SetTextColor(color);
370 fEDivN = new TGNumberEntry(f1, 0, 5, kVOL_DIVN);
375 nef->SetToolTipText("Set number of slices");
376 fEDivN->Associate(this);
377 f1->AddFrame(fEDivN, new TGLayoutHints(kLHintsRight, 2, 2, 0, 0));
378 container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
379
380 fCategories->Resize(163, 340);
382
385}
386
387////////////////////////////////////////////////////////////////////////////////
388/// Destructor
389
391{
395 fCategories->GetItem("Properties")->SetCleanup(0);
398 fCategories->GetItem("Daughters")->SetCleanup(0);
399 cont = (TGCompositeFrame *)fCategories->GetItem("Visualization")->GetContainer();
401 fCategories->GetItem("Visualization")->SetCleanup(0);
404 fCategories->GetItem("Division")->SetCleanup(0);
405
406 delete fBView[0];
407 delete fBView[1];
408 delete fBView[2];
409 delete fBDiv[0];
410 delete fBDiv[1];
411 delete fBDiv[2];
412 Cleanup();
413}
414
415////////////////////////////////////////////////////////////////////////////////
416/// Connect signals to slots.
417
419{
420 fVolumeName->Connect("TextChanged(const char *)", "TGeoVolumeEditor", this, "DoVolumeName()");
421 fDivName->Connect("TextChanged(const char *)", "TGeoVolumeEditor", this, "DoDivName()");
422 fEditMedium->Connect("Clicked()", "TGeoVolumeEditor", this, "DoEditMedium()");
423 fEditShape->Connect("Clicked()", "TGeoVolumeEditor", this, "DoEditShape()");
424 fEditMatrix->Connect("Clicked()", "TGeoVolumeEditor", this, "DoEditMatrix()");
425 fAddNode->Connect("Clicked()", "TGeoVolumeEditor", this, "DoAddNode()");
426 fRemoveNode->Connect("Clicked()", "TGeoVolumeEditor", this, "DoRemoveNode()");
427 fBSelShape->Connect("Clicked()", "TGeoVolumeEditor", this, "DoSelectShape()");
428 fBSelMedium->Connect("Clicked()", "TGeoVolumeEditor", this, "DoSelectMedium()");
429 fBSelVolume->Connect("Clicked()", "TGeoVolumeEditor", this, "DoSelectVolume()");
430 fBSelMatrix->Connect("Clicked()", "TGeoVolumeEditor", this, "DoSelectMatrix()");
431 fBVis[0]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoVisVolume()");
432 fBVis[1]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoVisDaughters()");
433 fBAuto->Connect("Clicked()", "TGeoVolumeEditor", this, "DoVisAuto()");
434 fEVisLevel->Connect("ValueSet(Long_t)", "TGeoVolumeEditor", this, "DoVisLevel()");
435 fBView[0]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoViewAll()");
436 fBView[1]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoViewLeaves()");
437 fBView[2]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoViewOnly()");
438 fBDiv[0]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoDivSelAxis()");
439 fBDiv[1]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoDivSelAxis()");
440 fBDiv[2]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoDivSelAxis()");
441 fEDivFrom->Connect("ValueSet(Long_t)", "TGeoVolumeEditor", this, "DoDivFromTo()");
442 fEDivStep->Connect("ValueSet(Long_t)", "TGeoVolumeEditor", this, "DoDivStep()");
443 fEDivN->Connect("ValueSet(Long_t)", "TGeoVolumeEditor", this, "DoDivN()");
444 fBRaytrace->Connect("Clicked()", "TGeoVolumeEditor", this, "DoRaytrace()");
445 fApplyDiv->Connect("Clicked()", "TGeoVolumeEditor", this, "DoApplyDiv()");
446}
447
448////////////////////////////////////////////////////////////////////////////////
449/// Connect to the picked volume.
450
452{
453 if (obj == nullptr || !obj->InheritsFrom(TGeoVolume::Class())) {
455 return;
456 }
457 fVolume = (TGeoVolume *)obj;
459 const char *vname = fVolume->GetName();
462 if (fSelectedShape)
465 if (fSelectedMedium)
467
470 TGeoNode *node;
471 Int_t icrt = 0;
472 while ((node = (TGeoNode *)next2()))
473 fNodeList->AddEntry(node->GetName(), icrt++);
474 fNodeList->Select(0);
476 if (!fVolume->GetNdaughters() || fVolume->GetFinder()) {
479 } else {
482 }
483 if (!fSelectedVolume)
485 if (fVolume->IsAssembly()) {
488 }
500 } else {
501 fCategories->GetItem("Division")->GetButton()->SetEnabled(kTRUE);
502 Double_t start = 0., step = 0., end = 0.;
503 Int_t ndiv = 2, iaxis = 1;
505 for (Int_t i = 0; i < 3; i++) {
508 }
509
510 if (fVolume->GetFinder()) {
513 start = fVolume->GetFinder()->GetStart();
514 step = fVolume->GetFinder()->GetStep();
515 ndiv = fVolume->GetFinder()->GetNdiv();
516 } else {
517 fDivName->SetText("Enter name");
518 fSelectedShape->GetAxisRange(iaxis, start, end);
519 step = 0;
520 }
522 fEDivFrom->SetNumber(start);
523 fEDivStep->SetNumber(step);
524 fEDivN->SetNumber(ndiv);
525 }
526
527 if (fInit)
529 SetActive();
530 if (GetParent() == fTabMgr->GetVolumeTab())
531 fTab->Layout();
532}
533
534////////////////////////////////////////////////////////////////////////////////
535/// Add editors to fGedFrame and exclude TLineEditor.
536
542
543////////////////////////////////////////////////////////////////////////////////
544/// Modify volume name.
545
550
551////////////////////////////////////////////////////////////////////////////////
552/// Select a new shape.
553
564
565////////////////////////////////////////////////////////////////////////////////
566/// Select a new medium.
567
578
579////////////////////////////////////////////////////////////////////////////////
580/// Select a matrix for positioning.
581
592
593////////////////////////////////////////////////////////////////////////////////
594/// Select a daughter volume.
595
608
609////////////////////////////////////////////////////////////////////////////////
610/// Edit the shape of the volume.
611
616
617////////////////////////////////////////////////////////////////////////////////
618/// Edit the medium of the volume.
619
624
625////////////////////////////////////////////////////////////////////////////////
626/// Edit the position of the selected node.
627
629{
630 if (!fVolume->GetNdaughters())
631 return;
633 if (i < 0)
634 return;
636}
637
638////////////////////////////////////////////////////////////////////////////////
639/// Add a daughter.
640
659
660////////////////////////////////////////////////////////////////////////////////
661/// Remove a daughter.
662
664{
665 if (!fVolume->GetNdaughters() || fVolume->GetFinder()) {
668 return;
669 }
671 if (i < 0)
672 return;
675 TIter next(fVolume->GetNodes());
676 TGeoNode *node;
677 i = 0;
678 while ((node = (TGeoNode *)next()))
679 fNodeList->AddEntry(node->GetName(), i++);
680 fNodeList->Select(0);
682 if (!fVolume->GetNdaughters()) {
685 fCategories->GetItem("Division")->GetButton()->SetEnabled(kTRUE);
686 Double_t start = 0., step = 0., end = 0.;
687 Int_t ndiv = 2, iaxis = 1;
688 fSelectedShape->GetAxisRange(iaxis, start, end);
689 step = end - start;
691 fEDivFrom->SetNumber(start);
692 fEDivStep->SetNumber(step);
693 fEDivN->SetNumber(ndiv);
694 }
695 Update();
696}
697
698////////////////////////////////////////////////////////////////////////////////
699/// Slot for setting volume visible/invisible.
700
702{
703 Bool_t on = (fBVis[0]->GetState() == kButtonDown) ? kTRUE : kFALSE;
704 if (fVolume->IsVisible() == on)
705 return;
707 Update();
708}
709
710////////////////////////////////////////////////////////////////////////////////
711/// Slot for setting daughters visible/invisible.
712
714{
715 Bool_t on = (fBVis[1]->GetState() == kButtonDown) ? kTRUE : kFALSE;
716 if (fVolume->IsVisibleDaughters() == on)
717 return;
719 Update();
720}
721
722////////////////////////////////////////////////////////////////////////////////
723/// Slot for setting visibility depth auto.
724
726{
728 if ((fGeometry->GetVisLevel() == 0) == on)
729 return;
730 if (on)
732 else
734 Update();
735}
736
737////////////////////////////////////////////////////////////////////////////////
738/// Slot for visibility level.
739
746
747////////////////////////////////////////////////////////////////////////////////
748/// Slot for viewing volume and containers.
749
751{
753 if (!on)
754 return;
755 if (fVolume->IsVisContainers() == on)
756 return;
757 if (fVolume->IsRaytracing()) {
760 }
762 Update();
763}
764
765////////////////////////////////////////////////////////////////////////////////
766/// Slot for viewing last leaves only.
767
769{
771 if (!on)
772 return;
773 if (fVolume->IsVisLeaves() == on)
774 return;
775 if (fVolume->IsRaytracing()) {
778 }
780 Update();
781}
782
783////////////////////////////////////////////////////////////////////////////////
784/// Slot for viewing volume only.
785
787{
789 if (!on)
790 return;
791 if (fVolume->IsVisOnly() == on)
792 return;
793 if (fVolume->IsRaytracing()) {
796 }
798 Update();
799}
800
801////////////////////////////////////////////////////////////////////////////////
802/// Slot for raytracing.
803
805{
807 if (fVolume->IsRaytracing() == on)
808 return;
810 Update();
811}
812
813////////////////////////////////////////////////////////////////////////////////
814/// Modify division name.
815
820
821////////////////////////////////////////////////////////////////////////////////
822/// Change division axis and preserve number of slices.
823
825{
826 Int_t iaxis = 1;
827 for (Int_t i = 0; i < 3; i++) {
828 if (fBDiv[i]->GetState() != kButtonDown)
829 continue;
830 iaxis = i + 1;
831 break;
832 }
833 TGeoShape *shape = fVolume->GetShape();
834 if (!shape) {
836 return;
837 }
838 Double_t xlo, xhi;
839 shape->GetAxisRange(iaxis, xlo, xhi);
840 if (xhi <= xlo) {
842 return;
843 }
844 fEDivFrom->SetNumber(xlo);
847}
848
849////////////////////////////////////////////////////////////////////////////////
850/// Handle division range modification.
851
853{
854 Double_t min, max, xlo, xhi, step;
855 Int_t iaxis = 1;
856 Int_t ndiv;
857 for (Int_t i = 0; i < 3; i++) {
858 if (fBDiv[i]->GetState() != kButtonDown)
859 continue;
860 iaxis = i + 1;
861 break;
862 }
863 TGeoShape *shape = fVolume->GetShape();
864 if (!shape) {
866 return;
867 }
868 shape->GetAxisRange(iaxis, xlo, xhi);
869 if (xhi - xlo <= 0) {
871 return;
872 }
873 min = fEDivFrom->GetNumber();
874 step = fEDivStep->GetNumber();
875 ndiv = fEDivN->GetIntNumber();
876 if (min < xlo) {
877 min = xlo;
878 fEDivFrom->SetNumber(xlo);
879 }
880 max = min + ndiv * step;
881 if (max > xhi) {
882 max = xhi;
883 step = (max - min) / ndiv;
884 fEDivStep->SetNumber(step);
885 }
886 if (min >= max) {
888 return;
889 }
891}
892
893////////////////////////////////////////////////////////////////////////////////
894/// Handle division step modification.
895
897{
898 Double_t min, max, xlo, xhi;
899 Int_t iaxis = 1;
900 for (Int_t i = 0; i < 3; i++) {
901 if (fBDiv[i]->GetState() != kButtonDown)
902 continue;
903 iaxis = i + 1;
904 break;
905 }
906 TGeoShape *shape = fVolume->GetShape();
907 if (!shape) {
909 return;
910 }
911 shape->GetAxisRange(iaxis, xlo, xhi);
912 if (xhi - xlo <= 0) {
914 return;
915 }
916 min = fEDivFrom->GetNumber();
917 Double_t step = fEDivStep->GetNumber();
918 Int_t ndiv = fEDivN->GetIntNumber();
919 max = min + ndiv * step;
920
921 // Check if ndiv*step < max-min
922 if (max <= xhi) {
924 return;
925 }
926 // Step too big - set value to fit range
927 max = xhi;
928 step = (max - min) / ndiv;
929 fEDivStep->SetNumber(step);
930 if (step < 0) {
932 return;
933 }
935}
936
937////////////////////////////////////////////////////////////////////////////////
938/// Handle division N modification.
939
941{
942 Double_t min, max, xlo, xhi;
943 Int_t iaxis = 1;
944 for (Int_t i = 0; i < 3; i++) {
945 if (fBDiv[i]->GetState() != kButtonDown)
946 continue;
947 iaxis = i + 1;
948 break;
949 }
950 TGeoShape *shape = fVolume->GetShape();
951 if (!shape) {
953 return;
954 }
955 shape->GetAxisRange(iaxis, xlo, xhi);
956 if (xhi - xlo <= 0) {
958 return;
959 }
960 Double_t step = fEDivStep->GetNumber();
961 // If step=0 it is discounted
962 if (step == 0) {
964 return;
965 }
966 Int_t ndiv = fEDivN->GetIntNumber();
967 min = fEDivFrom->GetNumber();
968 max = min + ndiv * step;
969 // Check if ndiv*step < max-min
970 if (max <= xhi) {
972 return;
973 }
974 max = xhi;
975 ndiv = (Int_t)((max - min) / step);
976 fEDivN->SetNumber(ndiv);
978}
979
980////////////////////////////////////////////////////////////////////////////////
981/// Apply current division settings
982
984{
985 Double_t xlo, xhi, step;
986 Int_t iaxis = 1;
987 Int_t ndiv;
988 for (Int_t i = 0; i < 3; i++) {
989 if (fBDiv[i]->GetState() != kButtonDown)
990 continue;
991 iaxis = i + 1;
992 break;
993 }
994 TGeoShape *shape = fVolume->GetShape();
995 if (!shape) {
997 return;
998 }
999 shape->GetAxisRange(iaxis, xlo, xhi);
1000 if (xhi - xlo <= 0) {
1002 return;
1003 }
1004 xlo = fEDivFrom->GetNumber();
1005 step = fEDivStep->GetNumber();
1006 ndiv = fEDivN->GetIntNumber();
1008 if (finder) {
1009 // we have to remove first the existing division
1010 TObjArray *nodes = fVolume->GetNodes();
1011 nodes->Delete();
1012 nodes->Clear();
1013 delete finder;
1014 fVolume->SetFinder(nullptr);
1015 }
1016 fVolume->Divide(fDivName->GetText(), iaxis, ndiv, xlo, step);
1019 Update();
1020 // fVolume->Draw();
1021}
@ kRaisedFrame
Definition GuiTypes.h:384
@ kSunkenFrame
Definition GuiTypes.h:383
@ kVerticalFrame
Definition GuiTypes.h:381
@ kDoubleBorder
Definition GuiTypes.h:385
@ kFixedWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
#define gClient
Definition TGClient.h:157
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
@ kCAT_GENERAL
@ kVOL_NODEID
@ kVOL_DIVSTEP
@ kCAT_VIS
@ kVOL_DIVEND
@ kVOL_EDIT_SHAPE
@ kVOL_EDIT_MEDIUM
@ kVOL_MATRIX_SELECT
@ kVOL_NAME
@ kVOL_NODE_SELECT
@ kVOL_UNDO
@ kVOL_SHAPE_SELECT
@ kVOL_VISLEVEL
@ kCAT_DIVISION
@ kVOL_APPLY
@ kVOL_DIVSTART
@ kVOL_MEDIA_SELECT
@ kCAT_GENERAL
@ kVOL_CANCEL
@ kCAT_DAUGHTERS
@ kDIV_NAME
@ kVOL_DIVN
@ kVOL_VOL_SELECT
@ kVOL_TITLE
static TClass * Class()
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
Organizes TGButton widgets in a group.
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:439
virtual EButtonState GetState() const
Definition TGButton.h:112
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition TGButton.cxx:453
Selects different options.
Definition TGButton.h:264
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set check button state.
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:288
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition TGComboBox.h:47
virtual Int_t GetSelected() const
Definition TGComboBox.h:114
virtual void AddEntry(TGString *s, Int_t id)
Definition TGComboBox.h:86
virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
Definition TGComboBox.h:105
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
virtual Int_t GetNumberOfEntries() const
Definition TGComboBox.h:107
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
UInt_t GetDefaultWidth() const override
Definition TGFrame.h:314
Int_t GetState(TGFrame *f) const
Get state of sub frame.
Definition TGFrame.cxx:1210
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:959
UInt_t GetDefaultHeight() const override
Definition TGFrame.h:316
TGCompositeFrame(const TGCompositeFrame &)=delete
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1249
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1064
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:313
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:675
A horizontal 3D line is a line that typically separates a toolbar from the menubar.
Definition TG3DLine.h:18
TGHotString is a string with a "hot" character underlined.
Definition TGString.h:42
This class handles GUI labels.
Definition TGLabel.h:24
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition TGLabel.cxx:361
virtual void SetText(TGString *newText)
Set new text in label.
Definition TGLabel.cxx:179
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGNumberEntry is a number entry input widget with up/down buttons.
TGNumberEntryField * GetNumberEntry() const
Get the number entry field.
void Associate(const TGWindow *w) override
Make w the window that will receive the generated messages.
virtual Long_t GetIntNumber() const
void SetNumAttr(EAttribute attr=kNEAAnyNumber)
virtual Double_t GetNumber() const
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
UInt_t GetDefaultHeight() const override
void SetNumStyle(EStyle style)
@ kNEAPositive
Positive number.
@ kNEANonNegative
Non-negative number.
@ kNESInteger
Style of number entry field.
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Yield an action as soon as it is clicked.
Definition TGButton.h:228
Selects different options.
Definition TGButton.h:321
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set radio button state.
TGButton * GetButton() const
Definition TGShutter.h:44
TGFrame * GetContainer() const
Definition TGShutter.h:45
A shutter widget contains a set of shutter items that can be open and closed like a shutter.
Definition TGShutter.h:55
virtual void AddItem(TGShutterItem *item)
Add shutter item to shutter frame.
Definition TGShutter.cxx:71
TGShutterItem * GetItem(const char *name)
returns a shutter item by name (name is hot string of shutter item)
virtual void SetDefaultSize(UInt_t w, UInt_t h)
Set the default / minimal size of the widget.
void Layout() override
Layout shutter items.
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
Yield an action as soon as it is clicked.
Definition TGButton.h:142
virtual void SetText(TGHotString *new_label)
Set new button text.
Definition TGButton.cxx:638
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
virtual void SetDefaultSize(UInt_t w, UInt_t h)
Set the default / minimal size of the widget.
const char * GetText() const
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line.
Organizes TGButton widgets in a group with one vertical column.
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
ROOT GUI Window base class.
Definition TGWindow.h:23
const TGWindow * GetParent() const
Definition TGWindow.h:83
void ExcludeClassEditor(TClass *cl, Bool_t recurse=kFALSE)
Exclude editor for class cl from current construction.
virtual void ActivateBaseClassEditors(TClass *cl)
Provide list of editors for base-classes.
TGedEditor * fGedEditor
manager of this frame
Definition TGedFrame.h:48
Bool_t fInit
init flag for setting signals/slots
Definition TGedFrame.h:47
Common base class for geombuilder editors.
void Update() override
Override Update from TGedFrame as fGedEditor can be null.
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
TGeoTabManager * fTabMgr
void SetVisLevel(Int_t level=3)
set default level down to which visualization is performed
Int_t GetVisLevel() const
Returns current depth to which geometry is drawn.
void SetTopVisible(Bool_t vis=kTRUE)
make top volume visible on screen
Geometrical transformation package.
Definition TGeoMatrix.h:38
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition TGeoMedium.h:23
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:39
TGeoVolume * GetVolume() const
Definition TGeoNode.h:99
virtual TGeoMatrix * GetMatrix() const =0
base finder class for patterns. A pattern is specifying a division type
virtual Int_t GetDivAxis()
Int_t GetNdiv() const
Double_t GetStep() const
Double_t GetStart() const
Base abstract class for all shapes.
Definition TGeoShape.h:25
virtual Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) const =0
virtual const char * GetAxisName(Int_t iaxis) const =0
const char * GetName() const override
Get the shape name.
TGCompositeFrame * GetVolumeTab() const
void GetMediumEditor(TGeoMedium *medium)
Get editor for a medium.
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
void GetShapeEditor(TGeoShape *shape)
Get editor for a shape.
void GetMatrixEditor(TGeoMatrix *matrix)
Get editor for a matrix.
static TObject * GetSelected()
static; return selected object
TGPictureButton * fBSelMatrix
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGTextButton * fApplyDiv
void DoApplyDiv()
Apply current division settings.
TGTextButton * fAddNode
TGPictureButton * fBSelShape
void DoRemoveNode()
Remove a daughter.
TGTextEntry * fVolumeName
TGNumberEntry * fEDivFrom
void DoSelectMatrix()
Select a matrix for positioning.
void DoEditMatrix()
Edit the position of the selected node.
void DoSelectMedium()
Select a new medium.
TGComboBox * fNodeList
void DoVisDaughters()
Slot for setting daughters visible/invisible.
TGNumberEntry * fEVisLevel
TGTextButton * fEditMatrix
TGNumberEntry * fEDivN
TGeoVolume * fVolume
TGTextButton * fEditShape
TGeoMedium * fSelectedMedium
TGeoVolume * fSelectedVolume
TGRadioButton * fBView[3]
void DoVisVolume()
Slot for setting volume visible/invisible.
TGeoShape * fSelectedShape
~TGeoVolumeEditor() override
Destructor.
void DoDivFromTo()
Handle division range modification.
void DoVisAuto()
Slot for setting visibility depth auto.
void DoViewLeaves()
Slot for viewing last leaves only.
void DoViewOnly()
Slot for viewing volume only.
TGCheckButton * fBVis[2]
TGNumberEntry * fEDivStep
TGTextButton * fRemoveNode
void DoDivStep()
Handle division step modification.
void DoVisLevel()
Slot for visibility level.
TGeoMatrix * fSelectedMatrix
void DoRaytrace()
Slot for raytracing.
void DoSelectVolume()
Select a daughter volume.
void DoEditShape()
Edit the shape of the volume.
TGTextEntry * fDivName
TGCheckButton * fBRaytrace
TGNumberEntry * fCopyNumber
TGPictureButton * fBSelVolume
TGCheckButton * fBAuto
TGeoManager * fGeometry
void DoEditMedium()
Edit the medium of the volume.
void SetModel(TObject *obj) override
Connect to the picked volume.
TGTextButton * fEditMedium
TGPictureButton * fBSelMedium
void DoDivN()
Handle division N modification.
void ActivateBaseClassEditors(TClass *cl) override
Add editors to fGedFrame and exclude TLineEditor.
TGShutter * fCategories
void DoSelectShape()
Select a new shape.
void DoViewAll()
Slot for viewing volume and containers.
void DoAddNode()
Add a daughter.
TGRadioButton * fBDiv[3]
void DoDivSelAxis()
Change division axis and preserve number of slices.
void DoDivName()
Modify division name.
TGeoVolumeEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for volume editor.
void DoVolumeName()
Modify volume name.
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
void SetVisContainers(Bool_t flag=kTRUE) override
Set visibility for containers.
void SetVisibility(Bool_t vis=kTRUE) override
set visibility of this volume
Bool_t IsVisContainers() const
Definition TGeoVolume.h:157
void RemoveNode(TGeoNode *node)
Remove an existing daughter.
void Raytrace(Bool_t flag=kTRUE)
Draw this volume with current settings and perform raytracing in the pad.
TGeoMedium * GetMedium() const
Definition TGeoVolume.h:175
TGeoManager * GetGeoManager() const
Definition TGeoVolume.h:173
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
Add a TGeoNode to the list of nodes.
void SetVisOnly(Bool_t flag=kTRUE) override
Set visibility for leaves.
void SetFinder(TGeoPatternFinder *finder)
Definition TGeoVolume.h:244
Int_t GetNdaughters() const
Definition TGeoVolume.h:362
static TClass * Class()
TObjArray * GetNodes()
Definition TGeoVolume.h:169
void VisibleDaughters(Bool_t vis=kTRUE)
set visibility for daughters
TGeoNode * GetNode(const char *name) const
get the pointer to a daughter node
Bool_t IsVisibleDaughters() const
Definition TGeoVolume.h:156
TGeoPatternFinder * GetFinder() const
Definition TGeoVolume.h:177
TGeoShape * GetShape() const
Definition TGeoVolume.h:190
virtual TGeoVolume * Divide(const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step, Int_t numed=0, Option_t *option="")
Division a la G3.
Bool_t IsRaytracing() const
Check if the painter is currently ray-tracing the content of this volume.
Bool_t IsVisLeaves() const
Definition TGeoVolume.h:158
Bool_t IsVisOnly() const
Definition TGeoVolume.h:159
virtual Bool_t IsAssembly() const
Returns true if the volume is an assembly or a scaled assembly.
virtual Bool_t IsVisible() const
Definition TGeoVolume.h:155
void SetVisLeaves(Bool_t flag=kTRUE) override
Set visibility for leaves.
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:149
An array of TObjects.
Definition TObjArray.h:31
void Clear(Option_t *option="") override
Remove all objects from the array.
void Delete(Option_t *option="") override
Remove all objects from the array AND delete all heap based objects.
Mother of all ROOT objects.
Definition TObject.h:41
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:543
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:865
Basic string class.
Definition TString.h:138
TF1 * f1
Definition legend1.C:11