Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
38
39////////////////////////////////////////////////////////////////////////////////
40/// Constructor for trd1 editor
41
43 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
44{
45 fShape = nullptr;
46 fDxi1 = fDxi2 = fDyi = fDzi = 0.0;
47 fNamei = "";
50
51 // TextEntry for shape name
52 MakeTitle("Name");
53 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTRD1_NAME);
55 fShapeName->SetToolTipText("Enter the box name");
56 fShapeName->Associate(this);
58
59 TGTextEntry *nef;
60 MakeTitle("Trd1 dimensions");
62
63 // Number entry for dx1
66 f1->AddFrame(new TGLabel(f1, "DX1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
67 fEDx1 = new TGNumberEntry(f1, 0., 5, kTRD1_X1);
70 nef->SetToolTipText("Enter the half-length in X1");
71 fEDx1->Associate(this);
72 f1->AddFrame(fEDx1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
73 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
74
75 // Number entry for dx2
77 f1->AddFrame(new TGLabel(f1, "DX2"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
78 fEDx2 = new TGNumberEntry(f1, 0., 5, kTRD1_X2);
81 nef->SetToolTipText("Enter the half-length in X2");
82 fEDx2->Associate(this);
83 f1->AddFrame(fEDx2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
84 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
85
86 // Number entry for dy
89 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
90 fEDy = new TGNumberEntry(f2, 0., 5, kTRD1_Y);
93 nef->SetToolTipText("Enter the half-length in Y");
94 fEDy->Associate(this);
95 f2->AddFrame(fEDy, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
96 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
97
98 // Number entry for dz
101 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
102 fEDz = new TGNumberEntry(f3, 0., 5, kTRD1_Z);
104 nef = (TGTextEntry *)fEDz->GetNumberEntry();
105 nef->SetToolTipText("Enter the half-length in Z");
106 fEDz->Associate(this);
107 f3->AddFrame(fEDz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
108 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
109
110 compxyz->Resize(150, 30);
111 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
112
113 // Delayed draw
115 fDelayed = new TGCheckButton(f1, "Delayed draw");
116 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
117 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
118
119 // Buttons
120 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
121 fApply = new TGTextButton(f1, "Apply");
122 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
123 fApply->Associate(this);
124 fUndo = new TGTextButton(f1, "Undo");
125 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
126 fUndo->Associate(this);
127 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
129}
130
131////////////////////////////////////////////////////////////////////////////////
132/// Destructor
133
135{
136 TGFrameElement *el;
137 TIter next(GetList());
138 while ((el = (TGFrameElement *)next())) {
139 if (el->fFrame->IsComposite())
141 }
142 Cleanup();
143}
144
145////////////////////////////////////////////////////////////////////////////////
146/// Connect signals to slots.
147
149{
150 fApply->Connect("Clicked()", "TGeoTrd1Editor", this, "DoApply()");
151 fUndo->Connect("Clicked()", "TGeoTrd1Editor", this, "DoUndo()");
152 fShapeName->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
153 fEDx1->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDx1()");
154 fEDx2->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDx2()");
155 fEDy->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDy()");
156 fEDz->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDz()");
157 fEDx1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
158 fEDx2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
159 fEDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
160 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
161 fInit = kFALSE;
162}
163
164////////////////////////////////////////////////////////////////////////////////
165/// Connect to the selected object.
166
168{
169 if (obj == nullptr || (obj->IsA() != TGeoTrd1::Class())) {
171 return;
172 }
173 fShape = (TGeoTrd1 *)obj;
174 fDxi1 = fShape->GetDx1();
175 fDxi2 = fShape->GetDx2();
176 fDyi = fShape->GetDy();
177 fDzi = fShape->GetDz();
178 const char *sname = fShape->GetName();
179 if (!strcmp(sname, fShape->ClassName()))
180 fShapeName->SetText("-no_name");
181 else {
182 fShapeName->SetText(sname);
183 fNamei = sname;
184 }
191
192 if (fInit)
194 SetActive();
195}
196
197////////////////////////////////////////////////////////////////////////////////
198/// Check if shape drawing is delayed.
199
201{
202 return (fDelayed->GetState() == kButtonDown);
203}
204
205////////////////////////////////////////////////////////////////////////////////
206/// Perform name change.
207
209{
210 DoModified();
211}
212
213////////////////////////////////////////////////////////////////////////////////
214/// Slot for applying modifications.
215
217{
218 const char *name = fShapeName->GetText();
219 if (strcmp(name, fShape->GetName()))
221 Double_t dx1 = fEDx1->GetNumber();
222 Double_t dx2 = fEDx2->GetNumber();
223 Double_t dy = fEDy->GetNumber();
224 Double_t dz = fEDz->GetNumber();
225 Double_t param[4];
226 param[0] = dx1;
227 param[1] = dx2;
228 param[2] = dy;
229 param[3] = dz;
230 fShape->SetDimensions(param);
232 fUndo->SetEnabled();
234 if (fPad) {
236 fShape->Draw();
237 fPad->GetView()->ShowAxis();
238 } else
239 Update();
240 }
241}
242
243////////////////////////////////////////////////////////////////////////////////
244/// Slot for signaling modifications.
245
247{
249}
250
251////////////////////////////////////////////////////////////////////////////////
252/// Slot for undoing last operation.
253
255{
260 DoApply();
263}
264
265////////////////////////////////////////////////////////////////////////////////
266/// Slot for dx1.
267
269{
270 Double_t dx1 = fEDx1->GetNumber();
271 Double_t dx2 = fEDx2->GetNumber();
272 if (dx1 < 0) {
273 dx1 = 0;
274 fEDx1->SetNumber(dx1);
275 }
276 if (dx1 < 1.e-6 && dx2 < 1.e-6) {
277 dx1 = 0.1;
278 fEDx1->SetNumber(dx1);
279 }
280 DoModified();
281 if (!IsDelayed())
282 DoApply();
283}
284
285////////////////////////////////////////////////////////////////////////////////
286/// Slot for dx2.
287
289{
290 Double_t dx1 = fEDx1->GetNumber();
291 Double_t dx2 = fEDx2->GetNumber();
292 if (dx2 < 0) {
293 dx2 = 0;
294 fEDx2->SetNumber(dx2);
295 }
296 if (dx1 < 1.e-6 && dx2 < 1.e-6) {
297 dx2 = 0.1;
298 fEDx2->SetNumber(dx2);
299 }
300 DoModified();
301 if (!IsDelayed())
302 DoApply();
303}
304
305////////////////////////////////////////////////////////////////////////////////
306/// Slot for dy.
307
309{
310 Double_t dy = fEDy->GetNumber();
311 if (dy <= 0) {
312 dy = 0.1;
313 fEDy->SetNumber(dy);
314 }
315 DoModified();
316 if (!IsDelayed())
317 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())
332 DoApply();
333}
@ 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
@ kFitWidth
Definition GuiTypes.h:386
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kOwnBackground
Definition GuiTypes.h:391
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
#define ClassImp(name)
Definition Rtypes.h:382
@ 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
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
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.
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
const char * GetText() const
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.
void Update() override
Override Update from TGedFrame as fGedEditor can be null.
TVirtualPad * fPad
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
TVirtualGeoPainter * GetPainter() const
void Draw(Option_t *option="") override
Draw this shape.
const char * GetName() const override
Get the shape name.
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 void ConnectSignals2Slots()
Connect signals to slots.
void SetModel(TObject *obj) override
Connect to the selected object.
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
~TGeoTrd1Editor() override
Destructor.
void DoDz()
Slot for dz.
Bool_t fIsShapeEditable
TGNumberEntry * fEDy
TGTextButton * fUndo
void DoApply()
Slot for applying modifications.
TGTextButton * fApply
TGNumberEntry * fEDx2
void DoName()
Perform name change.
TGTextEntry * fShapeName
Bool_t IsDelayed() const
Check if shape drawing is delayed.
void ComputeBBox() override
Double_t GetDy() const
Definition TGeoTrd1.h:60
Double_t GetDx2() const
Definition TGeoTrd1.h:59
Double_t GetDz() const
Definition TGeoTrd1.h:61
void SetDimensions(Double_t *param) override
Double_t GetDx1() const
Definition TGeoTrd1.h:58
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:225
virtual TClass * IsA() const
Definition TObject.h:243
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