Logo ROOT  
Reference Guide
TGeoTorusEditor.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 TGeoTorusEditor
13\ingroup Geometry_builder
14
15Editor for a TGeoTorus.
16
17\image html geom_torus_pic.png
18
19\image html geom_torus_ed.png
20
21*/
22
23#include "TGeoTorusEditor.h"
24#include "TGeoTabManager.h"
25#include "TGeoTorus.h"
26#include "TGeoManager.h"
27#include "TVirtualGeoPainter.h"
28#include "TPad.h"
29#include "TView.h"
30#include "TGTab.h"
31#include "TGComboBox.h"
32#include "TGButton.h"
33#include "TGTextEntry.h"
34#include "TGNumberEntry.h"
35#include "TGLabel.h"
36
38
42};
43
44////////////////////////////////////////////////////////////////////////////////
45/// Constructor for torus editor
46
48 Int_t height, UInt_t options, Pixel_t back)
49 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
50{
51 fShape = 0;
52 fRi = fRmini = fRmaxi = fPhi1i = fDphii = 0.0;
53 fNamei = "";
56
57 // TextEntry for shape name
58 MakeTitle("Name");
59 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTORUS_NAME);
61 fShapeName->SetToolTipText("Enter the torus name");
62 fShapeName->Associate(this);
64
65 TGTextEntry *nef;
66 MakeTitle("Dimensions");
67 // Number entry for R.
69 f1->AddFrame(new TGLabel(f1, "R"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
70 fER = new TGNumberEntry(f1, 0., 5, kTORUS_R);
74 nef->SetToolTipText("Enter the axial radius R");
75 fER->Associate(this);
76 f1->AddFrame(fER, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
77 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
78
79 // Number entry for rmin.
80 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
81 f1->AddFrame(new TGLabel(f1, "Rmin"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
82 fERmin = new TGNumberEntry(f1, 0., 5, kTORUS_RMIN);
86 nef->SetToolTipText("Enter the inner radius Rmin");
87 fERmin->Associate(this);
88 f1->AddFrame(fERmin, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
89 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
90
91 // Number entry for rmax
92 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
93 f1->AddFrame(new TGLabel(f1, "Rmax"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
94 fERmax = new TGNumberEntry(f1, 0., 5, kTORUS_RMAX);
98 nef->SetToolTipText("Enter the outer radius Rmax");
99 fERmax->Associate(this);
100 f1->AddFrame(fERmax, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
101 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
102
103 // Number entry for Phi1
104 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
105 f1->AddFrame(new TGLabel(f1, "Phi1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
106 fEPhi1 = new TGNumberEntry(f1, 0., 5, kTORUS_PHI1);
110 nef->SetToolTipText("Enter the starting phi angle[deg]");
111 fEPhi1->Associate(this);
112 f1->AddFrame(fEPhi1, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
113 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
114
115 // Number entry for Dphi
116 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
117 f1->AddFrame(new TGLabel(f1, "Dphi"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
118 fEDphi = new TGNumberEntry(f1, 0., 5, kTORUS_DPHI);
122 nef->SetToolTipText("Enter the extent phi Dphi [deg]");
123 fEDphi->Associate(this);
124 f1->AddFrame(fEDphi, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
125 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
126
127 // Delayed draw
129 fDelayed = new TGCheckButton(f1, "Delayed draw");
130 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
131 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
132
133 // Buttons
134 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
135 fApply = new TGTextButton(f1, "Apply");
136 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
137 fApply->Associate(this);
138 fUndo = new TGTextButton(f1, "Undo");
139 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
140 fUndo->Associate(this);
141 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
143}
144
145////////////////////////////////////////////////////////////////////////////////
146/// Destructor
147
149{
150 TGFrameElement *el;
151 TIter next(GetList());
152 while ((el = (TGFrameElement *)next())) {
153 if (el->fFrame->IsComposite())
155 }
156 Cleanup();
157}
158
159////////////////////////////////////////////////////////////////////////////////
160/// Connect signals to slots.
161
163{
164 fApply->Connect("Clicked()", "TGeoTorusEditor", this, "DoApply()");
165 fUndo->Connect("Clicked()", "TGeoTorusEditor", this, "DoUndo()");
166 fShapeName->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
167 fER->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoR()");
168 fERmin->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoRmin()");
169 fERmax->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoRmax()");
170 fEPhi1->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoPhi1()");
171 fEDphi->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoDphi()");
172 fER->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
173 fERmin->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
174 fERmax->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
175 fEPhi1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
176 fEDphi->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
177 fInit = kFALSE;
178}
179
180
181////////////////////////////////////////////////////////////////////////////////
182/// Connect to the selected object.
183
185{
186 if (obj == 0 || (obj->IsA()!=TGeoTorus::Class())) {
188 return;
189 }
190 fShape = (TGeoTorus*)obj;
191 fRi = fShape->GetR();
192 fRmini = fShape->GetRmin();
193 fRmaxi = fShape->GetRmax();
194 fPhi1i = fShape->GetPhi1();
195 fDphii = fShape->GetDphi();
196 const char *sname = fShape->GetName();
197 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
198 else {
199 fShapeName->SetText(sname);
200 fNamei = sname;
201 }
202 fER->SetNumber(fRi);
209
211 SetActive();
212}
213
214////////////////////////////////////////////////////////////////////////////////
215/// Check if shape drawing is delayed.
216
218{
219 return (fDelayed->GetState() == kButtonDown);
220}
221
222////////////////////////////////////////////////////////////////////////////////
223/// Slot for name.
224
226{
227 DoModified();
228}
229
230////////////////////////////////////////////////////////////////////////////////
231/// Slot for applying current settings.
232
234{
235 const char *name = fShapeName->GetText();
236 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
237 Double_t r = fER->GetNumber();
238 Double_t rmax = fERmax->GetNumber();
239 Double_t rmin = fERmin->GetNumber();
240 Double_t phi = fEPhi1->GetNumber();
241 Double_t dphi = fEDphi->GetNumber();
242 Double_t param[5];
243 param[0] = r;
244 param[1] = rmin;
245 param[2] = rmax;
246 param[3] = phi;
247 param[4] = dphi;
248 fShape->SetDimensions(param);
250 fUndo->SetEnabled();
252 if (fPad) {
254 TView *view = fPad->GetView();
255 if (!view) {
256 fShape->Draw();
257 fPad->GetView()->ShowAxis();
258 } else {
259 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(),
260 fShape->GetDX(), fShape->GetDY(), fShape->GetDZ());
261 Update();
262 }
263 } else Update();
264 }
265}
266
267////////////////////////////////////////////////////////////////////////////////
268/// Slot for notifying modifications.
269
271{
273}
274
275////////////////////////////////////////////////////////////////////////////////
276/// Slot for undoing last operation.
277
279{
280 fER->SetNumber(fRi);
285 DoApply();
288}
289
290////////////////////////////////////////////////////////////////////////////////
291/// Slot for R.
292
294{
295 Double_t r = fER->GetNumber();
296 Double_t rmax = fERmax->GetNumber();
297 if (r<rmax) {
298 r = rmax;
299 fER->SetNumber(r);
300 }
301 DoModified();
302 if (!IsDelayed()) DoApply();
303}
304
305////////////////////////////////////////////////////////////////////////////////
306/// Slot for Rmin.
307
309{
310 Double_t rmin = fERmin->GetNumber();
311 Double_t rmax = fERmax->GetNumber();
312 if (rmin>rmax) {
313 rmin = rmax-0.1;
314 fERmin->SetNumber(rmin);
315 }
316 DoModified();
317 if (!IsDelayed()) DoApply();
318}
319
320////////////////////////////////////////////////////////////////////////////////
321/// Slot for Rmax.
322
324{
325 Double_t r = fER->GetNumber();
326 Double_t rmin = fERmin->GetNumber();
327 Double_t rmax = fERmax->GetNumber();
328 if (rmax<=rmin) {
329 rmax = rmin+0.1;
330 fERmax->SetNumber(rmax);
331 }
332 if (rmax>r) {
333 rmax = r;
334 fERmax->SetNumber(rmax);
335 }
336 DoModified();
337 if (!IsDelayed()) DoApply();
338}
339
340////////////////////////////////////////////////////////////////////////////////
341/// Slot for phi.
342
344{
345 Double_t phi = fEPhi1->GetNumber();
346 if (phi<0 || phi>360) {
347 phi = 0;
348 fEPhi1->SetNumber(phi);
349 }
350 DoModified();
351 if (!IsDelayed()) DoApply();
352}
353
354////////////////////////////////////////////////////////////////////////////////
355/// Slot for Dphi.
356
358{
359 Double_t dphi = fEDphi->GetNumber();
360 if (dphi<=0 || dphi>360) {
361 dphi = 1;
362 fEDphi->SetNumber(dphi);
363 }
364 DoModified();
365 if (!IsDelayed()) DoApply();
366}
367
void Class()
Definition: Class.C:29
ULong_t Pixel_t
Definition: GuiTypes.h:39
ROOT::R::TRInterface & r
Definition: Object.C:4
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kButtonDown
Definition: TGButton.h:54
@ kSunkenFrame
Definition: TGFrame.h:61
@ kVerticalFrame
Definition: TGFrame.h:59
@ kFixedWidth
Definition: TGFrame.h:65
@ kHorizontalFrame
Definition: TGFrame.h:60
@ kLHintsRight
Definition: TGLayout.h:33
@ kLHintsLeft
Definition: TGLayout.h:31
char name[80]
Definition: TGX11.cxx:109
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:601
ETGeoTorusWid
@ kTORUS_DPHI
@ kTORUS_RMAX
@ kTORUS_APPLY
@ kTORUS_RMIN
@ kTORUS_PHI1
@ kTORUS_R
@ kTORUS_UNDO
@ kTORUS_NAME
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:409
virtual TList * GetList() const
Definition: TGFrame.h:369
TGCompositeFrame(const TGCompositeFrame &)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
TGFrame * fFrame
Definition: TGLayout.h:119
virtual void SetSize(const TGDimension &s)
Definition: TGFrame.h:299
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:238
TGDimension GetSize() const
Definition: TGFrame.h:277
virtual Bool_t IsComposite() const
Definition: TGFrame.h:259
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
virtual void SetNumber(Double_t val)
UInt_t GetDefaultHeight() const
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
Definition: TGTextEntry.h:134
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:84
Bool_t fInit
Definition: TGedFrame.h:53
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
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
Common base class for geombuilder editors.
Definition: TGeoGedFrame.h:13
virtual void Update()
Override Update from TGedFrame as fGedEditor can be null.
TVirtualPad * fPad
Definition: TGeoGedFrame.h:18
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
TVirtualGeoPainter * GetPainter() const
Definition: TGeoManager.h:212
virtual const char * GetName() const
Get the shape name.
Definition: TGeoShape.cxx:248
virtual void Draw(Option_t *option="")
Draw this shape.
Definition: TGeoShape.cxx:721
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
Editor for a TGeoTorus.
TGTextButton * fApply
void DoRmax()
Slot for Rmax.
void DoR()
Slot for R.
void DoPhi1()
Slot for phi.
virtual ~TGeoTorusEditor()
Destructor.
virtual void SetModel(TObject *obj)
Connect to the selected object.
void DoRmin()
Slot for Rmin.
TGNumberEntry * fEDphi
void DoUndo()
Slot for undoing last operation.
void DoName()
Slot for name.
TGNumberEntry * fEPhi1
TGTextButton * fUndo
TGNumberEntry * fER
TGCheckButton * fDelayed
void DoDphi()
Slot for Dphi.
void DoApply()
Slot for applying current settings.
TGNumberEntry * fERmin
void DoModified()
Slot for notifying modifications.
TGTextEntry * fShapeName
TGNumberEntry * fERmax
TGeoTorus * fShape
TGeoTorusEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for torus editor.
virtual void ConnectSignals2Slots()
Connect signals to slots.
Bool_t IsDelayed() const
Check if shape drawing is delayed.
Torus segment class.
Definition: TGeoTorus.h:18
Double_t GetRmax() const
Definition: TGeoTorus.h:71
virtual void SetDimensions(Double_t *param)
Set torus dimensions starting from a list.
Definition: TGeoTorus.cxx:785
Double_t GetRmin() const
Definition: TGeoTorus.h:70
Double_t GetR() const
Definition: TGeoTorus.h:69
virtual void ComputeBBox()
Compute bounding box of the torus.
Definition: TGeoTorus.cxx:124
Double_t GetPhi1() const
Definition: TGeoTorus.h:72
Double_t GetDphi() const
Definition: TGeoTorus.h:73
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:128
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:867
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