Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "TVirtualPad.h"
29#include "TView.h"
30#include "TGButton.h"
31#include "TGTextEntry.h"
32#include "TGNumberEntry.h"
33#include "TGLabel.h"
34
36
47};
48
49////////////////////////////////////////////////////////////////////////////////
50/// Constructor for para editor
51
53 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
54{
55 fShape = nullptr;
56 fXi = fYi = fZi = fAlphai = fThetai = fPhii = 0.0;
57 fNamei = "";
60
61 // TextEntry for shape name
62 MakeTitle("Name");
63 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kPARA_NAME);
65 fShapeName->SetToolTipText("Enter the parallelepiped name");
66 fShapeName->Associate(this);
68
69 TGTextEntry *nef;
70 MakeTitle("Dimensions");
71 // Number entry for dx
73 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
74 fEDx = new TGNumberEntry(f1, 0., 5, kPARA_X);
78 nef->SetToolTipText("Enter the half-length in X");
79 fEDx->Associate(this);
80 f1->AddFrame(fEDx, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
81 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
82
83 // Number entry for dy
84 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
85 f1->AddFrame(new TGLabel(f1, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
86 fEDy = new TGNumberEntry(f1, 0., 5, kPARA_Y);
90 nef->SetToolTipText("Enter the half-length in Y");
91 fEDy->Associate(this);
92 f1->AddFrame(fEDy, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
93 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
94
95 // Number entry for dz
96 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
97 f1->AddFrame(new TGLabel(f1, "Dz"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
98 fEDz = new TGNumberEntry(f1, 0., 5, kPARA_Z);
101 nef = (TGTextEntry *)fEDz->GetNumberEntry();
102 nef->SetToolTipText("Enter the half-length in Z");
103 fEDz->Associate(this);
104 f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
105 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
106
107 // Number entry for Alpha
108 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
109 f1->AddFrame(new TGLabel(f1, "Alpha"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
110 fEAlpha = new TGNumberEntry(f1, 0., 5, kPARA_ALPHA);
113 nef->SetToolTipText("Enter the angle with respect to Y axis [deg]");
114 fEAlpha->Associate(this);
115 f1->AddFrame(fEAlpha, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
116 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
117
118 // Number entry for Theta
119 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
120 f1->AddFrame(new TGLabel(f1, "Theta"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
121 fETheta = new TGNumberEntry(f1, 0., 5, kPARA_THETA);
125 nef->SetToolTipText("Enter the theta angle of the para axis [deg]");
126 fETheta->Associate(this);
127 f1->AddFrame(fETheta, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
128 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
129
130 // Number entry for Phi
131 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
132 f1->AddFrame(new TGLabel(f1, "Phi"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
133 fEPhi = new TGNumberEntry(f1, 0., 5, kPARA_PHI);
136 nef = (TGTextEntry *)fEPhi->GetNumberEntry();
137 nef->SetToolTipText("Enter the phi angle of the para axis [deg]");
138 fEPhi->Associate(this);
139 f1->AddFrame(fEPhi, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
140 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
141
142 // Delayed draw
144 fDelayed = new TGCheckButton(f1, "Delayed draw");
145 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
146 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
147
148 // Buttons
149 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
150 fApply = new TGTextButton(f1, "Apply");
151 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
152 fApply->Associate(this);
153 fUndo = new TGTextButton(f1, "Undo");
154 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
155 fUndo->Associate(this);
156 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
158}
159
160////////////////////////////////////////////////////////////////////////////////
161/// Destructor
162
164{
165 TGFrameElement *el;
166 TIter next(GetList());
167 while ((el = (TGFrameElement *)next())) {
168 if (el->fFrame->IsComposite())
170 }
171 Cleanup();
172}
173
174////////////////////////////////////////////////////////////////////////////////
175/// Connect signals to slots.
176
178{
179 fApply->Connect("Clicked()", "TGeoParaEditor", this, "DoApply()");
180 fUndo->Connect("Clicked()", "TGeoParaEditor", this, "DoUndo()");
181 fShapeName->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
182 fEDx->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoX()");
183 fEDy->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoY()");
184 fEDz->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoZ()");
185 fEAlpha->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoAlpha()");
186 fETheta->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoTheta()");
187 fEPhi->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoPhi()");
188 fEDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
189 fEDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
190 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
191 fEAlpha->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
192 fETheta->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
193 fEPhi->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
194 fInit = kFALSE;
195}
196
197////////////////////////////////////////////////////////////////////////////////
198/// Connect to the selected object.
199
201{
202 if (obj == nullptr || (obj->IsA() != TGeoPara::Class())) {
204 return;
205 }
206 fShape = (TGeoPara *)obj;
207 fXi = fShape->GetX();
208 fYi = fShape->GetY();
209 fZi = fShape->GetZ();
212 fPhii = fShape->GetPhi();
213 const char *sname = fShape->GetName();
214 if (!strcmp(sname, fShape->ClassName()))
215 fShapeName->SetText("-no_name");
216 else {
217 fShapeName->SetText(sname);
218 fNamei = sname;
219 }
228
229 if (fInit)
231 SetActive();
232}
233
234////////////////////////////////////////////////////////////////////////////////
235/// Check if shape drawing is delayed.
236
238{
239 return (fDelayed->GetState() == kButtonDown);
240}
241
242////////////////////////////////////////////////////////////////////////////////
243/// Slot for name.
244
246{
247 DoModified();
248}
249
250////////////////////////////////////////////////////////////////////////////////
251/// Slot for applying current settings.
252
254{
255 const char *name = fShapeName->GetText();
256 if (strcmp(name, fShape->GetName()))
258 Double_t dx = fEDx->GetNumber();
259 Double_t dy = fEDy->GetNumber();
260 Double_t dz = fEDz->GetNumber();
261 Double_t alpha = fEAlpha->GetNumber();
262 Double_t theta = fETheta->GetNumber();
263 Double_t phi = fEPhi->GetNumber();
264 Double_t param[6];
265 param[0] = dx;
266 param[1] = dy;
267 param[2] = dz;
268 param[3] = alpha;
269 param[4] = theta;
270 param[5] = phi;
271 fShape->SetDimensions(param);
273 fUndo->SetEnabled();
275 if (fPad) {
277 TView *view = fPad->GetView();
278 if (!view) {
279 fShape->Draw();
280 fPad->GetView()->ShowAxis();
281 } else {
282 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(), fShape->GetDX(), fShape->GetDY(),
283 fShape->GetDZ());
284 Update();
285 }
286 } else
287 Update();
288 }
289}
290
291////////////////////////////////////////////////////////////////////////////////
292/// Slot for notifying modifications.
293
295{
297}
298
299////////////////////////////////////////////////////////////////////////////////
300/// Slot for undoing last operation.
301
303{
310 DoApply();
313}
314
315////////////////////////////////////////////////////////////////////////////////
316/// Slot for X.
317
319{
320 Double_t dx = fEDx->GetNumber();
321 if (dx <= 0) {
322 dx = 0.1;
323 fEDx->SetNumber(dx);
324 }
325 DoModified();
326 if (!IsDelayed())
327 DoApply();
328}
329
330////////////////////////////////////////////////////////////////////////////////
331/// Slot for Y.
332
334{
335 Double_t dy = fEDy->GetNumber();
336 if (dy <= 0) {
337 dy = 0.1;
338 fEDy->SetNumber(dy);
339 }
340 DoModified();
341 if (!IsDelayed())
342 DoApply();
343}
344
345////////////////////////////////////////////////////////////////////////////////
346/// Slot for Z.
347
349{
350 Double_t dz = fEDz->GetNumber();
351 if (dz <= 0) {
352 dz = 0.1;
353 fEDz->SetNumber(dz);
354 }
355 DoModified();
356 if (!IsDelayed())
357 DoApply();
358}
359
360////////////////////////////////////////////////////////////////////////////////
361/// Slot for alpha.
362
364{
365 Double_t alpha = fEAlpha->GetNumber();
366 if (TMath::Abs(alpha) >= 90) {
367 alpha = 89.9 * TMath::Sign(1., alpha);
368 fEAlpha->SetNumber(alpha);
369 }
370 DoModified();
371 if (!IsDelayed())
372 DoApply();
373}
374
375////////////////////////////////////////////////////////////////////////////////
376/// Slot for theta.
377
379{
380 Double_t theta = fETheta->GetNumber();
381 if (theta < 0) {
382 theta = 0;
383 fETheta->SetNumber(theta);
384 }
385 if (theta > 180) {
386 theta = 180;
387 fETheta->SetNumber(theta);
388 }
389 DoModified();
390 if (!IsDelayed())
391 DoApply();
392}
393
394////////////////////////////////////////////////////////////////////////////////
395/// Slot for phi.
396
398{
399 Double_t phi = fEPhi->GetNumber();
400 if (phi < 0 || phi > 360) {
401 phi = 0;
402 fEPhi->SetNumber(phi);
403 }
404 DoModified();
405 if (!IsDelayed())
406 DoApply();
407}
@ 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
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
#define ClassImp(name)
Definition Rtypes.h:382
@ kButtonDown
Definition TGButton.h:54
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsLeft
Definition TGLayout.h:24
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
char name[80]
Definition TGX11.cxx:110
R__EXTERN TGeoManager * gGeoManager
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:459
Selects different options.
Definition TGButton.h:264
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual TList * GetList() const
Definition TGFrame.h:310
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:967
TGFrame * fFrame
Definition TGLayout.h:112
virtual void SetSize(const TGDimension &s)
Definition TGFrame.h:252
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:191
TGDimension GetSize() const
Definition TGFrame.h:230
virtual Bool_t IsComposite() const
Definition TGFrame.h:212
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGNumberEntry is a number entry input widget with up/down buttons.
TGNumberEntryField * GetNumberEntry() const
Get the number entry field.
void Associate(const TGWindow *w) override
Make w the window that will receive the generated messages.
void SetNumAttr(EAttribute attr=kNEAAnyNumber)
virtual Double_t GetNumber() const
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
UInt_t GetDefaultHeight() const override
@ kNEAPositive
Positive number.
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
Yield an action as soon as it is clicked.
Definition TGButton.h:142
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
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:72
ROOT GUI Window base class.
Definition TGWindow.h:23
Bool_t fInit
init flag for setting signals/slots
Definition TGedFrame.h:47
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:95
virtual Double_t GetDX() const
Definition TGeoBBox.h:79
virtual Double_t GetDZ() const
Definition TGeoBBox.h:81
virtual Double_t GetDY() const
Definition TGeoBBox.h:80
Common base class for geombuilder editors.
void Update() override
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
Editor for a TGeoPara.
void DoName()
Slot for name.
void DoX()
Slot for X.
TGNumberEntry * fETheta
TGNumberEntry * fEDy
void DoPhi()
Slot for phi.
TGeoParaEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for para editor.
TGNumberEntry * fEPhi
TGTextEntry * fShapeName
~TGeoParaEditor() override
Destructor.
Bool_t IsDelayed() const
Check if shape drawing is delayed.
TGTextButton * fApply
TGCheckButton * fDelayed
TGNumberEntry * fEDz
void SetModel(TObject *obj) override
Connect to the selected object.
void DoZ()
Slot for Z.
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.
Bool_t fIsShapeEditable
void DoTheta()
Slot for theta.
TGNumberEntry * fEAlpha
void DoApply()
Slot for applying current settings.
TGTextButton * fUndo
virtual void ConnectSignals2Slots()
Connect signals to slots.
void SetDimensions(Double_t *param) override
Double_t GetZ() const
Definition TGeoPara.h:68
Double_t GetPhi() const
Definition TGeoPara.h:71
Double_t GetAlpha() const
Definition TGeoPara.h:69
Double_t GetX() const
Definition TGeoPara.h:66
Double_t GetY() const
Definition TGeoPara.h:67
static TClass * Class()
Double_t GetTheta() const
Definition TGeoPara.h:70
void ComputeBBox() override
void Draw(Option_t *option="") override
Draw this shape.
const char * GetName() const override
Get the shape name.
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:41
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:213
virtual TClass * IsA() const
Definition TObject.h:243
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:869
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)
Returns a value with the magnitude of a and the sign of b.
Definition TMathBase.h:175
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123