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
35
47
48////////////////////////////////////////////////////////////////////////////////
49/// Constructor for para editor
50
52 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
53{
54 fShape = nullptr;
55 fXi = fYi = fZi = fAlphai = fThetai = fPhii = 0.0;
56 fNamei = "";
59
60 // TextEntry for shape name
61 MakeTitle("Name");
62 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kPARA_NAME);
64 fShapeName->SetToolTipText("Enter the parallelepiped name");
65 fShapeName->Associate(this);
67
69 MakeTitle("Dimensions");
70 // Number entry for dx
72 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
73 fEDx = new TGNumberEntry(f1, 0., 5, kPARA_X);
77 nef->SetToolTipText("Enter the half-length in X");
78 fEDx->Associate(this);
79 f1->AddFrame(fEDx, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
80 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
81
82 // Number entry for dy
83 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
84 f1->AddFrame(new TGLabel(f1, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
85 fEDy = new TGNumberEntry(f1, 0., 5, kPARA_Y);
89 nef->SetToolTipText("Enter the half-length in Y");
90 fEDy->Associate(this);
91 f1->AddFrame(fEDy, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
92 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
93
94 // Number entry for dz
95 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
96 f1->AddFrame(new TGLabel(f1, "Dz"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
97 fEDz = new TGNumberEntry(f1, 0., 5, kPARA_Z);
101 nef->SetToolTipText("Enter the half-length in Z");
102 fEDz->Associate(this);
103 f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
104 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
105
106 // Number entry for Alpha
107 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
108 f1->AddFrame(new TGLabel(f1, "Alpha"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
109 fEAlpha = new TGNumberEntry(f1, 0., 5, kPARA_ALPHA);
112 nef->SetToolTipText("Enter the angle with respect to Y axis [deg]");
113 fEAlpha->Associate(this);
114 f1->AddFrame(fEAlpha, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
115 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
116
117 // Number entry for Theta
118 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
119 f1->AddFrame(new TGLabel(f1, "Theta"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
120 fETheta = new TGNumberEntry(f1, 0., 5, kPARA_THETA);
124 nef->SetToolTipText("Enter the theta angle of the para axis [deg]");
125 fETheta->Associate(this);
126 f1->AddFrame(fETheta, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
127 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
128
129 // Number entry for Phi
130 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
131 f1->AddFrame(new TGLabel(f1, "Phi"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
132 fEPhi = new TGNumberEntry(f1, 0., 5, kPARA_PHI);
136 nef->SetToolTipText("Enter the phi angle of the para axis [deg]");
137 fEPhi->Associate(this);
138 f1->AddFrame(fEPhi, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
139 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
140
141 // Delayed draw
143 fDelayed = new TGCheckButton(f1, "Delayed draw");
144 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
145 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
146
147 // Buttons
148 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
149 fApply = new TGTextButton(f1, "Apply");
150 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
151 fApply->Associate(this);
152 fUndo = new TGTextButton(f1, "Undo");
153 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
154 fUndo->Associate(this);
155 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
157}
158
159////////////////////////////////////////////////////////////////////////////////
160/// Destructor
161
163{
165 TIter next(GetList());
166 while ((el = (TGFrameElement *)next())) {
167 if (el->fFrame->IsComposite())
169 }
170 Cleanup();
171}
172
173////////////////////////////////////////////////////////////////////////////////
174/// Connect signals to slots.
175
177{
178 fApply->Connect("Clicked()", "TGeoParaEditor", this, "DoApply()");
179 fUndo->Connect("Clicked()", "TGeoParaEditor", this, "DoUndo()");
180 fShapeName->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
181 fEDx->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoX()");
182 fEDy->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoY()");
183 fEDz->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoZ()");
184 fEAlpha->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoAlpha()");
185 fETheta->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoTheta()");
186 fEPhi->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoPhi()");
187 fEDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
188 fEDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
189 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
190 fEAlpha->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
191 fETheta->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
192 fEPhi->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
193 fInit = kFALSE;
194}
195
196////////////////////////////////////////////////////////////////////////////////
197/// Connect to the selected object.
198
200{
201 if (obj == nullptr || (obj->IsA() != TGeoPara::Class())) {
203 return;
204 }
205 fShape = (TGeoPara *)obj;
206 fXi = fShape->GetX();
207 fYi = fShape->GetY();
208 fZi = fShape->GetZ();
211 fPhii = fShape->GetPhi();
212 const char *sname = fShape->GetName();
213 if (!strcmp(sname, fShape->ClassName()))
214 fShapeName->SetText("-no_name");
215 else {
217 fNamei = sname;
218 }
227
228 if (fInit)
230 SetActive();
231}
232
233////////////////////////////////////////////////////////////////////////////////
234/// Check if shape drawing is delayed.
235
237{
238 return (fDelayed->GetState() == kButtonDown);
239}
240
241////////////////////////////////////////////////////////////////////////////////
242/// Slot for name.
243
245{
246 DoModified();
247}
248
249////////////////////////////////////////////////////////////////////////////////
250/// Slot for applying current settings.
251
253{
254 const char *name = fShapeName->GetText();
255 if (strcmp(name, fShape->GetName()))
260 Double_t alpha = fEAlpha->GetNumber();
261 Double_t theta = fETheta->GetNumber();
262 Double_t phi = fEPhi->GetNumber();
263 Double_t param[6];
264 param[0] = dx;
265 param[1] = dy;
266 param[2] = dz;
267 param[3] = alpha;
268 param[4] = theta;
269 param[5] = phi;
270 fShape->SetDimensions(param);
272 fUndo->SetEnabled();
274 if (fPad) {
276 TView *view = fPad->GetView();
277 if (!view) {
278 fShape->Draw();
279 fPad->GetView()->ShowAxis();
280 } else {
281 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(), fShape->GetDX(), fShape->GetDY(),
282 fShape->GetDZ());
283 Update();
284 }
285 } else
286 Update();
287 }
288}
289
290////////////////////////////////////////////////////////////////////////////////
291/// Slot for notifying modifications.
292
297
298////////////////////////////////////////////////////////////////////////////////
299/// Slot for undoing last operation.
300
313
314////////////////////////////////////////////////////////////////////////////////
315/// Slot for X.
316
318{
320 if (dx <= 0) {
321 dx = 0.1;
322 fEDx->SetNumber(dx);
323 }
324 DoModified();
325 if (!IsDelayed())
326 DoApply();
327}
328
329////////////////////////////////////////////////////////////////////////////////
330/// Slot for Y.
331
333{
335 if (dy <= 0) {
336 dy = 0.1;
337 fEDy->SetNumber(dy);
338 }
339 DoModified();
340 if (!IsDelayed())
341 DoApply();
342}
343
344////////////////////////////////////////////////////////////////////////////////
345/// Slot for Z.
346
348{
350 if (dz <= 0) {
351 dz = 0.1;
352 fEDz->SetNumber(dz);
353 }
354 DoModified();
355 if (!IsDelayed())
356 DoApply();
357}
358
359////////////////////////////////////////////////////////////////////////////////
360/// Slot for alpha.
361
363{
364 Double_t alpha = fEAlpha->GetNumber();
365 if (TMath::Abs(alpha) >= 90) {
366 alpha = 89.9 * TMath::Sign(1., alpha);
367 fEAlpha->SetNumber(alpha);
368 }
369 DoModified();
370 if (!IsDelayed())
371 DoApply();
372}
373
374////////////////////////////////////////////////////////////////////////////////
375/// Slot for theta.
376
378{
379 Double_t theta = fETheta->GetNumber();
380 if (theta < 0) {
381 theta = 0;
382 fETheta->SetNumber(theta);
383 }
384 if (theta > 180) {
385 theta = 180;
386 fETheta->SetNumber(theta);
387 }
388 DoModified();
389 if (!IsDelayed())
390 DoApply();
391}
392
393////////////////////////////////////////////////////////////////////////////////
394/// Slot for phi.
395
397{
398 Double_t phi = fEPhi->GetNumber();
399 if (phi < 0 || phi > 360) {
400 phi = 0;
401 fEPhi->SetNumber(phi);
402 }
403 DoModified();
404 if (!IsDelayed())
405 DoApply();
406}
@ 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:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ 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:453
Selects different options.
Definition TGButton.h:264
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
virtual TList * GetList() const
Definition TGFrame.h:312
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:959
TGCompositeFrame(const TGCompositeFrame &)=delete
virtual void SetSize(const TGDimension &s)
Definition TGFrame.h:254
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
TGDimension GetSize() const
Definition TGFrame.h:232
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:94
virtual Double_t GetDX() const
Definition TGeoBBox.h:76
virtual Double_t GetDZ() const
Definition TGeoBBox.h:78
virtual Double_t GetDY() const
Definition TGeoBBox.h:77
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
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.
Parallelepiped class.
Definition TGeoPara.h:17
void SetDimensions(Double_t *param) override
Set dimensions starting from an array.
Definition TGeoPara.cxx:636
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
compute bounding box
Definition TGeoPara.cxx:170
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:149
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:226
virtual TClass * IsA() const
Definition TObject.h:246
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:865
See TView3D.
Definition TView.h:25
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:176
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:124