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
36
38
39////////////////////////////////////////////////////////////////////////////////
40/// Constructor for volume editor.
41
43 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
44{
45 fShape = nullptr;
46 fDxi = fDyi = fDzi = 0.0;
47 memset(fOrigi, 0, 3 * sizeof(Double_t));
48 fNamei = "";
51
52 // TextEntry for shape name
53 MakeTitle("Name");
54 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kBOX_NAME);
56 fShapeName->SetToolTipText("Enter the box name");
57 fShapeName->Associate(this);
59
60 TGTextEntry *nef;
61 MakeTitle("Box half-lengths");
63 // Number entry for dx
66 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
67 fBoxDx = new TGNumberEntry(f1, 0., 5, kBOX_X);
70 nef->SetToolTipText("Enter the box half-length in X");
71 fBoxDx->Associate(this);
72 f1->AddFrame(fBoxDx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
73 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
74
75 // Number entry for dy
78 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
79 fBoxDy = new TGNumberEntry(f2, 0., 5, kBOX_Y);
82 nef->SetToolTipText("Enter the box half-length in Y");
83 fBoxDy->Associate(this);
85 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
86
87 // Number entry for dx
90 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
91 fBoxDz = new TGNumberEntry(f3, 0., 5, kBOX_Z);
94 nef->SetToolTipText("Enter the box half-length in Z");
95 fBoxDz->Associate(this);
97 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
98
99 compxyz->Resize(150, 30);
100 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
101
102 MakeTitle("Box origin");
103 compxyz = new TGCompositeFrame(this, 118, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
104 // Number entry for dx
106 f1->AddFrame(new TGLabel(f1, "OX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
107 fBoxOx = new TGNumberEntry(f1, 0., 5, kBOX_OX);
109 nef->SetToolTipText("Enter the box origin X coordinate");
110 fBoxOx->Associate(this);
111 f1->AddFrame(fBoxOx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
112 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
113
114 // Number entry for dy
115 f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame | kFitWidth | kFixedWidth | kOwnBackground);
116 f2->AddFrame(new TGLabel(f2, "OY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
117 fBoxOy = new TGNumberEntry(f2, 0., 5, kBOX_OY);
119 nef->SetToolTipText("Enter the box origin Y coordinate");
120 fBoxOy->Associate(this);
121 f2->AddFrame(fBoxOy, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
122 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
123
124 // Number entry for dx
125 f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame | kFitWidth | kFixedWidth | kOwnBackground);
126 f3->AddFrame(new TGLabel(f3, "OZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
127 fBoxOz = new TGNumberEntry(f3, 0., 5, kBOX_OZ);
129 nef->SetToolTipText("Enter the box origin Z coordinate");
130 fBoxOz->Associate(this);
131 f3->AddFrame(fBoxOz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
132 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
133
134 compxyz->Resize(150, 30);
135 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
136
137 // Delayed draw
139 fDelayed = new TGCheckButton(f1, "Delayed draw");
140 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
141 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
142
143 // Buttons
144 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
145 fApply = new TGTextButton(f1, "Apply");
146 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
147 fApply->Associate(this);
148 fUndo = new TGTextButton(f1, "Undo");
149 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
150 fUndo->Associate(this);
151 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
153}
154
155////////////////////////////////////////////////////////////////////////////////
156/// Destructor.
157
159{
160 TGFrameElement *el;
161 TIter next(GetList());
162 while ((el = (TGFrameElement *)next())) {
163 if (el->fFrame->IsComposite())
165 }
166 Cleanup();
167}
168
169////////////////////////////////////////////////////////////////////////////////
170/// Connect signals to slots.
171
173{
174 fApply->Connect("Clicked()", "TGeoBBoxEditor", this, "DoApply()");
175 fUndo->Connect("Clicked()", "TGeoBBoxEditor", this, "DoUndo()");
176 fShapeName->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
177 fBoxDx->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoDx()");
178 fBoxDy->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoDy()");
179 fBoxDz->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoDz()");
180 fBoxDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
181 fBoxDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
182 fBoxDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
183 fBoxOx->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoOx()");
184 fBoxOy->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoOy()");
185 fBoxOz->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoOz()");
186 fBoxOx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
187 fBoxOy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
188 fBoxOz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
189 fInit = kFALSE;
190}
191
192////////////////////////////////////////////////////////////////////////////////
193/// Update editor for a new selected box.
194
196{
197 if (obj == nullptr || (obj->IsA() != TGeoBBox::Class())) {
199 return;
200 }
201 fShape = (TGeoBBox *)obj;
202 fDxi = fShape->GetDX();
203 fDyi = fShape->GetDY();
204 fDzi = fShape->GetDZ();
205 memcpy(fOrigi, fShape->GetOrigin(), 3 * sizeof(Double_t));
206 const char *sname = fShape->GetName();
207 if (!strcmp(sname, fShape->ClassName()))
208 fShapeName->SetText("-no_name");
209 else {
210 fShapeName->SetText(sname);
211 fNamei = sname;
212 }
221
222 if (fInit)
224 SetActive();
225}
226
227////////////////////////////////////////////////////////////////////////////////
228/// Check if shape drawing is delayed.
229
231{
232 return (fDelayed->GetState() == kButtonDown);
233}
234
235////////////////////////////////////////////////////////////////////////////////
236/// Slot for name.
237
239{
240 DoModified();
241}
242
243////////////////////////////////////////////////////////////////////////////////
244/// Slot for applying current parameters.
245
247{
248 const char *name = fShapeName->GetText();
249 if (strcmp(name, fShape->GetName()))
251 Double_t dx = fBoxDx->GetNumber();
252 Double_t dy = fBoxDy->GetNumber();
253 Double_t dz = fBoxDz->GetNumber();
254 Double_t orig[3];
255 orig[0] = fBoxOx->GetNumber();
256 orig[1] = fBoxOy->GetNumber();
257 orig[2] = fBoxOz->GetNumber();
258 fShape->SetBoxDimensions(dx, dy, dz, orig);
259 fUndo->SetEnabled();
261 if (fPad) {
263 TView *view = fPad->GetView();
264 if (!view) {
265 fShape->Draw();
266 fPad->GetView()->ShowAxis();
267 } else {
268 const Double_t *origin = fShape->GetOrigin();
269 view->SetRange(origin[0] - fShape->GetDX(), origin[1] - fShape->GetDY(), origin[2] - fShape->GetDZ(),
270 origin[0] + fShape->GetDX(), origin[1] + fShape->GetDY(), origin[2] + fShape->GetDZ());
271 Update();
272 }
273 } else
274 Update();
275 }
276}
277
278////////////////////////////////////////////////////////////////////////////////
279/// Slot for modifying current parameters.
280
282{
284}
285
286////////////////////////////////////////////////////////////////////////////////
287/// Slot for undoing last operation.
288
290{
297 DoApply();
300}
301
302////////////////////////////////////////////////////////////////////////////////
303/// Slot for Dx modification.
304
306{
307 Double_t dx = fBoxDx->GetNumber();
308 if (dx <= 0) {
309 dx = 0.1;
310 fBoxDx->SetNumber(dx);
311 }
312 DoModified();
313 if (!IsDelayed())
314 DoApply();
315}
316
317////////////////////////////////////////////////////////////////////////////////
318/// Slot for Dy modification.
319
321{
322 Double_t dy = fBoxDy->GetNumber();
323 if (dy <= 0) {
324 dy = 0.1;
325 fBoxDy->SetNumber(dy);
326 }
327 DoModified();
328 if (!IsDelayed())
329 DoApply();
330}
331
332////////////////////////////////////////////////////////////////////////////////
333/// Slot for Dz modification.
334
336{
337 Double_t dz = fBoxDz->GetNumber();
338 if (dz <= 0) {
339 dz = 0.1;
340 fBoxDz->SetNumber(dz);
341 }
342 DoModified();
343 if (!IsDelayed())
344 DoApply();
345}
346
347////////////////////////////////////////////////////////////////////////////////
348/// Slot for Ox modification.
349
351{
352 DoModified();
353 if (!IsDelayed())
354 DoApply();
355}
356
357////////////////////////////////////////////////////////////////////////////////
358/// Slot for Oy modification.
359
361{
362 DoModified();
363 if (!IsDelayed())
364 DoApply();
365}
366
367////////////////////////////////////////////////////////////////////////////////
368/// Slot for Oz modification.
369
371{
372 DoModified();
373 if (!IsDelayed())
374 DoApply();
375}
@ 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:94
#define ClassImp(name)
Definition Rtypes.h:382
@ 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:459
Selects different options.
Definition TGButton.h:264
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual TList * GetList() const
Definition TGFrame.h:310
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:967
TGFrame * fFrame
Definition TGLayout.h:112
virtual void SetSize(const TGDimension &s)
Definition TGFrame.h:252
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:191
TGDimension GetSize() const
Definition TGFrame.h:230
virtual Bool_t IsComposite() const
Definition TGFrame.h:212
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:95
Editor for a TGeoBBox.
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
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)
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:140
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:225
virtual TClass * IsA() const
Definition TObject.h:243
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:869
See TView3D.
Definition TView.h:25
virtual void ShowAxis()=0
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