ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TGeoPgonEditor //
15 // //
16 //////////////////////////////////////////////////////////////////////////
17 //Begin_Html
18 /*
19 <img src="gif/pgon_pic.gif">
20 */
21 //End_Html
22 //Begin_Html
23 /*
24 <img src="gif/pgon_ed.jpg">
25 */
26 //End_Html
27 
28 #include "TGeoPgonEditor.h"
29 #include "TGeoTabManager.h"
30 #include "TGeoPgon.h"
31 #include "TGeoManager.h"
32 #include "TVirtualGeoPainter.h"
33 #include "TPad.h"
34 #include "TView.h"
35 #include "TGTab.h"
36 #include "TGComboBox.h"
37 #include "TGButton.h"
38 #include "TGTextEntry.h"
39 #include "TGNumberEntry.h"
40 #include "TGLabel.h"
41 
43 
44 enum ETGeoPgonWid {
45  kPGON_NEDGES
46 };
47 
48 ////////////////////////////////////////////////////////////////////////////////
49 /// Constructor for polycone editor
50 
52  Int_t height, UInt_t options, Pixel_t back)
53  : TGeoPconEditor(p, width, height, options | kVerticalFrame, back)
54 {
55  fNedgesi = 0;
56  CreateEdges();
59  fENedges->Connect("ValueSet(Long_t)", "TGeoPgonEditor", this, "DoNedges()");
60  fENedges->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoPgonEditor", this, "DoModified()");
61 }
62 
63 ////////////////////////////////////////////////////////////////////////////////
64 /// Destructor
65 
67 {
68  TGFrameElement *el;
69  TIter next(GetList());
70  while ((el = (TGFrameElement *)next())) {
71  if (el->fFrame->IsComposite())
73  }
74  Cleanup();
75 }
76 
77 ////////////////////////////////////////////////////////////////////////////////
78 /// Connect to a given pcon.
79 
81 {
82  if (obj == 0 || (obj->IsA()!=TGeoPgon::Class())) {
84  return;
85  }
86  fShape = (TGeoPcon*)obj;
87  const char *sname = fShape->GetName();
88  if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
89  else fShapeName->SetText(sname);
90 
91  Int_t nsections = fShape->GetNz();
92  fNsecti = nsections;
93  fNedgesi = ((TGeoPgon*)fShape)->GetNedges();
94  fENz->SetNumber(nsections);
97  fPhi1i = fShape->GetPhi1();
99  fDPhii = fShape->GetDphi();
100  CreateSections(nsections);
101  UpdateSections();
102 
105 
107  SetActive();
108 }
109 
110 ////////////////////////////////////////////////////////////////////////////////
111 /// Slot for applying modifications.
112 
114 {
115  TGeoPgon *shape = (TGeoPgon*)fShape;
116  const char *name = fShapeName->GetText();
117  if (strcmp(name,fShape->GetName())) fShape->SetName(name);
119  fUndo->SetEnabled();
120  if (!CheckSections()) return;
121  // check if number of sections changed
122  Bool_t recreate = kFALSE;
123  Int_t nz = fENz->GetIntNumber();
124  Int_t nedges = fENedges->GetIntNumber();
125  Double_t phi1 = fEPhi1->GetNumber();
126  Double_t dphi = fEDPhi->GetNumber();
127  if (nz != fShape->GetNz()) recreate = kTRUE;
128  TGeoPconSection *sect;
129  Int_t isect;
130  if (recreate) {
131  Double_t *array = new Double_t[3*(nz+1)+1];
132  array[0] = phi1;
133  array[1] = dphi;
134  array[2] = nedges;
135  array[3] = nz;
136  for (isect=0; isect<nz; isect++) {
137  sect = (TGeoPconSection*)fSections->At(isect);
138  array[4+3*isect] = sect->GetZ();
139  array[5+3*isect] = sect->GetRmin();
140  array[6+3*isect] = sect->GetRmax();
141  }
142  shape->SetDimensions(array);
143  delete [] array;
144  if (fPad) {
146  TView *view = fPad->GetView();
147  if (!view) {
148  fShape->Draw();
149  fPad->GetView()->ShowAxis();
150  } else {
151  const Double_t *orig = fShape->GetOrigin();
152  view->SetRange(orig[0]-fShape->GetDX(), orig[1]-fShape->GetDY(), orig[2]-fShape->GetDZ(),
153  orig[0]+fShape->GetDX(), orig[1]+fShape->GetDY(), orig[2]+fShape->GetDZ());
154  Update();
155  }
156  } else Update();
157  }
158  return;
159  }
160  // No need to call SetDimensions
161  if (TMath::Abs(phi1-fShape->GetPhi1())>1.e-6) fShape->Phi1() = phi1;
162  if (TMath::Abs(dphi-fShape->GetDphi())>1.e-6) fShape->Dphi() = dphi;
163  if (nedges != shape->GetNedges()) shape->SetNedges(nedges);
164  for (isect=0; isect<fNsections; isect++) {
165  sect = (TGeoPconSection*)fSections->At(isect);
166  fShape->Z(isect) = sect->GetZ();
167  fShape->Rmin(isect) = sect->GetRmin();
168  fShape->Rmax(isect) = sect->GetRmax();
169  }
170  shape->ComputeBBox();
171  if (fPad) {
173  TView *view = fPad->GetView();
174  if (!view) {
175  shape->Draw();
176  fPad->GetView()->ShowAxis();
177  } else {
178  const Double_t *orig = fShape->GetOrigin();
179  view->SetRange(orig[0]-fShape->GetDX(), orig[1]-fShape->GetDY(), orig[2]-fShape->GetDZ(),
180  orig[0]+fShape->GetDX(), orig[1]+fShape->GetDY(), orig[2]+fShape->GetDZ());
181  Update();
182  }
183  } else Update();
184  }
185 }
186 
187 ////////////////////////////////////////////////////////////////////////////////
188 /// Slot for undoing last operation.
189 
191 {
194 }
195 
196 ////////////////////////////////////////////////////////////////////////////////
197 /// Create number entry for Nedges.
198 
200 {
201  TGTextEntry *nef;
203  f1->AddFrame(new TGLabel(f1, "Nedges"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
204  fENedges = new TGNumberEntry(f1, 0., 5, kPGON_NEDGES);
209  nef->SetToolTipText("Enter the number of edges of the polygon");
210  fENedges->Associate(this);
211  f1->AddFrame(fENedges, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
212  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
213 }
214 
215 ////////////////////////////////////////////////////////////////////////////////
216 /// Change number of edges.
217 
219 {
220  Int_t nedges = fENedges->GetIntNumber();
221  if (nedges < 3) {
222  nedges = 3;
223  fENedges->SetNumber(nedges);
224  }
225  DoModified();
226  if (!IsDelayed()) DoApply();
227 }
228 
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
ClassImp(TGeoPgonEditor) enum ETGeoPgonWid
TGNumberEntry * fEPhi1
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
virtual Bool_t IsComposite() const
Definition: TGFrame.h:275
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
TGeoPcon * fShape
virtual void SetName(const char *name)
Change (i.e.
Definition: TNamed.cxx:128
Double_t GetRmin() const
Rmin value getter.
virtual void SetNumber(Double_t val)
See TView3D.
Definition: TView.h:36
Double_t GetZ() const
Z value getter.
virtual void SetRange(const Double_t *min, const Double_t *max)=0
Double_t & Rmin(Int_t ipl)
Definition: TGeoPcon.h:104
virtual Bool_t IsPaintingShape() const =0
virtual TList * GetList() const
Definition: TGFrame.h:385
Double_t GetPhi1() const
Definition: TGeoPcon.h:85
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Double_t & Phi1()
Definition: TGeoPcon.h:102
void DoNedges()
Change number of edges.
void CreateSections(Int_t inew)
Change dynamically the number of sections.
TGCompositeFrame * fBFrame
virtual Double_t GetDY() const
Definition: TGeoBBox.h:83
virtual void DoUndo()
Slot for undoing last operation.
virtual Double_t GetDZ() const
Definition: TGeoBBox.h:84
Short_t Abs(Short_t d)
Definition: TMathBase.h:110
Double_t GetRmax() const
Rmax value getter.
Double_t & Dphi()
Definition: TGeoPcon.h:103
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hirarchically all daughters of a composite frame.
virtual void DoUndo()
Slot for undoing last operation.
TGNumberEntryField * GetNumberEntry() const
ULong_t Pixel_t
Definition: GuiTypes.h:41
Int_t GetNedges() const
Definition: TGeoPgon.h:93
void Class()
Definition: Class.C:29
const char * GetText() const
Definition: TGTextEntry.h:140
TVirtualGeoPainter * GetPainter() const
Definition: TGeoManager.h:193
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:202
TGTextEntry * fShapeName
virtual const Double_t * GetOrigin() const
Definition: TGeoBBox.h:85
virtual TView * GetView() const =0
Bool_t CheckSections(Bool_t change=kFALSE)
Check validity of sections.
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:1135
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
virtual Double_t GetDX() const
Definition: TGeoBBox.h:82
Double_t GetDphi() const
Definition: TGeoPcon.h:86
virtual ~TGeoPgonEditor()
Destructor.
TGNumberEntry * fENz
TGNumberEntry * fEDPhi
void SetNumStyle(EStyle style)
TGTextButton * fUndo
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:187
unsigned int UInt_t
Definition: RtypesCore.h:42
void UpdateSections()
Update sections according fShape.
TGFrame * fFrame
Definition: TGLayout.h:125
virtual void ShowAxis()=0
const std::string sname
Definition: testIO.cxx:45
static void MoveFrame(TGCompositeFrame *fr, TGCompositeFrame *p)
Move frame fr at the end of the list of parent p.
virtual const char * GetName() const
Get the shape name.
Definition: TGeoShape.cxx:247
void SetNumAttr(EAttribute attr=kNEAAnyNumber)
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:556
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 void ConnectSignals2Slots()
Connect signals to slots.
TGNumberEntry * fENedges
tuple view
Definition: tornado.py:20
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
#define name(a, b)
Definition: linkTestLib0.cpp:5
virtual void SetModel(TObject *obj)
Connect to a given pcon.
Mother of all ROOT objects.
Definition: TObject.h:58
TGTextButton * fApply
Double_t & Z(Int_t ipl)
Definition: TGeoPcon.h:106
Bool_t fInit
Definition: TGedFrame.h:55
virtual void SetDimensions(Double_t *param)
Set PGON dimensions starting from an array.
Definition: TGeoPgon.cxx:1814
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 polycone 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.
virtual Long_t GetIntNumber() const
void SetNedges(Int_t ne)
Definition: TGeoPgon.h:104
virtual Double_t GetNumber() const
Double_t & Rmax(Int_t ipl)
Definition: TGeoPcon.h:105
UInt_t GetDefaultHeight() const
TObject * At(Int_t idx) const
Definition: TObjArray.h:167
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 IsDelayed() const
Check if shape drawing is delayed.
TVirtualPad * fPad
Definition: TGeoGedFrame.h:28
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:720
const Bool_t kTRUE
Definition: Rtypes.h:91
TGCompositeFrame * fDFrame
TObject * obj
virtual void CreateEdges()
Create number entry for Nedges.
Int_t GetNz() const
Definition: TGeoPcon.h:87