Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "TVirtualPad.h"
29#include "TView.h"
30#include "TGButton.h"
31#include "TGTextEntry.h"
32#include "TGNumberEntry.h"
33#include "TGLabel.h"
34
36
40};
41
42////////////////////////////////////////////////////////////////////////////////
43/// Constructor for para editor
44
46 Int_t height, UInt_t options, Pixel_t back)
47 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
48{
49 fShape = 0;
50 fAi = fBi = fDzi = 0.0;
51 fNamei = "";
54
55 // TextEntry for shape name
56 MakeTitle("Name");
57 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kELTU_NAME);
59 fShapeName->SetToolTipText("Enter the elliptical tube name");
60 fShapeName->Associate(this);
62
63 TGTextEntry *nef;
64 MakeTitle("Dimensions");
65 // Number entry for A
67 f1->AddFrame(new TGLabel(f1, "A"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
68 fEA = new TGNumberEntry(f1, 0., 5, kELTU_A);
72 nef->SetToolTipText("Enter the semi-axis of the ellipse along x");
73 fEA->Associate(this);
74 f1->AddFrame(fEA, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
75 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
76
77 // Number entry for B
78 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
79 f1->AddFrame(new TGLabel(f1, "B"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
80 fEB = new TGNumberEntry(f1, 0., 5, kELTU_B);
84 nef->SetToolTipText("Enter the semi-axis of the ellipse along y");
85 fEB->Associate(this);
86 f1->AddFrame(fEB, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
87 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
88
89 // Number entry for dz
90 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
91 f1->AddFrame(new TGLabel(f1, "Dz"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
92 fEDz = new TGNumberEntry(f1, 0., 5, kELTU_DZ);
96 nef->SetToolTipText("Enter the half-length in Z");
97 fEDz->Associate(this);
98 f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
99 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
100
101 // Delayed draw
103 fDelayed = new TGCheckButton(f1, "Delayed draw");
104 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
105 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
106
107 // Buttons
108 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
109 fApply = new TGTextButton(f1, "Apply");
110 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
111 fApply->Associate(this);
112 fUndo = new TGTextButton(f1, "Undo");
113 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
114 fUndo->Associate(this);
115 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
117}
118
119////////////////////////////////////////////////////////////////////////////////
120/// Destructor
121
123{
124 TGFrameElement *el;
125 TIter next(GetList());
126 while ((el = (TGFrameElement *)next())) {
127 if (el->fFrame->IsComposite())
129 }
130 Cleanup();
131}
132
133////////////////////////////////////////////////////////////////////////////////
134/// Connect signals to slots.
135
137{
138 fApply->Connect("Clicked()", "TGeoEltuEditor", this, "DoApply()");
139 fUndo->Connect("Clicked()", "TGeoEltuEditor", this, "DoUndo()");
140 fShapeName->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
141 fEA->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoA()");
142 fEB->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoB()");
143 fEDz->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoDz()");
144 fEA->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
145 fEB->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
146 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
147 fInit = kFALSE;
148}
149
150////////////////////////////////////////////////////////////////////////////////
151/// Connect to the selected object.
152
154{
155 if (obj == 0 || (obj->IsA()!=TGeoEltu::Class())) {
157 return;
158 }
159 fShape = (TGeoEltu*)obj;
160 fAi = fShape->GetA();
161 fBi = fShape->GetB();
162 fDzi = fShape->GetDz();
163 const char *sname = fShape->GetName();
164 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
165 else {
166 fShapeName->SetText(sname);
167 fNamei = sname;
168 }
169 fEA->SetNumber(fAi);
170 fEB->SetNumber(fBi);
174
176 SetActive();
177}
178
179////////////////////////////////////////////////////////////////////////////////
180/// Slot for name.
181
183{
184 DoModified();
185}
186
187////////////////////////////////////////////////////////////////////////////////
188/// Check if shape drawing is delayed.
189
191{
192 return (fDelayed->GetState() == kButtonDown);
193}
194
195////////////////////////////////////////////////////////////////////////////////
196/// Slot for applying current settings.
197
199{
200 const char *name = fShapeName->GetText();
201 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
202 Double_t a = fEA->GetNumber();
203 Double_t b = fEB->GetNumber();
204 Double_t z = fEDz->GetNumber();
205 Double_t param[3];
206 param[0] = a;
207 param[1] = b;
208 param[2] = z;
209 fShape->SetDimensions(param);
211 fUndo->SetEnabled();
213 if (fPad) {
215 TView *view = fPad->GetView();
216 if (!view) {
217 fShape->Draw();
218 fPad->GetView()->ShowAxis();
219 } else {
220 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(),
221 fShape->GetDX(), fShape->GetDY(), fShape->GetDZ());
222 Update();
223 }
224 } else Update();
225 }
226}
227
228////////////////////////////////////////////////////////////////////////////////
229/// Slot for notifying modifications.
230
232{
234}
235
236////////////////////////////////////////////////////////////////////////////////
237/// Slot for undoing last operation.
238
240{
241 fEA->SetNumber(fAi);
242 fEB->SetNumber(fBi);
244 DoApply();
247}
248
249////////////////////////////////////////////////////////////////////////////////
250/// Slot for A.
251
253{
254 Double_t a = fEA->GetNumber();
255 if (a <= 0) {
256 a = 0.1;
257 fEA->SetNumber(a);
258 }
259 DoModified();
260 if (!IsDelayed()) DoApply();
261}
262
263////////////////////////////////////////////////////////////////////////////////
264/// Slot for B.
265
267{
268 Double_t b = fEB->GetNumber();
269 if (b <= 0) {
270 b = 0.1;
271 fEB->SetNumber(b);
272 }
273 DoModified();
274 if (!IsDelayed()) DoApply();
275}
276
277////////////////////////////////////////////////////////////////////////////////
278/// Slot for Z.
279
281{
282 Double_t z = fEDz->GetNumber();
283 if (z <= 0) {
284 z = 0.1;
285 fEDz->SetNumber(z);
286 }
287 DoModified();
288 if (!IsDelayed()) DoApply();
289}
290
@ kSunkenFrame
Definition GuiTypes.h:383
@ 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
#define b(i)
Definition RSha256.hxx:100
#define a(i)
Definition RSha256.hxx:99
const Bool_t kFALSE
Definition RtypesCore.h:92
double Double_t
Definition RtypesCore.h:59
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
@ kButtonDown
Definition TGButton.h:54
@ kLHintsRight
Definition TGLayout.h:33
@ kLHintsLeft
Definition TGLayout.h:31
char name[80]
Definition TGX11.cxx:110
ETGeoEltuWid
@ kELTU_A
@ kELTU_NAME
@ kELTU_UNDO
@ kELTU_B
@ kELTU_APPLY
@ kELTU_DZ
R__EXTERN TGeoManager * gGeoManager
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:412
virtual TList * GetList() const
Definition TGFrame.h:346
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1102
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:952
TGFrame * fFrame
Definition TGLayout.h:119
virtual void SetSize(const TGDimension &s)
Definition TGFrame.h:276
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:215
TGDimension GetSize() const
Definition TGFrame.h:254
virtual Bool_t IsComposite() const
Definition TGFrame.h:236
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:590
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
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:82
Bool_t fInit
Definition TGedFrame.h:54
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.
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
virtual const char * GetName() const
Get the shape name.
virtual void Draw(Option_t *option="")
Draw this shape.
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:130
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:866
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