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
40};
41
42////////////////////////////////////////////////////////////////////////////////
43/// Constructor for para editor
44
46 Int_t height, UInt_t options, Pixel_t back)
47 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
48{
49 fShape = 0;
50 fXi = fYi = fZi = fAlphai = fThetai = fPhii = 0.0;
51 fNamei = "";
54
55 // TextEntry for shape name
56 MakeTitle("Name");
57 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kPARA_NAME);
59 fShapeName->SetToolTipText("Enter the parallelepiped name");
60 fShapeName->Associate(this);
62
63 TGTextEntry *nef;
64 MakeTitle("Dimensions");
65 // Number entry for dx
67 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
68 fEDx = new TGNumberEntry(f1, 0., 5, kPARA_X);
72 nef->SetToolTipText("Enter the half-length in X");
73 fEDx->Associate(this);
74 f1->AddFrame(fEDx, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
75 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
76
77 // Number entry for dy
78 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
79 f1->AddFrame(new TGLabel(f1, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
80 fEDy = new TGNumberEntry(f1, 0., 5, kPARA_Y);
84 nef->SetToolTipText("Enter the half-length in Y");
85 fEDy->Associate(this);
86 f1->AddFrame(fEDy, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
87 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
88
89 // Number entry for dz
90 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
91 f1->AddFrame(new TGLabel(f1, "Dz"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
92 fEDz = new TGNumberEntry(f1, 0., 5, kPARA_Z);
96 nef->SetToolTipText("Enter the half-length in Z");
97 fEDz->Associate(this);
98 f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
99 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
100
101 // Number entry for Alpha
102 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
103 f1->AddFrame(new TGLabel(f1, "Alpha"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
104 fEAlpha = new TGNumberEntry(f1, 0., 5, kPARA_ALPHA);
107 nef->SetToolTipText("Enter the angle with respect to Y axis [deg]");
108 fEAlpha->Associate(this);
109 f1->AddFrame(fEAlpha, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
110 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
111
112 // Number entry for Theta
113 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
114 f1->AddFrame(new TGLabel(f1, "Theta"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
115 fETheta = new TGNumberEntry(f1, 0., 5, kPARA_THETA);
119 nef->SetToolTipText("Enter the theta angle of the para axis [deg]");
120 fETheta->Associate(this);
121 f1->AddFrame(fETheta, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
122 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
123
124 // Number entry for Phi
125 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
126 f1->AddFrame(new TGLabel(f1, "Phi"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
127 fEPhi = new TGNumberEntry(f1, 0., 5, kPARA_PHI);
131 nef->SetToolTipText("Enter the phi angle of the para axis [deg]");
132 fEPhi->Associate(this);
133 f1->AddFrame(fEPhi, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
134 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
135
136 // Delayed draw
138 fDelayed = new TGCheckButton(f1, "Delayed draw");
139 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
140 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
141
142 // Buttons
143 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
144 fApply = new TGTextButton(f1, "Apply");
145 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
146 fApply->Associate(this);
147 fUndo = new TGTextButton(f1, "Undo");
148 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
149 fUndo->Associate(this);
150 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
152}
153
154////////////////////////////////////////////////////////////////////////////////
155/// Destructor
156
158{
159 TGFrameElement *el;
160 TIter next(GetList());
161 while ((el = (TGFrameElement *)next())) {
162 if (el->fFrame->IsComposite())
164 }
165 Cleanup();
166}
167
168////////////////////////////////////////////////////////////////////////////////
169/// Connect signals to slots.
170
172{
173 fApply->Connect("Clicked()", "TGeoParaEditor", this, "DoApply()");
174 fUndo->Connect("Clicked()", "TGeoParaEditor", this, "DoUndo()");
175 fShapeName->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
176 fEDx->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoX()");
177 fEDy->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoY()");
178 fEDz->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoZ()");
179 fEAlpha->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoAlpha()");
180 fETheta->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoTheta()");
181 fEPhi->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoPhi()");
182 fEDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
183 fEDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
184 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
185 fEAlpha->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
186 fETheta->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
187 fEPhi->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()");
188 fInit = kFALSE;
189}
190
191
192////////////////////////////////////////////////////////////////////////////////
193/// Connect to the selected object.
194
196{
197 if (obj == 0 || (obj->IsA()!=TGeoPara::Class())) {
199 return;
200 }
201 fShape = (TGeoPara*)obj;
202 fXi = fShape->GetX();
203 fYi = fShape->GetY();
204 fZi = fShape->GetZ();
207 fPhii = fShape->GetPhi();
208 const char *sname = fShape->GetName();
209 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
210 else {
211 fShapeName->SetText(sname);
212 fNamei = sname;
213 }
222
224 SetActive();
225}
226
227////////////////////////////////////////////////////////////////////////////////
228/// Check if shape drawing is delayed.
229
231{
232 return (fDelayed->GetState() == kButtonDown);
233}
234
235////////////////////////////////////////////////////////////////////////////////
236/// Slot for name.
237
239{
240 DoModified();
241}
242
243////////////////////////////////////////////////////////////////////////////////
244/// Slot for applying current settings.
245
247{
248 const char *name = fShapeName->GetText();
249 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
250 Double_t dx = fEDx->GetNumber();
251 Double_t dy = fEDy->GetNumber();
252 Double_t dz = fEDz->GetNumber();
253 Double_t alpha = fEAlpha->GetNumber();
254 Double_t theta = fETheta->GetNumber();
255 Double_t phi = fEPhi->GetNumber();
256 Double_t param[6];
257 param[0] = dx;
258 param[1] = dy;
259 param[2] = dz;
260 param[3] = alpha;
261 param[4] = theta;
262 param[5] = phi;
263 fShape->SetDimensions(param);
265 fUndo->SetEnabled();
267 if (fPad) {
269 TView *view = fPad->GetView();
270 if (!view) {
271 fShape->Draw();
272 fPad->GetView()->ShowAxis();
273 } else {
274 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(),
275 fShape->GetDX(), fShape->GetDY(), fShape->GetDZ());
276 Update();
277 }
278 } else Update();
279 }
280}
281
282////////////////////////////////////////////////////////////////////////////////
283/// Slot for notifying modifications.
284
286{
288}
289
290////////////////////////////////////////////////////////////////////////////////
291/// Slot for undoing last operation.
292
294{
301 DoApply();
304}
305
306////////////////////////////////////////////////////////////////////////////////
307/// Slot for X.
308
310{
311 Double_t dx = fEDx->GetNumber();
312 if (dx<=0) {
313 dx = 0.1;
314 fEDx->SetNumber(dx);
315 }
316 DoModified();
317 if (!IsDelayed()) DoApply();
318}
319
320////////////////////////////////////////////////////////////////////////////////
321/// Slot for Y.
322
324{
325 Double_t dy = fEDy->GetNumber();
326 if (dy<=0) {
327 dy = 0.1;
328 fEDy->SetNumber(dy);
329 }
330 DoModified();
331 if (!IsDelayed()) DoApply();
332}
333
334////////////////////////////////////////////////////////////////////////////////
335/// Slot for Z.
336
338{
339 Double_t dz = fEDz->GetNumber();
340 if (dz<=0) {
341 dz = 0.1;
342 fEDz->SetNumber(dz);
343 }
344 DoModified();
345 if (!IsDelayed()) DoApply();
346}
347
348////////////////////////////////////////////////////////////////////////////////
349/// Slot for alpha.
350
352{
353 Double_t alpha = fEAlpha->GetNumber();
354 if (TMath::Abs(alpha)>=90) {
355 alpha = 89.9*TMath::Sign(1.,alpha);
356 fEAlpha->SetNumber(alpha);
357 }
358 DoModified();
359 if (!IsDelayed()) DoApply();
360}
361
362////////////////////////////////////////////////////////////////////////////////
363/// Slot for theta.
364
366{
367 Double_t theta = fETheta->GetNumber();
368 if (theta<0) {
369 theta = 0;
370 fETheta->SetNumber(theta);
371 }
372 if (theta>180) {
373 theta = 180;
374 fETheta->SetNumber(theta);
375 }
376 DoModified();
377 if (!IsDelayed()) DoApply();
378}
379
380////////////////////////////////////////////////////////////////////////////////
381/// Slot for phi.
382
384{
385 Double_t phi = fEPhi->GetNumber();
386 if (phi<0 || phi>360) {
387 phi = 0;
388 fEPhi->SetNumber(phi);
389 }
390 DoModified();
391 if (!IsDelayed()) DoApply();
392}
393
@ 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:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
@ 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:74
virtual Double_t GetDZ() const
Definition TGeoBBox.h:76
virtual Double_t GetDY() const
Definition TGeoBBox.h:75
Common base class for geombuilder editors.
virtual void Update()
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.
virtual ~TGeoParaEditor()
Destructor.
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
Bool_t IsDelayed() const
Check if shape drawing is delayed.
TGTextButton * fApply
TGCheckButton * fDelayed
TGNumberEntry * fEDz
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.
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:18
Double_t GetZ() const
Definition TGeoPara.h:66
Double_t GetPhi() const
Definition TGeoPara.h:69
virtual void SetDimensions(Double_t *param)
Set dimensions starting from an array.
Definition TGeoPara.cxx:605
Double_t GetAlpha() const
Definition TGeoPara.h:67
virtual void ComputeBBox()
compute bounding box
Definition TGeoPara.cxx:173
Double_t GetX() const
Definition TGeoPara.h:64
Double_t GetY() const
Definition TGeoPara.h:65
static TClass * Class()
Double_t GetTheta() const
Definition TGeoPara.h:68
virtual const char * GetName() const
Get the shape name.
virtual void Draw(Option_t *option="")
Draw this shape.
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:207
virtual TClass * IsA() const
Definition TObject.h:245
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