Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGeoSphereEditor.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 TGeoSphereEditor
13\ingroup Geometry_builder
14
15Editor for a TGeoSphere.
16
17\image html geom_sphe_pic.png
18
19\image html geom_sphe_ed.png
20
21*/
22
23#include "TGeoSphereEditor.h"
24#include "TGeoTabManager.h"
25#include "TGeoSphere.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#include "TGDoubleSlider.h"
35
36
50
51////////////////////////////////////////////////////////////////////////////////
52/// Constructor for sphere editor
53
55 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
56{
57 fShape = nullptr;
59 fNamei = "";
62 fLock = kFALSE;
63
64 // TextEntry for shape name
65 MakeTitle("Name");
66 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kSPHERE_NAME);
68 fShapeName->SetToolTipText("Enter the sphere name");
69 fShapeName->Associate(this);
71
73 MakeTitle("Sphere dimensions");
75 // Number entry for rmin
77 f1->AddFrame(new TGLabel(f1, "Rmin"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
78 fERmin = new TGNumberEntry(f1, 0., 5, kSPHERE_RMIN);
81 nef->SetToolTipText("Enter the inner radius");
82 fERmin->Associate(this);
84 f1->AddFrame(fERmin, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
85 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
86
87 // Number entry for Rmax
89 f1->AddFrame(new TGLabel(f1, "Rmax"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
90 fERmax = new TGNumberEntry(f1, 0., 5, kSPHERE_RMAX);
93 nef->SetToolTipText("Enter the outer radius");
94 fERmax->Associate(this);
96 f1->AddFrame(fERmax, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
97 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
98 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
99
100 MakeTitle("Phi/theta range");
101 TGCompositeFrame *f11 = new TGCompositeFrame(this, 150, 200, kHorizontalFrame);
103 // Vertical slider
104 fSPhi = new TGDoubleVSlider(compxyz, 140);
105 fSPhi->SetRange(0., 720.);
106 compxyz->AddFrame(fSPhi, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 2, 2, 4, 4));
107 f1 = new TGCompositeFrame(compxyz, 50, 200, kVerticalFrame);
108 f1->AddFrame(new TGLabel(f1, "Phi min."), new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2));
109 fEPhi1 = new TGNumberEntry(f1, 0., 5, kSPHERE_PHI1);
113 nef->SetToolTipText("Enter the phi1 value");
114 fEPhi1->Associate(this);
115 f1->AddFrame(fEPhi1, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
116
117 fEPhi2 = new TGNumberEntry(f1, 0., 5, kSPHERE_PHI2);
121 nef->SetToolTipText("Enter the phi2 value");
122 fEPhi2->Associate(this);
124 f1->AddFrame(fEPhi2, new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
125 f1->AddFrame(new TGLabel(f1, "Phi max."), new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2));
126 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
127
128 compxyz->Resize(75, 150);
129 f11->AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
130
132 // Vertical slider
133 fSTheta = new TGDoubleVSlider(compxyz, 140);
134 fSTheta->SetRange(0., 180.);
135 compxyz->AddFrame(fSTheta, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 2, 2, 4, 4));
136 f1 = new TGCompositeFrame(compxyz, 50, 200, kVerticalFrame);
137 f1->AddFrame(new TGLabel(f1, "Theta min."), new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2));
142 nef->SetToolTipText("Enter the theta1 value");
143 fETheta1->Associate(this);
144 f1->AddFrame(fETheta1, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
145
150 nef->SetToolTipText("Enter the theta2 value");
151 fETheta2->Associate(this);
152 f1->AddFrame(fETheta2, new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
153 f1->AddFrame(new TGLabel(f1, "Theta max."), new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2));
154 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
155
156 compxyz->Resize(75, 150);
157 f11->AddFrame(compxyz, new TGLayoutHints(kLHintsRight, 0, 0, 0, 0));
158
159 AddFrame(f11, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
160
161 // Delayed draw
163 fDelayed = new TGCheckButton(f1, "Delayed draw");
164 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
165 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
166
167 // Buttons
168 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
169 fApply = new TGTextButton(f1, "Apply");
170 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
171 fApply->Associate(this);
172 fUndo = new TGTextButton(f1, "Undo");
173 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
174 fUndo->Associate(this);
175 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
177}
178
179////////////////////////////////////////////////////////////////////////////////
180/// Destructor.
181
183{
185 TIter next(GetList());
186 while ((el = (TGFrameElement *)next())) {
187 if (el->fFrame->IsComposite())
189 }
190 Cleanup();
191}
192
193////////////////////////////////////////////////////////////////////////////////
194/// Connect signals to slots.
195
197{
198 fApply->Connect("Clicked()", "TGeoSphereEditor", this, "DoApply()");
199 fUndo->Connect("Clicked()", "TGeoSphereEditor", this, "DoUndo()");
200 fShapeName->Connect("TextChanged(const char *)", "TGeoSphereEditor", this, "DoModified()");
201 fERmin->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoRmin()");
202 fERmax->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoRmax()");
203 fEPhi1->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoPhi1()");
204 fEPhi2->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoPhi2()");
205 fETheta1->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoTheta1()");
206 fETheta2->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoTheta2()");
207 fSPhi->Connect("PositionChanged()", "TGeoSphereEditor", this, "DoPhi()");
208 fSTheta->Connect("PositionChanged()", "TGeoSphereEditor", this, "DoTheta()");
209 fInit = kFALSE;
210}
211
212////////////////////////////////////////////////////////////////////////////////
213/// Connect to a given sphere.
214
246
247////////////////////////////////////////////////////////////////////////////////
248/// Check if shape drawing is delayed.
249
251{
252 return (fDelayed->GetState() == kButtonDown);
253}
254
255////////////////////////////////////////////////////////////////////////////////
256/// Slot for name.
257
259{
260 DoModified();
261}
262
263////////////////////////////////////////////////////////////////////////////////
264/// Slot for applying modifications.
265
267{
268 const char *name = fShapeName->GetText();
269 if (strcmp(name, fShape->GetName()))
275 if ((phi2 - phi1) > 360.001) {
276 phi1 = 0.;
277 phi2 = 360.;
280 fLock = kTRUE;
282 fLock = kFALSE;
283 }
288 fUndo->SetEnabled();
290 if (fPad) {
292 fShape->Draw();
293 fPad->GetView()->ShowAxis();
294 } else
295 Update();
296 }
297}
298
299////////////////////////////////////////////////////////////////////////////////
300/// Slot for signaling modifications.
301
306
307////////////////////////////////////////////////////////////////////////////////
308/// Slot for undoing last operation.
309
324
325////////////////////////////////////////////////////////////////////////////////
326/// Slot for Rmin.
327
329{
332 if (rmin <= 0.) {
333 rmin = 0.;
335 }
336 if (rmin >= rmax) {
337 rmin = rmax - 0.1;
339 }
340 DoModified();
341 if (!IsDelayed())
342 DoApply();
343}
344
345////////////////////////////////////////////////////////////////////////////////
346/// Slot for Rmax.
347
349{
352 if (rmax <= 0.) {
353 rmax = 0.1;
355 }
356 if (rmax < rmin + 1.e-10) {
357 rmax = rmin + 0.1;
359 }
360 DoModified();
361 if (!IsDelayed())
362 DoApply();
363}
364
365////////////////////////////////////////////////////////////////////////////////
366/// Slot for phi1.
367
369{
372 if (phi1 > 360 - 1.e-10) {
373 phi1 = 0.;
375 }
376 if (phi2 < phi1 + 1.e-10) {
377 phi1 = phi2 - 0.1;
379 }
380 if (!fLock) {
381 DoModified();
382 fLock = kTRUE;
384 } else
385 fLock = kFALSE;
386 if (!IsDelayed())
387 DoApply();
388}
389
390////////////////////////////////////////////////////////////////////////////////
391/// Slot for phi2.
392
394{
397 if (phi2 - phi1 > 360.) {
398 phi2 -= 360.;
400 }
401 if (phi2 < phi1 + 1.e-10) {
402 phi2 = phi1 + 0.1;
404 }
405 if (!fLock) {
406 DoModified();
407 fLock = kTRUE;
409 } else
410 fLock = kFALSE;
411 if (!IsDelayed())
412 DoApply();
413}
414
415////////////////////////////////////////////////////////////////////////////////
416/// Slot for phi slider.
417
419{
420 if (!fLock) {
421 DoModified();
422 fLock = kTRUE;
424 fLock = kTRUE;
426 } else
427 fLock = kFALSE;
428 if (!IsDelayed())
429 DoApply();
430}
431
432////////////////////////////////////////////////////////////////////////////////
433/// Slot for theta1.
434
436{
439 if (theta2 < theta1 + 1.e-10) {
440 theta2 = theta1 + 0.1;
442 }
443 if (!fLock) {
444 DoModified();
445 fLock = kTRUE;
447 } else
448 fLock = kFALSE;
449 if (!IsDelayed())
450 DoApply();
451}
452
453////////////////////////////////////////////////////////////////////////////////
454/// Slot for theta2.
455
457{
460 if (theta2 < theta1 + 1.e-10) {
461 theta1 = theta2 - 0.1;
463 }
464 if (!fLock) {
465 DoModified();
466 fLock = kTRUE;
468 } else
469 fLock = kFALSE;
470 if (!IsDelayed())
471 DoApply();
472}
473
474////////////////////////////////////////////////////////////////////////////////
475/// Slot for theta slider.
476
478{
479 if (!fLock) {
480 DoModified();
481 fLock = kTRUE;
483 fLock = kTRUE;
485 } else
486 fLock = kFALSE;
487 if (!IsDelayed())
488 DoApply();
489}
@ kRaisedFrame
Definition GuiTypes.h:384
@ kSunkenFrame
Definition GuiTypes.h:383
@ kVerticalFrame
Definition GuiTypes.h:381
@ kFixedWidth
Definition GuiTypes.h:387
@ kFitWidth
Definition GuiTypes.h:386
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kOwnBackground
Definition GuiTypes.h:391
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
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
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
R__EXTERN TGeoManager * gGeoManager
ETGeoSphereWid
@ kSPHERE_UNDO
@ kSPHERE_PHI1
@ kSPHERE_THETA1
@ kSPHERE_APPLY
@ kSPHERE_THETA
@ kSPHERE_NAME
@ kSPHERE_THETA2
@ kSPHERE_PHI2
@ kSPHERE_PHI
@ kSPHERE_RMIN
@ kSPHERE_RMAX
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 Float_t GetMaxPosition() const
virtual Float_t GetMinPosition() const
virtual void SetRange(Float_t min, Float_t max)
virtual void SetPosition(Float_t min, Float_t max)
Dragging the slider will generate the event:
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
@ 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
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.
TGNumberEntry * fEPhi2
TGCheckButton * fDelayed
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGeoSphereEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for sphere editor.
TGNumberEntry * fERmax
void DoTheta1()
Slot for theta1.
void DoRmin()
Slot for Rmin.
TGNumberEntry * fETheta1
TGNumberEntry * fETheta2
void DoName()
Slot for name.
TGNumberEntry * fERmin
void DoPhi2()
Slot for phi2.
TGDoubleVSlider * fSPhi
Bool_t IsDelayed() const
Check if shape drawing is delayed.
void DoTheta()
Slot for theta slider.
void DoModified()
Slot for signaling modifications.
void DoTheta2()
Slot for theta2.
TGTextEntry * fShapeName
void DoPhi()
Slot for phi slider.
TGeoSphere * fShape
void SetModel(TObject *obj) override
Connect to a given sphere.
TGNumberEntry * fEPhi1
TGDoubleVSlider * fSTheta
void DoPhi1()
Slot for phi1.
void DoRmax()
Slot for Rmax.
virtual void DoUndo()
Slot for undoing last operation.
TGTextButton * fUndo
~TGeoSphereEditor() override
Destructor.
virtual void DoApply()
Slot for applying modifications.
TGTextButton * fApply
TGeoSphere are not just balls having internal and external radii, but sectors of a sphere having defi...
Definition TGeoSphere.h:17
Double_t GetPhi1() const
Definition TGeoSphere.h:76
void SetSphDimensions(Double_t rmin, Double_t rmax, Double_t theta1, Double_t theta2, Double_t phi1, Double_t phi2)
Set spherical segment dimensions.
Double_t GetPhi2() const
Definition TGeoSphere.h:77
virtual Double_t GetRmin() const
Definition TGeoSphere.h:72
void ComputeBBox() override
compute bounding box of the sphere
Double_t GetTheta2() const
Definition TGeoSphere.h:75
virtual Double_t GetRmax() const
Definition TGeoSphere.h:73
Double_t GetTheta1() const
Definition TGeoSphere.h:74
static TClass * Class()
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
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 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
virtual Bool_t IsPaintingShape() const =0
virtual TView * GetView() const =0
TF1 * f1
Definition legend1.C:11