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
50TGeoTorusEditor::TGeoTorusEditor(const TGWindow *p, Int_t width, Int_t height, UInt_t options, Pixel_t back)
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);
62 fShapeName->Resize(135, fShapeName->GetDefaultHeight());
63 fShapeName->SetToolTipText("Enter the torus name");
64 fShapeName->Associate(this);
66
67 TGTextEntry *nef;
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);
74 fER->Resize(100, fER->GetDefaultHeight());
75 nef = (TGTextEntry *)fER->GetNumberEntry();
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);
86 fERmin->Resize(100, fERmin->GetDefaultHeight());
87 nef = (TGTextEntry *)fERmin->GetNumberEntry();
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);
98 fERmax->Resize(100, fERmax->GetDefaultHeight());
99 nef = (TGTextEntry *)fERmax->GetNumberEntry();
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);
110 fEPhi1->Resize(100, fEPhi1->GetDefaultHeight());
111 nef = (TGTextEntry *)fEPhi1->GetNumberEntry();
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);
122 fEDphi->Resize(100, fEDphi->GetDefaultHeight());
123 nef = (TGTextEntry *)fEDphi->GetNumberEntry();
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));
144 fUndo->SetSize(fApply->GetSize());
145}
146
147////////////////////////////////////////////////////////////////////////////////
148/// Destructor
149
151{
152 TGFrameElement *el;
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 {
201 fShapeName->SetText(sname);
202 fNamei = sname;
203 }
204 fER->SetNumber(fRi);
205 fERmin->SetNumber(fRmini);
206 fERmax->SetNumber(fRmaxi);
207 fEPhi1->SetNumber(fPhi1i);
208 fEDphi->SetNumber(fDphii);
209 fApply->SetEnabled(kFALSE);
210 fUndo->SetEnabled(kFALSE);
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()))
240 fShape->SetName(name);
241 Double_t r = fER->GetNumber();
242 Double_t rmax = fERmax->GetNumber();
243 Double_t rmin = fERmin->GetNumber();
244 Double_t phi = fEPhi1->GetNumber();
245 Double_t dphi = fEDphi->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);
253 fShape->ComputeBBox();
254 fUndo->SetEnabled();
255 fApply->SetEnabled(kFALSE);
256 if (fPad) {
257 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
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
276{
277 fApply->SetEnabled();
278}
279
280////////////////////////////////////////////////////////////////////////////////
281/// Slot for undoing last operation.
282
284{
285 fER->SetNumber(fRi);
286 fERmin->SetNumber(fRmini);
287 fERmax->SetNumber(fRmaxi);
288 fEPhi1->SetNumber(fPhi1i);
289 fEDphi->SetNumber(fDphii);
290 DoApply();
291 fUndo->SetEnabled(kFALSE);
292 fApply->SetEnabled(kFALSE);
293}
294
295////////////////////////////////////////////////////////////////////////////////
296/// Slot for R.
297
299{
300 Double_t r = fER->GetNumber();
301 Double_t rmax = fERmax->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{
316 Double_t rmin = fERmin->GetNumber();
317 Double_t rmax = fERmax->GetNumber();
318 if (rmin > rmax) {
319 rmin = rmax - 0.1;
320 fERmin->SetNumber(rmin);
321 }
322 DoModified();
323 if (!IsDelayed())
324 DoApply();
325}
326
327////////////////////////////////////////////////////////////////////////////////
328/// Slot for Rmax.
329
331{
332 Double_t r = fER->GetNumber();
333 Double_t rmin = fERmin->GetNumber();
334 Double_t rmax = fERmax->GetNumber();
335 if (rmax <= rmin) {
336 rmax = rmin + 0.1;
337 fERmax->SetNumber(rmax);
338 }
339 if (rmax > r) {
340 rmax = r;
341 fERmax->SetNumber(rmax);
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{
368 Double_t dphi = fEDphi->GetNumber();
369 if (dphi <= 0 || dphi > 360) {
370 dphi = 1;
371 fEDphi->SetNumber(dphi);
372 }
373 DoModified();
374 if (!IsDelayed())
375 DoApply();
376}
@ kSunkenFrame
Definition GuiTypes.h:384
@ kVerticalFrame
Definition GuiTypes.h:382
@ kFixedWidth
Definition GuiTypes.h:388
@ kHorizontalFrame
Definition GuiTypes.h:383
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
ROOT::R::TRInterface & r
Definition Object.C:4
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kButtonDown
Definition TGButton.h:54
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsLeft
Definition TGLayout.h:24
char name[80]
Definition TGX11.cxx:148
externTGeoManager * gGeoManager
ETGeoTorusWid
@ kTORUS_DPHI
@ kTORUS_RMAX
@ kTORUS_APPLY
@ kTORUS_RMIN
@ kTORUS_PHI1
@ kTORUS_R
@ kTORUS_UNDO
@ kTORUS_NAME
Selects different options.
Definition TGButton.h:264
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
TGFrame * fFrame
Definition TGLayout.h:112
virtual Bool_t IsComposite() const
Definition TGFrame.h:214
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.
@ 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
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
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
void Update() override
Override Update from TGedFrame as fGedEditor can be null.
TVirtualPad * fPad
TGeoGedFrame(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor.
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
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.
static TClass * Class()
Mother of all ROOT objects.
Definition TObject.h:42
virtual TClass * IsA() const
Definition TObject.h:248
See TView3D.
Definition TView.h:25
virtual void SetRange(const Double_t *min, const Double_t *max)=0
TF1 * f1
Definition legend1.C:11