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
36
38
39////////////////////////////////////////////////////////////////////////////////
40/// Constructor for para editor
41
43 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
44{
45 fShape = nullptr;
46 fAi = fBi = fDzi = 0.0;
47 fNamei = "";
50
51 // TextEntry for shape name
52 MakeTitle("Name");
53 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kELTU_NAME);
54 fShapeName->Resize(135, fShapeName->GetDefaultHeight());
55 fShapeName->SetToolTipText("Enter the elliptical tube name");
56 fShapeName->Associate(this);
58
59 TGTextEntry *nef;
60 MakeTitle("Dimensions");
61 // Number entry for A
63 f1->AddFrame(new TGLabel(f1, "A"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
64 fEA = new TGNumberEntry(f1, 0., 5, kELTU_A);
66 fEA->Resize(100, fEA->GetDefaultHeight());
67 nef = (TGTextEntry *)fEA->GetNumberEntry();
68 nef->SetToolTipText("Enter the semi-axis of the ellipse along x");
69 fEA->Associate(this);
70 f1->AddFrame(fEA, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
71 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
72
73 // Number entry for B
74 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
75 f1->AddFrame(new TGLabel(f1, "B"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
76 fEB = new TGNumberEntry(f1, 0., 5, kELTU_B);
78 fEB->Resize(100, fEB->GetDefaultHeight());
79 nef = (TGTextEntry *)fEB->GetNumberEntry();
80 nef->SetToolTipText("Enter the semi-axis of the ellipse along y");
81 fEB->Associate(this);
82 f1->AddFrame(fEB, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
83 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
84
85 // Number entry for dz
86 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
87 f1->AddFrame(new TGLabel(f1, "Dz"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
88 fEDz = new TGNumberEntry(f1, 0., 5, kELTU_DZ);
90 fEDz->Resize(100, fEDz->GetDefaultHeight());
91 nef = (TGTextEntry *)fEDz->GetNumberEntry();
92 nef->SetToolTipText("Enter the half-length in Z");
93 fEDz->Associate(this);
94 f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
95 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
96
97 // Delayed draw
99 fDelayed = new TGCheckButton(f1, "Delayed draw");
100 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
101 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
102
103 // Buttons
104 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
105 fApply = new TGTextButton(f1, "Apply");
106 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
107 fApply->Associate(this);
108 fUndo = new TGTextButton(f1, "Undo");
109 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
110 fUndo->Associate(this);
111 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
112 fUndo->SetSize(fApply->GetSize());
113}
114
115////////////////////////////////////////////////////////////////////////////////
116/// Destructor
117
119{
120 TGFrameElement *el;
121 TIter next(GetList());
122 while ((el = (TGFrameElement *)next())) {
123 if (el->fFrame->IsComposite())
125 }
126 Cleanup();
127}
128
129////////////////////////////////////////////////////////////////////////////////
130/// Connect signals to slots.
131
133{
134 fApply->Connect("Clicked()", "TGeoEltuEditor", this, "DoApply()");
135 fUndo->Connect("Clicked()", "TGeoEltuEditor", this, "DoUndo()");
136 fShapeName->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
137 fEA->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoA()");
138 fEB->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoB()");
139 fEDz->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoDz()");
140 fEA->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
141 fEB->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
142 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()");
143 fInit = kFALSE;
144}
145
146////////////////////////////////////////////////////////////////////////////////
147/// Connect to the selected object.
148
150{
151 if (obj == nullptr || (obj->IsA() != TGeoEltu::Class())) {
153 return;
154 }
155 fShape = (TGeoEltu *)obj;
156 fAi = fShape->GetA();
157 fBi = fShape->GetB();
158 fDzi = fShape->GetDz();
159 const char *sname = fShape->GetName();
160 if (!strcmp(sname, fShape->ClassName()))
161 fShapeName->SetText("-no_name");
162 else {
163 fShapeName->SetText(sname);
164 fNamei = sname;
165 }
166 fEA->SetNumber(fAi);
167 fEB->SetNumber(fBi);
168 fEDz->SetNumber(fDzi);
169 fApply->SetEnabled(kFALSE);
170 fUndo->SetEnabled(kFALSE);
171
172 if (fInit)
174 SetActive();
175}
176
177////////////////////////////////////////////////////////////////////////////////
178/// Slot for name.
179
181{
182 DoModified();
183}
184
185////////////////////////////////////////////////////////////////////////////////
186/// Check if shape drawing is delayed.
187
189{
190 return (fDelayed->GetState() == kButtonDown);
191}
192
193////////////////////////////////////////////////////////////////////////////////
194/// Slot for applying current settings.
195
197{
198 const char *name = fShapeName->GetText();
199 if (strcmp(name, fShape->GetName()))
200 fShape->SetName(name);
201 Double_t a = fEA->GetNumber();
202 Double_t b = fEB->GetNumber();
203 Double_t z = fEDz->GetNumber();
204 Double_t param[3];
205 param[0] = a;
206 param[1] = b;
207 param[2] = z;
208 fShape->SetDimensions(param);
209 fShape->ComputeBBox();
210 fUndo->SetEnabled();
211 fApply->SetEnabled(kFALSE);
212 if (fPad) {
213 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
214 TView *view = fPad->GetView();
215 if (!view) {
216 fShape->Draw();
217 fPad->GetView()->ShowAxis();
218 } else {
219 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(), fShape->GetDX(), fShape->GetDY(),
220 fShape->GetDZ());
221 Update();
222 }
223 } else
224 Update();
225 }
226}
227
228////////////////////////////////////////////////////////////////////////////////
229/// Slot for notifying modifications.
230
232{
233 fApply->SetEnabled();
234}
235
236////////////////////////////////////////////////////////////////////////////////
237/// Slot for undoing last operation.
238
240{
241 fEA->SetNumber(fAi);
242 fEB->SetNumber(fBi);
243 fEDz->SetNumber(fDzi);
244 DoApply();
245 fUndo->SetEnabled(kFALSE);
246 fApply->SetEnabled(kFALSE);
247}
248
249////////////////////////////////////////////////////////////////////////////////
250/// Slot for A.
251
253{
254 Double_t a = fEA->GetNumber();
255 if (a <= 0) {
256 a = 0.1;
257 fEA->SetNumber(a);
258 }
259 DoModified();
260 if (!IsDelayed())
261 DoApply();
262}
263
264////////////////////////////////////////////////////////////////////////////////
265/// Slot for B.
266
268{
269 Double_t b = fEB->GetNumber();
270 if (b <= 0) {
271 b = 0.1;
272 fEB->SetNumber(b);
273 }
274 DoModified();
275 if (!IsDelayed())
276 DoApply();
277}
278
279////////////////////////////////////////////////////////////////////////////////
280/// Slot for Z.
281
283{
284 Double_t z = fEDz->GetNumber();
285 if (z <= 0) {
286 z = 0.1;
287 fEDz->SetNumber(z);
288 }
289 DoModified();
290 if (!IsDelayed())
291 DoApply();
292}
@ 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
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
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
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
Selects different options.
Definition TGButton.h:264
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
TGCompositeFrame(const TGCompositeFrame &)=delete
TGFrame * fFrame
Definition TGLayout.h:112
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.
@ 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
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
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
Editor for a TGeoEltu.
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 Update() override
Override Update from TGedFrame as fGedEditor can be null.
TVirtualPad * fPad
TGeoGedFrame(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor.
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
Mother of all ROOT objects.
Definition TObject.h:41
virtual TClass * IsA() const
Definition TObject.h:240
See TView3D.
Definition TView.h:25
virtual void SetRange(const Double_t *min, const Double_t *max)=0
TF1 * f1
Definition legend1.C:11