Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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/** \class TGeoEltuEditor
13\ingroup Geometry_builder
14
15Editor for a TGeoEltu.
16
17\image html geom_eltu_pic.png
18
19\image html geom_eltu_ed.png
20
21*/
22
23#include "TGeoEltuEditor.h"
24#include "TGeoTabManager.h"
25#include "TGeoEltu.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
37
38////////////////////////////////////////////////////////////////////////////////
39/// Constructor for para editor
40
42 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
43{
44 fShape = nullptr;
45 fAi = fBi = fDzi = 0.0;
46 fNamei = "";
49
50 // TextEntry for shape name
51 MakeTitle("Name");
52 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kELTU_NAME);
54 fShapeName->SetToolTipText("Enter the elliptical tube name");
55 fShapeName->Associate(this);
57
59 MakeTitle("Dimensions");
60 // Number entry for A
62 f1->AddFrame(new TGLabel(f1, "A"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
63 fEA = new TGNumberEntry(f1, 0., 5, kELTU_A);
67 nef->SetToolTipText("Enter the semi-axis of the ellipse along x");
68 fEA->Associate(this);
69 f1->AddFrame(fEA, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
70 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
71
72 // Number entry for B
73 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
74 f1->AddFrame(new TGLabel(f1, "B"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
75 fEB = new TGNumberEntry(f1, 0., 5, kELTU_B);
79 nef->SetToolTipText("Enter the semi-axis of the ellipse along y");
80 fEB->Associate(this);
81 f1->AddFrame(fEB, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
82 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
83
84 // Number entry for dz
85 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
86 f1->AddFrame(new TGLabel(f1, "Dz"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
87 fEDz = new TGNumberEntry(f1, 0., 5, kELTU_DZ);
91 nef->SetToolTipText("Enter the half-length in Z");
92 fEDz->Associate(this);
93 f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
94 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
95
96 // Delayed draw
98 fDelayed = new TGCheckButton(f1, "Delayed draw");
99 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
100 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
101
102 // Buttons
103 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
104 fApply = new TGTextButton(f1, "Apply");
105 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
106 fApply->Associate(this);
107 fUndo = new TGTextButton(f1, "Undo");
108 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
109 fUndo->Associate(this);
110 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// Destructor
116
118{
120 TIter next(GetList());
121 while ((el = (TGFrameElement *)next())) {
122 if (el->fFrame->IsComposite())
124 }
125 Cleanup();
126}
127
128////////////////////////////////////////////////////////////////////////////////
129/// Connect signals to slots.
130
132{
133 fApply->Connect("Clicked()", "TGeoEltuEditor", this, "DoApply()");
134 fUndo->Connect("Clicked()", "TGeoEltuEditor", this, "DoUndo()");
135 fShapeName->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
136 fEA->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoA()");
137 fEB->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoB()");
138 fEDz->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoDz()");
139 fEA->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
140 fEB->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
141 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
142 fInit = kFALSE;
143}
144
145////////////////////////////////////////////////////////////////////////////////
146/// Connect to the selected object.
147
149{
150 if (obj == nullptr || (obj->IsA() != TGeoEltu::Class())) {
152 return;
153 }
154 fShape = (TGeoEltu *)obj;
155 fAi = fShape->GetA();
156 fBi = fShape->GetB();
157 fDzi = fShape->GetDz();
158 const char *sname = fShape->GetName();
159 if (!strcmp(sname, fShape->ClassName()))
160 fShapeName->SetText("-no_name");
161 else {
163 fNamei = sname;
164 }
165 fEA->SetNumber(fAi);
166 fEB->SetNumber(fBi);
170
171 if (fInit)
173 SetActive();
174}
175
176////////////////////////////////////////////////////////////////////////////////
177/// Slot for name.
178
180{
181 DoModified();
182}
183
184////////////////////////////////////////////////////////////////////////////////
185/// Check if shape drawing is delayed.
186
188{
189 return (fDelayed->GetState() == kButtonDown);
190}
191
192////////////////////////////////////////////////////////////////////////////////
193/// Slot for applying current settings.
194
196{
197 const char *name = fShapeName->GetText();
198 if (strcmp(name, fShape->GetName()))
200 Double_t a = fEA->GetNumber();
201 Double_t b = fEB->GetNumber();
202 Double_t z = fEDz->GetNumber();
203 Double_t param[3];
204 param[0] = a;
205 param[1] = b;
206 param[2] = z;
207 fShape->SetDimensions(param);
209 fUndo->SetEnabled();
211 if (fPad) {
213 TView *view = fPad->GetView();
214 if (!view) {
215 fShape->Draw();
216 fPad->GetView()->ShowAxis();
217 } else {
218 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(), fShape->GetDX(), fShape->GetDY(),
219 fShape->GetDZ());
220 Update();
221 }
222 } else
223 Update();
224 }
225}
226
227////////////////////////////////////////////////////////////////////////////////
228/// Slot for notifying modifications.
229
234
235////////////////////////////////////////////////////////////////////////////////
236/// Slot for undoing last operation.
237
247
248////////////////////////////////////////////////////////////////////////////////
249/// Slot for A.
250
252{
253 Double_t a = fEA->GetNumber();
254 if (a <= 0) {
255 a = 0.1;
256 fEA->SetNumber(a);
257 }
258 DoModified();
259 if (!IsDelayed())
260 DoApply();
261}
262
263////////////////////////////////////////////////////////////////////////////////
264/// Slot for B.
265
267{
268 Double_t b = fEB->GetNumber();
269 if (b <= 0) {
270 b = 0.1;
271 fEB->SetNumber(b);
272 }
273 DoModified();
274 if (!IsDelayed())
275 DoApply();
276}
277
278////////////////////////////////////////////////////////////////////////////////
279/// Slot for Z.
280
282{
283 Double_t z = fEDz->GetNumber();
284 if (z <= 0) {
285 z = 0.1;
286 fEDz->SetNumber(z);
287 }
288 DoModified();
289 if (!IsDelayed())
290 DoApply();
291}
@ 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
#define b(i)
Definition RSha256.hxx:100
#define a(i)
Definition RSha256.hxx:99
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
ETGeoEltuWid
@ kELTU_A
@ kELTU_NAME
@ kELTU_UNDO
@ kELTU_B
@ kELTU_APPLY
@ kELTU_DZ
R__EXTERN TGeoManager * gGeoManager
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
TGTextButton * fApply
~TGeoEltuEditor() override
Destructor.
Bool_t fIsShapeEditable
TGTextButton * fUndo
TGNumberEntry * fEDz
void DoB()
Slot for B.
TGTextEntry * fShapeName
TGeoEltu * fShape
TGCheckButton * fDelayed
void SetModel(TObject *obj) override
Connect to the selected object.
void DoDz()
Slot for Z.
void DoApply()
Slot for applying current settings.
TGNumberEntry * fEA
void DoName()
Slot for name.
TGeoEltuEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for para editor.
virtual void ConnectSignals2Slots()
Connect signals to slots.
void DoUndo()
Slot for undoing last operation.
TGNumberEntry * fEB
void DoModified()
Slot for notifying modifications.
Bool_t IsDelayed() const
Check if shape drawing is delayed.
void DoA()
Slot for A.
An elliptical tube is defined by the two semi-axes A and B.
Definition TGeoEltu.h:17
static TClass * Class()
void ComputeBBox() override
compute bounding box of the tube
Definition TGeoEltu.cxx:110
void SetDimensions(Double_t *param) override
Set shape dimensions starting from an array.
Definition TGeoEltu.cxx:478
virtual Double_t GetA() const
Definition TGeoEltu.h:47
virtual Double_t GetB() const
Definition TGeoEltu.h:48
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 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 Double_t GetDz() const
Definition TGeoTube.h:74
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