Logo ROOT  
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 "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 trd2 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 fDxi1 = fDxi2 = fDyi1 = fDyi2 = fDzi = 0.0;
51 fNamei = "";
54
55 // TextEntry for shape name
56 MakeTitle("Name");
57 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTRD2_NAME);
59 fShapeName->SetToolTipText("Enter the box name");
60 fShapeName->Associate(this);
62
63 TGTextEntry *nef;
64 MakeTitle("Trd2 dimensions");
66
67 // Number entry for dx1
68 TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
70 f1->AddFrame(new TGLabel(f1, "DX1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
71 fEDx1 = new TGNumberEntry(f1, 0., 5, kTRD2_X1);
74 nef->SetToolTipText("Enter the half-length in X1");
75 fEDx1->Associate(this);
76 f1->AddFrame(fEDx1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
77 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
78
79 // Number entry for dx2
80 f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
82 f1->AddFrame(new TGLabel(f1, "DX2"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
83 fEDx2 = new TGNumberEntry(f1, 0., 5, kTRD2_X2);
86 nef->SetToolTipText("Enter the half-length in X2");
87 fEDx2->Associate(this);
88 f1->AddFrame(fEDx2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
89 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
90
91 // Number entry for dy1
92 TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
94 f2->AddFrame(new TGLabel(f2, "DY1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
95 fEDy1 = new TGNumberEntry(f2, 0., 5, kTRD2_Y1);
98 nef->SetToolTipText("Enter the half-length in Y1");
99 fEDy1->Associate(this);
100 f2->AddFrame(fEDy1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
101 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
102
103 // Number entry for dy2
104 f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
106 f2->AddFrame(new TGLabel(f2, "DY2"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
107 fEDy2 = new TGNumberEntry(f2, 0., 5, kTRD2_Y2);
110 nef->SetToolTipText("Enter the half-length in Y2");
111 fEDy2->Associate(this);
112 f2->AddFrame(fEDy2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
113 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
114
115 // Number entry for dz
116 TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
118 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
119 fEDz = new TGNumberEntry(f3, 0., 5, kTRD2_Z);
122 nef->SetToolTipText("Enter the half-length in Z");
123 fEDz->Associate(this);
124 f3->AddFrame(fEDz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
125 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
126
127 compxyz->Resize(150,30);
128 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
129
130 // Delayed draw
132 fDelayed = new TGCheckButton(f1, "Delayed draw");
133 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
134 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
135
136 // Buttons
137 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
138 fApply = new TGTextButton(f1, "Apply");
139 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
140 fApply->Associate(this);
141 fUndo = new TGTextButton(f1, "Undo");
142 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
143 fUndo->Associate(this);
144 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
146}
147
148////////////////////////////////////////////////////////////////////////////////
149/// Destructor.
150
152{
153 TGFrameElement *el;
154 TIter next(GetList());
155 while ((el = (TGFrameElement *)next())) {
156 if (el->fFrame->IsComposite())
158 }
159 Cleanup();
160}
161
162////////////////////////////////////////////////////////////////////////////////
163/// Connect signals to slots.
164
166{
167 fApply->Connect("Clicked()", "TGeoTrd2Editor", this, "DoApply()");
168 fUndo->Connect("Clicked()", "TGeoTrd2Editor", this, "DoUndo()");
169 fShapeName->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
170 fEDx1->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDx1()");
171 fEDx2->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDx2()");
172 fEDy1->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDy1()");
173 fEDy2->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDy2()");
174 fEDz->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDz()");
175 fEDx1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
176 fEDx2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
177 fEDy1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
178 fEDy2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
179 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
180 fInit = kFALSE;
181}
182
183
184////////////////////////////////////////////////////////////////////////////////
185/// Connect to the selected object.
186
188{
189 if (obj == 0 || (obj->IsA()!=TGeoTrd2::Class())) {
191 return;
192 }
193 fShape = (TGeoTrd2*)obj;
194 fDxi1 = fShape->GetDx1();
195 fDxi2 = fShape->GetDx2();
196 fDyi1 = fShape->GetDy1();
197 fDyi2 = fShape->GetDy2();
198 fDzi = fShape->GetDz();
199 const char *sname = fShape->GetName();
200 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
201 else {
202 fShapeName->SetText(sname);
203 fNamei = sname;
204 }
212
214 SetActive();
215}
216
217////////////////////////////////////////////////////////////////////////////////
218/// Check if shape drawing is delayed.
219
221{
222 return (fDelayed->GetState() == kButtonDown);
223}
224
225////////////////////////////////////////////////////////////////////////////////
226/// Perform name change.
227
229{
230 DoModified();
231}
232
233////////////////////////////////////////////////////////////////////////////////
234/// Slot for applying modifications.
235
237{
238 const char *name = fShapeName->GetText();
239 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
240 Double_t dx1 = fEDx1->GetNumber();
241 Double_t dx2 = fEDx2->GetNumber();
242 Double_t dy1 = fEDy1->GetNumber();
243 Double_t dy2 = fEDy2->GetNumber();
244 Double_t dz = fEDz->GetNumber();
245 Double_t param[5];
246 param[0] = dx1;
247 param[1] = dx2;
248 param[2] = dy1;
249 param[3] = dy2;
250 param[4] = dz;
251 fShape->SetDimensions(param);
253 fUndo->SetEnabled();
255 if (fPad) {
257 fShape->Draw();
258 fPad->GetView()->ShowAxis();
259 } else Update();
260 }
261}
262
263////////////////////////////////////////////////////////////////////////////////
264/// Slot for signaling modifications.
265
267{
269}
270
271////////////////////////////////////////////////////////////////////////////////
272/// Slot for undoing last operation.
273
275{
281 DoApply();
284}
285
286////////////////////////////////////////////////////////////////////////////////
287/// Slot for dx1.
288
290{
291 Double_t dx1 = fEDx1->GetNumber();
292 Double_t dx2 = fEDx2->GetNumber();
293 if (dx1<0) {
294 dx1 = 0;
295 fEDx1->SetNumber(dx1);
296 }
297 if (dx1<1.e-6 && dx2<1.e-6) {
298 dx1 = 0.1;
299 fEDx1->SetNumber(dx1);
300 }
301 DoModified();
302 if (!IsDelayed()) DoApply();
303}
304
305////////////////////////////////////////////////////////////////////////////////
306/// Slot for dx2.
307
309{
310 Double_t dx1 = fEDx1->GetNumber();
311 Double_t dx2 = fEDx2->GetNumber();
312 if (dx2<0) {
313 dx2 = 0;
314 fEDx2->SetNumber(dx2);
315 }
316 if (dx1<1.e-6 && dx2<1.e-6) {
317 dx2 = 0.1;
318 fEDx2->SetNumber(dx2);
319 }
320 DoModified();
321 if (!IsDelayed()) DoApply();
322}
323
324////////////////////////////////////////////////////////////////////////////////
325/// Slot for dy1.
326
328{
329 Double_t dy1 = fEDy1->GetNumber();
330 Double_t dy2 = fEDy2->GetNumber();
331 if (dy1<0) {
332 dy1 = 0;
333 fEDy1->SetNumber(dy1);
334 }
335 if (dy1<1.e-6 && dy2<1.e-6) {
336 dy1 = 0.1;
337 fEDy1->SetNumber(dy1);
338 }
339 DoModified();
340 if (!IsDelayed()) DoApply();
341}
342
343////////////////////////////////////////////////////////////////////////////////
344/// Slot for dy2.
345
347{
348 Double_t dy1 = fEDy1->GetNumber();
349 Double_t dy2 = fEDy2->GetNumber();
350 if (dy2<0) {
351 dy2 = 0;
352 fEDy2->SetNumber(dy2);
353 }
354 if (dy1<1.e-6 && dy2<1.e-6) {
355 dy2 = 0.1;
356 fEDy2->SetNumber(dy2);
357 }
358 DoModified();
359 if (!IsDelayed()) DoApply();
360}
361
362////////////////////////////////////////////////////////////////////////////////
363/// Slot for dz.
364
366{
367 Double_t dz = fEDz->GetNumber();
368 if (dz<=0) {
369 dz = 0.1;
370 fEDz->SetNumber(dz);
371 }
372 DoModified();
373 if (!IsDelayed()) DoApply();
374}
375
376
@ kRaisedFrame
Definition: GuiTypes.h:384
@ kSunkenFrame
Definition: GuiTypes.h:383
@ kVerticalFrame
Definition: GuiTypes.h:381
@ kDoubleBorder
Definition: GuiTypes.h:385
@ kFixedWidth
Definition: GuiTypes.h:387
@ kHorizontalFrame
Definition: GuiTypes.h:382
@ kOwnBackground
Definition: GuiTypes.h:391
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
const Bool_t kFALSE
Definition: RtypesCore.h:101
#define ClassImp(name)
Definition: Rtypes.h:375
@ kButtonDown
Definition: TGButton.h:54
@ kLHintsRight
Definition: TGLayout.h:26
@ kLHintsLeft
Definition: TGLayout.h:24
@ kLHintsExpandX
Definition: TGLayout.h:30
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
Definition: TGeoManager.h:602
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: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
TGCompositeFrame(const TGCompositeFrame &)=delete
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)
@ kNEAPositive
Positive number.
Definition: TGNumberEntry.h:43
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
Definition: TGTextBuffer.h:17
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
Definition: TGTextEntry.h:119
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
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:213
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.
TGeoTrd2Editor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for trd2 editor.
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.
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 only X varying with Z.
Definition: TGeoTrd2.h:18
Double_t GetDy2() const
Definition: TGeoTrd2.h:61
Double_t GetDy1() const
Definition: TGeoTrd2.h:60
Double_t GetDx2() const
Definition: TGeoTrd2.h:59
static TClass * Class()
virtual void ComputeBBox()
compute bounding box for a trd2
Definition: TGeoTrd2.cxx:135
Double_t GetDz() const
Definition: TGeoTrd2.h:62
virtual void SetDimensions(Double_t *param)
set arb8 params in one step :
Definition: TGeoTrd2.cxx:685
Double_t GetDx1() const
Definition: TGeoTrd2.h:58
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
virtual void ShowAxis()=0
virtual Bool_t IsPaintingShape() const =0
virtual TView * GetView() const =0
TF1 * f1
Definition: legend1.C:11