Logo ROOT  
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 "TVirtualPad.h"
29 #include "TView.h"
30 #include "TGTextEntry.h"
31 #include "TGNumberEntry.h"
32 #include "TGLabel.h"
33 
35 
38 };
39 
40 ////////////////////////////////////////////////////////////////////////////////
41 /// Constructor for polygone editor
42 
44  Int_t height, UInt_t options, Pixel_t back)
45  : TGeoPconEditor(p, width, height, options | kVerticalFrame, back)
46 {
47  fNedgesi = 0;
48  CreateEdges();
51  fENedges->Connect("ValueSet(Long_t)", "TGeoPgonEditor", this, "DoNedges()");
52  fENedges->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoPgonEditor", this, "DoModified()");
53 }
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 /// Destructor
57 
59 {
60  TGFrameElement *el;
61  TIter next(GetList());
62  while ((el = (TGFrameElement *)next())) {
63  if (el->fFrame->IsComposite())
65  }
66  Cleanup();
67 }
68 
69 ////////////////////////////////////////////////////////////////////////////////
70 /// Connect to a given pgon.
71 
73 {
74  if (obj == 0 || (obj->IsA()!=TGeoPgon::Class())) {
76  return;
77  }
78  fShape = (TGeoPcon*)obj;
79  const char *sname = fShape->GetName();
80  if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
81  else fShapeName->SetText(sname);
82 
83  Int_t nsections = fShape->GetNz();
84  fNsecti = nsections;
85  fNedgesi = ((TGeoPgon*)fShape)->GetNedges();
86  fENz->SetNumber(nsections);
89  fPhi1i = fShape->GetPhi1();
91  fDPhii = fShape->GetDphi();
92  CreateSections(nsections);
94 
97 
99  SetActive();
100 }
101 
102 ////////////////////////////////////////////////////////////////////////////////
103 /// Slot for applying modifications.
104 
106 {
107  TGeoPgon *shape = (TGeoPgon*)fShape;
108  const char *name = fShapeName->GetText();
109  if (strcmp(name,fShape->GetName())) fShape->SetName(name);
111  fUndo->SetEnabled();
112  if (!CheckSections()) return;
113  // check if number of sections changed
114  Bool_t recreate = kFALSE;
115  Int_t nz = fENz->GetIntNumber();
116  Int_t nedges = fENedges->GetIntNumber();
117  Double_t phi1 = fEPhi1->GetNumber();
118  Double_t dphi = fEDPhi->GetNumber();
119  if (nz != fShape->GetNz()) recreate = kTRUE;
120  TGeoPconSection *sect;
121  Int_t isect;
122  if (recreate) {
123  Double_t *array = new Double_t[3*(nz+1)+1];
124  array[0] = phi1;
125  array[1] = dphi;
126  array[2] = nedges;
127  array[3] = nz;
128  for (isect=0; isect<nz; isect++) {
129  sect = (TGeoPconSection*)fSections->At(isect);
130  array[4+3*isect] = sect->GetZ();
131  array[5+3*isect] = sect->GetRmin();
132  array[6+3*isect] = sect->GetRmax();
133  }
134  shape->SetDimensions(array);
135  delete [] array;
136  if (fPad) {
138  TView *view = fPad->GetView();
139  if (!view) {
140  fShape->Draw();
141  fPad->GetView()->ShowAxis();
142  } else {
143  const Double_t *orig = fShape->GetOrigin();
144  view->SetRange(orig[0]-fShape->GetDX(), orig[1]-fShape->GetDY(), orig[2]-fShape->GetDZ(),
145  orig[0]+fShape->GetDX(), orig[1]+fShape->GetDY(), orig[2]+fShape->GetDZ());
146  Update();
147  }
148  } else Update();
149  }
150  return;
151  }
152  // No need to call SetDimensions
153  if (TMath::Abs(phi1-fShape->GetPhi1())>1.e-6) fShape->Phi1() = phi1;
154  if (TMath::Abs(dphi-fShape->GetDphi())>1.e-6) fShape->Dphi() = dphi;
155  if (nedges != shape->GetNedges()) shape->SetNedges(nedges);
156  for (isect=0; isect<fNsections; isect++) {
157  sect = (TGeoPconSection*)fSections->At(isect);
158  fShape->Z(isect) = sect->GetZ();
159  fShape->Rmin(isect) = sect->GetRmin();
160  fShape->Rmax(isect) = sect->GetRmax();
161  }
162  shape->ComputeBBox();
163  if (fPad) {
165  TView *view = fPad->GetView();
166  if (!view) {
167  shape->Draw();
168  fPad->GetView()->ShowAxis();
169  } else {
170  const Double_t *orig = fShape->GetOrigin();
171  view->SetRange(orig[0]-fShape->GetDX(), orig[1]-fShape->GetDY(), orig[2]-fShape->GetDZ(),
172  orig[0]+fShape->GetDX(), orig[1]+fShape->GetDY(), orig[2]+fShape->GetDZ());
173  Update();
174  }
175  } else Update();
176  }
177 }
178 
179 ////////////////////////////////////////////////////////////////////////////////
180 /// Slot for undoing last operation.
181 
183 {
186 }
187 
188 ////////////////////////////////////////////////////////////////////////////////
189 /// Create number entry for Nedges.
190 
192 {
193  TGTextEntry *nef;
195  f1->AddFrame(new TGLabel(f1, "Nedges"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
196  fENedges = new TGNumberEntry(f1, 0., 5, kPGON_NEDGES);
201  nef->SetToolTipText("Enter the number of edges of the polygon");
202  fENedges->Associate(this);
203  f1->AddFrame(fENedges, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
204  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
205 }
206 
207 ////////////////////////////////////////////////////////////////////////////////
208 /// Change number of edges.
209 
211 {
212  Int_t nedges = fENedges->GetIntNumber();
213  if (nedges < 3) {
214  nedges = 3;
215  fENedges->SetNumber(nedges);
216  }
217  DoModified();
218  if (!IsDelayed()) DoApply();
219 }
220 
TGeoPcon::Z
Double_t & Z(Int_t ipl)
Definition: TGeoPcon.h:102
TGeoPconEditor::ConnectSignals2Slots
virtual void ConnectSignals2Slots()
Connect signals to slots.
Definition: TGeoPconEditor.cxx:164
TGButton::SetEnabled
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:412
TGeoPcon::Phi1
Double_t & Phi1()
Definition: TGeoPcon.h:98
TView::SetRange
virtual void SetRange(const Double_t *min, const Double_t *max)=0
TGWindow
Definition: TGWindow.h:31
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGTextEntry::SetText
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.
Definition: TGTextEntry.cxx:623
kFixedWidth
@ kFixedWidth
Definition: GuiTypes.h:387
TGeoTabManager.h
TGCompositeFrame::GetList
virtual TList * GetList() const
Definition: TGFrame.h:347
ETGeoPgonWid
ETGeoPgonWid
Definition: TGeoPgonEditor.cxx:36
TGeoPconEditor::fBFrame
TGCompositeFrame * fBFrame
Definition: TGeoPconEditor.h:52
TGeoPconEditor::CheckSections
Bool_t CheckSections(Bool_t change=kFALSE)
Check validity of sections.
Definition: TGeoPconEditor.cxx:247
TNamed::SetName
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
TGNumberEntry::GetDefaultHeight
UInt_t GetDefaultHeight() const
Definition: TGNumberEntry.h:280
TGeoPconEditor
Definition: TGeoPconEditor.h:29
TGeoPconEditor::fNsections
Int_t fNsections
Definition: TGeoPconEditor.h:38
gGeoManager
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:602
TGCompositeFrame::TGCompositeFrame
TGCompositeFrame(const TGCompositeFrame &)
TGeoPgonEditor::DoUndo
virtual void DoUndo()
Slot for undoing last operation.
Definition: TGeoPgonEditor.cxx:182
TGeoPconEditor::fPhi1i
Double_t fPhi1i
Definition: TGeoPconEditor.h:33
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
TGeoPgonEditor
Definition: TGeoPgonEditor.h:20
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TGeoPconSection::GetRmax
Double_t GetRmax() const
Rmax value getter.
Definition: TGeoPconEditor.cxx:567
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
TGeoPconEditor::DoUndo
virtual void DoUndo()
Slot for undoing last operation.
Definition: TGeoPconEditor.cxx:445
kLHintsLeft
@ kLHintsLeft
Definition: TGLayout.h:37
TView.h
TGTextEntry::SetToolTipText
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
Definition: TGTextEntry.cxx:1663
TGeoPconEditor::fEPhi1
TGNumberEntry * fEPhi1
Definition: TGeoPconEditor.h:48
TGLabel
Definition: TGLabel.h:32
TGCompositeFrame::Cleanup
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:952
TGeoPconSection::GetZ
Double_t GetZ() const
Z value getter.
Definition: TGeoPconEditor.cxx:551
TGeoPconEditor::UpdateSections
void UpdateSections()
Update sections according fShape.
Definition: TGeoPconEditor.cxx:274
TGeoPconEditor::fDPhii
Double_t fDPhii
Definition: TGeoPconEditor.h:34
TGNumberFormat::kNEAPositive
@ kNEAPositive
Definition: TGNumberEntry.h:58
TGeoPgon::SetNedges
void SetNedges(Int_t ne)
Definition: TGeoPgon.h:100
width
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
TGeoPconEditor::fSections
TObjArray * fSections
Definition: TGeoPconEditor.h:39
TGeoBBox::GetDZ
virtual Double_t GetDZ() const
Definition: TGeoBBox.h:78
TGeoPgonEditor::DoNedges
void DoNedges()
Change number of edges.
Definition: TGeoPgonEditor.cxx:210
TGeoPconEditor::fEDPhi
TGNumberEntry * fEDPhi
Definition: TGeoPconEditor.h:49
kPGON_NEDGES
@ kPGON_NEDGES
Definition: TGeoPgonEditor.cxx:37
TGeoTabManager::MoveFrame
static void MoveFrame(TGCompositeFrame *fr, TGCompositeFrame *p)
Move frame fr at the end of the list of parent p.
Definition: TGeoTabManager.cxx:231
TGeoGedFrame::Update
virtual void Update()
Override Update from TGedFrame as fGedEditor can be null.
Definition: TGeoGedFrame.cxx:55
TMath::Abs
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
TGeoPconEditor::fShape
TGeoPcon * fShape
Definition: TGeoPconEditor.h:41
TGNumberEntry::GetNumberEntry
TGNumberEntryField * GetNumberEntry() const
Definition: TGNumberEntry.h:268
TObjArray::At
TObject * At(Int_t idx) const
Definition: TObjArray.h:166
TGeoPgon::ComputeBBox
virtual void ComputeBBox()
compute bounding box for a polygone Check if the sections are in increasing Z order
Definition: TGeoPgon.cxx:210
TGeoTabManager::Cleanup
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
Definition: TGeoTabManager.cxx:88
bool
TGeoPgonEditor::fNedgesi
Int_t fNedgesi
Definition: TGeoPgonEditor.h:23
TGFrameElement::fFrame
TGFrame * fFrame
Definition: TGLayout.h:119
TGeoPgonEditor::DoApply
virtual void DoApply()
Slot for applying modifications.
Definition: TGeoPgonEditor.cxx:105
TGeoShape::Draw
virtual void Draw(Option_t *option="")
Draw this shape.
Definition: TGeoShape.cxx:721
TGeoBBox::GetDX
virtual Double_t GetDX() const
Definition: TGeoBBox.h:76
TGeoPcon::GetPhi1
Double_t GetPhi1() const
Definition: TGeoPcon.h:81
TView
Definition: TView.h:25
TGNumberEntry::SetNumber
virtual void SetNumber(Double_t val)
Definition: TGNumberEntry.h:186
TGeoPconEditor::IsDelayed
Bool_t IsDelayed() const
Check if shape drawing is delayed.
Definition: TGeoPconEditor.cxx:297
TGeoPconEditor::fApply
TGTextButton * fApply
Definition: TGeoPconEditor.h:50
TGeoPconEditor::CreateSections
void CreateSections(Int_t inew)
Change dynamically the number of sections.
Definition: TGeoPconEditor.cxx:210
TGFrame::Resize
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:590
TGTextEntry
Definition: TGTextEntry.h:39
TGeoPgonEditor::~TGeoPgonEditor
virtual ~TGeoPgonEditor()
Destructor.
Definition: TGeoPgonEditor.cxx:58
TGeoGedFrame::fPad
TVirtualPad * fPad
Definition: TGeoGedFrame.h:18
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
kLHintsRight
@ kLHintsRight
Definition: TGLayout.h:39
TGeoPcon::Dphi
Double_t & Dphi()
Definition: TGeoPcon.h:99
TGLayoutHints
Definition: TGLayout.h:57
TGeoPcon::GetNz
Int_t GetNz() const
Definition: TGeoPcon.h:83
TVirtualPad.h
TGeoPgonEditor.h
TGeoPgon
Definition: TGeoPgon.h:20
TGeoShape::GetName
virtual const char * GetName() const
Get the shape name.
Definition: TGeoShape.cxx:248
TGeoPcon
Definition: TGeoPcon.h:17
TGeoBBox::GetOrigin
virtual const Double_t * GetOrigin() const
Definition: TGeoBBox.h:79
TVirtualPad::GetView
virtual TView * GetView() const =0
TGeoPconEditor::fNsecti
Int_t fNsecti
Definition: TGeoPconEditor.h:32
TGeoPgon::GetNedges
Int_t GetNedges() const
Definition: TGeoPgon.h:89
TView::ShowAxis
virtual void ShowAxis()=0
unsigned int
TGeoGedFrame::SetActive
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
Definition: TGeoGedFrame.cxx:35
kHorizontalFrame
@ kHorizontalFrame
Definition: GuiTypes.h:382
TGeoManager.h
TGLabel.h
TGeoPconEditor::DoModified
void DoModified()
Slot for signaling modifications.
Definition: TGeoPconEditor.cxx:437
f1
TF1 * f1
Definition: legend1.C:11
TVirtualGeoPainter.h
Double_t
double Double_t
Definition: RtypesCore.h:59
TQObject::Connect
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:864
TGeoBBox::GetDY
virtual Double_t GetDY() const
Definition: TGeoBBox.h:77
TGFrame::IsComposite
virtual Bool_t IsComposite() const
Definition: TGFrame.h:237
TGNumberEntry::SetNumAttr
void SetNumAttr(EAttribute attr=kNEAAnyNumber)
Definition: TGNumberEntry.h:255
TGeoPconEditor::fDFrame
TGCompositeFrame * fDFrame
Definition: TGeoPconEditor.h:54
TObject
Definition: TObject.h:37
TGTextEntry.h
TGeoManager::GetPainter
TVirtualGeoPainter * GetPainter() const
Definition: TGeoManager.h:213
TGeoPgonEditor::SetModel
virtual void SetModel(TObject *obj)
Connect to a given pgon.
Definition: TGeoPgonEditor.cxx:72
TGeoPconEditor::fShapeName
TGTextEntry * fShapeName
Definition: TGeoPconEditor.h:46
name
char name[80]
Definition: TGX11.cxx:110
TGNumberEntry::Associate
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
Definition: TGNumberEntry.cxx:2009
TGeoPcon::Rmin
Double_t & Rmin(Int_t ipl)
Definition: TGeoPcon.h:100
TGeoPconSection::GetRmin
Double_t GetRmin() const
Rmin value getter.
Definition: TGeoPconEditor.cxx:559
TGFrameElement
Definition: TGLayout.h:112
TGTextEntry::GetText
const char * GetText() const
Definition: TGTextEntry.h:134
TGNumberEntry::GetIntNumber
virtual Long_t GetIntNumber() const
Definition: TGNumberEntry.h:209
TIter
Definition: TCollection.h:233
TGeoPconEditor::fUndo
TGTextButton * fUndo
Definition: TGeoPconEditor.h:51
TGeoPcon::GetDphi
Double_t GetDphi() const
Definition: TGeoPcon.h:82
TGNumberEntry.h
TGNumberEntry::GetNumber
virtual Double_t GetNumber() const
Definition: TGNumberEntry.h:206
TGeoPgonEditor::fENedges
TGNumberEntry * fENedges
Definition: TGeoPgonEditor.h:24
TGeoPgon::SetDimensions
virtual void SetDimensions(Double_t *param)
Set PGON dimensions starting from an array.
Definition: TGeoPgon.cxx:1938
TGNumberEntry
Definition: TGNumberEntry.h:156
TGNumberEntry::SetNumStyle
void SetNumStyle(EStyle style)
Definition: TGNumberEntry.h:253
TGedFrame::fInit
Bool_t fInit
Definition: TGedFrame.h:53
TGeoPconSection
Definition: TGeoPconEditor.h:82
Class
void Class()
Definition: Class.C:29
TGCompositeFrame
Definition: TGFrame.h:324
TGeoPgonEditor::CreateEdges
virtual void CreateEdges()
Create number entry for Nedges.
Definition: TGeoPgonEditor.cxx:191
TGeoPconEditor::fENz
TGNumberEntry * fENz
Definition: TGeoPconEditor.h:47
TObject::ClassName
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:130
TGCompositeFrame::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1102
TVirtualGeoPainter::IsPaintingShape
virtual Bool_t IsPaintingShape() const =0
TGeoPcon::Rmax
Double_t & Rmax(Int_t ipl)
Definition: TGeoPcon.h:101
TGeoPgonEditor::TGeoPgonEditor
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.
Definition: TGeoPgonEditor.cxx:43
TGNumberFormat::kNESInteger
@ kNESInteger
Definition: TGNumberEntry.h:46
TGeoPgon.h
int