Logo ROOT  
Reference Guide
TGeoTrd1Editor.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 TGeoTrd1Editor
13\ingroup Geometry_builder
14
15Editor for a TGeoTrd1.
16
17\image html geom_trd1_pic.png
18
19\image html geom_trd1_ed.png
20
21*/
22
23#include "TGeoTrd1Editor.h"
24#include "TGeoTabManager.h"
25#include "TGeoTrd1.h"
26#include "TGeoManager.h"
27#include "TVirtualGeoPainter.h"
28#include "TPad.h"
29#include "TView.h"
30#include "TGTab.h"
31#include "TGComboBox.h"
32#include "TGButton.h"
33#include "TGTextEntry.h"
34#include "TGNumberEntry.h"
35#include "TGLabel.h"
36
38
42};
43
44////////////////////////////////////////////////////////////////////////////////
45/// Constructor for trd1 editor
46
48 Int_t height, UInt_t options, Pixel_t back)
49 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
50{
51 fShape = 0;
52 fDxi1 = fDxi2 = fDyi = fDzi = 0.0;
53 fNamei = "";
56
57 // TextEntry for shape name
58 MakeTitle("Name");
59 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTRD1_NAME);
61 fShapeName->SetToolTipText("Enter the box name");
62 fShapeName->Associate(this);
64
65 TGTextEntry *nef;
66 MakeTitle("Trd1 dimensions");
68
69 // Number entry for dx1
70 TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
72 f1->AddFrame(new TGLabel(f1, "DX1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
73 fEDx1 = new TGNumberEntry(f1, 0., 5, kTRD1_X1);
76 nef->SetToolTipText("Enter the half-length in X1");
77 fEDx1->Associate(this);
78 f1->AddFrame(fEDx1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
79 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
80
81 // Number entry for dx2
82 f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
84 f1->AddFrame(new TGLabel(f1, "DX2"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
85 fEDx2 = new TGNumberEntry(f1, 0., 5, kTRD1_X2);
88 nef->SetToolTipText("Enter the half-length in X2");
89 fEDx2->Associate(this);
90 f1->AddFrame(fEDx2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
91 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
92
93 // Number entry for dy
94 TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
96 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
97 fEDy = new TGNumberEntry(f2, 0., 5, kTRD1_Y);
100 nef->SetToolTipText("Enter the half-length in Y");
101 fEDy->Associate(this);
102 f2->AddFrame(fEDy, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
103 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
104
105 // Number entry for dz
106 TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
108 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
109 fEDz = new TGNumberEntry(f3, 0., 5, kTRD1_Z);
112 nef->SetToolTipText("Enter the half-length in Z");
113 fEDz->Associate(this);
114 f3->AddFrame(fEDz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
115 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
116
117 compxyz->Resize(150,30);
118 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
119
120 // Delayed draw
122 fDelayed = new TGCheckButton(f1, "Delayed draw");
123 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
124 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
125
126 // Buttons
127 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
128 fApply = new TGTextButton(f1, "Apply");
129 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
130 fApply->Associate(this);
131 fUndo = new TGTextButton(f1, "Undo");
132 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
133 fUndo->Associate(this);
134 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
136}
137
138////////////////////////////////////////////////////////////////////////////////
139/// Destructor
140
142{
143 TGFrameElement *el;
144 TIter next(GetList());
145 while ((el = (TGFrameElement *)next())) {
146 if (el->fFrame->IsComposite())
148 }
149 Cleanup();
150}
151
152////////////////////////////////////////////////////////////////////////////////
153/// Connect signals to slots.
154
156{
157 fApply->Connect("Clicked()", "TGeoTrd1Editor", this, "DoApply()");
158 fUndo->Connect("Clicked()", "TGeoTrd1Editor", this, "DoUndo()");
159 fShapeName->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
160 fEDx1->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDx1()");
161 fEDx2->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDx2()");
162 fEDy->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDy()");
163 fEDz->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDz()");
164 fEDx1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
165 fEDx2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
166 fEDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
167 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
168 fInit = kFALSE;
169}
170
171
172////////////////////////////////////////////////////////////////////////////////
173/// Connect to the selected object.
174
176{
177 if (obj == 0 || (obj->IsA()!=TGeoTrd1::Class())) {
179 return;
180 }
181 fShape = (TGeoTrd1*)obj;
182 fDxi1 = fShape->GetDx1();
183 fDxi2 = fShape->GetDx2();
184 fDyi = fShape->GetDy();
185 fDzi = fShape->GetDz();
186 const char *sname = fShape->GetName();
187 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
188 else {
189 fShapeName->SetText(sname);
190 fNamei = sname;
191 }
198
199
201 SetActive();
202}
203
204////////////////////////////////////////////////////////////////////////////////
205/// Check if shape drawing is delayed.
206
208{
209 return (fDelayed->GetState() == kButtonDown);
210}
211
212////////////////////////////////////////////////////////////////////////////////
213/// Perform name change.
214
216{
217 DoModified();
218}
219
220////////////////////////////////////////////////////////////////////////////////
221/// Slot for applying modifications.
222
224{
225 const char *name = fShapeName->GetText();
226 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
227 Double_t dx1 = fEDx1->GetNumber();
228 Double_t dx2 = fEDx2->GetNumber();
229 Double_t dy = fEDy->GetNumber();
230 Double_t dz = fEDz->GetNumber();
231 Double_t param[4];
232 param[0] = dx1;
233 param[1] = dx2;
234 param[2] = dy;
235 param[3] = dz;
236 fShape->SetDimensions(param);
238 fUndo->SetEnabled();
240 if (fPad) {
242 fShape->Draw();
243 fPad->GetView()->ShowAxis();
244 } else Update();
245 }
246}
247
248////////////////////////////////////////////////////////////////////////////////
249/// Slot for signaling modifications.
250
252{
254}
255
256////////////////////////////////////////////////////////////////////////////////
257/// Slot for undoing last operation.
258
260{
265 DoApply();
268}
269
270////////////////////////////////////////////////////////////////////////////////
271/// Slot for dx1.
272
274{
275 Double_t dx1 = fEDx1->GetNumber();
276 Double_t dx2 = fEDx2->GetNumber();
277 if (dx1<0) {
278 dx1 = 0;
279 fEDx1->SetNumber(dx1);
280 }
281 if (dx1<1.e-6 && dx2<1.e-6) {
282 dx1 = 0.1;
283 fEDx1->SetNumber(dx1);
284 }
285 DoModified();
286 if (!IsDelayed()) DoApply();
287}
288
289////////////////////////////////////////////////////////////////////////////////
290/// Slot for dx2.
291
293{
294 Double_t dx1 = fEDx1->GetNumber();
295 Double_t dx2 = fEDx2->GetNumber();
296 if (dx2<0) {
297 dx2 = 0;
298 fEDx2->SetNumber(dx2);
299 }
300 if (dx1<1.e-6 && dx2<1.e-6) {
301 dx2 = 0.1;
302 fEDx2->SetNumber(dx2);
303 }
304 DoModified();
305 if (!IsDelayed()) DoApply();
306}
307
308////////////////////////////////////////////////////////////////////////////////
309/// Slot for dy.
310
312{
313 Double_t dy = fEDy->GetNumber();
314 if (dy<=0) {
315 dy = 0.1;
316 fEDy->SetNumber(dy);
317 }
318 DoModified();
319 if (!IsDelayed()) DoApply();
320}
321
322////////////////////////////////////////////////////////////////////////////////
323/// Slot for dz.
324
326{
327 Double_t dz = fEDz->GetNumber();
328 if (dz<=0) {
329 dz = 0.1;
330 fEDz->SetNumber(dz);
331 }
332 DoModified();
333 if (!IsDelayed()) DoApply();
334}
335
336
void Class()
Definition: Class.C:29
ULong_t Pixel_t
Definition: GuiTypes.h:39
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
#define ClassImp(name)
Definition: Rtypes.h:365
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kButtonDown
Definition: TGButton.h:54
@ kRaisedFrame
Definition: TGFrame.h:62
@ kSunkenFrame
Definition: TGFrame.h:61
@ kVerticalFrame
Definition: TGFrame.h:59
@ kDoubleBorder
Definition: TGFrame.h:63
@ kFixedWidth
Definition: TGFrame.h:65
@ kHorizontalFrame
Definition: TGFrame.h:60
@ kOwnBackground
Definition: TGFrame.h:69
@ kLHintsRight
Definition: TGLayout.h:33
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsExpandX
Definition: TGLayout.h:37
char name[80]
Definition: TGX11.cxx:109
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:601
ETGeoTrd1Wid
@ kTRD1_Z
@ kTRD1_X2
@ kTRD1_APPLY
@ kTRD1_UNDO
@ kTRD1_Y
@ kTRD1_NAME
@ kTRD1_X1
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:409
virtual TList * GetList() const
Definition: TGFrame.h:369
TGCompositeFrame(const TGCompositeFrame &)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
TGFrame * fFrame
Definition: TGLayout.h:119
virtual void SetSize(const TGDimension &s)
Definition: TGFrame.h:299
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:238
TGDimension GetSize() const
Definition: TGFrame.h:277
virtual Bool_t IsComposite() const
Definition: TGFrame.h:259
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
virtual void SetNumber(Double_t val)
TGNumberEntryField * GetNumberEntry() const
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
void SetNumAttr(EAttribute attr=kNEAAnyNumber)
virtual Double_t GetNumber() const
const char * GetText() const
Definition: TGTextEntry.h:134
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:84
Bool_t fInit
Definition: TGedFrame.h:53
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
Common base class for geombuilder editors.
Definition: TGeoGedFrame.h:13
virtual void Update()
Override Update from TGedFrame as fGedEditor can be null.
TVirtualPad * fPad
Definition: TGeoGedFrame.h:18
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
TVirtualGeoPainter * GetPainter() const
Definition: TGeoManager.h:212
virtual const char * GetName() const
Get the shape name.
Definition: TGeoShape.cxx:248
virtual void Draw(Option_t *option="")
Draw this shape.
Definition: TGeoShape.cxx:721
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
Editor for a TGeoTrd1.
void DoDx2()
Slot for dx2.
virtual ~TGeoTrd1Editor()
Destructor.
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGNumberEntry * fEDz
TGCheckButton * fDelayed
TGeoTrd1 * fShape
void DoDy()
Slot for dy.
void DoUndo()
Slot for undoing last operation.
void DoDx1()
Slot for dx1.
void DoModified()
Slot for signaling modifications.
TGNumberEntry * fEDx1
void DoDz()
Slot for dz.
Bool_t fIsShapeEditable
TGNumberEntry * fEDy
TGTextButton * fUndo
void DoApply()
Slot for applying modifications.
virtual void SetModel(TObject *obj)
Connect to the selected object.
TGeoTrd1Editor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for trd1 editor.
TGTextButton * fApply
TGNumberEntry * fEDx2
void DoName()
Perform name change.
TGTextEntry * fShapeName
Bool_t IsDelayed() const
Check if shape drawing is delayed.
A trapezoid with only x length varying with z.
Definition: TGeoTrd1.h:18
virtual void ComputeBBox()
compute bounding box for a trd1
Definition: TGeoTrd1.cxx:131
Double_t GetDy() const
Definition: TGeoTrd1.h:57
Double_t GetDx2() const
Definition: TGeoTrd1.h:56
Double_t GetDz() const
Definition: TGeoTrd1.h:58
Double_t GetDx1() const
Definition: TGeoTrd1.h:55
virtual void SetDimensions(Double_t *param)
set trd1 params in one step :
Definition: TGeoTrd1.cxx:655
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
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:867
virtual void ShowAxis()=0
virtual Bool_t IsPaintingShape() const =0
virtual TView * GetView() const =0
TF1 * f1
Definition: legend1.C:11