Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "TVirtualPad.h"
29#include "TView.h"
30#include "TGButton.h"
31#include "TGTextEntry.h"
32#include "TGNumberEntry.h"
33#include "TGLabel.h"
34
36
40};
41
42////////////////////////////////////////////////////////////////////////////////
43/// Constructor for torus editor
44
46 Int_t height, UInt_t options, Pixel_t back)
47 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
48{
49 fShape = 0;
50 fRi = fRmini = fRmaxi = fPhi1i = fDphii = 0.0;
51 fNamei = "";
54
55 // TextEntry for shape name
56 MakeTitle("Name");
57 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTORUS_NAME);
59 fShapeName->SetToolTipText("Enter the torus name");
60 fShapeName->Associate(this);
62
63 TGTextEntry *nef;
64 MakeTitle("Dimensions");
65 // Number entry for R.
67 f1->AddFrame(new TGLabel(f1, "R"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
68 fER = new TGNumberEntry(f1, 0., 5, kTORUS_R);
72 nef->SetToolTipText("Enter the axial radius R");
73 fER->Associate(this);
74 f1->AddFrame(fER, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
75 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
76
77 // Number entry for rmin.
78 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
79 f1->AddFrame(new TGLabel(f1, "Rmin"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
80 fERmin = new TGNumberEntry(f1, 0., 5, kTORUS_RMIN);
84 nef->SetToolTipText("Enter the inner radius Rmin");
85 fERmin->Associate(this);
86 f1->AddFrame(fERmin, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
87 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
88
89 // Number entry for rmax
90 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
91 f1->AddFrame(new TGLabel(f1, "Rmax"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
92 fERmax = new TGNumberEntry(f1, 0., 5, kTORUS_RMAX);
96 nef->SetToolTipText("Enter the outer radius Rmax");
97 fERmax->Associate(this);
98 f1->AddFrame(fERmax, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
99 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
100
101 // Number entry for Phi1
102 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
103 f1->AddFrame(new TGLabel(f1, "Phi1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
104 fEPhi1 = new TGNumberEntry(f1, 0., 5, kTORUS_PHI1);
108 nef->SetToolTipText("Enter the starting phi angle[deg]");
109 fEPhi1->Associate(this);
110 f1->AddFrame(fEPhi1, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
111 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
112
113 // Number entry for Dphi
114 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
115 f1->AddFrame(new TGLabel(f1, "Dphi"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
116 fEDphi = new TGNumberEntry(f1, 0., 5, kTORUS_DPHI);
120 nef->SetToolTipText("Enter the extent phi Dphi [deg]");
121 fEDphi->Associate(this);
122 f1->AddFrame(fEDphi, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
123 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
124
125 // Delayed draw
127 fDelayed = new TGCheckButton(f1, "Delayed draw");
128 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
129 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
130
131 // Buttons
132 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
133 fApply = new TGTextButton(f1, "Apply");
134 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
135 fApply->Associate(this);
136 fUndo = new TGTextButton(f1, "Undo");
137 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
138 fUndo->Associate(this);
139 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
141}
142
143////////////////////////////////////////////////////////////////////////////////
144/// Destructor
145
147{
148 TGFrameElement *el;
149 TIter next(GetList());
150 while ((el = (TGFrameElement *)next())) {
151 if (el->fFrame->IsComposite())
153 }
154 Cleanup();
155}
156
157////////////////////////////////////////////////////////////////////////////////
158/// Connect signals to slots.
159
161{
162 fApply->Connect("Clicked()", "TGeoTorusEditor", this, "DoApply()");
163 fUndo->Connect("Clicked()", "TGeoTorusEditor", this, "DoUndo()");
164 fShapeName->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
165 fER->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoR()");
166 fERmin->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoRmin()");
167 fERmax->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoRmax()");
168 fEPhi1->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoPhi1()");
169 fEDphi->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoDphi()");
170 fER->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
171 fERmin->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
172 fERmax->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
173 fEPhi1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
174 fEDphi->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
175 fInit = kFALSE;
176}
177
178
179////////////////////////////////////////////////////////////////////////////////
180/// Connect to the selected object.
181
183{
184 if (obj == 0 || (obj->IsA()!=TGeoTorus::Class())) {
186 return;
187 }
188 fShape = (TGeoTorus*)obj;
189 fRi = fShape->GetR();
190 fRmini = fShape->GetRmin();
191 fRmaxi = fShape->GetRmax();
192 fPhi1i = fShape->GetPhi1();
193 fDphii = fShape->GetDphi();
194 const char *sname = fShape->GetName();
195 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
196 else {
197 fShapeName->SetText(sname);
198 fNamei = sname;
199 }
200 fER->SetNumber(fRi);
207
209 SetActive();
210}
211
212////////////////////////////////////////////////////////////////////////////////
213/// Check if shape drawing is delayed.
214
216{
217 return (fDelayed->GetState() == kButtonDown);
218}
219
220////////////////////////////////////////////////////////////////////////////////
221/// Slot for name.
222
224{
225 DoModified();
226}
227
228////////////////////////////////////////////////////////////////////////////////
229/// Slot for applying current settings.
230
232{
233 const char *name = fShapeName->GetText();
234 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
235 Double_t r = fER->GetNumber();
236 Double_t rmax = fERmax->GetNumber();
237 Double_t rmin = fERmin->GetNumber();
238 Double_t phi = fEPhi1->GetNumber();
239 Double_t dphi = fEDphi->GetNumber();
240 Double_t param[5];
241 param[0] = r;
242 param[1] = rmin;
243 param[2] = rmax;
244 param[3] = phi;
245 param[4] = dphi;
246 fShape->SetDimensions(param);
248 fUndo->SetEnabled();
250 if (fPad) {
252 TView *view = fPad->GetView();
253 if (!view) {
254 fShape->Draw();
255 fPad->GetView()->ShowAxis();
256 } else {
257 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(),
258 fShape->GetDX(), fShape->GetDY(), fShape->GetDZ());
259 Update();
260 }
261 } else Update();
262 }
263}
264
265////////////////////////////////////////////////////////////////////////////////
266/// Slot for notifying modifications.
267
269{
271}
272
273////////////////////////////////////////////////////////////////////////////////
274/// Slot for undoing last operation.
275
277{
278 fER->SetNumber(fRi);
283 DoApply();
286}
287
288////////////////////////////////////////////////////////////////////////////////
289/// Slot for R.
290
292{
293 Double_t r = fER->GetNumber();
294 Double_t rmax = fERmax->GetNumber();
295 if (r<rmax) {
296 r = rmax;
297 fER->SetNumber(r);
298 }
299 DoModified();
300 if (!IsDelayed()) DoApply();
301}
302
303////////////////////////////////////////////////////////////////////////////////
304/// Slot for Rmin.
305
307{
308 Double_t rmin = fERmin->GetNumber();
309 Double_t rmax = fERmax->GetNumber();
310 if (rmin>rmax) {
311 rmin = rmax-0.1;
312 fERmin->SetNumber(rmin);
313 }
314 DoModified();
315 if (!IsDelayed()) DoApply();
316}
317
318////////////////////////////////////////////////////////////////////////////////
319/// Slot for Rmax.
320
322{
323 Double_t r = fER->GetNumber();
324 Double_t rmin = fERmin->GetNumber();
325 Double_t rmax = fERmax->GetNumber();
326 if (rmax<=rmin) {
327 rmax = rmin+0.1;
328 fERmax->SetNumber(rmax);
329 }
330 if (rmax>r) {
331 rmax = r;
332 fERmax->SetNumber(rmax);
333 }
334 DoModified();
335 if (!IsDelayed()) DoApply();
336}
337
338////////////////////////////////////////////////////////////////////////////////
339/// Slot for phi.
340
342{
343 Double_t phi = fEPhi1->GetNumber();
344 if (phi<0 || phi>360) {
345 phi = 0;
346 fEPhi1->SetNumber(phi);
347 }
348 DoModified();
349 if (!IsDelayed()) DoApply();
350}
351
352////////////////////////////////////////////////////////////////////////////////
353/// Slot for Dphi.
354
356{
357 Double_t dphi = fEDphi->GetNumber();
358 if (dphi<=0 || dphi>360) {
359 dphi = 1;
360 fEDphi->SetNumber(dphi);
361 }
362 DoModified();
363 if (!IsDelayed()) DoApply();
364}
365
@ kSunkenFrame
Definition GuiTypes.h:383
@ kVerticalFrame
Definition GuiTypes.h:381
@ kFixedWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
ROOT::R::TRInterface & r
Definition Object.C:4
const Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
const Bool_t kTRUE
Definition RtypesCore.h:100
#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:26
@ kLHintsLeft
Definition TGLayout.h:24
char name[80]
Definition TGX11.cxx:110
R__EXTERN TGeoManager * gGeoManager
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:459
Selects different options.
Definition TGButton.h:264
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual TList * GetList() const
Definition TGFrame.h:310
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
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
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
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:605
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.
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
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
@ kNEAPositive
Positive number.
@ kNEANonNegative
Non-negative 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
virtual Double_t GetDX() const
Definition TGeoBBox.h:74
virtual Double_t GetDZ() const
Definition TGeoBBox.h:76
virtual Double_t GetDY() const
Definition TGeoBBox.h:75
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.
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.
The torus is defined by its axial radius, its inner and outer radius.
Definition TGeoTorus.h:18
Double_t GetRmax() const
Definition TGeoTorus.h:73
virtual void SetDimensions(Double_t *param)
Set torus dimensions starting from a list.
Double_t GetRmin() const
Definition TGeoTorus.h:72
Double_t GetR() const
Definition TGeoTorus.h:71
virtual void ComputeBBox()
Compute bounding box of the torus.
Double_t GetPhi1() const
Definition TGeoTorus.h:74
Double_t GetDphi() const
Definition TGeoTorus.h:75
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:200
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