Logo ROOT   6.08/07
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 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TGeoEltuEditor //
15 // //
16 //////////////////////////////////////////////////////////////////////////
17 //Begin_Html
18 /*
19 <img src="gif/eltu_pic.gif">
20 */
21 //End_Html
22 //Begin_Html
23 /*
24 <img src="gif/eltu_ed.jpg">
25 */
26 //End_Html
27 
28 #include "TGeoEltuEditor.h"
29 #include "TGeoTabManager.h"
30 #include "TGeoEltu.h"
31 #include "TGeoManager.h"
32 #include "TVirtualGeoPainter.h"
33 #include "TPad.h"
34 #include "TView.h"
35 #include "TGTab.h"
36 #include "TGComboBox.h"
37 #include "TGButton.h"
38 #include "TGTextEntry.h"
39 #include "TGNumberEntry.h"
40 #include "TGLabel.h"
41 
43 
47 };
48 
49 ////////////////////////////////////////////////////////////////////////////////
50 /// Constructor for para editor
51 
53  Int_t height, UInt_t options, Pixel_t back)
54  : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
55 {
56  fShape = 0;
57  fAi = fBi = fDzi = 0.0;
58  fNamei = "";
61 
62  // TextEntry for shape name
63  MakeTitle("Name");
64  fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kELTU_NAME);
66  fShapeName->SetToolTipText("Enter the elliptical tube name");
67  fShapeName->Associate(this);
68  AddFrame(fShapeName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
69 
70  TGTextEntry *nef;
71  MakeTitle("Dimensions");
72  // Number entry for A
74  f1->AddFrame(new TGLabel(f1, "A"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
75  fEA = new TGNumberEntry(f1, 0., 5, kELTU_A);
77  fEA->Resize(100, fEA->GetDefaultHeight());
78  nef = (TGTextEntry*)fEA->GetNumberEntry();
79  nef->SetToolTipText("Enter the semi-axis of the ellipse along x");
80  fEA->Associate(this);
81  f1->AddFrame(fEA, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
82  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
83 
84  // Number entry for B
85  f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
86  f1->AddFrame(new TGLabel(f1, "B"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
87  fEB = new TGNumberEntry(f1, 0., 5, kELTU_B);
89  fEB->Resize(100, fEB->GetDefaultHeight());
90  nef = (TGTextEntry*)fEB->GetNumberEntry();
91  nef->SetToolTipText("Enter the semi-axis of the ellipse along y");
92  fEB->Associate(this);
93  f1->AddFrame(fEB, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
94  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
95 
96  // Number entry for dz
97  f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
98  f1->AddFrame(new TGLabel(f1, "Dz"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
99  fEDz = new TGNumberEntry(f1, 0., 5, kELTU_DZ);
101  fEDz->Resize(100, fEDz->GetDefaultHeight());
102  nef = (TGTextEntry*)fEDz->GetNumberEntry();
103  nef->SetToolTipText("Enter the half-lenth in Z");
104  fEDz->Associate(this);
105  f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
106  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
107 
108  // Delayed draw
109  f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame);
110  fDelayed = new TGCheckButton(f1, "Delayed draw");
111  f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
112  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
113 
114  // Buttons
115  f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
116  fApply = new TGTextButton(f1, "Apply");
117  f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
118  fApply->Associate(this);
119  fUndo = new TGTextButton(f1, "Undo");
120  f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
121  fUndo->Associate(this);
122  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
124 }
125 
126 ////////////////////////////////////////////////////////////////////////////////
127 /// Destructor
128 
130 {
131  TGFrameElement *el;
132  TIter next(GetList());
133  while ((el = (TGFrameElement *)next())) {
134  if (el->fFrame->IsComposite())
136  }
137  Cleanup();
138 }
139 
140 ////////////////////////////////////////////////////////////////////////////////
141 /// Connect signals to slots.
142 
144 {
145  fApply->Connect("Clicked()", "TGeoEltuEditor", this, "DoApply()");
146  fUndo->Connect("Clicked()", "TGeoEltuEditor", this, "DoUndo()");
147  fShapeName->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
148  fEA->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoA()");
149  fEB->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoB()");
150  fEDz->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoDz()");
151  fEA->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
152  fEB->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
153  fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
154  fInit = kFALSE;
155 }
156 
157 ////////////////////////////////////////////////////////////////////////////////
158 /// Connect to the selected object.
159 
161 {
162  if (obj == 0 || (obj->IsA()!=TGeoEltu::Class())) {
163  SetActive(kFALSE);
164  return;
165  }
166  fShape = (TGeoEltu*)obj;
167  fAi = fShape->GetA();
168  fBi = fShape->GetB();
169  fDzi = fShape->GetDz();
170  const char *sname = fShape->GetName();
171  if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
172  else {
173  fShapeName->SetText(sname);
174  fNamei = sname;
175  }
176  fEA->SetNumber(fAi);
177  fEB->SetNumber(fBi);
178  fEDz->SetNumber(fDzi);
181 
183  SetActive();
184 }
185 
186 ////////////////////////////////////////////////////////////////////////////////
187 /// Slot for name.
188 
190 {
191  DoModified();
192 }
193 
194 ////////////////////////////////////////////////////////////////////////////////
195 /// Check if shape drawing is delayed.
196 
198 {
199  return (fDelayed->GetState() == kButtonDown);
200 }
201 
202 ////////////////////////////////////////////////////////////////////////////////
203 /// Slot for applying current settings.
204 
206 {
207  const char *name = fShapeName->GetText();
208  if (strcmp(name,fShape->GetName())) fShape->SetName(name);
209  Double_t a = fEA->GetNumber();
210  Double_t b = fEB->GetNumber();
211  Double_t z = fEDz->GetNumber();
212  Double_t param[3];
213  param[0] = a;
214  param[1] = b;
215  param[2] = z;
216  fShape->SetDimensions(param);
217  fShape->ComputeBBox();
218  fUndo->SetEnabled();
220  if (fPad) {
222  TView *view = fPad->GetView();
223  if (!view) {
224  fShape->Draw();
225  fPad->GetView()->ShowAxis();
226  } else {
227  view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(),
228  fShape->GetDX(), fShape->GetDY(), fShape->GetDZ());
229  Update();
230  }
231  } else Update();
232  }
233 }
234 
235 ////////////////////////////////////////////////////////////////////////////////
236 /// Slot for notifying modifications.
237 
239 {
240  fApply->SetEnabled();
241 }
242 
243 ////////////////////////////////////////////////////////////////////////////////
244 /// Slot for undoing last operation.
245 
247 {
248  fEA->SetNumber(fAi);
249  fEB->SetNumber(fBi);
250  fEDz->SetNumber(fDzi);
251  DoApply();
254 }
255 
256 ////////////////////////////////////////////////////////////////////////////////
257 /// Slot for A.
258 
260 {
261  Double_t a = fEA->GetNumber();
262  if (a <= 0) {
263  a = 0.1;
264  fEA->SetNumber(a);
265  }
266  DoModified();
267  if (!IsDelayed()) DoApply();
268 }
269 
270 ////////////////////////////////////////////////////////////////////////////////
271 /// Slot for B.
272 
274 {
275  Double_t b = fEB->GetNumber();
276  if (b <= 0) {
277  b = 0.1;
278  fEB->SetNumber(b);
279  }
280  DoModified();
281  if (!IsDelayed()) DoApply();
282 }
283 
284 ////////////////////////////////////////////////////////////////////////////////
285 /// Slot for Z.
286 
288 {
289  Double_t z = fEDz->GetNumber();
290  if (z <= 0) {
291  z = 0.1;
292  fEDz->SetNumber(z);
293  }
294  DoModified();
295  if (!IsDelayed()) DoApply();
296 }
297 
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:72
Bool_t IsDelayed() const
Check if shape drawing is delayed.
TVirtualGeoPainter * GetPainter() const
Definition: TGeoManager.h:187
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:131
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:46
See TView3D.
Definition: TView.h:29
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
TArc * a
Definition: textangle.C:12
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual Bool_t IsComposite() const
Definition: TGFrame.h:275
const char * Class
Definition: TXMLSetup.cxx:64
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hirarchically 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:188
ULong_t Pixel_t
Definition: GuiTypes.h:41
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:385
virtual EButtonState GetState() const
Definition: TGButton.h:116
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:250
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:1137
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:315
TGNumberEntry * fEB
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:90
unsigned int UInt_t
Definition: RtypesCore.h:42
TGFrame * fFrame
Definition: TGLayout.h:125
virtual void ShowAxis()=0
virtual void SetModel(TObject *obj)
Connect to the selected object.
const std::string sname
Definition: testIO.cxx:45
void DoModified()
Slot for notifying modifications.
TGTextButton * fApply
virtual Double_t GetDY() const
Definition: TGeoBBox.h:73
void SetNumAttr(EAttribute attr=kNEAAnyNumber)
TGDimension GetSize() const
Definition: TGFrame.h:293
const char * GetText() const
Definition: TGTextEntry.h:140
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:254
#define ClassImp(name)
Definition: Rtypes.h:279
virtual ~TGeoEltuEditor()
Destructor.
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:554
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:55
TGNumberEntryField * GetNumberEntry() const
TGTextButton * fUndo
TGeoEltu * fShape
Elliptical tube class.
Definition: TGeoEltu.h:19
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:45
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:28
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:723
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
virtual Double_t GetDz() const
Definition: TGeoTube.h:70
char name[80]
Definition: TGX11.cxx:109
UInt_t GetDefaultHeight() const
virtual Double_t GetDZ() const
Definition: TGeoBBox.h:74
TGTextEntry * fShapeName