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
41};
42
43////////////////////////////////////////////////////////////////////////////////
44/// Constructor for volume editor.
45
47 Int_t height, UInt_t options, Pixel_t back)
48 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
49{
50 fShape = 0;
51 fDxi = fDyi = fDzi = 0.0;
52 memset(fOrigi, 0, 3*sizeof(Double_t));
53 fNamei = "";
56
57 // TextEntry for shape name
58 MakeTitle("Name");
59 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kBOX_NAME);
61 fShapeName->SetToolTipText("Enter the box name");
62 fShapeName->Associate(this);
64
65 TGTextEntry *nef;
66 MakeTitle("Box half-lengths");
68 // Number entry for dx
69 TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
71 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
72 fBoxDx = new TGNumberEntry(f1, 0., 5, kBOX_X);
75 nef->SetToolTipText("Enter the box half-length in X");
76 fBoxDx->Associate(this);
77 f1->AddFrame(fBoxDx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
78 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
79
80 // Number entry for dy
81 TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
83 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
84 fBoxDy = new TGNumberEntry(f2, 0., 5, kBOX_Y);
87 nef->SetToolTipText("Enter the box half-length in Y");
88 fBoxDy->Associate(this);
89 f2->AddFrame(fBoxDy, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
90 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
91
92 // Number entry for dx
93 TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
95 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
96 fBoxDz = new TGNumberEntry(f3, 0., 5, kBOX_Z);
99 nef->SetToolTipText("Enter the box half-length in Z");
100 fBoxDz->Associate(this);
101 f3->AddFrame(fBoxDz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
102 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
103
104 compxyz->Resize(150,30);
105 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
106
107 MakeTitle("Box origin");
108 compxyz = new TGCompositeFrame(this, 118, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
109 // Number entry for dx
110 f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
112 f1->AddFrame(new TGLabel(f1, "OX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
113 fBoxOx = new TGNumberEntry(f1, 0., 5, kBOX_OX);
115 nef->SetToolTipText("Enter the box origin X coordinate");
116 fBoxOx->Associate(this);
117 f1->AddFrame(fBoxOx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
118 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
119
120 // Number entry for dy
121 f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
123 f2->AddFrame(new TGLabel(f2, "OY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
124 fBoxOy = new TGNumberEntry(f2, 0., 5, kBOX_OY);
126 nef->SetToolTipText("Enter the box origin Y coordinate");
127 fBoxOy->Associate(this);
128 f2->AddFrame(fBoxOy, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
129 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
130
131 // Number entry for dx
132 f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
134 f3->AddFrame(new TGLabel(f3, "OZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
135 fBoxOz = new TGNumberEntry(f3, 0., 5, kBOX_OZ);
137 nef->SetToolTipText("Enter the box origin Z coordinate");
138 fBoxOz->Associate(this);
139 f3->AddFrame(fBoxOz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
140 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
141
142 compxyz->Resize(150,30);
143 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
144
145 // Delayed draw
147 fDelayed = new TGCheckButton(f1, "Delayed draw");
148 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
149 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
150
151 // Buttons
152 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
153 fApply = new TGTextButton(f1, "Apply");
154 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
155 fApply->Associate(this);
156 fUndo = new TGTextButton(f1, "Undo");
157 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
158 fUndo->Associate(this);
159 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
161}
162
163////////////////////////////////////////////////////////////////////////////////
164/// Destructor.
165
167{
168 TGFrameElement *el;
169 TIter next(GetList());
170 while ((el = (TGFrameElement *)next())) {
171 if (el->fFrame->IsComposite())
173 }
174 Cleanup();
175}
176
177////////////////////////////////////////////////////////////////////////////////
178/// Connect signals to slots.
179
181{
182 fApply->Connect("Clicked()", "TGeoBBoxEditor", this, "DoApply()");
183 fUndo->Connect("Clicked()", "TGeoBBoxEditor", this, "DoUndo()");
184 fShapeName->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
185 fBoxDx->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoDx()");
186 fBoxDy->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoDy()");
187 fBoxDz->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoDz()");
188 fBoxDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
189 fBoxDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
190 fBoxDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
191 fBoxOx->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoOx()");
192 fBoxOy->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoOy()");
193 fBoxOz->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoOz()");
194 fBoxOx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
195 fBoxOy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
196 fBoxOz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()");
197 fInit = kFALSE;
198}
199
200
201////////////////////////////////////////////////////////////////////////////////
202/// Update editor for a new selected box.
203
205{
206 if (obj == 0 || (obj->IsA()!=TGeoBBox::Class())) {
208 return;
209 }
210 fShape = (TGeoBBox*)obj;
211 fDxi = fShape->GetDX();
212 fDyi = fShape->GetDY();
213 fDzi = fShape->GetDZ();
214 memcpy(fOrigi, fShape->GetOrigin(), 3*sizeof(Double_t));
215 const char *sname = fShape->GetName();
216 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
217 else {
218 fShapeName->SetText(sname);
219 fNamei = sname;
220 }
229
231 SetActive();
232}
233
234////////////////////////////////////////////////////////////////////////////////
235/// Check if shape drawing is delayed.
236
238{
239 return (fDelayed->GetState() == kButtonDown);
240}
241
242////////////////////////////////////////////////////////////////////////////////
243///Slot for name.
244
246{
247 DoModified();
248}
249
250////////////////////////////////////////////////////////////////////////////////
251///Slot for applying current parameters.
252
254{
255 const char *name = fShapeName->GetText();
256 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
257 Double_t dx = fBoxDx->GetNumber();
258 Double_t dy = fBoxDy->GetNumber();
259 Double_t dz = fBoxDz->GetNumber();
260 Double_t orig[3];
261 orig[0] = fBoxOx->GetNumber();
262 orig[1] = fBoxOy->GetNumber();
263 orig[2] = fBoxOz->GetNumber();
264 fShape->SetBoxDimensions(dx, dy, dz, orig);
265 fUndo->SetEnabled();
267 if (fPad) {
269 TView *view = fPad->GetView();
270 if (!view) {
271 fShape->Draw();
272 fPad->GetView()->ShowAxis();
273 } else {
274 const Double_t *origin = fShape->GetOrigin();
275 view->SetRange(origin[0]-fShape->GetDX(), origin[1]-fShape->GetDY(), origin[2]-fShape->GetDZ(),
276 origin[0]+fShape->GetDX(), origin[1]+fShape->GetDY(), origin[2]+fShape->GetDZ());
277 Update();
278 }
279 } else Update();
280 }
281}
282
283////////////////////////////////////////////////////////////////////////////////
284///Slot for modifying current parameters.
285
287{
289}
290
291////////////////////////////////////////////////////////////////////////////////
292/// Slot for undoing last operation.
293
295{
302 DoApply();
305}
306
307////////////////////////////////////////////////////////////////////////////////
308///Slot for Dx modification.
309
311{
312 Double_t dx = fBoxDx->GetNumber();
313 if (dx<=0) {
314 dx=0.1;
315 fBoxDx->SetNumber(dx);
316 }
317 DoModified();
318 if (!IsDelayed()) DoApply();
319}
320
321////////////////////////////////////////////////////////////////////////////////
322///Slot for Dy modification.
323
325{
326 Double_t dy = fBoxDy->GetNumber();
327 if (dy<=0) {
328 dy=0.1;
329 fBoxDy->SetNumber(dy);
330 }
331 DoModified();
332 if (!IsDelayed()) DoApply();
333}
334
335////////////////////////////////////////////////////////////////////////////////
336///Slot for Dz modification.
337
339{
340 Double_t dz = fBoxDz->GetNumber();
341 if (dz<=0) {
342 dz=0.1;
343 fBoxDz->SetNumber(dz);
344 }
345 DoModified();
346 if (!IsDelayed()) DoApply();
347}
348
349////////////////////////////////////////////////////////////////////////////////
350///Slot for Ox modification.
351
353{
354 DoModified();
355 if (!IsDelayed()) DoApply();
356}
357
358////////////////////////////////////////////////////////////////////////////////
359///Slot for Oy modification.
360
362{
363 DoModified();
364 if (!IsDelayed()) DoApply();
365}
366
367////////////////////////////////////////////////////////////////////////////////
368///Slot for Oz modification.
369
371{
372 DoModified();
373 if (!IsDelayed()) DoApply();
374}
375
376
@ 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
@ kOwnBackground
Definition GuiTypes.h:391
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
const Bool_t kFALSE
Definition RtypesCore.h:92
double Double_t
Definition RtypesCore.h:59
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
@ kButtonDown
Definition TGButton.h:54
@ kLHintsRight
Definition TGLayout.h:33
@ kLHintsLeft
Definition TGLayout.h:31
@ kLHintsExpandX
Definition TGLayout.h:37
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:412
virtual TList * GetList() const
Definition TGFrame.h:346
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1102
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:952
TGFrame * fFrame
Definition TGLayout.h:119
virtual void SetSize(const TGDimension &s)
Definition TGFrame.h:276
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:215
TGDimension GetSize() const
Definition TGFrame.h:254
virtual Bool_t IsComposite() const
Definition TGFrame.h:236
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:590
virtual void SetNumber(Double_t val)
TGNumberEntryField * GetNumberEntry() const
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
void SetNumAttr(EAttribute attr=kNEAAnyNumber)
virtual Double_t GetNumber() const
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:82
Bool_t fInit
Definition TGedFrame.h:54
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:96
Editor for a TGeoBBox.
void DoDy()
Slot for Dy modification.
TGTextButton * fUndo
TGNumberEntry * fBoxDx
TGNumberEntry * fBoxDy
TGTextEntry * fShapeName
TGNumberEntry * fBoxOy
void DoApply()
Slot for applying current parameters.
void DoDz()
Slot for Dz modification.
virtual ~TGeoBBoxEditor()
Destructor.
TGeoBBox * fShape
TGCheckButton * fDelayed
void DoOz()
Slot for Oz modification.
TGNumberEntry * fBoxOx
virtual void SetModel(TObject *obj)
Update editor for a new selected box.
Double_t fOrigi[3]
void DoUndo()
Slot for undoing last operation.
TGeoBBoxEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for volume editor.
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.
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:18
virtual const Double_t * GetOrigin() const
Definition TGeoBBox.h:73
virtual Double_t GetDX() const
Definition TGeoBBox.h:70
virtual Double_t GetDZ() const
Definition TGeoBBox.h:72
virtual Double_t GetDY() const
Definition TGeoBBox.h:71
void SetBoxDimensions(Double_t dx, Double_t dy, Double_t dz, Double_t *origin=0)
Set parameters of the box.
Definition TGeoBBox.cxx:899
Common base class for geombuilder editors.
virtual void Update()
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
virtual const char * GetName() const
Get the shape name.
virtual void Draw(Option_t *option="")
Draw this shape.
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:37
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:130
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:866
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