Logo ROOT   6.18/05
Reference Guide
TGeoTrd2Editor.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 TGeoTrd2Editor
13\ingroup Geometry_builder
14
15Editor for a TGeoTrd2.
16
17\image html geom_trd2_pic.png
18
19\image html geom_trd2_ed.png
20
21*/
22
23#include "TGeoTrd2Editor.h"
24#include "TGeoTabManager.h"
25#include "TGeoTrd2.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 trd2 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 = fDyi1 = fDyi2 = fDzi = 0.0;
53 fNamei = "";
56
57 // TextEntry for shape name
58 MakeTitle("Name");
59 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTRD2_NAME);
61 fShapeName->SetToolTipText("Enter the box name");
62 fShapeName->Associate(this);
64
65 TGTextEntry *nef;
66 MakeTitle("Trd2 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, kTRD2_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, kTRD2_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 dy1
94 TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
96 f2->AddFrame(new TGLabel(f2, "DY1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
97 fEDy1 = new TGNumberEntry(f2, 0., 5, kTRD2_Y1);
100 nef->SetToolTipText("Enter the half-length in Y1");
101 fEDy1->Associate(this);
102 f2->AddFrame(fEDy1, 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 dy2
106 f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
108 f2->AddFrame(new TGLabel(f2, "DY2"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
109 fEDy2 = new TGNumberEntry(f2, 0., 5, kTRD2_Y2);
112 nef->SetToolTipText("Enter the half-length in Y2");
113 fEDy2->Associate(this);
114 f2->AddFrame(fEDy2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
115 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
116
117 // Number entry for dz
118 TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
120 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
121 fEDz = new TGNumberEntry(f3, 0., 5, kTRD2_Z);
124 nef->SetToolTipText("Enter the half-length in Z");
125 fEDz->Associate(this);
126 f3->AddFrame(fEDz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
127 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
128
129 compxyz->Resize(150,30);
130 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
131
132 // Delayed draw
134 fDelayed = new TGCheckButton(f1, "Delayed draw");
135 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
136 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
137
138 // Buttons
139 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
140 fApply = new TGTextButton(f1, "Apply");
141 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
142 fApply->Associate(this);
143 fUndo = new TGTextButton(f1, "Undo");
144 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
145 fUndo->Associate(this);
146 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
148}
149
150////////////////////////////////////////////////////////////////////////////////
151/// Destructor.
152
154{
155 TGFrameElement *el;
156 TIter next(GetList());
157 while ((el = (TGFrameElement *)next())) {
158 if (el->fFrame->IsComposite())
160 }
161 Cleanup();
162}
163
164////////////////////////////////////////////////////////////////////////////////
165/// Connect signals to slots.
166
168{
169 fApply->Connect("Clicked()", "TGeoTrd2Editor", this, "DoApply()");
170 fUndo->Connect("Clicked()", "TGeoTrd2Editor", this, "DoUndo()");
171 fShapeName->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
172 fEDx1->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDx1()");
173 fEDx2->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDx2()");
174 fEDy1->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDy1()");
175 fEDy2->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDy2()");
176 fEDz->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDz()");
177 fEDx1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
178 fEDx2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
179 fEDy1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
180 fEDy2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
181 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
182 fInit = kFALSE;
183}
184
185
186////////////////////////////////////////////////////////////////////////////////
187/// Connect to the selected object.
188
190{
191 if (obj == 0 || (obj->IsA()!=TGeoTrd2::Class())) {
193 return;
194 }
195 fShape = (TGeoTrd2*)obj;
196 fDxi1 = fShape->GetDx1();
197 fDxi2 = fShape->GetDx2();
198 fDyi1 = fShape->GetDy1();
199 fDyi2 = fShape->GetDy2();
200 fDzi = fShape->GetDz();
201 const char *sname = fShape->GetName();
202 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
203 else {
204 fShapeName->SetText(sname);
205 fNamei = sname;
206 }
214
216 SetActive();
217}
218
219////////////////////////////////////////////////////////////////////////////////
220/// Check if shape drawing is delayed.
221
223{
224 return (fDelayed->GetState() == kButtonDown);
225}
226
227////////////////////////////////////////////////////////////////////////////////
228/// Perform name change.
229
231{
232 DoModified();
233}
234
235////////////////////////////////////////////////////////////////////////////////
236/// Slot for applying modifications.
237
239{
240 const char *name = fShapeName->GetText();
241 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
242 Double_t dx1 = fEDx1->GetNumber();
243 Double_t dx2 = fEDx2->GetNumber();
244 Double_t dy1 = fEDy1->GetNumber();
245 Double_t dy2 = fEDy2->GetNumber();
246 Double_t dz = fEDz->GetNumber();
247 Double_t param[5];
248 param[0] = dx1;
249 param[1] = dx2;
250 param[2] = dy1;
251 param[3] = dy2;
252 param[4] = dz;
253 fShape->SetDimensions(param);
255 fUndo->SetEnabled();
257 if (fPad) {
259 fShape->Draw();
260 fPad->GetView()->ShowAxis();
261 } else Update();
262 }
263}
264
265////////////////////////////////////////////////////////////////////////////////
266/// Slot for signaling modifications.
267
269{
271}
272
273////////////////////////////////////////////////////////////////////////////////
274/// Slot for undoing last operation.
275
277{
283 DoApply();
286}
287
288////////////////////////////////////////////////////////////////////////////////
289/// Slot for dx1.
290
292{
293 Double_t dx1 = fEDx1->GetNumber();
294 Double_t dx2 = fEDx2->GetNumber();
295 if (dx1<0) {
296 dx1 = 0;
297 fEDx1->SetNumber(dx1);
298 }
299 if (dx1<1.e-6 && dx2<1.e-6) {
300 dx1 = 0.1;
301 fEDx1->SetNumber(dx1);
302 }
303 DoModified();
304 if (!IsDelayed()) DoApply();
305}
306
307////////////////////////////////////////////////////////////////////////////////
308/// Slot for dx2.
309
311{
312 Double_t dx1 = fEDx1->GetNumber();
313 Double_t dx2 = fEDx2->GetNumber();
314 if (dx2<0) {
315 dx2 = 0;
316 fEDx2->SetNumber(dx2);
317 }
318 if (dx1<1.e-6 && dx2<1.e-6) {
319 dx2 = 0.1;
320 fEDx2->SetNumber(dx2);
321 }
322 DoModified();
323 if (!IsDelayed()) DoApply();
324}
325
326////////////////////////////////////////////////////////////////////////////////
327/// Slot for dy1.
328
330{
331 Double_t dy1 = fEDy1->GetNumber();
332 Double_t dy2 = fEDy2->GetNumber();
333 if (dy1<0) {
334 dy1 = 0;
335 fEDy1->SetNumber(dy1);
336 }
337 if (dy1<1.e-6 && dy2<1.e-6) {
338 dy1 = 0.1;
339 fEDy1->SetNumber(dy1);
340 }
341 DoModified();
342 if (!IsDelayed()) DoApply();
343}
344
345////////////////////////////////////////////////////////////////////////////////
346/// Slot for dy2.
347
349{
350 Double_t dy1 = fEDy1->GetNumber();
351 Double_t dy2 = fEDy2->GetNumber();
352 if (dy2<0) {
353 dy2 = 0;
354 fEDy2->SetNumber(dy2);
355 }
356 if (dy1<1.e-6 && dy2<1.e-6) {
357 dy2 = 0.1;
358 fEDy2->SetNumber(dy2);
359 }
360 DoModified();
361 if (!IsDelayed()) DoApply();
362}
363
364////////////////////////////////////////////////////////////////////////////////
365/// Slot for dz.
366
368{
369 Double_t dz = fEDz->GetNumber();
370 if (dz<=0) {
371 dz = 0.1;
372 fEDz->SetNumber(dz);
373 }
374 DoModified();
375 if (!IsDelayed()) DoApply();
376}
377
378
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
ETGeoTrd2Wid
@ kTRD2_Y1
@ kTRD2_UNDO
@ kTRD2_X1
@ kTRD2_Y2
@ kTRD2_NAME
@ kTRD2_APPLY
@ kTRD2_Z
@ kTRD2_X2
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 TGeoTrd2.
void DoName()
Perform name change.
virtual ~TGeoTrd2Editor()
Destructor.
TGNumberEntry * fEDy2
virtual void ConnectSignals2Slots()
Connect signals to slots.
void DoApply()
Slot for applying modifications.
void DoModified()
Slot for signaling modifications.
Bool_t fIsShapeEditable
void DoDx1()
Slot for dx1.
TGTextButton * fUndo
TGCheckButton * fDelayed
TGNumberEntry * fEDz
virtual void SetModel(TObject *obj)
Connect to the selected object.
void DoDz()
Slot for dz.
void DoUndo()
Slot for undoing last operation.
TGeoTrd2Editor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for trd2 editor.
TGTextButton * fApply
TGNumberEntry * fEDx1
void DoDx2()
Slot for dx2.
TGNumberEntry * fEDy1
Bool_t IsDelayed() const
Check if shape drawing is delayed.
void DoDy2()
Slot for dy2.
TGTextEntry * fShapeName
void DoDy1()
Slot for dy1.
TGNumberEntry * fEDx2
TGeoTrd2 * fShape
A trapezoid with both x and y lengths varying with z.
Definition: TGeoTrd2.h:18
Double_t GetDy2() const
Definition: TGeoTrd2.h:59
Double_t GetDy1() const
Definition: TGeoTrd2.h:58
Double_t GetDx2() const
Definition: TGeoTrd2.h:57
virtual void ComputeBBox()
compute bounding box for a trd2
Definition: TGeoTrd2.cxx:134
Double_t GetDz() const
Definition: TGeoTrd2.h:60
virtual void SetDimensions(Double_t *param)
set arb8 params in one step :
Definition: TGeoTrd2.cxx:687
Double_t GetDx1() const
Definition: TGeoTrd2.h:56
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