Logo ROOT   6.18/05
Reference Guide
TGeoParaEditor.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 TGeoParaEditor
13\ingroup Geometry_builder
14
15Editor for a TGeoPara.
16
17\image html geom_para_pic.png
18
19\image html geom_para_ed.png
20
21*/
22
23#include "TGeoParaEditor.h"
24#include "TGeoTabManager.h"
25#include "TGeoPara.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 fXi = fYi = fZi = fAlphai = fThetai = fPhii = 0.0;
53 fNamei = "";
56
57 // TextEntry for shape name
58 MakeTitle("Name");
59 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kPARA_NAME);
61 fShapeName->SetToolTipText("Enter the parallelepiped name");
62 fShapeName->Associate(this);
64
65 TGTextEntry *nef;
66 MakeTitle("Dimensions");
67 // Number entry for dx
69 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
70 fEDx = new TGNumberEntry(f1, 0., 5, kPARA_X);
74 nef->SetToolTipText("Enter the half-length in X");
75 fEDx->Associate(this);
76 f1->AddFrame(fEDx, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
77 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
78
79 // Number entry for dy
80 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
81 f1->AddFrame(new TGLabel(f1, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
82 fEDy = new TGNumberEntry(f1, 0., 5, kPARA_Y);
86 nef->SetToolTipText("Enter the half-length in Y");
87 fEDy->Associate(this);
88 f1->AddFrame(fEDy, 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, kPARA_Z);
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 // Number entry for Alpha
104 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
105 f1->AddFrame(new TGLabel(f1, "Alpha"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
106 fEAlpha = new TGNumberEntry(f1, 0., 5, kPARA_ALPHA);
109 nef->SetToolTipText("Enter the angle with respect to Y axis [deg]");
110 fEAlpha->Associate(this);
111 f1->AddFrame(fEAlpha, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
112 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
113
114 // Number entry for Theta
115 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
116 f1->AddFrame(new TGLabel(f1, "Theta"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
117 fETheta = new TGNumberEntry(f1, 0., 5, kPARA_THETA);
121 nef->SetToolTipText("Enter the theta angle of the para axis [deg]");
122 fETheta->Associate(this);
123 f1->AddFrame(fETheta, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
124 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
125
126 // Number entry for Phi
127 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
128 f1->AddFrame(new TGLabel(f1, "Phi"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
129 fEPhi = new TGNumberEntry(f1, 0., 5, kPARA_PHI);
133 nef->SetToolTipText("Enter the phi angle of the para axis [deg]");
134 fEPhi->Associate(this);
135 f1->AddFrame(fEPhi, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
136 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
137
138 // Delayed draw
140 fDelayed = new TGCheckButton(f1, "Delayed draw");
141 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
142 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
143
144 // Buttons
145 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
146 fApply = new TGTextButton(f1, "Apply");
147 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
148 fApply->Associate(this);
149 fUndo = new TGTextButton(f1, "Undo");
150 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
151 fUndo->Associate(this);
152 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
154}
155
156////////////////////////////////////////////////////////////////////////////////
157/// Destructor
158
160{
161 TGFrameElement *el;
162 TIter next(GetList());
163 while ((el = (TGFrameElement *)next())) {
164 if (el->fFrame->IsComposite())
166 }
167 Cleanup();
168}
169
170////////////////////////////////////////////////////////////////////////////////
171/// Connect signals to slots.
172
174{
175 fApply->Connect("Clicked()", "TGeoParaEditor", this, "DoApply()");
176 fUndo->Connect("Clicked()", "TGeoParaEditor", this, "DoUndo()");
177 fShapeName->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
178 fEDx->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoX()");
179 fEDy->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoY()");
180 fEDz->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoZ()");
181 fEAlpha->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoAlpha()");
182 fETheta->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoTheta()");
183 fEPhi->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoPhi()");
184 fEDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
185 fEDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
186 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
187 fEAlpha->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
188 fETheta->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
189 fEPhi->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
190 fInit = kFALSE;
191}
192
193
194////////////////////////////////////////////////////////////////////////////////
195/// Connect to the selected object.
196
198{
199 if (obj == 0 || (obj->IsA()!=TGeoPara::Class())) {
201 return;
202 }
203 fShape = (TGeoPara*)obj;
204 fXi = fShape->GetX();
205 fYi = fShape->GetY();
206 fZi = fShape->GetZ();
209 fPhii = fShape->GetPhi();
210 const char *sname = fShape->GetName();
211 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
212 else {
213 fShapeName->SetText(sname);
214 fNamei = sname;
215 }
224
226 SetActive();
227}
228
229////////////////////////////////////////////////////////////////////////////////
230/// Check if shape drawing is delayed.
231
233{
234 return (fDelayed->GetState() == kButtonDown);
235}
236
237////////////////////////////////////////////////////////////////////////////////
238/// Slot for name.
239
241{
242 DoModified();
243}
244
245////////////////////////////////////////////////////////////////////////////////
246/// Slot for applying current settings.
247
249{
250 const char *name = fShapeName->GetText();
251 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
252 Double_t dx = fEDx->GetNumber();
253 Double_t dy = fEDy->GetNumber();
254 Double_t dz = fEDz->GetNumber();
255 Double_t alpha = fEAlpha->GetNumber();
256 Double_t theta = fETheta->GetNumber();
257 Double_t phi = fEPhi->GetNumber();
258 Double_t param[6];
259 param[0] = dx;
260 param[1] = dy;
261 param[2] = dz;
262 param[3] = alpha;
263 param[4] = theta;
264 param[5] = phi;
265 fShape->SetDimensions(param);
267 fUndo->SetEnabled();
269 if (fPad) {
271 TView *view = fPad->GetView();
272 if (!view) {
273 fShape->Draw();
274 fPad->GetView()->ShowAxis();
275 } else {
276 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(),
277 fShape->GetDX(), fShape->GetDY(), fShape->GetDZ());
278 Update();
279 }
280 } else Update();
281 }
282}
283
284////////////////////////////////////////////////////////////////////////////////
285/// Slot for notifying modifications.
286
288{
290}
291
292////////////////////////////////////////////////////////////////////////////////
293/// Slot for undoing last operation.
294
296{
303 DoApply();
306}
307
308////////////////////////////////////////////////////////////////////////////////
309/// Slot for X.
310
312{
313 Double_t dx = fEDx->GetNumber();
314 if (dx<=0) {
315 dx = 0.1;
316 fEDx->SetNumber(dx);
317 }
318 DoModified();
319 if (!IsDelayed()) DoApply();
320}
321
322////////////////////////////////////////////////////////////////////////////////
323/// Slot for Y.
324
326{
327 Double_t dy = fEDy->GetNumber();
328 if (dy<=0) {
329 dy = 0.1;
330 fEDy->SetNumber(dy);
331 }
332 DoModified();
333 if (!IsDelayed()) DoApply();
334}
335
336////////////////////////////////////////////////////////////////////////////////
337/// Slot for Z.
338
340{
341 Double_t dz = fEDz->GetNumber();
342 if (dz<=0) {
343 dz = 0.1;
344 fEDz->SetNumber(dz);
345 }
346 DoModified();
347 if (!IsDelayed()) DoApply();
348}
349
350////////////////////////////////////////////////////////////////////////////////
351/// Slot for alpha.
352
354{
355 Double_t alpha = fEAlpha->GetNumber();
356 if (TMath::Abs(alpha)>=90) {
357 alpha = 89.9*TMath::Sign(1.,alpha);
358 fEAlpha->SetNumber(alpha);
359 }
360 DoModified();
361 if (!IsDelayed()) DoApply();
362}
363
364////////////////////////////////////////////////////////////////////////////////
365/// Slot for theta.
366
368{
369 Double_t theta = fETheta->GetNumber();
370 if (theta<0) {
371 theta = 0;
372 fETheta->SetNumber(theta);
373 }
374 if (theta>180) {
375 theta = 180;
376 fETheta->SetNumber(theta);
377 }
378 DoModified();
379 if (!IsDelayed()) DoApply();
380}
381
382////////////////////////////////////////////////////////////////////////////////
383/// Slot for phi.
384
386{
387 Double_t phi = fEPhi->GetNumber();
388 if (phi<0 || phi>360) {
389 phi = 0;
390 fEPhi->SetNumber(phi);
391 }
392 DoModified();
393 if (!IsDelayed()) DoApply();
394}
395
void Class()
Definition: Class.C:29
ULong_t Pixel_t
Definition: GuiTypes.h:39
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:365
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
char name[80]
Definition: TGX11.cxx:109
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:601
ETGeoParaWid
@ kPARA_Z
@ kPARA_X
@ kPARA_NAME
@ kPARA_UNDO
@ kPARA_APPLY
@ kPARA_PHI
@ kPARA_THETA
@ kPARA_ALPHA
@ kPARA_Y
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
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:212
Editor for a TGeoPara.
void DoName()
Slot for name.
void DoX()
Slot for X.
virtual ~TGeoParaEditor()
Destructor.
TGNumberEntry * fETheta
TGNumberEntry * fEDy
void DoPhi()
Slot for phi.
TGNumberEntry * fEPhi
TGTextEntry * fShapeName
Bool_t IsDelayed() const
Check if shape drawing is delayed.
TGTextButton * fApply
TGCheckButton * fDelayed
TGNumberEntry * fEDz
TGeoParaEditor(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 DoZ()
Slot for Z.
virtual void SetModel(TObject *obj)
Connect to the selected object.
void DoAlpha()
Slot for alpha.
TGNumberEntry * fEDx
void DoUndo()
Slot for undoing last operation.
TGeoPara * fShape
void DoY()
Slot for Y.
void DoModified()
Slot for notifying modifications.
Double_t fAlphai
Bool_t fIsShapeEditable
void DoTheta()
Slot for theta.
Double_t fThetai
TGNumberEntry * fEAlpha
void DoApply()
Slot for applying current settings.
TGTextButton * fUndo
virtual void ConnectSignals2Slots()
Connect signals to slots.
Parallelepiped class.
Definition: TGeoPara.h:18
Double_t GetZ() const
Definition: TGeoPara.h:63
Double_t GetPhi() const
Definition: TGeoPara.h:66
virtual void SetDimensions(Double_t *param)
Set dimensions starting from an array.
Definition: TGeoPara.cxx:592
Double_t GetAlpha() const
Definition: TGeoPara.h:64
virtual void ComputeBBox()
compute bounding box
Definition: TGeoPara.cxx:158
Double_t GetX() const
Definition: TGeoPara.h:61
Double_t GetY() const
Definition: TGeoPara.h:62
Double_t GetTheta() const
Definition: TGeoPara.h:65
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 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
T1 Sign(T1 a, T2 b)
Definition: TMathBase.h:165
Short_t Abs(Short_t d)
Definition: TMathBase.h:120