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
37
42};
43
44////////////////////////////////////////////////////////////////////////////////
45/// Constructor for sphere editor
46
48 Int_t height, UInt_t options, Pixel_t back)
49 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
50{
51 fShape = 0;
53 fNamei = "";
56 fLock = kFALSE;
57
58 // TextEntry for shape name
59 MakeTitle("Name");
60 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kSPHERE_NAME);
62 fShapeName->SetToolTipText("Enter the sphere name");
63 fShapeName->Associate(this);
65
66 TGTextEntry *nef;
67 MakeTitle("Sphere dimensions");
68 TGCompositeFrame *compxyz = new TGCompositeFrame(this, 118, 30, kVerticalFrame | kRaisedFrame);
69 // Number entry for rmin
70 TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
72 f1->AddFrame(new TGLabel(f1, "Rmin"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
73 fERmin = new TGNumberEntry(f1, 0., 5, kSPHERE_RMIN);
76 nef->SetToolTipText("Enter the inner radius");
77 fERmin->Associate(this);
79 f1->AddFrame(fERmin, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
80 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
81
82 // Number entry for Rmax
83 f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
85 f1->AddFrame(new TGLabel(f1, "Rmax"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
86 fERmax = new TGNumberEntry(f1, 0., 5, kSPHERE_RMAX);
89 nef->SetToolTipText("Enter the outer radius");
90 fERmax->Associate(this);
92 f1->AddFrame(fERmax, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
93 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
94 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
95
96 MakeTitle("Phi/theta range");
97 TGCompositeFrame *f11 = new TGCompositeFrame(this, 150,200, kHorizontalFrame);
98 compxyz = new TGCompositeFrame(f11, 75, 200, kHorizontalFrame | kRaisedFrame);
99 // Vertical slider
100 fSPhi = new TGDoubleVSlider(compxyz,140);
101 fSPhi->SetRange(0.,720.);
102 compxyz->AddFrame(fSPhi, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 2, 2, 4, 4));
103 f1 = new TGCompositeFrame(compxyz, 50, 200, kVerticalFrame);
104 f1->AddFrame(new TGLabel(f1, "Phi min."), new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2));
105 fEPhi1 = new TGNumberEntry(f1, 0., 5, kSPHERE_PHI1);
109 nef->SetToolTipText("Enter the phi1 value");
110 fEPhi1->Associate(this);
111 f1->AddFrame(fEPhi1, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
112
113 fEPhi2 = new TGNumberEntry(f1, 0., 5, kSPHERE_PHI2);
117 nef->SetToolTipText("Enter the phi2 value");
118 fEPhi2->Associate(this);
120 f1->AddFrame(fEPhi2, new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
121 f1->AddFrame(new TGLabel(f1, "Phi max."), new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2));
122 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
123
124 compxyz->Resize(75,150);
125 f11->AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 0,0,0,0));
126
127 compxyz = new TGCompositeFrame(f11, 75, 200, kHorizontalFrame | kRaisedFrame);
128 // Vertical slider
129 fSTheta = new TGDoubleVSlider(compxyz,140);
130 fSTheta->SetRange(0.,180.);
131 compxyz->AddFrame(fSTheta, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 2, 2, 4, 4));
132 f1 = new TGCompositeFrame(compxyz, 50, 200, kVerticalFrame);
133 f1->AddFrame(new TGLabel(f1, "Theta min."), new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2));
138 nef->SetToolTipText("Enter the theta1 value");
139 fETheta1->Associate(this);
140 f1->AddFrame(fETheta1, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
141
146 nef->SetToolTipText("Enter the theta2 value");
147 fETheta2->Associate(this);
148 f1->AddFrame(fETheta2, new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
149 f1->AddFrame(new TGLabel(f1, "Theta max."), new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2));
150 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
151
152 compxyz->Resize(75,150);
153 f11->AddFrame(compxyz, new TGLayoutHints(kLHintsRight, 0, 0, 0, 0));
154
155 AddFrame(f11, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
156
157 // Delayed draw
159 fDelayed = new TGCheckButton(f1, "Delayed draw");
160 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
161 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
162
163 // Buttons
164 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
165 fApply = new TGTextButton(f1, "Apply");
166 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
167 fApply->Associate(this);
168 fUndo = new TGTextButton(f1, "Undo");
169 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
170 fUndo->Associate(this);
171 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
173}
174
175////////////////////////////////////////////////////////////////////////////////
176/// Destructor.
177
179{
180 TGFrameElement *el;
181 TIter next(GetList());
182 while ((el = (TGFrameElement *)next())) {
183 if (el->fFrame->IsComposite())
185 }
186 Cleanup();
187}
188
189////////////////////////////////////////////////////////////////////////////////
190/// Connect signals to slots.
191
193{
194 fApply->Connect("Clicked()", "TGeoSphereEditor", this, "DoApply()");
195 fUndo->Connect("Clicked()", "TGeoSphereEditor", this, "DoUndo()");
196 fShapeName->Connect("TextChanged(const char *)", "TGeoSphereEditor", this, "DoModified()");
197 fERmin->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoRmin()");
198 fERmax->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoRmax()");
199 fEPhi1->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoPhi1()");
200 fEPhi2->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoPhi2()");
201 fETheta1->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoTheta1()");
202 fETheta2->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoTheta2()");
203 fSPhi->Connect("PositionChanged()", "TGeoSphereEditor", this, "DoPhi()");
204 fSTheta->Connect("PositionChanged()", "TGeoSphereEditor", this, "DoTheta()");
205 fInit = kFALSE;
206}
207
208
209////////////////////////////////////////////////////////////////////////////////
210/// Connect to a given sphere.
211
213{
214 if (obj == 0 || (obj->IsA()!=TGeoSphere::Class())) {
216 return;
217 }
218 fShape = (TGeoSphere*)obj;
219 fRmini = fShape->GetRmin();
220 fRmaxi = fShape->GetRmax();
221 fPhi1i = fShape->GetPhi1();
222 fPhi2i = fShape->GetPhi2();
225 fNamei = fShape->GetName();
235
238
240 SetActive();
241}
242
243////////////////////////////////////////////////////////////////////////////////
244/// Check if shape drawing is delayed.
245
247{
248 return (fDelayed->GetState() == kButtonDown);
249}
250
251////////////////////////////////////////////////////////////////////////////////
252/// Slot for name.
253
255{
256 DoModified();
257}
258
259////////////////////////////////////////////////////////////////////////////////
260/// Slot for applying modifications.
261
263{
264 const char *name = fShapeName->GetText();
265 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
266 Double_t rmin = fERmin->GetNumber();
267 Double_t rmax = fERmax->GetNumber();
268 Double_t phi1 = fEPhi1->GetNumber();
269 Double_t phi2 = fEPhi2->GetNumber();
270 if ((phi2-phi1) > 360.001) {
271 phi1 = 0.;
272 phi2 = 360.;
273 fEPhi1->SetNumber(phi1);
274 fEPhi2->SetNumber(phi2);
275 fLock = kTRUE;
276 fSPhi->SetPosition(phi1,phi2);
277 fLock = kFALSE;
278 }
279 Double_t theta1 = fETheta1->GetNumber();
280 Double_t theta2 = fETheta2->GetNumber();
281 fShape->SetSphDimensions(rmin, rmax, theta1,theta2,phi1,phi2);
283 fUndo->SetEnabled();
285 if (fPad) {
287 fShape->Draw();
288 fPad->GetView()->ShowAxis();
289 } else Update();
290 }
291}
292
293////////////////////////////////////////////////////////////////////////////////
294/// Slot for signaling modifications.
295
297{
299}
300
301////////////////////////////////////////////////////////////////////////////////
302/// Slot for undoing last operation.
303
305{
314 DoApply();
317}
318
319////////////////////////////////////////////////////////////////////////////////
320/// Slot for Rmin.
321
323{
324 Double_t rmin = fERmin->GetNumber();
325 Double_t rmax = fERmax->GetNumber();
326 if (rmin <= 0.) {
327 rmin = 0.;
328 fERmin->SetNumber(rmin);
329 }
330 if (rmin >= rmax) {
331 rmin = rmax - 0.1;
332 fERmin->SetNumber(rmin);
333 }
334 DoModified();
335 if (!IsDelayed()) DoApply();
336}
337
338////////////////////////////////////////////////////////////////////////////////
339/// Slot for Rmax.
340
342{
343 Double_t rmin = fERmin->GetNumber();
344 Double_t rmax = fERmax->GetNumber();
345 if (rmax <= 0.) {
346 rmax = 0.1;
347 fERmax->SetNumber(rmax);
348 }
349 if (rmax < rmin+1.e-10) {
350 rmax = rmin + 0.1;
351 if (rmin < 0.) rmin = 0.;
352 fERmax->SetNumber(rmax);
353 }
354 DoModified();
355 if (!IsDelayed()) DoApply();
356}
357
358////////////////////////////////////////////////////////////////////////////////
359/// Slot for phi1.
360
362{
363 Double_t phi1 = fEPhi1->GetNumber();
364 Double_t phi2 = fEPhi2->GetNumber();
365 if (phi1 > 360-1.e-10) {
366 phi1 = 0.;
367 fEPhi1->SetNumber(phi1);
368 }
369 if (phi2<phi1+1.e-10) {
370 phi1 = phi2 - 0.1;
371 fEPhi1->SetNumber(phi1);
372 }
373 if (!fLock) {
374 DoModified();
375 fLock = kTRUE;
376 fSPhi->SetPosition(phi1,phi2);
377 } else fLock = kFALSE;
378 if (!IsDelayed()) DoApply();
379}
380
381////////////////////////////////////////////////////////////////////////////////
382/// Slot for phi2.
383
385{
386 Double_t phi1 = fEPhi1->GetNumber();
387 Double_t phi2 = fEPhi2->GetNumber();
388 if (phi2-phi1 > 360.) {
389 phi2 -= 360.;
390 fEPhi2->SetNumber(phi2);
391 }
392 if (phi2<phi1+1.e-10) {
393 phi2 = phi1 + 0.1;
394 fEPhi2->SetNumber(phi2);
395 }
396 if (!fLock) {
397 DoModified();
398 fLock = kTRUE;
399 fSPhi->SetPosition(phi1,phi2);
400 } else fLock = kFALSE;
401 if (!IsDelayed()) DoApply();
402}
403
404////////////////////////////////////////////////////////////////////////////////
405/// Slot for phi slider.
406
408{
409 if (!fLock) {
410 DoModified();
411 fLock = kTRUE;
413 fLock = kTRUE;
415 } else fLock = kFALSE;
416 if (!IsDelayed()) DoApply();
417}
418
419////////////////////////////////////////////////////////////////////////////////
420/// Slot for theta1.
421
423{
424 Double_t theta1 = fETheta1->GetNumber();
425 Double_t theta2 = fETheta2->GetNumber();
426 if (theta2<theta1+1.e-10) {
427 theta2 = theta1 + 0.1;
428 fETheta2->SetNumber(theta2);
429 }
430 if (!fLock) {
431 DoModified();
432 fLock = kTRUE;
433 fSTheta->SetPosition(theta1,theta2);
434 } else fLock = kFALSE;
435 if (!IsDelayed()) DoApply();
436}
437
438////////////////////////////////////////////////////////////////////////////////
439/// Slot for theta2.
440
442{
443 Double_t theta1 = fETheta1->GetNumber();
444 Double_t theta2 = fETheta2->GetNumber();
445 if (theta2<theta1+1.e-10) {
446 theta1 = theta2 - 0.1;
447 fETheta1->SetNumber(theta1);
448 }
449 if (!fLock) {
450 DoModified();
451 fLock = kTRUE;
452 fSTheta->SetPosition(theta1,theta2);
453 } else fLock = kFALSE;
454 if (!IsDelayed()) DoApply();
455}
456
457////////////////////////////////////////////////////////////////////////////////
458/// Slot for theta slider.
459
461{
462 if (!fLock) {
463 DoModified();
464 fLock = kTRUE;
466 fLock = kTRUE;
468 } else fLock = kFALSE;
469 if (!IsDelayed()) DoApply();
470}
@ kRaisedFrame
Definition GuiTypes.h:384
@ kSunkenFrame
Definition GuiTypes.h:383
@ kVerticalFrame
Definition GuiTypes.h:381
@ kFixedWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kOwnBackground
Definition GuiTypes.h:391
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
const Bool_t kFALSE
Definition RtypesCore.h:92
double Double_t
Definition RtypesCore.h:59
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
@ kButtonDown
Definition TGButton.h:54
@ 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: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:412
virtual TList * GetList() const
Definition TGFrame.h:346
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1102
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:952
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:276
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:215
TGDimension GetSize() const
Definition TGFrame.h:254
virtual Bool_t IsComposite() const
Definition TGFrame.h:236
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:590
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
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:82
Bool_t fInit
Definition TGedFrame.h:54
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:96
Common base class for geombuilder editors.
virtual void Update()
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
virtual const char * GetName() const
Get the shape name.
virtual void Draw(Option_t *option="")
Draw this shape.
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
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:866
virtual void ShowAxis()=0
virtual Bool_t IsPaintingShape() const =0
virtual TView * GetView() const =0
TF1 * f1
Definition legend1.C:11