Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGeoBBoxEditor.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 TGeoBBoxEditor
13\ingroup Geometry_builder
14
15Editor for a TGeoBBox.
16
17\image html geom_box_pic.png
18
19\image html geom_box_ed.png
20
21*/
22
23#include "TGeoBBoxEditor.h"
24#include "TGeoTabManager.h"
25#include "TGeoBBox.h"
26#include "TGeoManager.h"
27#include "TVirtualGeoPainter.h"
28#include "TVirtualPad.h"
29#include "TView.h"
30#include "TGButton.h"
31#include "TGTextEntry.h"
32#include "TGNumberEntry.h"
33#include "TGLabel.h"
34
35
37
38////////////////////////////////////////////////////////////////////////////////
39/// Constructor for volume editor.
40
42 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
43{
44 fShape = nullptr;
45 fDxi = fDyi = fDzi = 0.0;
46 memset(fOrigi, 0, 3 * sizeof(Double_t));
47 fNamei = "";
50
51 // TextEntry for shape name
52 MakeTitle("Name");
53 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kBOX_NAME);
55 fShapeName->SetToolTipText("Enter the box name");
56 fShapeName->Associate(this);
58
60 MakeTitle("Box half-lengths");
62 // Number entry for dx
65 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
66 fBoxDx = new TGNumberEntry(f1, 0., 5, kBOX_X);
69 nef->SetToolTipText("Enter the box half-length in X");
70 fBoxDx->Associate(this);
71 f1->AddFrame(fBoxDx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
72 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
73
74 // Number entry for dy
77 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
78 fBoxDy = new TGNumberEntry(f2, 0., 5, kBOX_Y);
81 nef->SetToolTipText("Enter the box half-length in Y");
82 fBoxDy->Associate(this);
84 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
85
86 // Number entry for dx
89 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
90 fBoxDz = new TGNumberEntry(f3, 0., 5, kBOX_Z);
93 nef->SetToolTipText("Enter the box half-length in Z");
94 fBoxDz->Associate(this);
96 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
97
98 compxyz->Resize(150, 30);
99 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
100
101 MakeTitle("Box origin");
103 // Number entry for dx
105 f1->AddFrame(new TGLabel(f1, "OX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
106 fBoxOx = new TGNumberEntry(f1, 0., 5, kBOX_OX);
108 nef->SetToolTipText("Enter the box origin X coordinate");
109 fBoxOx->Associate(this);
110 f1->AddFrame(fBoxOx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
111 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
112
113 // Number entry for dy
115 f2->AddFrame(new TGLabel(f2, "OY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
116 fBoxOy = new TGNumberEntry(f2, 0., 5, kBOX_OY);
118 nef->SetToolTipText("Enter the box origin Y coordinate");
119 fBoxOy->Associate(this);
120 f2->AddFrame(fBoxOy, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
121 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
122
123 // Number entry for dx
125 f3->AddFrame(new TGLabel(f3, "OZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
126 fBoxOz = new TGNumberEntry(f3, 0., 5, kBOX_OZ);
128 nef->SetToolTipText("Enter the box origin Z coordinate");
129 fBoxOz->Associate(this);
130 f3->AddFrame(fBoxOz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
131 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
132
133 compxyz->Resize(150, 30);
134 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
135
136 // Delayed draw
138 fDelayed = new TGCheckButton(f1, "Delayed draw");
139 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
140 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
141
142 // Buttons
143 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
144 fApply = new TGTextButton(f1, "Apply");
145 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
146 fApply->Associate(this);
147 fUndo = new TGTextButton(f1, "Undo");
148 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
149 fUndo->Associate(this);
150 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
152}
153
154////////////////////////////////////////////////////////////////////////////////
155/// Destructor.
156
158{
160 TIter next(GetList());
161 while ((el = (TGFrameElement *)next())) {
162 if (el->fFrame->IsComposite())
164 }
165 Cleanup();
166}
167
168////////////////////////////////////////////////////////////////////////////////
169/// Connect signals to slots.
170
172{
173 fApply->Connect("Clicked()", "TGeoBBoxEditor", this, "DoApply()");
174 fUndo->Connect("Clicked()", "TGeoBBoxEditor", this, "DoUndo()");
175 fShapeName->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
176 fBoxDx->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoDx()");
177 fBoxDy->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoDy()");
178 fBoxDz->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoDz()");
179 fBoxDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
180 fBoxDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
181 fBoxDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
182 fBoxOx->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoOx()");
183 fBoxOy->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoOy()");
184 fBoxOz->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoOz()");
185 fBoxOx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
186 fBoxOy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
187 fBoxOz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
188 fInit = kFALSE;
189}
190
191////////////////////////////////////////////////////////////////////////////////
192/// Update editor for a new selected box.
193
195{
196 if (obj == nullptr || (obj->IsA() != TGeoBBox::Class())) {
198 return;
199 }
200 fShape = (TGeoBBox *)obj;
201 fDxi = fShape->GetDX();
202 fDyi = fShape->GetDY();
203 fDzi = fShape->GetDZ();
204 memcpy(fOrigi, fShape->GetOrigin(), 3 * sizeof(Double_t));
205 const char *sname = fShape->GetName();
206 if (!strcmp(sname, fShape->ClassName()))
207 fShapeName->SetText("-no_name");
208 else {
210 fNamei = sname;
211 }
220
221 if (fInit)
223 SetActive();
224}
225
226////////////////////////////////////////////////////////////////////////////////
227/// Check if shape drawing is delayed.
228
230{
231 return (fDelayed->GetState() == kButtonDown);
232}
233
234////////////////////////////////////////////////////////////////////////////////
235/// Slot for name.
236
238{
239 DoModified();
240}
241
242////////////////////////////////////////////////////////////////////////////////
243/// Slot for applying current parameters.
244
246{
247 const char *name = fShapeName->GetText();
248 if (strcmp(name, fShape->GetName()))
253 Double_t orig[3];
254 orig[0] = fBoxOx->GetNumber();
255 orig[1] = fBoxOy->GetNumber();
256 orig[2] = fBoxOz->GetNumber();
258 fUndo->SetEnabled();
260 if (fPad) {
262 TView *view = fPad->GetView();
263 if (!view) {
264 fShape->Draw();
265 fPad->GetView()->ShowAxis();
266 } else {
267 const Double_t *origin = fShape->GetOrigin();
268 view->SetRange(origin[0] - fShape->GetDX(), origin[1] - fShape->GetDY(), origin[2] - fShape->GetDZ(),
269 origin[0] + fShape->GetDX(), origin[1] + fShape->GetDY(), origin[2] + fShape->GetDZ());
270 Update();
271 }
272 } else
273 Update();
274 }
275}
276
277////////////////////////////////////////////////////////////////////////////////
278/// Slot for modifying current parameters.
279
284
285////////////////////////////////////////////////////////////////////////////////
286/// Slot for undoing last operation.
287
300
301////////////////////////////////////////////////////////////////////////////////
302/// Slot for Dx modification.
303
305{
307 if (dx <= 0) {
308 dx = 0.1;
310 }
311 DoModified();
312 if (!IsDelayed())
313 DoApply();
314}
315
316////////////////////////////////////////////////////////////////////////////////
317/// Slot for Dy modification.
318
320{
322 if (dy <= 0) {
323 dy = 0.1;
325 }
326 DoModified();
327 if (!IsDelayed())
328 DoApply();
329}
330
331////////////////////////////////////////////////////////////////////////////////
332/// Slot for Dz modification.
333
335{
337 if (dz <= 0) {
338 dz = 0.1;
340 }
341 DoModified();
342 if (!IsDelayed())
343 DoApply();
344}
345
346////////////////////////////////////////////////////////////////////////////////
347/// Slot for Ox modification.
348
350{
351 DoModified();
352 if (!IsDelayed())
353 DoApply();
354}
355
356////////////////////////////////////////////////////////////////////////////////
357/// Slot for Oy modification.
358
360{
361 DoModified();
362 if (!IsDelayed())
363 DoApply();
364}
365
366////////////////////////////////////////////////////////////////////////////////
367/// Slot for Oz modification.
368
370{
371 DoModified();
372 if (!IsDelayed())
373 DoApply();
374}
@ 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
@ kFitWidth
Definition GuiTypes.h:386
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kOwnBackground
Definition GuiTypes.h:391
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kButtonDown
Definition TGButton.h:54
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsExpandX
Definition TGLayout.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
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
char name[80]
Definition TGX11.cxx:110
ETGeoBBoxWid
@ kBOX_OZ
@ kBOX_CANCEL
@ kBOX_OX
@ kBOX_APPLY
@ kBOX_Y
@ kBOX_Z
@ kBOX_OY
@ kBOX_NAME
@ kBOX_X
@ kBOX_UNDO
R__EXTERN TGeoManager * gGeoManager
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
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
virtual TList * GetList() const
Definition TGFrame.h:312
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:959
TGCompositeFrame(const TGCompositeFrame &)=delete
virtual void SetSize(const TGDimension &s)
Definition TGFrame.h:254
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
TGDimension GetSize() const
Definition TGFrame.h:232
This class handles GUI labels.
Definition TGLabel.h:24
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.
void SetNumAttr(EAttribute attr=kNEAAnyNumber)
virtual Double_t GetNumber() const
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
@ kNEAPositive
Positive number.
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
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
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.
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
ROOT GUI Window base class.
Definition TGWindow.h:23
Bool_t fInit
init flag for setting signals/slots
Definition TGedFrame.h:47
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:94
void DoDy()
Slot for Dy modification.
TGTextButton * fUndo
void SetModel(TObject *obj) override
Update editor for a new selected box.
TGNumberEntry * fBoxDx
TGNumberEntry * fBoxDy
TGTextEntry * fShapeName
TGNumberEntry * fBoxOy
void DoApply()
Slot for applying current parameters.
TGeoBBoxEditor(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 DoDz()
Slot for Dz modification.
TGeoBBox * fShape
TGCheckButton * fDelayed
void DoOz()
Slot for Oz modification.
TGNumberEntry * fBoxOx
Double_t fOrigi[3]
void DoUndo()
Slot for undoing last operation.
void DoDx()
Slot for Dx modification.
Bool_t fIsShapeEditable
void DoName()
Slot for name.
void DoModified()
Slot for modifying current parameters.
void DoOx()
Slot for Ox modification.
void DoOy()
Slot for Oy modification.
~TGeoBBoxEditor() override
Destructor.
Bool_t IsDelayed() const
Check if shape drawing is delayed.
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGNumberEntry * fBoxOz
TGNumberEntry * fBoxDz
TGTextButton * fApply
Box class.
Definition TGeoBBox.h:17
virtual const Double_t * GetOrigin() const
Definition TGeoBBox.h:79
void SetBoxDimensions(Double_t dx, Double_t dy, Double_t dz, Double_t *origin=nullptr)
Set parameters of the box.
Definition TGeoBBox.cxx:969
virtual Double_t GetDX() const
Definition TGeoBBox.h:76
virtual Double_t GetDZ() const
Definition TGeoBBox.h:78
virtual Double_t GetDY() const
Definition TGeoBBox.h:77
static TClass * Class()
Common base class for geombuilder editors.
void Update() override
Override Update from TGedFrame as fGedEditor can be null.
TVirtualPad * fPad
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
TVirtualGeoPainter * GetPainter() const
void Draw(Option_t *option="") override
Draw this shape.
const char * GetName() const override
Get the shape name.
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:149
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual TClass * IsA() const
Definition TObject.h:246
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
See TView3D.
Definition TView.h:25
virtual void SetRange(const Double_t *min, const Double_t *max)=0
virtual Bool_t IsPaintingShape() const =0
virtual TView * GetView() const =0
TF1 * f1
Definition legend1.C:11