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 "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 trd1 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 = fDyi = fDzi = 0.0;
51 fNamei = "";
54
55 // TextEntry for shape name
56 MakeTitle("Name");
57 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTRD1_NAME);
59 fShapeName->SetToolTipText("Enter the box name");
60 fShapeName->Associate(this);
62
63 TGTextEntry *nef;
64 MakeTitle("Trd1 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, kTRD1_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, kTRD1_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 dy
92 TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
94 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
95 fEDy = new TGNumberEntry(f2, 0., 5, kTRD1_Y);
98 nef->SetToolTipText("Enter the half-length in Y");
99 fEDy->Associate(this);
100 f2->AddFrame(fEDy, 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 dz
104 TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
106 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
107 fEDz = new TGNumberEntry(f3, 0., 5, kTRD1_Z);
110 nef->SetToolTipText("Enter the half-length in Z");
111 fEDz->Associate(this);
112 f3->AddFrame(fEDz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
113 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
114
115 compxyz->Resize(150,30);
116 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
117
118 // Delayed draw
120 fDelayed = new TGCheckButton(f1, "Delayed draw");
121 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
122 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
123
124 // Buttons
125 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
126 fApply = new TGTextButton(f1, "Apply");
127 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
128 fApply->Associate(this);
129 fUndo = new TGTextButton(f1, "Undo");
130 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
131 fUndo->Associate(this);
132 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
134}
135
136////////////////////////////////////////////////////////////////////////////////
137/// Destructor
138
140{
141 TGFrameElement *el;
142 TIter next(GetList());
143 while ((el = (TGFrameElement *)next())) {
144 if (el->fFrame->IsComposite())
146 }
147 Cleanup();
148}
149
150////////////////////////////////////////////////////////////////////////////////
151/// Connect signals to slots.
152
154{
155 fApply->Connect("Clicked()", "TGeoTrd1Editor", this, "DoApply()");
156 fUndo->Connect("Clicked()", "TGeoTrd1Editor", this, "DoUndo()");
157 fShapeName->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
158 fEDx1->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDx1()");
159 fEDx2->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDx2()");
160 fEDy->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDy()");
161 fEDz->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDz()");
162 fEDx1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
163 fEDx2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
164 fEDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
165 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
166 fInit = kFALSE;
167}
168
169
170////////////////////////////////////////////////////////////////////////////////
171/// Connect to the selected object.
172
174{
175 if (obj == 0 || (obj->IsA()!=TGeoTrd1::Class())) {
177 return;
178 }
179 fShape = (TGeoTrd1*)obj;
180 fDxi1 = fShape->GetDx1();
181 fDxi2 = fShape->GetDx2();
182 fDyi = fShape->GetDy();
183 fDzi = fShape->GetDz();
184 const char *sname = fShape->GetName();
185 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
186 else {
187 fShapeName->SetText(sname);
188 fNamei = sname;
189 }
196
197
199 SetActive();
200}
201
202////////////////////////////////////////////////////////////////////////////////
203/// Check if shape drawing is delayed.
204
206{
207 return (fDelayed->GetState() == kButtonDown);
208}
209
210////////////////////////////////////////////////////////////////////////////////
211/// Perform name change.
212
214{
215 DoModified();
216}
217
218////////////////////////////////////////////////////////////////////////////////
219/// Slot for applying modifications.
220
222{
223 const char *name = fShapeName->GetText();
224 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
225 Double_t dx1 = fEDx1->GetNumber();
226 Double_t dx2 = fEDx2->GetNumber();
227 Double_t dy = fEDy->GetNumber();
228 Double_t dz = fEDz->GetNumber();
229 Double_t param[4];
230 param[0] = dx1;
231 param[1] = dx2;
232 param[2] = dy;
233 param[3] = dz;
234 fShape->SetDimensions(param);
236 fUndo->SetEnabled();
238 if (fPad) {
240 fShape->Draw();
241 fPad->GetView()->ShowAxis();
242 } else Update();
243 }
244}
245
246////////////////////////////////////////////////////////////////////////////////
247/// Slot for signaling modifications.
248
250{
252}
253
254////////////////////////////////////////////////////////////////////////////////
255/// Slot for undoing last operation.
256
258{
263 DoApply();
266}
267
268////////////////////////////////////////////////////////////////////////////////
269/// Slot for dx1.
270
272{
273 Double_t dx1 = fEDx1->GetNumber();
274 Double_t dx2 = fEDx2->GetNumber();
275 if (dx1<0) {
276 dx1 = 0;
277 fEDx1->SetNumber(dx1);
278 }
279 if (dx1<1.e-6 && dx2<1.e-6) {
280 dx1 = 0.1;
281 fEDx1->SetNumber(dx1);
282 }
283 DoModified();
284 if (!IsDelayed()) DoApply();
285}
286
287////////////////////////////////////////////////////////////////////////////////
288/// Slot for dx2.
289
291{
292 Double_t dx1 = fEDx1->GetNumber();
293 Double_t dx2 = fEDx2->GetNumber();
294 if (dx2<0) {
295 dx2 = 0;
296 fEDx2->SetNumber(dx2);
297 }
298 if (dx1<1.e-6 && dx2<1.e-6) {
299 dx2 = 0.1;
300 fEDx2->SetNumber(dx2);
301 }
302 DoModified();
303 if (!IsDelayed()) DoApply();
304}
305
306////////////////////////////////////////////////////////////////////////////////
307/// Slot for dy.
308
310{
311 Double_t dy = fEDy->GetNumber();
312 if (dy<=0) {
313 dy = 0.1;
314 fEDy->SetNumber(dy);
315 }
316 DoModified();
317 if (!IsDelayed()) DoApply();
318}
319
320////////////////////////////////////////////////////////////////////////////////
321/// Slot for dz.
322
324{
325 Double_t dz = fEDz->GetNumber();
326 if (dz<=0) {
327 dz = 0.1;
328 fEDz->SetNumber(dz);
329 }
330 DoModified();
331 if (!IsDelayed()) DoApply();
332}
333
334
@ 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
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: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 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.
TGeoTrd1Editor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for trd1 editor.
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.
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 varying with Z.
Definition: TGeoTrd1.h:18
virtual void ComputeBBox()
compute bounding box for a trd1
Definition: TGeoTrd1.cxx:136
Double_t GetDy() const
Definition: TGeoTrd1.h:59
Double_t GetDx2() const
Definition: TGeoTrd1.h:58
Double_t GetDz() const
Definition: TGeoTrd1.h:60
Double_t GetDx1() const
Definition: TGeoTrd1.h:57
virtual void SetDimensions(Double_t *param)
set trd1 params in one step :
Definition: TGeoTrd1.cxx:657
static TClass * Class()
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