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
37
38////////////////////////////////////////////////////////////////////////////////
39/// Constructor for polygone editor
40
42 : TGeoPconEditor(p, width, height, options | kVerticalFrame, back)
43{
44 fNedgesi = 0;
48 fENedges->Connect("ValueSet(Long_t)", "TGeoPgonEditor", this, "DoNedges()");
49 fENedges->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoPgonEditor", this, "DoModified()");
50}
51
52////////////////////////////////////////////////////////////////////////////////
53/// Destructor
54
56{
58 TIter next(GetList());
59 while ((el = (TGFrameElement *)next())) {
60 if (el->fFrame->IsComposite())
62 }
63 Cleanup();
64}
65
66////////////////////////////////////////////////////////////////////////////////
67/// Connect to a given pgon.
68
70{
71 if (obj == nullptr || (obj->IsA() != TGeoPgon::Class())) {
73 return;
74 }
75 fShape = (TGeoPcon *)obj;
76 const char *sname = fShape->GetName();
77 if (!strcmp(sname, fShape->ClassName()))
78 fShapeName->SetText("-no_name");
79 else
80 fShapeName->SetText(sname);
81
82 Int_t nsections = fShape->GetNz();
83 fNsecti = nsections;
84 fNedgesi = ((TGeoPgon *)fShape)->GetNedges();
85 fENz->SetNumber(nsections);
91 CreateSections(nsections);
93
96
97 if (fInit)
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()))
112 fUndo->SetEnabled();
113 if (!CheckSections())
114 return;
115 // check if number of sections changed
116 Bool_t recreate = kFALSE;
117 Int_t nz = fENz->GetIntNumber();
118 Int_t nedges = fENedges->GetIntNumber();
119 Double_t phi1 = fEPhi1->GetNumber();
120 Double_t dphi = fEDPhi->GetNumber();
121 if (nz != fShape->GetNz())
122 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
152 Update();
153 }
154 return;
155 }
156 // No need to call SetDimensions
157 if (TMath::Abs(phi1 - fShape->GetPhi1()) > 1.e-6)
158 fShape->Phi1() = phi1;
159 if (TMath::Abs(dphi - fShape->GetDphi()) > 1.e-6)
160 fShape->Dphi() = dphi;
161 if (nedges != shape->GetNedges())
162 shape->SetNedges(nedges);
163 for (isect = 0; isect < fNsections; isect++) {
164 sect = (TGeoPconSection *)fSections->At(isect);
165 fShape->Z(isect) = sect->GetZ();
166 fShape->Rmin(isect) = sect->GetRmin();
167 fShape->Rmax(isect) = sect->GetRmax();
168 }
169 shape->ComputeBBox();
170 if (fPad) {
172 TView *view = fPad->GetView();
173 if (!view) {
174 shape->Draw();
175 fPad->GetView()->ShowAxis();
176 } else {
177 const Double_t *orig = fShape->GetOrigin();
178 view->SetRange(orig[0] - fShape->GetDX(), orig[1] - fShape->GetDY(), orig[2] - fShape->GetDZ(),
179 orig[0] + fShape->GetDX(), orig[1] + fShape->GetDY(), orig[2] + fShape->GetDZ());
180 Update();
181 }
182 } else
183 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())
227 DoApply();
228}
@ 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:82
virtual Double_t GetDX() const
Definition TGeoBBox.h:79
virtual Double_t GetDZ() const
Definition TGeoBBox.h:81
virtual Double_t GetDY() const
Definition TGeoBBox.h:80
void Update() override
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:17
Double_t & Rmin(Int_t ipl)
Definition TGeoPcon.h:95
Double_t GetDphi() const
Definition TGeoPcon.h:77
Double_t & Rmax(Int_t ipl)
Definition TGeoPcon.h:96
Double_t & Z(Int_t ipl)
Definition TGeoPcon.h:97
Double_t & Phi1()
Definition TGeoPcon.h:93
Double_t & Dphi()
Definition TGeoPcon.h:94
Int_t GetNz() const
Definition TGeoPcon.h:78
Double_t GetPhi1() const
Definition TGeoPcon.h:76
Editor for a TGeoPgon.
~TGeoPgonEditor() override
Destructor.
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.
void SetModel(TObject *obj) override
Connect to a given pgon.
void CreateEdges() override
Create number entry for Nedges.
void DoUndo() override
Slot for undoing last operation.
TGNumberEntry * fENedges
void DoNedges()
Change number of edges.
void DoApply() override
Slot for applying modifications.
Polygons are defined in the same way as polycones, the difference being just that the segments betwee...
Definition TGeoPgon.h:20
static TClass * Class()
Int_t GetNedges() const
Definition TGeoPgon.h:93
void SetNedges(Int_t ne)
Definition TGeoPgon.h:108
void SetDimensions(Double_t *param) override
Set PGON dimensions starting from an array.
void ComputeBBox() override
compute bounding box for a polygone Check if the sections are in increasing Z order
Definition TGeoPgon.cxx:215
void Draw(Option_t *option="") override
Draw this shape.
const char * GetName() const override
Get the shape name.
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