Logo ROOT   6.18/05
Reference Guide
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 "TPad.h"
29#include "TView.h"
30#include "TGTab.h"
31#include "TGComboBox.h"
32#include "TGButton.h"
33#include "TGTextEntry.h"
34#include "TGNumberEntry.h"
35#include "TGLabel.h"
36#include "TGDoubleSlider.h"
37
39
44};
45
46////////////////////////////////////////////////////////////////////////////////
47/// Constructor for sphere editor
48
50 Int_t height, UInt_t options, Pixel_t back)
51 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
52{
53 fShape = 0;
55 fNamei = "";
58 fLock = kFALSE;
59
60 // TextEntry for shape name
61 MakeTitle("Name");
62 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kSPHERE_NAME);
64 fShapeName->SetToolTipText("Enter the sphere name");
65 fShapeName->Associate(this);
67
68 TGTextEntry *nef;
69 MakeTitle("Sphere dimensions");
70 TGCompositeFrame *compxyz = new TGCompositeFrame(this, 118, 30, kVerticalFrame | kRaisedFrame);
71 // Number entry for rmin
72 TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
74 f1->AddFrame(new TGLabel(f1, "Rmin"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
75 fERmin = new TGNumberEntry(f1, 0., 5, kSPHERE_RMIN);
78 nef->SetToolTipText("Enter the inner radius");
79 fERmin->Associate(this);
81 f1->AddFrame(fERmin, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
82 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
83
84 // Number entry for Rmax
85 f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
87 f1->AddFrame(new TGLabel(f1, "Rmax"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
88 fERmax = new TGNumberEntry(f1, 0., 5, kSPHERE_RMAX);
91 nef->SetToolTipText("Enter the outer radius");
92 fERmax->Associate(this);
94 f1->AddFrame(fERmax, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
95 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
96 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
97
98 MakeTitle("Phi/theta range");
99 TGCompositeFrame *f11 = new TGCompositeFrame(this, 150,200, kHorizontalFrame);
100 compxyz = new TGCompositeFrame(f11, 75, 200, kHorizontalFrame | kRaisedFrame);
101 // Vertical slider
102 fSPhi = new TGDoubleVSlider(compxyz,140);
103 fSPhi->SetRange(0.,720.);
104 compxyz->AddFrame(fSPhi, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 2, 2, 4, 4));
105 f1 = new TGCompositeFrame(compxyz, 50, 200, kVerticalFrame);
106 f1->AddFrame(new TGLabel(f1, "Phi min."), new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2));
107 fEPhi1 = new TGNumberEntry(f1, 0., 5, kSPHERE_PHI1);
111 nef->SetToolTipText("Enter the phi1 value");
112 fEPhi1->Associate(this);
113 f1->AddFrame(fEPhi1, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
114
115 fEPhi2 = new TGNumberEntry(f1, 0., 5, kSPHERE_PHI2);
119 nef->SetToolTipText("Enter the phi2 value");
120 fEPhi2->Associate(this);
122 f1->AddFrame(fEPhi2, new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
123 f1->AddFrame(new TGLabel(f1, "Phi max."), new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2));
124 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
125
126 compxyz->Resize(75,150);
127 f11->AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 0,0,0,0));
128
129 compxyz = new TGCompositeFrame(f11, 75, 200, kHorizontalFrame | kRaisedFrame);
130 // Vertical slider
131 fSTheta = new TGDoubleVSlider(compxyz,140);
132 fSTheta->SetRange(0.,180.);
133 compxyz->AddFrame(fSTheta, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 2, 2, 4, 4));
134 f1 = new TGCompositeFrame(compxyz, 50, 200, kVerticalFrame);
135 f1->AddFrame(new TGLabel(f1, "Theta min."), new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2));
140 nef->SetToolTipText("Enter the theta1 value");
141 fETheta1->Associate(this);
142 f1->AddFrame(fETheta1, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
143
148 nef->SetToolTipText("Enter the theta2 value");
149 fETheta2->Associate(this);
150 f1->AddFrame(fETheta2, new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
151 f1->AddFrame(new TGLabel(f1, "Theta max."), new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2));
152 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
153
154 compxyz->Resize(75,150);
155 f11->AddFrame(compxyz, new TGLayoutHints(kLHintsRight, 0, 0, 0, 0));
156
157 AddFrame(f11, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
158
159 // Delayed draw
161 fDelayed = new TGCheckButton(f1, "Delayed draw");
162 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
163 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
164
165 // Buttons
166 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
167 fApply = new TGTextButton(f1, "Apply");
168 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
169 fApply->Associate(this);
170 fUndo = new TGTextButton(f1, "Undo");
171 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
172 fUndo->Associate(this);
173 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
175}
176
177////////////////////////////////////////////////////////////////////////////////
178/// Destructor.
179
181{
182 TGFrameElement *el;
183 TIter next(GetList());
184 while ((el = (TGFrameElement *)next())) {
185 if (el->fFrame->IsComposite())
187 }
188 Cleanup();
189}
190
191////////////////////////////////////////////////////////////////////////////////
192/// Connect signals to slots.
193
195{
196 fApply->Connect("Clicked()", "TGeoSphereEditor", this, "DoApply()");
197 fUndo->Connect("Clicked()", "TGeoSphereEditor", this, "DoUndo()");
198 fShapeName->Connect("TextChanged(const char *)", "TGeoSphereEditor", this, "DoModified()");
199 fERmin->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoRmin()");
200 fERmax->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoRmax()");
201 fEPhi1->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoPhi1()");
202 fEPhi2->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoPhi2()");
203 fETheta1->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoTheta1()");
204 fETheta2->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoTheta2()");
205 fSPhi->Connect("PositionChanged()", "TGeoSphereEditor", this, "DoPhi()");
206 fSTheta->Connect("PositionChanged()", "TGeoSphereEditor", this, "DoTheta()");
207 fInit = kFALSE;
208}
209
210
211////////////////////////////////////////////////////////////////////////////////
212/// Connect to a given sphere.
213
215{
216 if (obj == 0 || (obj->IsA()!=TGeoSphere::Class())) {
218 return;
219 }
220 fShape = (TGeoSphere*)obj;
221 fRmini = fShape->GetRmin();
222 fRmaxi = fShape->GetRmax();
223 fPhi1i = fShape->GetPhi1();
224 fPhi2i = fShape->GetPhi2();
227 fNamei = fShape->GetName();
237
240
242 SetActive();
243}
244
245////////////////////////////////////////////////////////////////////////////////
246/// Check if shape drawing is delayed.
247
249{
250 return (fDelayed->GetState() == kButtonDown);
251}
252
253////////////////////////////////////////////////////////////////////////////////
254/// Slot for name.
255
257{
258 DoModified();
259}
260
261////////////////////////////////////////////////////////////////////////////////
262/// Slot for applying modifications.
263
265{
266 const char *name = fShapeName->GetText();
267 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
268 Double_t rmin = fERmin->GetNumber();
269 Double_t rmax = fERmax->GetNumber();
270 Double_t phi1 = fEPhi1->GetNumber();
271 Double_t phi2 = fEPhi2->GetNumber();
272 if ((phi2-phi1) > 360.001) {
273 phi1 = 0.;
274 phi2 = 360.;
275 fEPhi1->SetNumber(phi1);
276 fEPhi2->SetNumber(phi2);
277 fLock = kTRUE;
278 fSPhi->SetPosition(phi1,phi2);
279 fLock = kFALSE;
280 }
281 Double_t theta1 = fETheta1->GetNumber();
282 Double_t theta2 = fETheta2->GetNumber();
283 fShape->SetSphDimensions(rmin, rmax, theta1,theta2,phi1,phi2);
285 fUndo->SetEnabled();
287 if (fPad) {
289 fShape->Draw();
290 fPad->GetView()->ShowAxis();
291 } else Update();
292 }
293}
294
295////////////////////////////////////////////////////////////////////////////////
296/// Slot for signaling modifications.
297
299{
301}
302
303////////////////////////////////////////////////////////////////////////////////
304/// Slot for undoing last operation.
305
307{
316 DoApply();
319}
320
321////////////////////////////////////////////////////////////////////////////////
322/// Slot for Rmin.
323
325{
326 Double_t rmin = fERmin->GetNumber();
327 Double_t rmax = fERmax->GetNumber();
328 if (rmin <= 0.) {
329 rmin = 0.;
330 fERmin->SetNumber(rmin);
331 }
332 if (rmin >= rmax) {
333 rmin = rmax - 0.1;
334 fERmin->SetNumber(rmin);
335 }
336 DoModified();
337 if (!IsDelayed()) DoApply();
338}
339
340////////////////////////////////////////////////////////////////////////////////
341/// Slot for Rmax.
342
344{
345 Double_t rmin = fERmin->GetNumber();
346 Double_t rmax = fERmax->GetNumber();
347 if (rmax <= 0.) {
348 rmax = 0.1;
349 fERmax->SetNumber(rmax);
350 }
351 if (rmax < rmin+1.e-10) {
352 rmax = rmin + 0.1;
353 if (rmin < 0.) rmin = 0.;
354 fERmax->SetNumber(rmax);
355 }
356 DoModified();
357 if (!IsDelayed()) DoApply();
358}
359
360////////////////////////////////////////////////////////////////////////////////
361/// Slot for phi1.
362
364{
365 Double_t phi1 = fEPhi1->GetNumber();
366 Double_t phi2 = fEPhi2->GetNumber();
367 if (phi1 > 360-1.e-10) {
368 phi1 = 0.;
369 fEPhi1->SetNumber(phi1);
370 }
371 if (phi2<phi1+1.e-10) {
372 phi1 = phi2 - 0.1;
373 fEPhi1->SetNumber(phi1);
374 }
375 if (!fLock) {
376 DoModified();
377 fLock = kTRUE;
378 fSPhi->SetPosition(phi1,phi2);
379 } else fLock = kFALSE;
380 if (!IsDelayed()) DoApply();
381}
382
383////////////////////////////////////////////////////////////////////////////////
384/// Slot for phi2.
385
387{
388 Double_t phi1 = fEPhi1->GetNumber();
389 Double_t phi2 = fEPhi2->GetNumber();
390 if (phi2-phi1 > 360.) {
391 phi2 -= 360.;
392 fEPhi2->SetNumber(phi2);
393 }
394 if (phi2<phi1+1.e-10) {
395 phi2 = phi1 + 0.1;
396 fEPhi2->SetNumber(phi2);
397 }
398 if (!fLock) {
399 DoModified();
400 fLock = kTRUE;
401 fSPhi->SetPosition(phi1,phi2);
402 } else fLock = kFALSE;
403 if (!IsDelayed()) DoApply();
404}
405
406////////////////////////////////////////////////////////////////////////////////
407/// Slot for phi slider.
408
410{
411 if (!fLock) {
412 DoModified();
413 fLock = kTRUE;
415 fLock = kTRUE;
417 } else fLock = kFALSE;
418 if (!IsDelayed()) DoApply();
419}
420
421////////////////////////////////////////////////////////////////////////////////
422/// Slot for theta1.
423
425{
426 Double_t theta1 = fETheta1->GetNumber();
427 Double_t theta2 = fETheta2->GetNumber();
428 if (theta2<theta1+1.e-10) {
429 theta2 = theta1 + 0.1;
430 fETheta2->SetNumber(theta2);
431 }
432 if (!fLock) {
433 DoModified();
434 fLock = kTRUE;
435 fSTheta->SetPosition(theta1,theta2);
436 } else fLock = kFALSE;
437 if (!IsDelayed()) DoApply();
438}
439
440////////////////////////////////////////////////////////////////////////////////
441/// Slot for theta2.
442
444{
445 Double_t theta1 = fETheta1->GetNumber();
446 Double_t theta2 = fETheta2->GetNumber();
447 if (theta2<theta1+1.e-10) {
448 theta1 = theta2 - 0.1;
449 fETheta1->SetNumber(theta1);
450 }
451 if (!fLock) {
452 DoModified();
453 fLock = kTRUE;
454 fSTheta->SetPosition(theta1,theta2);
455 } else fLock = kFALSE;
456 if (!IsDelayed()) DoApply();
457}
458
459////////////////////////////////////////////////////////////////////////////////
460/// Slot for theta slider.
461
463{
464 if (!fLock) {
465 DoModified();
466 fLock = kTRUE;
468 fLock = kTRUE;
470 } else fLock = kFALSE;
471 if (!IsDelayed()) DoApply();
472}
void Class()
Definition: Class.C:29
ULong_t Pixel_t
Definition: GuiTypes.h:39
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kButtonDown
Definition: TGButton.h:54
@ kRaisedFrame
Definition: TGFrame.h:62
@ kSunkenFrame
Definition: TGFrame.h:61
@ kVerticalFrame
Definition: TGFrame.h:59
@ kFixedWidth
Definition: TGFrame.h:65
@ kHorizontalFrame
Definition: TGFrame.h:60
@ kOwnBackground
Definition: TGFrame.h:69
@ kLHintsRight
Definition: TGLayout.h:33
@ kLHintsExpandY
Definition: TGLayout.h:38
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsBottom
Definition: TGLayout.h:36
@ kLHintsTop
Definition: TGLayout.h:34
@ kLHintsExpandX
Definition: TGLayout.h:37
char name[80]
Definition: TGX11.cxx:109
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:601
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:409
virtual TList * GetList() const
Definition: TGFrame.h:369
TGCompositeFrame(const TGCompositeFrame &)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
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)
TGFrame * fFrame
Definition: TGLayout.h:119
virtual void SetSize(const TGDimension &s)
Definition: TGFrame.h:299
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:238
TGDimension GetSize() const
Definition: TGFrame.h:277
virtual Bool_t IsComposite() const
Definition: TGFrame.h:259
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
virtual void SetNumber(Double_t val)
UInt_t GetDefaultHeight() const
TGNumberEntryField * GetNumberEntry() const
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
void SetNumAttr(EAttribute attr=kNEAAnyNumber)
virtual Double_t GetNumber() const
const char * GetText() const
Definition: TGTextEntry.h:134
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:84
Bool_t fInit
Definition: TGedFrame.h:53
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
Common base class for geombuilder editors.
Definition: TGeoGedFrame.h:13
virtual void Update()
Override Update from TGedFrame as fGedEditor can be null.
TVirtualPad * fPad
Definition: TGeoGedFrame.h:18
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
TVirtualGeoPainter * GetPainter() const
Definition: TGeoManager.h:212
virtual const char * GetName() const
Get the shape name.
Definition: TGeoShape.cxx:248
virtual void Draw(Option_t *option="")
Draw this shape.
Definition: TGeoShape.cxx:721
Editor for a TGeoSphere.
TGNumberEntry * fEPhi2
virtual ~TGeoSphereEditor()
Destructor.
TGeoSphereEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for sphere editor.
TGCheckButton * fDelayed
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGNumberEntry * fERmax
void DoTheta1()
Slot for theta1.
void DoRmin()
Slot for Rmin.
TGNumberEntry * fETheta1
TGNumberEntry * fETheta2
virtual void SetModel(TObject *obj)
Connect to a given sphere.
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
TGNumberEntry * fEPhi1
TGDoubleVSlider * fSTheta
void DoPhi1()
Slot for phi1.
void DoRmax()
Slot for Rmax.
virtual void DoUndo()
Slot for undoing last operation.
TGTextButton * fUndo
virtual void DoApply()
Slot for applying modifications.
TGTextButton * fApply
Spherical shell class.
Definition: TGeoSphere.h:18
Double_t GetPhi1() const
Definition: TGeoSphere.h:71
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:72
virtual Double_t GetRmin() const
Definition: TGeoSphere.h:67
virtual void ComputeBBox()
compute bounding box of the sphere
Definition: TGeoSphere.cxx:143
Double_t GetTheta2() const
Definition: TGeoSphere.h:70
virtual Double_t GetRmax() const
Definition: TGeoSphere.h:68
Double_t GetTheta1() const
Definition: TGeoSphere.h:69
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:140
Mother of all ROOT objects.
Definition: TObject.h:37
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:867
virtual void ShowAxis()=0
virtual Bool_t IsPaintingShape() const =0
virtual TView * GetView() const =0
TF1 * f1
Definition: legend1.C:11