Logo ROOT   6.14/05
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 
15 Editor 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;
51  CreateEdges();
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 {
63  TGFrameElement *el;
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);
92  fPhi1i = fShape->GetPhi1();
94  fDPhii = fShape->GetDphi();
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 
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
TGNumberEntry * fEPhi1
Double_t GetDphi() const
Definition: TGeoPcon.h:72
virtual Double_t GetDX() const
Definition: TGeoBBox.h:70
image html pict1_TGaxis_012 png width
Define new text attributes for the label number "labNum".
Definition: TGaxis.cxx:2551
TVirtualGeoPainter * GetPainter() const
Definition: TGeoManager.h:191
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
A polycone.
Definition: TGeoPcon.h:17
TGeoPcon * fShape
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
A polygone.
Definition: TGeoPgon.h:19
Int_t GetNedges() const
Definition: TGeoPgon.h:81
virtual void SetNumber(Double_t val)
See TView3D.
Definition: TView.h:25
virtual void SetRange(const Double_t *min, const Double_t *max)=0
Double_t & Rmin(Int_t ipl)
Definition: TGeoPcon.h:90
virtual Bool_t IsPaintingShape() const =0
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Double_t & Phi1()
Definition: TGeoPcon.h:88
void DoNedges()
Change number of edges.
void CreateSections(Int_t inew)
Change dynamically the number of sections.
TGCompositeFrame * fBFrame
virtual Bool_t IsComposite() const
Definition: TGFrame.h:259
TObject * At(Int_t idx) const
Definition: TObjArray.h:165
virtual void DoUndo()
Slot for undoing last operation.
Short_t Abs(Short_t d)
Definition: TMathBase.h:108
Double_t & Dphi()
Definition: TGeoPcon.h:89
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
virtual void DoUndo()
Slot for undoing last operation.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
ULong_t Pixel_t
Definition: GuiTypes.h:39
Double_t GetRmin() const
Rmin value getter.
virtual Long_t GetIntNumber() const
void Class()
Definition: Class.C:29
ETGeoPgonWid
Int_t GetNz() const
Definition: TGeoPcon.h:73
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
TGCompositeFrame(const TGCompositeFrame &)
virtual void DoApply()
Slot for applying modifications.
virtual void ComputeBBox()
compute bounding box for a polygone Check if the sections are in increasing Z order ...
Definition: TGeoPgon.cxx:210
virtual TList * GetList() const
Definition: TGFrame.h:369
TGTextEntry * fShapeName
virtual TView * GetView() const =0
Bool_t CheckSections(Bool_t change=kFALSE)
Check validity of sections.
virtual const char * GetName() const
Get the shape name.
Definition: TGeoShape.cxx:248
Editor for a TGeoPcon.
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 Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
Editor for a TGeoPgon.
virtual ~TGeoPgonEditor()
Destructor.
TGNumberEntry * fENz
TGNumberEntry * fEDPhi
void SetNumStyle(EStyle style)
TGTextButton * fUndo
Double_t GetRmax() const
Rmax value getter.
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual const Double_t * GetOrigin() const
Definition: TGeoBBox.h:73
void UpdateSections()
Update sections according fShape.
TGFrame * fFrame
Definition: TGLayout.h:119
virtual void ShowAxis()=0
static void MoveFrame(TGCompositeFrame *fr, TGCompositeFrame *p)
Move frame fr at the end of the list of parent p.
virtual Double_t GetDY() const
Definition: TGeoBBox.h:71
void SetNumAttr(EAttribute attr=kNEAAnyNumber)
Bool_t IsDelayed() const
Check if shape drawing is delayed.
const Bool_t kFALSE
Definition: RtypesCore.h:88
Double_t GetPhi1() const
Definition: TGeoPcon.h:71
const char * GetText() const
Definition: TGTextEntry.h:134
#define ClassImp(name)
Definition: Rtypes.h:359
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:562
double Double_t
Definition: RtypesCore.h:55
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:409
virtual Double_t GetNumber() const
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGNumberEntry * fENedges
Utility frame used by TGeoPcon editor.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
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 SetModel(TObject *obj)
Connect to a given pgon.
Mother of all ROOT objects.
Definition: TObject.h:37
TGTextButton * fApply
Double_t & Z(Int_t ipl)
Definition: TGeoPcon.h:92
Bool_t fInit
Definition: TGedFrame.h:53
virtual void SetDimensions(Double_t *param)
Set PGON dimensions starting from an array.
Definition: TGeoPgon.cxx:1845
TGNumberEntryField * GetNumberEntry() const
TObjArray * fSections
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.
TF1 * f1
Definition: legend1.C:11
virtual void Update()
Override Update from TGedFrame as fGedEditor can be null.
void DoModified()
Slot for signaling modifications.
void SetNedges(Int_t ne)
Definition: TGeoPgon.h:92
Double_t & Rmax(Int_t ipl)
Definition: TGeoPcon.h:91
Double_t GetZ() const
Z value getter.
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...
TVirtualPad * fPad
Definition: TGeoGedFrame.h:18
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
virtual void Draw(Option_t *option="")
Draw this shape.
Definition: TGeoShape.cxx:721
TGCompositeFrame * fDFrame
virtual void CreateEdges()
Create number entry for Nedges.
const Bool_t kTRUE
Definition: RtypesCore.h:87
char name[80]
Definition: TGX11.cxx:109
UInt_t GetDefaultHeight() const
virtual Double_t GetDZ() const
Definition: TGeoBBox.h:72