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
35
46
47////////////////////////////////////////////////////////////////////////////////
48/// Constructor for torus editor
49
51 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
52{
53 fShape = nullptr;
54 fRi = fRmini = fRmaxi = fPhi1i = fDphii = 0.0;
55 fNamei = "";
58
59 // TextEntry for shape name
60 MakeTitle("Name");
61 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTORUS_NAME);
63 fShapeName->SetToolTipText("Enter the torus name");
64 fShapeName->Associate(this);
66
68 MakeTitle("Dimensions");
69 // Number entry for R.
71 f1->AddFrame(new TGLabel(f1, "R"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
72 fER = new TGNumberEntry(f1, 0., 5, kTORUS_R);
76 nef->SetToolTipText("Enter the axial radius R");
77 fER->Associate(this);
78 f1->AddFrame(fER, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
79 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
80
81 // Number entry for rmin.
82 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
83 f1->AddFrame(new TGLabel(f1, "Rmin"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
84 fERmin = new TGNumberEntry(f1, 0., 5, kTORUS_RMIN);
88 nef->SetToolTipText("Enter the inner radius Rmin");
89 fERmin->Associate(this);
90 f1->AddFrame(fERmin, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
91 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
92
93 // Number entry for rmax
94 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
95 f1->AddFrame(new TGLabel(f1, "Rmax"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
96 fERmax = new TGNumberEntry(f1, 0., 5, kTORUS_RMAX);
100 nef->SetToolTipText("Enter the outer radius Rmax");
101 fERmax->Associate(this);
102 f1->AddFrame(fERmax, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
103 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
104
105 // Number entry for Phi1
106 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
107 f1->AddFrame(new TGLabel(f1, "Phi1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
108 fEPhi1 = new TGNumberEntry(f1, 0., 5, kTORUS_PHI1);
112 nef->SetToolTipText("Enter the starting phi angle[deg]");
113 fEPhi1->Associate(this);
114 f1->AddFrame(fEPhi1, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
115 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
116
117 // Number entry for Dphi
118 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
119 f1->AddFrame(new TGLabel(f1, "Dphi"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
120 fEDphi = new TGNumberEntry(f1, 0., 5, kTORUS_DPHI);
124 nef->SetToolTipText("Enter the extent phi Dphi [deg]");
125 fEDphi->Associate(this);
126 f1->AddFrame(fEDphi, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
127 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
128
129 // Delayed draw
131 fDelayed = new TGCheckButton(f1, "Delayed draw");
132 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
133 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
134
135 // Buttons
136 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
137 fApply = new TGTextButton(f1, "Apply");
138 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
139 fApply->Associate(this);
140 fUndo = new TGTextButton(f1, "Undo");
141 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
142 fUndo->Associate(this);
143 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
145}
146
147////////////////////////////////////////////////////////////////////////////////
148/// Destructor
149
151{
153 TIter next(GetList());
154 while ((el = (TGFrameElement *)next())) {
155 if (el->fFrame->IsComposite())
157 }
158 Cleanup();
159}
160
161////////////////////////////////////////////////////////////////////////////////
162/// Connect signals to slots.
163
165{
166 fApply->Connect("Clicked()", "TGeoTorusEditor", this, "DoApply()");
167 fUndo->Connect("Clicked()", "TGeoTorusEditor", this, "DoUndo()");
168 fShapeName->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
169 fER->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoR()");
170 fERmin->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoRmin()");
171 fERmax->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoRmax()");
172 fEPhi1->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoPhi1()");
173 fEDphi->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoDphi()");
174 fER->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
175 fERmin->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
176 fERmax->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
177 fEPhi1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
178 fEDphi->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
179 fInit = kFALSE;
180}
181
182////////////////////////////////////////////////////////////////////////////////
183/// Connect to the selected object.
184
186{
187 if (obj == nullptr || (obj->IsA() != TGeoTorus::Class())) {
189 return;
190 }
191 fShape = (TGeoTorus *)obj;
192 fRi = fShape->GetR();
193 fRmini = fShape->GetRmin();
194 fRmaxi = fShape->GetRmax();
195 fPhi1i = fShape->GetPhi1();
196 fDphii = fShape->GetDphi();
197 const char *sname = fShape->GetName();
198 if (!strcmp(sname, fShape->ClassName()))
199 fShapeName->SetText("-no_name");
200 else {
202 fNamei = sname;
203 }
204 fER->SetNumber(fRi);
211
212 if (fInit)
214 SetActive();
215}
216
217////////////////////////////////////////////////////////////////////////////////
218/// Check if shape drawing is delayed.
219
221{
222 return (fDelayed->GetState() == kButtonDown);
223}
224
225////////////////////////////////////////////////////////////////////////////////
226/// Slot for name.
227
229{
230 DoModified();
231}
232
233////////////////////////////////////////////////////////////////////////////////
234/// Slot for applying current settings.
235
237{
238 const char *name = fShapeName->GetText();
239 if (strcmp(name, fShape->GetName()))
241 Double_t r = fER->GetNumber();
244 Double_t phi = fEPhi1->GetNumber();
246 Double_t param[5];
247 param[0] = r;
248 param[1] = rmin;
249 param[2] = rmax;
250 param[3] = phi;
251 param[4] = dphi;
252 fShape->SetDimensions(param);
254 fUndo->SetEnabled();
256 if (fPad) {
258 TView *view = fPad->GetView();
259 if (!view) {
260 fShape->Draw();
261 fPad->GetView()->ShowAxis();
262 } else {
263 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(), fShape->GetDX(), fShape->GetDY(),
264 fShape->GetDZ());
265 Update();
266 }
267 } else
268 Update();
269 }
270}
271
272////////////////////////////////////////////////////////////////////////////////
273/// Slot for notifying modifications.
274
279
280////////////////////////////////////////////////////////////////////////////////
281/// Slot for undoing last operation.
282
294
295////////////////////////////////////////////////////////////////////////////////
296/// Slot for R.
297
299{
300 Double_t r = fER->GetNumber();
302 if (r < rmax) {
303 r = rmax;
304 fER->SetNumber(r);
305 }
306 DoModified();
307 if (!IsDelayed())
308 DoApply();
309}
310
311////////////////////////////////////////////////////////////////////////////////
312/// Slot for Rmin.
313
315{
318 if (rmin > rmax) {
319 rmin = rmax - 0.1;
321 }
322 DoModified();
323 if (!IsDelayed())
324 DoApply();
325}
326
327////////////////////////////////////////////////////////////////////////////////
328/// Slot for Rmax.
329
331{
332 Double_t r = fER->GetNumber();
335 if (rmax <= rmin) {
336 rmax = rmin + 0.1;
338 }
339 if (rmax > r) {
340 rmax = r;
342 }
343 DoModified();
344 if (!IsDelayed())
345 DoApply();
346}
347
348////////////////////////////////////////////////////////////////////////////////
349/// Slot for phi.
350
352{
353 Double_t phi = fEPhi1->GetNumber();
354 if (phi < 0 || phi > 360) {
355 phi = 0;
356 fEPhi1->SetNumber(phi);
357 }
358 DoModified();
359 if (!IsDelayed())
360 DoApply();
361}
362
363////////////////////////////////////////////////////////////////////////////////
364/// Slot for Dphi.
365
367{
369 if (dphi <= 0 || dphi > 360) {
370 dphi = 1;
372 }
373 DoModified();
374 if (!IsDelayed())
375 DoApply();
376}
@ 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
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
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
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
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
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: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)
UInt_t GetDefaultHeight() const override
@ 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:94
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
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.
TGTextButton * fApply
void DoRmax()
Slot for Rmax.
void DoR()
Slot for R.
void DoPhi1()
Slot for phi.
void DoRmin()
Slot for Rmin.
TGNumberEntry * fEDphi
void DoUndo()
Slot for undoing last operation.
void DoName()
Slot for name.
TGNumberEntry * fEPhi1
TGeoTorusEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for torus editor.
TGTextButton * fUndo
TGNumberEntry * fER
TGCheckButton * fDelayed
void DoDphi()
Slot for Dphi.
~TGeoTorusEditor() override
Destructor.
void SetModel(TObject *obj) override
Connect to the selected object.
void DoApply()
Slot for applying current settings.
TGNumberEntry * fERmin
void DoModified()
Slot for notifying modifications.
TGTextEntry * fShapeName
TGNumberEntry * fERmax
TGeoTorus * fShape
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:17
Double_t GetRmax() const
Definition TGeoTorus.h:75
static TClass * Class()
Double_t GetRmin() const
Definition TGeoTorus.h:74
Double_t GetR() const
Definition TGeoTorus.h:73
Double_t GetPhi1() const
Definition TGeoTorus.h:76
void SetDimensions(Double_t *param) override
Set torus dimensions starting from a list.
void ComputeBBox() override
Compute bounding box of the torus.
Double_t GetDphi() const
Definition TGeoTorus.h:77
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