Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGeoHypeEditor.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 TGeoHypeEditor
13\ingroup Geometry_builder
14
15Editor for a TGeoHype.
16
17\image html geom_hype_pic.png
18
19\image html geom_hype_ed.png
20
21*/
22
23#include "TGeoHypeEditor.h"
24#include "TGeoTabManager.h"
25#include "TGeoHype.h"
26#include "TGeoManager.h"
27#include "TVirtualGeoPainter.h"
28#include "TVirtualPad.h"
29#include "TView.h"
30#include "TMath.h"
31#include "TGButton.h"
32#include "TGTextEntry.h"
33#include "TGNumberEntry.h"
34#include "TGLabel.h"
35
36
38
39////////////////////////////////////////////////////////////////////////////////
40/// Constructor for Hype editor
41
43 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
44{
45 fShape = nullptr;
46 fRini = fRouti = fStIni = fStOuti = 0.0;
47 fNamei = "";
50
51 // TextEntry for shape name
52 MakeTitle("Name");
53 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kHYPE_NAME);
55 fShapeName->SetToolTipText("Enter the hyperboloid name");
56 fShapeName->Associate(this);
58
60 MakeTitle("Dimensions");
61 // Number entry for Rin
63 f1->AddFrame(new TGLabel(f1, "Rin"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
64 fERin = new TGNumberEntry(f1, 0., 5, kHYPE_RIN);
68 nef->SetToolTipText("Enter the inner radius ");
69 fERin->Associate(this);
70 f1->AddFrame(fERin, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
71 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
72
73 // Number entry for Rout
74 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
75 f1->AddFrame(new TGLabel(f1, "Rout"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
76 fERout = new TGNumberEntry(f1, 0., 5, kHYPE_ROUT);
80 nef->SetToolTipText("Enter the outer radius");
81 fERout->Associate(this);
82 f1->AddFrame(fERout, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
83 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
84
85 // Number entry for Dz
86 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
87 f1->AddFrame(new TGLabel(f1, "Dz"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
88 fEDz = new TGNumberEntry(f1, 0., 5, kHYPE_DZ);
92 nef->SetToolTipText("Enter the half-length in Dz");
93 fEDz->Associate(this);
94 f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
95 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
96
97 // Number entry for StIn.
98 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
99 f1->AddFrame(new TGLabel(f1, "StIn"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
100 fEStIn = new TGNumberEntry(f1, 0., 5, kHYPE_STIN);
103 nef->SetToolTipText("Enter the stereo angle for inner surface");
104 fEStIn->Associate(this);
105 f1->AddFrame(fEStIn, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
106 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
107
108 // Number entry for StOut.
109 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
110 f1->AddFrame(new TGLabel(f1, "StOut"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
111 fEStOut = new TGNumberEntry(f1, 0., 5, kHYPE_STOUT);
115 nef->SetToolTipText("Enter the stereo angle for outer surface");
116 fEStOut->Associate(this);
117 f1->AddFrame(fEStOut, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
118 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
119
120 // Delayed draw
122 fDelayed = new TGCheckButton(f1, "Delayed draw");
123 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
124 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
125
126 // Buttons
127 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
128 fApply = new TGTextButton(f1, "Apply");
129 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
130 fApply->Associate(this);
131 fUndo = new TGTextButton(f1, "Undo");
132 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
133 fUndo->Associate(this);
134 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
136}
137
138////////////////////////////////////////////////////////////////////////////////
139/// Destructor
140
142{
144 TIter next(GetList());
145 while ((el = (TGFrameElement *)next())) {
146 if (el->fFrame->IsComposite())
148 }
149 Cleanup();
150}
151
152////////////////////////////////////////////////////////////////////////////////
153/// Connect signals to slots.
154
156{
157 fApply->Connect("Clicked()", "TGeoHypeEditor", this, "DoApply()");
158 fUndo->Connect("Clicked()", "TGeoHypeEditor", this, "DoUndo()");
159 fShapeName->Connect("TextChanged(const char *)", "TGeoHypeEditor", this, "DoModified()");
160 fERin->Connect("ValueSet(Long_t)", "TGeoHypeEditor", this, "DoRin()");
161 fERout->Connect("ValueSet(Long_t)", "TGeoHypeEditor", this, "DoRout()");
162 fEDz->Connect("ValueSet(Long_t)", "TGeoHypeEditor", this, "DoDz()");
163 fEStIn->Connect("ValueSet(Long_t)", "TGeoHypeEditor", this, "DoStIn()");
164 fEStOut->Connect("ValueSet(Long_t)", "TGeoHypeEditor", this, "DoStOut()");
165 fERin->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoHypeEditor", this, "DoModified()");
166 fERout->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoHypeEditor", this, "DoModified()");
167 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoHypeEditor", this, "DoModified()");
168 fEStIn->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoHypeEditor", this, "DoModified()");
169 fEStOut->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoHypeEditor", this, "DoModified()");
170 fInit = kFALSE;
171}
172
173////////////////////////////////////////////////////////////////////////////////
174/// Connect to the selected object.
175
177{
178 if (obj == nullptr || (obj->IsA() != TGeoHype::Class())) {
180 return;
181 }
182 fShape = (TGeoHype *)obj;
183 fRini = fShape->GetRmin();
184 fRouti = fShape->GetRmax();
185 fDzi = fShape->GetDz();
186 fStIni = fShape->GetStIn();
188 const char *sname = fShape->GetName();
189 if (!strcmp(sname, fShape->ClassName()))
190 fShapeName->SetText("-no_name");
191 else {
193 fNamei = sname;
194 }
202
203 if (fInit)
205 SetActive();
206}
207
208////////////////////////////////////////////////////////////////////////////////
209/// Check if shape drawing is delayed.
210
212{
213 return (fDelayed->GetState() == kButtonDown);
214}
215
216////////////////////////////////////////////////////////////////////////////////
217/// Slot for name.
218
220{
221 DoModified();
222}
223
224////////////////////////////////////////////////////////////////////////////////
225/// Slot for applying current settings.
226
228{
229 const char *name = fShapeName->GetText();
230 if (strcmp(name, fShape->GetName()))
239 if ((dz <= 0) || (rin < 0) || (rin > rout) ||
240 (rin * rin + tin * tin * dz * dz > rout * rout + tout * tout * dz * dz)) {
241 fUndo->SetEnabled();
243 return;
244 }
245 Double_t param[5];
246 param[0] = dz;
247 param[1] = rin;
248 param[2] = stin;
249 param[3] = rout;
250 param[4] = stout;
251 fShape->SetDimensions(param);
253 fUndo->SetEnabled();
255 if (fPad) {
257 TView *view = fPad->GetView();
258 if (!view) {
259 fShape->Draw();
260 fPad->GetView()->ShowAxis();
261 } else {
262 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(), fShape->GetDX(), fShape->GetDY(),
263 fShape->GetDZ());
264 Update();
265 }
266 } else
267 Update();
268 }
269}
270
271////////////////////////////////////////////////////////////////////////////////
272/// Slot for notifying modifications.
273
278
279////////////////////////////////////////////////////////////////////////////////
280/// Slot for undoing last operation.
281
293
294////////////////////////////////////////////////////////////////////////////////
295/// Slot for Rin.
296
298{
306 if (rin < 0) {
307 rin = 0;
309 }
310 Double_t rinmax = TMath::Sqrt((rout * rout + tout * tout * dz * dz) / (tin * tin * dz * dz));
312 if (rin > rinmax) {
313 rin = rinmax - 1.e-6;
315 }
316 DoModified();
317 if (!IsDelayed())
318 DoApply();
319}
320
321////////////////////////////////////////////////////////////////////////////////
322/// Slot for Rout.
323
343
344////////////////////////////////////////////////////////////////////////////////
345/// Slot for Z.
346
348{
354 if (TMath::Abs(stin - stout) < 1.e-6) {
355 stin = stout + 1.;
357 }
360 if (dz <= 0) {
361 dz = 0.1;
362 fEDz->SetNumber(dz);
363 }
364 Double_t dzmax = TMath::Sqrt((rout * rout - rin * rin) / (tin * tin - tout * tout));
365 if (dz > dzmax) {
366 dz = dzmax;
367 fEDz->SetNumber(dz);
368 }
369 DoModified();
370 if (!IsDelayed())
371 DoApply();
372}
373
374////////////////////////////////////////////////////////////////////////////////
375/// Slot for StIn.
376
378{
384 if (stin >= 90) {
385 stin = 89.;
387 }
390 Double_t tinmax = TMath::Sqrt(tout * tout + (rout * rout - rin * rin) / (dz * dz));
391 if (tin > tinmax) {
392 tin = tinmax - 1.e-6;
395 }
396 DoModified();
397 if (!IsDelayed())
398 DoApply();
399}
400
401////////////////////////////////////////////////////////////////////////////////
402/// Slot for StOut.
403
405{
411 if (stout > 90) {
412 stout = 89;
414 }
417 Double_t tinmin = TMath::Sqrt((rout * rout - rin * rin) / (dz * dz));
418 if (tin < tinmin) {
419 tin = tinmin;
422 }
424 if (tout < toutmin) {
425 tout = toutmin + 1.e-6;
428 }
429 DoModified();
430 if (!IsDelayed())
431 DoApply();
432}
@ 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 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
ETGeoHypeWid
@ kHYPE_APPLY
@ kHYPE_UNDO
@ kHYPE_NAME
@ kHYPE_DZ
@ kHYPE_RIN
@ kHYPE_STOUT
@ kHYPE_STIN
@ kHYPE_ROUT
R__EXTERN TGeoManager * gGeoManager
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.
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.
void DoUndo()
Slot for undoing last operation.
TGTextEntry * fShapeName
Bool_t IsDelayed() const
Check if shape drawing is delayed.
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGeoHype * fShape
TGCheckButton * fDelayed
TGNumberEntry * fEStIn
void DoRin()
Slot for Rin.
TGTextButton * fUndo
void DoRout()
Slot for Rout.
void DoModified()
Slot for notifying modifications.
TGNumberEntry * fEStOut
void DoStOut()
Slot for StOut.
void SetModel(TObject *obj) override
Connect to the selected object.
TGTextButton * fApply
TGNumberEntry * fERout
void DoName()
Slot for name.
TGNumberEntry * fEDz
void DoDz()
Slot for Z.
void DoStIn()
Slot for StIn.
Bool_t fIsShapeEditable
void DoApply()
Slot for applying current settings.
TGNumberEntry * fERin
TGeoHypeEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for Hype editor.
~TGeoHypeEditor() override
Destructor.
A hyperboloid is represented as a solid limited by two planes perpendicular to the Z axis (top and bo...
Definition TGeoHype.h:17
static TClass * Class()
void ComputeBBox() override
Compute bounding box of the hyperboloid.
Definition TGeoHype.cxx:161
void SetDimensions(Double_t *param) override
Set dimensions of the hyperboloid starting from an array.
Definition TGeoHype.cxx:880
Double_t GetStIn() const
Definition TGeoHype.h:72
Double_t GetStOut() const
Definition TGeoHype.h:73
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.
virtual Double_t GetRmin() const
Definition TGeoTube.h:72
virtual Double_t GetDz() const
Definition TGeoTube.h:74
virtual Double_t GetRmax() const
Definition TGeoTube.h:73
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
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:251
Double_t ATan(Double_t)
Returns the principal value of the arc tangent of x, expressed in radians.
Definition TMath.h:651
constexpr Double_t DegToRad()
Conversion from degree to radian: .
Definition TMath.h:82
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:673
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:199
Double_t Tan(Double_t)
Returns the tangent of an angle of x radians.
Definition TMath.h:611
constexpr Double_t RadToDeg()
Conversion from radian to degree: .
Definition TMath.h:75
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:124