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
46};
47
48////////////////////////////////////////////////////////////////////////////////
49/// Constructor for torus editor
50
52 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
53{
54 fShape = 0;
55 fRi = fRmini = fRmaxi = fPhi1i = fDphii = 0.0;
56 fNamei = "";
59
60 // TextEntry for shape name
61 MakeTitle("Name");
62 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTORUS_NAME);
64 fShapeName->SetToolTipText("Enter the torus name");
65 fShapeName->Associate(this);
67
68 TGTextEntry *nef;
69 MakeTitle("Dimensions");
70 // Number entry for R.
72 f1->AddFrame(new TGLabel(f1, "R"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
73 fER = new TGNumberEntry(f1, 0., 5, kTORUS_R);
76 nef = (TGTextEntry *)fER->GetNumberEntry();
77 nef->SetToolTipText("Enter the axial radius R");
78 fER->Associate(this);
79 f1->AddFrame(fER, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
80 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
81
82 // Number entry for rmin.
83 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
84 f1->AddFrame(new TGLabel(f1, "Rmin"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
85 fERmin = new TGNumberEntry(f1, 0., 5, kTORUS_RMIN);
89 nef->SetToolTipText("Enter the inner radius Rmin");
90 fERmin->Associate(this);
91 f1->AddFrame(fERmin, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
92 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
93
94 // Number entry for rmax
95 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
96 f1->AddFrame(new TGLabel(f1, "Rmax"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
97 fERmax = new TGNumberEntry(f1, 0., 5, kTORUS_RMAX);
101 nef->SetToolTipText("Enter the outer radius Rmax");
102 fERmax->Associate(this);
103 f1->AddFrame(fERmax, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
104 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
105
106 // Number entry for Phi1
107 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
108 f1->AddFrame(new TGLabel(f1, "Phi1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
109 fEPhi1 = new TGNumberEntry(f1, 0., 5, kTORUS_PHI1);
113 nef->SetToolTipText("Enter the starting phi angle[deg]");
114 fEPhi1->Associate(this);
115 f1->AddFrame(fEPhi1, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
116 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
117
118 // Number entry for Dphi
119 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
120 f1->AddFrame(new TGLabel(f1, "Dphi"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
121 fEDphi = new TGNumberEntry(f1, 0., 5, kTORUS_DPHI);
125 nef->SetToolTipText("Enter the extent phi Dphi [deg]");
126 fEDphi->Associate(this);
127 f1->AddFrame(fEDphi, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
128 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
129
130 // Delayed draw
132 fDelayed = new TGCheckButton(f1, "Delayed draw");
133 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
134 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
135
136 // Buttons
137 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
138 fApply = new TGTextButton(f1, "Apply");
139 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
140 fApply->Associate(this);
141 fUndo = new TGTextButton(f1, "Undo");
142 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
143 fUndo->Associate(this);
144 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
146}
147
148////////////////////////////////////////////////////////////////////////////////
149/// Destructor
150
152{
153 TGFrameElement *el;
154 TIter next(GetList());
155 while ((el = (TGFrameElement *)next())) {
156 if (el->fFrame->IsComposite())
158 }
159 Cleanup();
160}
161
162////////////////////////////////////////////////////////////////////////////////
163/// Connect signals to slots.
164
166{
167 fApply->Connect("Clicked()", "TGeoTorusEditor", this, "DoApply()");
168 fUndo->Connect("Clicked()", "TGeoTorusEditor", this, "DoUndo()");
169 fShapeName->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
170 fER->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoR()");
171 fERmin->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoRmin()");
172 fERmax->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoRmax()");
173 fEPhi1->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoPhi1()");
174 fEDphi->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoDphi()");
175 fER->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
176 fERmin->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
177 fERmax->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
178 fEPhi1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
179 fEDphi->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()");
180 fInit = kFALSE;
181}
182
183////////////////////////////////////////////////////////////////////////////////
184/// Connect to the selected object.
185
187{
188 if (obj == 0 || (obj->IsA() != TGeoTorus::Class())) {
190 return;
191 }
192 fShape = (TGeoTorus *)obj;
193 fRi = fShape->GetR();
194 fRmini = fShape->GetRmin();
195 fRmaxi = fShape->GetRmax();
196 fPhi1i = fShape->GetPhi1();
197 fDphii = fShape->GetDphi();
198 const char *sname = fShape->GetName();
199 if (!strcmp(sname, fShape->ClassName()))
200 fShapeName->SetText("-no_name");
201 else {
202 fShapeName->SetText(sname);
203 fNamei = sname;
204 }
205 fER->SetNumber(fRi);
212
213 if (fInit)
215 SetActive();
216}
217
218////////////////////////////////////////////////////////////////////////////////
219/// Check if shape drawing is delayed.
220
222{
223 return (fDelayed->GetState() == kButtonDown);
224}
225
226////////////////////////////////////////////////////////////////////////////////
227/// Slot for name.
228
230{
231 DoModified();
232}
233
234////////////////////////////////////////////////////////////////////////////////
235/// Slot for applying current settings.
236
238{
239 const char *name = fShapeName->GetText();
240 if (strcmp(name, fShape->GetName()))
242 Double_t r = fER->GetNumber();
243 Double_t rmax = fERmax->GetNumber();
244 Double_t rmin = fERmin->GetNumber();
245 Double_t phi = fEPhi1->GetNumber();
246 Double_t dphi = fEDphi->GetNumber();
247 Double_t param[5];
248 param[0] = r;
249 param[1] = rmin;
250 param[2] = rmax;
251 param[3] = phi;
252 param[4] = dphi;
253 fShape->SetDimensions(param);
255 fUndo->SetEnabled();
257 if (fPad) {
259 TView *view = fPad->GetView();
260 if (!view) {
261 fShape->Draw();
262 fPad->GetView()->ShowAxis();
263 } else {
264 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(), fShape->GetDX(), fShape->GetDY(),
265 fShape->GetDZ());
266 Update();
267 }
268 } else
269 Update();
270 }
271}
272
273////////////////////////////////////////////////////////////////////////////////
274/// Slot for notifying modifications.
275
277{
279}
280
281////////////////////////////////////////////////////////////////////////////////
282/// Slot for undoing last operation.
283
285{
286 fER->SetNumber(fRi);
291 DoApply();
294}
295
296////////////////////////////////////////////////////////////////////////////////
297/// Slot for R.
298
300{
301 Double_t r = fER->GetNumber();
302 Double_t rmax = fERmax->GetNumber();
303 if (r < rmax) {
304 r = rmax;
305 fER->SetNumber(r);
306 }
307 DoModified();
308 if (!IsDelayed())
309 DoApply();
310}
311
312////////////////////////////////////////////////////////////////////////////////
313/// Slot for Rmin.
314
316{
317 Double_t rmin = fERmin->GetNumber();
318 Double_t rmax = fERmax->GetNumber();
319 if (rmin > rmax) {
320 rmin = rmax - 0.1;
321 fERmin->SetNumber(rmin);
322 }
323 DoModified();
324 if (!IsDelayed())
325 DoApply();
326}
327
328////////////////////////////////////////////////////////////////////////////////
329/// Slot for Rmax.
330
332{
333 Double_t r = fER->GetNumber();
334 Double_t rmin = fERmin->GetNumber();
335 Double_t rmax = fERmax->GetNumber();
336 if (rmax <= rmin) {
337 rmax = rmin + 0.1;
338 fERmax->SetNumber(rmax);
339 }
340 if (rmax > r) {
341 rmax = r;
342 fERmax->SetNumber(rmax);
343 }
344 DoModified();
345 if (!IsDelayed())
346 DoApply();
347}
348
349////////////////////////////////////////////////////////////////////////////////
350/// Slot for phi.
351
353{
354 Double_t phi = fEPhi1->GetNumber();
355 if (phi < 0 || phi > 360) {
356 phi = 0;
357 fEPhi1->SetNumber(phi);
358 }
359 DoModified();
360 if (!IsDelayed())
361 DoApply();
362}
363
364////////////////////////////////////////////////////////////////////////////////
365/// Slot for Dphi.
366
368{
369 Double_t dphi = fEDphi->GetNumber();
370 if (dphi <= 0 || dphi > 360) {
371 dphi = 1;
372 fEDphi->SetNumber(dphi);
373 }
374 DoModified();
375 if (!IsDelayed())
376 DoApply();
377}
@ 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:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
@ 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: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)
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:95
virtual Double_t GetDX() const
Definition TGeoBBox.h:77
virtual Double_t GetDZ() const
Definition TGeoBBox.h:79
virtual Double_t GetDY() const
Definition TGeoBBox.h:78
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.
Editor for a TGeoTorus.
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: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:207
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