Logo ROOT   6.14/05
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 
15 Editor 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);
63  AddFrame(fShapeName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
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);
72  fEA->Resize(100, fEA->GetDefaultHeight());
73  nef = (TGTextEntry*)fEA->GetNumberEntry();
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);
84  fEB->Resize(100, fEB->GetDefaultHeight());
85  nef = (TGTextEntry*)fEB->GetNumberEntry();
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);
96  fEDz->Resize(100, fEDz->GetDefaultHeight());
97  nef = (TGTextEntry*)fEDz->GetNumberEntry();
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
104  f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame);
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())) {
158  SetActive(kFALSE);
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);
173  fEDz->SetNumber(fDzi);
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);
212  fShape->ComputeBBox();
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 {
235  fApply->SetEnabled();
236 }
237 
238 ////////////////////////////////////////////////////////////////////////////////
239 /// Slot for undoing last operation.
240 
242 {
243  fEA->SetNumber(fAi);
244  fEB->SetNumber(fBi);
245  fEDz->SetNumber(fDzi);
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 
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
virtual void SetDimensions(Double_t *param)
Set shape dimensions starting from an array.
Definition: TGeoEltu.cxx:453
TGNumberEntry * fEDz
virtual Double_t GetDX() const
Definition: TGeoBBox.h:70
Bool_t IsDelayed() const
Check if shape drawing is delayed.
image html pict1_TGaxis_012 png width
Define new text attributes for the label number "labNum".
Definition: TGaxis.cxx:2551
TVirtualGeoPainter * GetPainter() const
Definition: TGeoManager.h:191
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
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.
virtual void SetNumber(Double_t val)
virtual Double_t GetB() const
Definition: TGeoEltu.h:44
See TView3D.
Definition: TView.h:25
Bool_t fIsShapeEditable
virtual void SetRange(const Double_t *min, const Double_t *max)=0
virtual Bool_t IsPaintingShape() const =0
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Editor for a TGeoEltu.
virtual Bool_t IsComposite() const
Definition: TGFrame.h:259
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
TGNumberEntry * fEA
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
ULong_t Pixel_t
Definition: GuiTypes.h:39
void Class()
Definition: Class.C:29
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
TGCompositeFrame(const TGCompositeFrame &)
virtual TList * GetList() const
Definition: TGFrame.h:369
virtual EButtonState GetState() const
Definition: TGButton.h:112
void DoB()
Slot for B.
void DoApply()
Slot for applying current settings.
virtual TView * GetView() const =0
ETGeoEltuWid
virtual const char * GetName() const
Get the shape name.
Definition: TGeoShape.cxx:248
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
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
virtual void SetSize(const TGDimension &s)
Definition: TGFrame.h:299
TGNumberEntry * fEB
auto * a
Definition: textangle.C:12
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
unsigned int UInt_t
Definition: RtypesCore.h:42
TGFrame * fFrame
Definition: TGLayout.h:119
virtual void ShowAxis()=0
virtual void SetModel(TObject *obj)
Connect to the selected object.
void DoModified()
Slot for notifying modifications.
TGTextButton * fApply
virtual Double_t GetDY() const
Definition: TGeoBBox.h:71
void SetNumAttr(EAttribute attr=kNEAAnyNumber)
const Bool_t kFALSE
Definition: RtypesCore.h:88
TGDimension GetSize() const
Definition: TGFrame.h:277
const char * GetText() const
Definition: TGTextEntry.h:134
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:238
#define ClassImp(name)
Definition: Rtypes.h:359
virtual ~TGeoEltuEditor()
Destructor.
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:562
double Double_t
Definition: RtypesCore.h:55
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:409
void DoDz()
Slot for Z.
virtual Double_t GetNumber() const
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
void DoName()
Slot for name.
TGCheckButton * fDelayed
Mother of all ROOT objects.
Definition: TObject.h:37
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
Bool_t fInit
Definition: TGedFrame.h:53
TGNumberEntryField * GetNumberEntry() const
TGTextButton * fUndo
TGeoEltu * fShape
Elliptical tube class.
Definition: TGeoEltu.h:17
void DoUndo()
Slot for undoing last operation.
TF1 * f1
Definition: legend1.C:11
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
virtual void Update()
Override Update from TGedFrame as fGedEditor can be null.
virtual Double_t GetA() const
Definition: TGeoEltu.h:43
void DoA()
Slot for A.
virtual void ConnectSignals2Slots()
Connect signals to slots.
virtual void ComputeBBox()
compute bounding box of the tube
Definition: TGeoEltu.cxx:114
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...
TVirtualPad * fPad
Definition: TGeoGedFrame.h:18
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
virtual void Draw(Option_t *option="")
Draw this shape.
Definition: TGeoShape.cxx:721
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
virtual Double_t GetDz() const
Definition: TGeoTube.h:68
char name[80]
Definition: TGX11.cxx:109
UInt_t GetDefaultHeight() const
Common base class for geombuilder editors.
Definition: TGeoGedFrame.h:13
virtual Double_t GetDZ() const
Definition: TGeoBBox.h:72
TGTextEntry * fShapeName