Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "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;
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{
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);
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
@ kVerticalFrame
Definition GuiTypes.h:381
@ kFixedWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsLeft
Definition TGLayout.h:24
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
char name[80]
Definition TGX11.cxx:110
R__EXTERN TGeoManager * gGeoManager
ETGeoPgonWid
@ kPGON_NEDGES
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition TGButton.cxx:459
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual TList * GetList() const
Definition TGFrame.h:310
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:967
TGFrame * fFrame
Definition TGLayout.h:112
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
virtual Bool_t IsComposite() const
Definition TGFrame.h:212
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGNumberEntry is a number entry input widget with up/down buttons.
TGNumberEntryField * GetNumberEntry() const
Get the number entry field.
void Associate(const TGWindow *w) override
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
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
UInt_t GetDefaultHeight() const override
void SetNumStyle(EStyle style)
@ kNEAPositive
Positive number.
@ kNESInteger
Style of number entry field.
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
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.
ROOT GUI Window base class.
Definition TGWindow.h:23
Bool_t fInit
init flag for setting signals/slots
Definition TGedFrame.h:47
virtual const Double_t * GetOrigin() const
Definition TGeoBBox.h:77
virtual Double_t GetDX() const
Definition TGeoBBox.h:74
virtual Double_t GetDZ() const
Definition TGeoBBox.h:76
virtual Double_t GetDY() const
Definition TGeoBBox.h:75
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
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 is represented by a sequence of tubes/cones, glued together at defined Z planes.
Definition TGeoPcon.h:18
Double_t & Rmin(Int_t ipl)
Definition TGeoPcon.h:94
Double_t GetDphi() const
Definition TGeoPcon.h:76
Double_t & Rmax(Int_t ipl)
Definition TGeoPcon.h:95
Double_t & Z(Int_t ipl)
Definition TGeoPcon.h:96
Double_t & Phi1()
Definition TGeoPcon.h:92
Double_t & Dphi()
Definition TGeoPcon.h:93
Int_t GetNz() const
Definition TGeoPcon.h:77
Double_t GetPhi1() const
Definition TGeoPcon.h:75
Editor for a TGeoPgon.
virtual void SetModel(TObject *obj)
Connect to a given pgon.
TGeoPgonEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for polygone editor.
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.
void DoNedges()
Change number of edges.
Polygons are defined in the same way as polycones, the difference being just that the segments betwee...
Definition TGeoPgon.h:21
virtual void SetDimensions(Double_t *param)
Set PGON dimensions starting from an array.
virtual void ComputeBBox()
compute bounding box for a polygone Check if the sections are in increasing Z order
Definition TGeoPgon.cxx:217
static TClass * Class()
Int_t GetNedges() const
Definition TGeoPgon.h:86
void SetNedges(Int_t ne)
Definition TGeoPgon.h:97
virtual const char * GetName() const
Get the shape name.
virtual void Draw(Option_t *option="")
Draw this shape.
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 override
Definition TObjArray.h:164
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:207
virtual TClass * IsA() const
Definition TObject.h:245
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:869
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)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123