Logo ROOT   6.16/01
Reference Guide
TGeoEltuEditor.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 TGeoEltuEditor
13\ingroup Geometry_builder
14
15Editor for a TGeoEltu.
16
17\image html geom_eltu_pic.png
18
19\image html geom_eltu_ed.png
20
21*/
22
23#include "TGeoEltuEditor.h"
24#include "TGeoTabManager.h"
25#include "TGeoEltu.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
42};
43
44////////////////////////////////////////////////////////////////////////////////
45/// Constructor for para editor
46
48 Int_t height, UInt_t options, Pixel_t back)
49 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
50{
51 fShape = 0;
52 fAi = fBi = fDzi = 0.0;
53 fNamei = "";
56
57 // TextEntry for shape name
58 MakeTitle("Name");
59 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kELTU_NAME);
61 fShapeName->SetToolTipText("Enter the elliptical tube name");
62 fShapeName->Associate(this);
64
65 TGTextEntry *nef;
66 MakeTitle("Dimensions");
67 // Number entry for A
69 f1->AddFrame(new TGLabel(f1, "A"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
70 fEA = new TGNumberEntry(f1, 0., 5, kELTU_A);
74 nef->SetToolTipText("Enter the semi-axis of the ellipse along x");
75 fEA->Associate(this);
76 f1->AddFrame(fEA, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
77 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
78
79 // Number entry for B
80 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
81 f1->AddFrame(new TGLabel(f1, "B"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
82 fEB = new TGNumberEntry(f1, 0., 5, kELTU_B);
86 nef->SetToolTipText("Enter the semi-axis of the ellipse along y");
87 fEB->Associate(this);
88 f1->AddFrame(fEB, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
89 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
90
91 // Number entry for dz
92 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
93 f1->AddFrame(new TGLabel(f1, "Dz"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
94 fEDz = new TGNumberEntry(f1, 0., 5, kELTU_DZ);
98 nef->SetToolTipText("Enter the half-length in Z");
99 fEDz->Associate(this);
100 f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
101 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
102
103 // Delayed draw
105 fDelayed = new TGCheckButton(f1, "Delayed draw");
106 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
107 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
108
109 // Buttons
110 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
111 fApply = new TGTextButton(f1, "Apply");
112 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
113 fApply->Associate(this);
114 fUndo = new TGTextButton(f1, "Undo");
115 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
116 fUndo->Associate(this);
117 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
119}
120
121////////////////////////////////////////////////////////////////////////////////
122/// Destructor
123
125{
126 TGFrameElement *el;
127 TIter next(GetList());
128 while ((el = (TGFrameElement *)next())) {
129 if (el->fFrame->IsComposite())
131 }
132 Cleanup();
133}
134
135////////////////////////////////////////////////////////////////////////////////
136/// Connect signals to slots.
137
139{
140 fApply->Connect("Clicked()", "TGeoEltuEditor", this, "DoApply()");
141 fUndo->Connect("Clicked()", "TGeoEltuEditor", this, "DoUndo()");
142 fShapeName->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
143 fEA->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoA()");
144 fEB->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoB()");
145 fEDz->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoDz()");
146 fEA->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
147 fEB->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
148 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
149 fInit = kFALSE;
150}
151
152////////////////////////////////////////////////////////////////////////////////
153/// Connect to the selected object.
154
156{
157 if (obj == 0 || (obj->IsA()!=TGeoEltu::Class())) {
159 return;
160 }
161 fShape = (TGeoEltu*)obj;
162 fAi = fShape->GetA();
163 fBi = fShape->GetB();
164 fDzi = fShape->GetDz();
165 const char *sname = fShape->GetName();
166 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
167 else {
168 fShapeName->SetText(sname);
169 fNamei = sname;
170 }
171 fEA->SetNumber(fAi);
172 fEB->SetNumber(fBi);
176
178 SetActive();
179}
180
181////////////////////////////////////////////////////////////////////////////////
182/// Slot for name.
183
185{
186 DoModified();
187}
188
189////////////////////////////////////////////////////////////////////////////////
190/// Check if shape drawing is delayed.
191
193{
194 return (fDelayed->GetState() == kButtonDown);
195}
196
197////////////////////////////////////////////////////////////////////////////////
198/// Slot for applying current settings.
199
201{
202 const char *name = fShapeName->GetText();
203 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
204 Double_t a = fEA->GetNumber();
205 Double_t b = fEB->GetNumber();
206 Double_t z = fEDz->GetNumber();
207 Double_t param[3];
208 param[0] = a;
209 param[1] = b;
210 param[2] = z;
211 fShape->SetDimensions(param);
213 fUndo->SetEnabled();
215 if (fPad) {
217 TView *view = fPad->GetView();
218 if (!view) {
219 fShape->Draw();
220 fPad->GetView()->ShowAxis();
221 } else {
222 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(),
223 fShape->GetDX(), fShape->GetDY(), fShape->GetDZ());
224 Update();
225 }
226 } else Update();
227 }
228}
229
230////////////////////////////////////////////////////////////////////////////////
231/// Slot for notifying modifications.
232
234{
236}
237
238////////////////////////////////////////////////////////////////////////////////
239/// Slot for undoing last operation.
240
242{
243 fEA->SetNumber(fAi);
244 fEB->SetNumber(fBi);
246 DoApply();
249}
250
251////////////////////////////////////////////////////////////////////////////////
252/// Slot for A.
253
255{
256 Double_t a = fEA->GetNumber();
257 if (a <= 0) {
258 a = 0.1;
259 fEA->SetNumber(a);
260 }
261 DoModified();
262 if (!IsDelayed()) DoApply();
263}
264
265////////////////////////////////////////////////////////////////////////////////
266/// Slot for B.
267
269{
270 Double_t b = fEB->GetNumber();
271 if (b <= 0) {
272 b = 0.1;
273 fEB->SetNumber(b);
274 }
275 DoModified();
276 if (!IsDelayed()) DoApply();
277}
278
279////////////////////////////////////////////////////////////////////////////////
280/// Slot for Z.
281
283{
284 Double_t z = fEDz->GetNumber();
285 if (z <= 0) {
286 z = 0.1;
287 fEDz->SetNumber(z);
288 }
289 DoModified();
290 if (!IsDelayed()) DoApply();
291}
292
void Class()
Definition: Class.C:29
ULong_t Pixel_t
Definition: GuiTypes.h:39
#define b(i)
Definition: RSha256.hxx:100
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:363
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kButtonDown
Definition: TGButton.h:54
@ kSunkenFrame
Definition: TGFrame.h:61
@ kVerticalFrame
Definition: TGFrame.h:59
@ kFixedWidth
Definition: TGFrame.h:65
@ kHorizontalFrame
Definition: TGFrame.h:60
@ kLHintsRight
Definition: TGLayout.h:33
@ kLHintsLeft
Definition: TGLayout.h:31
ETGeoEltuWid
@ kELTU_A
@ kELTU_NAME
@ kELTU_UNDO
@ kELTU_B
@ kELTU_APPLY
@ kELTU_DZ
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:572
virtual EButtonState GetState() const
Definition: TGButton.h:112
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:409
virtual TList * GetList() const
Definition: TGFrame.h:369
TGCompositeFrame(const TGCompositeFrame &)
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 Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
TGFrame * fFrame
Definition: TGLayout.h:119
virtual void SetSize(const TGDimension &s)
Definition: TGFrame.h:299
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:238
TGDimension GetSize() const
Definition: TGFrame.h:277
virtual Bool_t IsComposite() const
Definition: TGFrame.h:259
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
virtual void SetNumber(Double_t val)
UInt_t GetDefaultHeight() const
TGNumberEntryField * GetNumberEntry() const
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
void SetNumAttr(EAttribute attr=kNEAAnyNumber)
virtual Double_t GetNumber() const
const char * GetText() const
Definition: TGTextEntry.h:134
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.
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
Bool_t fInit
Definition: TGedFrame.h:53
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
virtual Double_t GetDX() const
Definition: TGeoBBox.h:70
virtual Double_t GetDZ() const
Definition: TGeoBBox.h:72
virtual Double_t GetDY() const
Definition: TGeoBBox.h:71
Editor for a TGeoEltu.
TGTextButton * fApply
virtual ~TGeoEltuEditor()
Destructor.
virtual void SetModel(TObject *obj)
Connect to the selected object.
Bool_t fIsShapeEditable
TGTextButton * fUndo
TGNumberEntry * fEDz
void DoB()
Slot for B.
TGTextEntry * fShapeName
TGeoEltu * fShape
TGCheckButton * fDelayed
TGeoEltuEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for para editor.
void DoDz()
Slot for Z.
void DoApply()
Slot for applying current settings.
TGNumberEntry * fEA
void DoName()
Slot for name.
virtual void ConnectSignals2Slots()
Connect signals to slots.
void DoUndo()
Slot for undoing last operation.
TGNumberEntry * fEB
void DoModified()
Slot for notifying modifications.
Bool_t IsDelayed() const
Check if shape drawing is delayed.
void DoA()
Slot for A.
Elliptical tube class.
Definition: TGeoEltu.h:18
virtual Double_t GetA() const
Definition: TGeoEltu.h:43
virtual void SetDimensions(Double_t *param)
Set shape dimensions starting from an array.
Definition: TGeoEltu.cxx:453
virtual void ComputeBBox()
compute bounding box of the tube
Definition: TGeoEltu.cxx:114
virtual Double_t GetB() const
Definition: TGeoEltu.h:44
Common base class for geombuilder editors.
Definition: TGeoGedFrame.h:13
virtual void Update()
Override Update from TGedFrame as fGedEditor can be null.
TVirtualPad * fPad
Definition: TGeoGedFrame.h:18
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
TVirtualGeoPainter * GetPainter() const
Definition: TGeoManager.h:198
virtual const char * GetName() const
Get the shape name.
Definition: TGeoShape.cxx:248
virtual void Draw(Option_t *option="")
Draw this shape.
Definition: TGeoShape.cxx:721
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
virtual Double_t GetDz() const
Definition: TGeoTube.h:68
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
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
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
auto * a
Definition: textangle.C:12