Logo ROOT   6.16/01
Reference Guide
TGeoPgonEditor.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 TGeoPgonEditor
13\ingroup Geometry_builder
14
15Editor for a TGeoPgon.
16
17\image html geom_pgon_pic.png
18
19\image html geom_pgon_ed.png
20
21*/
22
23#include "TGeoPgonEditor.h"
24#include "TGeoTabManager.h"
25#include "TGeoPgon.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
38
41};
42
43////////////////////////////////////////////////////////////////////////////////
44/// Constructor for polygone editor
45
47 Int_t height, UInt_t options, Pixel_t back)
48 : TGeoPconEditor(p, width, height, options | kVerticalFrame, back)
49{
50 fNedgesi = 0;
54 fENedges->Connect("ValueSet(Long_t)", "TGeoPgonEditor", this, "DoNedges()");
55 fENedges->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoPgonEditor", this, "DoModified()");
56}
57
58////////////////////////////////////////////////////////////////////////////////
59/// Destructor
60
62{
64 TIter next(GetList());
65 while ((el = (TGFrameElement *)next())) {
66 if (el->fFrame->IsComposite())
68 }
69 Cleanup();
70}
71
72////////////////////////////////////////////////////////////////////////////////
73/// Connect to a given pgon.
74
76{
77 if (obj == 0 || (obj->IsA()!=TGeoPgon::Class())) {
79 return;
80 }
81 fShape = (TGeoPcon*)obj;
82 const char *sname = fShape->GetName();
83 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
84 else fShapeName->SetText(sname);
85
86 Int_t nsections = fShape->GetNz();
87 fNsecti = nsections;
88 fNedgesi = ((TGeoPgon*)fShape)->GetNedges();
89 fENz->SetNumber(nsections);
95 CreateSections(nsections);
97
100
102 SetActive();
103}
104
105////////////////////////////////////////////////////////////////////////////////
106/// Slot for applying modifications.
107
109{
110 TGeoPgon *shape = (TGeoPgon*)fShape;
111 const char *name = fShapeName->GetText();
112 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
114 fUndo->SetEnabled();
115 if (!CheckSections()) return;
116 // check if number of sections changed
117 Bool_t recreate = kFALSE;
118 Int_t nz = fENz->GetIntNumber();
119 Int_t nedges = fENedges->GetIntNumber();
120 Double_t phi1 = fEPhi1->GetNumber();
121 Double_t dphi = fEDPhi->GetNumber();
122 if (nz != fShape->GetNz()) recreate = kTRUE;
123 TGeoPconSection *sect;
124 Int_t isect;
125 if (recreate) {
126 Double_t *array = new Double_t[3*(nz+1)+1];
127 array[0] = phi1;
128 array[1] = dphi;
129 array[2] = nedges;
130 array[3] = nz;
131 for (isect=0; isect<nz; isect++) {
132 sect = (TGeoPconSection*)fSections->At(isect);
133 array[4+3*isect] = sect->GetZ();
134 array[5+3*isect] = sect->GetRmin();
135 array[6+3*isect] = sect->GetRmax();
136 }
137 shape->SetDimensions(array);
138 delete [] array;
139 if (fPad) {
141 TView *view = fPad->GetView();
142 if (!view) {
143 fShape->Draw();
144 fPad->GetView()->ShowAxis();
145 } else {
146 const Double_t *orig = fShape->GetOrigin();
147 view->SetRange(orig[0]-fShape->GetDX(), orig[1]-fShape->GetDY(), orig[2]-fShape->GetDZ(),
148 orig[0]+fShape->GetDX(), orig[1]+fShape->GetDY(), orig[2]+fShape->GetDZ());
149 Update();
150 }
151 } else Update();
152 }
153 return;
154 }
155 // No need to call SetDimensions
156 if (TMath::Abs(phi1-fShape->GetPhi1())>1.e-6) fShape->Phi1() = phi1;
157 if (TMath::Abs(dphi-fShape->GetDphi())>1.e-6) fShape->Dphi() = dphi;
158 if (nedges != shape->GetNedges()) shape->SetNedges(nedges);
159 for (isect=0; isect<fNsections; isect++) {
160 sect = (TGeoPconSection*)fSections->At(isect);
161 fShape->Z(isect) = sect->GetZ();
162 fShape->Rmin(isect) = sect->GetRmin();
163 fShape->Rmax(isect) = sect->GetRmax();
164 }
165 shape->ComputeBBox();
166 if (fPad) {
168 TView *view = fPad->GetView();
169 if (!view) {
170 shape->Draw();
171 fPad->GetView()->ShowAxis();
172 } else {
173 const Double_t *orig = fShape->GetOrigin();
174 view->SetRange(orig[0]-fShape->GetDX(), orig[1]-fShape->GetDY(), orig[2]-fShape->GetDZ(),
175 orig[0]+fShape->GetDX(), orig[1]+fShape->GetDY(), orig[2]+fShape->GetDZ());
176 Update();
177 }
178 } else Update();
179 }
180}
181
182////////////////////////////////////////////////////////////////////////////////
183/// Slot for undoing last operation.
184
186{
189}
190
191////////////////////////////////////////////////////////////////////////////////
192/// Create number entry for Nedges.
193
195{
196 TGTextEntry *nef;
198 f1->AddFrame(new TGLabel(f1, "Nedges"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
199 fENedges = new TGNumberEntry(f1, 0., 5, kPGON_NEDGES);
204 nef->SetToolTipText("Enter the number of edges of the polygon");
205 fENedges->Associate(this);
206 f1->AddFrame(fENedges, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
207 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
208}
209
210////////////////////////////////////////////////////////////////////////////////
211/// Change number of edges.
212
214{
215 Int_t nedges = fENedges->GetIntNumber();
216 if (nedges < 3) {
217 nedges = 3;
218 fENedges->SetNumber(nedges);
219 }
220 DoModified();
221 if (!IsDelayed()) DoApply();
222}
223
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:363
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kVerticalFrame
Definition: TGFrame.h:59
@ kFixedWidth
Definition: TGFrame.h:65
@ kHorizontalFrame
Definition: TGFrame.h:60
@ kLHintsRight
Definition: TGLayout.h:33
@ kLHintsLeft
Definition: TGLayout.h:31
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:572
ETGeoPgonWid
@ kPGON_NEDGES
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
TGFrame * fFrame
Definition: TGLayout.h:119
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.
virtual Long_t GetIntNumber() const
void SetNumAttr(EAttribute attr=kNEAAnyNumber)
virtual Double_t GetNumber() const
void SetNumStyle(EStyle style)
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.
Bool_t fInit
Definition: TGedFrame.h:53
virtual const Double_t * GetOrigin() const
Definition: TGeoBBox.h:73
virtual Double_t GetDX() const
Definition: TGeoBBox.h:70
virtual Double_t GetDZ() const
Definition: TGeoBBox.h:72
virtual Double_t GetDY() const
Definition: TGeoBBox.h:71
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:198
Editor for a TGeoPcon.
TGTextEntry * fShapeName
TObjArray * fSections
void CreateSections(Int_t inew)
Change dynamically the number of sections.
virtual void DoUndo()
Slot for undoing last operation.
void DoModified()
Slot for signaling modifications.
Bool_t IsDelayed() const
Check if shape drawing is delayed.
TGNumberEntry * fEPhi1
TGTextButton * fUndo
Bool_t CheckSections(Bool_t change=kFALSE)
Check validity of sections.
TGNumberEntry * fEDPhi
TGeoPcon * fShape
TGCompositeFrame * fBFrame
TGCompositeFrame * fDFrame
TGTextButton * fApply
virtual void ConnectSignals2Slots()
Connect signals to slots.
void UpdateSections()
Update sections according fShape.
TGNumberEntry * fENz
Utility frame used by TGeoPcon editor.
Double_t GetRmax() const
Rmax value getter.
Double_t GetZ() const
Z value getter.
Double_t GetRmin() const
Rmin value getter.
A polycone.
Definition: TGeoPcon.h:18
Double_t & Rmin(Int_t ipl)
Definition: TGeoPcon.h:90
Double_t GetDphi() const
Definition: TGeoPcon.h:72
Double_t & Rmax(Int_t ipl)
Definition: TGeoPcon.h:91
Double_t & Z(Int_t ipl)
Definition: TGeoPcon.h:92
Double_t & Phi1()
Definition: TGeoPcon.h:88
Double_t & Dphi()
Definition: TGeoPcon.h:89
Int_t GetNz() const
Definition: TGeoPcon.h:73
Double_t GetPhi1() const
Definition: TGeoPcon.h:71
Editor for a TGeoPgon.
virtual void SetModel(TObject *obj)
Connect to a given pgon.
virtual void DoApply()
Slot for applying modifications.
virtual ~TGeoPgonEditor()
Destructor.
virtual void DoUndo()
Slot for undoing last operation.
TGNumberEntry * fENedges
virtual void CreateEdges()
Create number entry for Nedges.
TGeoPgonEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for polygone editor.
void DoNedges()
Change number of edges.
A polygone.
Definition: TGeoPgon.h:20
virtual void SetDimensions(Double_t *param)
Set PGON dimensions starting from an array.
Definition: TGeoPgon.cxx:1845
virtual void ComputeBBox()
compute bounding box for a polygone Check if the sections are in increasing Z order
Definition: TGeoPgon.cxx:210
Int_t GetNedges() const
Definition: TGeoPgon.h:81
void SetNedges(Int_t ne)
Definition: TGeoPgon.h:92
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
static void MoveFrame(TGCompositeFrame *fr, TGCompositeFrame *p)
Move frame fr at the end of the list of parent p.
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
TObject * At(Int_t idx) const
Definition: TObjArray.h:165
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
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
See TView3D.
Definition: TView.h:25
virtual void ShowAxis()=0
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 Abs(Short_t d)
Definition: TMathBase.h:120