Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
38
39////////////////////////////////////////////////////////////////////////////////
40/// Constructor for trd2 editor
41
43 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
44{
45 fShape = 0;
46 fDxi1 = fDxi2 = fDyi1 = fDyi2 = fDzi = 0.0;
47 fNamei = "";
50
51 // TextEntry for shape name
52 MakeTitle("Name");
53 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTRD2_NAME);
55 fShapeName->SetToolTipText("Enter the box name");
56 fShapeName->Associate(this);
58
59 TGTextEntry *nef;
60 MakeTitle("Trd2 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, kTRD2_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, kTRD2_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 dy1
89 f2->AddFrame(new TGLabel(f2, "DY1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
90 fEDy1 = new TGNumberEntry(f2, 0., 5, kTRD2_Y1);
93 nef->SetToolTipText("Enter the half-length in Y1");
94 fEDy1->Associate(this);
95 f2->AddFrame(fEDy1, 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 dy2
100 f2->AddFrame(new TGLabel(f2, "DY2"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
101 fEDy2 = new TGNumberEntry(f2, 0., 5, kTRD2_Y2);
103 nef = (TGTextEntry *)fEDy2->GetNumberEntry();
104 nef->SetToolTipText("Enter the half-length in Y2");
105 fEDy2->Associate(this);
106 f2->AddFrame(fEDy2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
107 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
108
109 // Number entry for dz
110 TGCompositeFrame *f3 =
112 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
113 fEDz = new TGNumberEntry(f3, 0., 5, kTRD2_Z);
115 nef = (TGTextEntry *)fEDz->GetNumberEntry();
116 nef->SetToolTipText("Enter the half-length in Z");
117 fEDz->Associate(this);
118 f3->AddFrame(fEDz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
119 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
120
121 compxyz->Resize(150, 30);
122 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
123
124 // Delayed draw
126 fDelayed = new TGCheckButton(f1, "Delayed draw");
127 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
128 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
129
130 // Buttons
131 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
132 fApply = new TGTextButton(f1, "Apply");
133 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
134 fApply->Associate(this);
135 fUndo = new TGTextButton(f1, "Undo");
136 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
137 fUndo->Associate(this);
138 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
140}
141
142////////////////////////////////////////////////////////////////////////////////
143/// Destructor.
144
146{
147 TGFrameElement *el;
148 TIter next(GetList());
149 while ((el = (TGFrameElement *)next())) {
150 if (el->fFrame->IsComposite())
152 }
153 Cleanup();
154}
155
156////////////////////////////////////////////////////////////////////////////////
157/// Connect signals to slots.
158
160{
161 fApply->Connect("Clicked()", "TGeoTrd2Editor", this, "DoApply()");
162 fUndo->Connect("Clicked()", "TGeoTrd2Editor", this, "DoUndo()");
163 fShapeName->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
164 fEDx1->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDx1()");
165 fEDx2->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDx2()");
166 fEDy1->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDy1()");
167 fEDy2->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDy2()");
168 fEDz->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDz()");
169 fEDx1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
170 fEDx2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
171 fEDy1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
172 fEDy2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
173 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
174 fInit = kFALSE;
175}
176
177////////////////////////////////////////////////////////////////////////////////
178/// Connect to the selected object.
179
181{
182 if (obj == 0 || (obj->IsA() != TGeoTrd2::Class())) {
184 return;
185 }
186 fShape = (TGeoTrd2 *)obj;
187 fDxi1 = fShape->GetDx1();
188 fDxi2 = fShape->GetDx2();
189 fDyi1 = fShape->GetDy1();
190 fDyi2 = fShape->GetDy2();
191 fDzi = fShape->GetDz();
192 const char *sname = fShape->GetName();
193 if (!strcmp(sname, fShape->ClassName()))
194 fShapeName->SetText("-no_name");
195 else {
196 fShapeName->SetText(sname);
197 fNamei = sname;
198 }
206
207 if (fInit)
209 SetActive();
210}
211
212////////////////////////////////////////////////////////////////////////////////
213/// Check if shape drawing is delayed.
214
216{
217 return (fDelayed->GetState() == kButtonDown);
218}
219
220////////////////////////////////////////////////////////////////////////////////
221/// Perform name change.
222
224{
225 DoModified();
226}
227
228////////////////////////////////////////////////////////////////////////////////
229/// Slot for applying modifications.
230
232{
233 const char *name = fShapeName->GetText();
234 if (strcmp(name, fShape->GetName()))
236 Double_t dx1 = fEDx1->GetNumber();
237 Double_t dx2 = fEDx2->GetNumber();
238 Double_t dy1 = fEDy1->GetNumber();
239 Double_t dy2 = fEDy2->GetNumber();
240 Double_t dz = fEDz->GetNumber();
241 Double_t param[5];
242 param[0] = dx1;
243 param[1] = dx2;
244 param[2] = dy1;
245 param[3] = dy2;
246 param[4] = dz;
247 fShape->SetDimensions(param);
249 fUndo->SetEnabled();
251 if (fPad) {
253 fShape->Draw();
254 fPad->GetView()->ShowAxis();
255 } else
256 Update();
257 }
258}
259
260////////////////////////////////////////////////////////////////////////////////
261/// Slot for signaling modifications.
262
264{
266}
267
268////////////////////////////////////////////////////////////////////////////////
269/// Slot for undoing last operation.
270
272{
278 DoApply();
281}
282
283////////////////////////////////////////////////////////////////////////////////
284/// Slot for dx1.
285
287{
288 Double_t dx1 = fEDx1->GetNumber();
289 Double_t dx2 = fEDx2->GetNumber();
290 if (dx1 < 0) {
291 dx1 = 0;
292 fEDx1->SetNumber(dx1);
293 }
294 if (dx1 < 1.e-6 && dx2 < 1.e-6) {
295 dx1 = 0.1;
296 fEDx1->SetNumber(dx1);
297 }
298 DoModified();
299 if (!IsDelayed())
300 DoApply();
301}
302
303////////////////////////////////////////////////////////////////////////////////
304/// Slot for dx2.
305
307{
308 Double_t dx1 = fEDx1->GetNumber();
309 Double_t dx2 = fEDx2->GetNumber();
310 if (dx2 < 0) {
311 dx2 = 0;
312 fEDx2->SetNumber(dx2);
313 }
314 if (dx1 < 1.e-6 && dx2 < 1.e-6) {
315 dx2 = 0.1;
316 fEDx2->SetNumber(dx2);
317 }
318 DoModified();
319 if (!IsDelayed())
320 DoApply();
321}
322
323////////////////////////////////////////////////////////////////////////////////
324/// Slot for dy1.
325
327{
328 Double_t dy1 = fEDy1->GetNumber();
329 Double_t dy2 = fEDy2->GetNumber();
330 if (dy1 < 0) {
331 dy1 = 0;
332 fEDy1->SetNumber(dy1);
333 }
334 if (dy1 < 1.e-6 && dy2 < 1.e-6) {
335 dy1 = 0.1;
336 fEDy1->SetNumber(dy1);
337 }
338 DoModified();
339 if (!IsDelayed())
340 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())
360 DoApply();
361}
362
363////////////////////////////////////////////////////////////////////////////////
364/// Slot for dz.
365
367{
368 Double_t dz = fEDz->GetNumber();
369 if (dz <= 0) {
370 dz = 0.1;
371 fEDz->SetNumber(dz);
372 }
373 DoModified();
374 if (!IsDelayed())
375 DoApply();
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
@ 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:101
#define ClassImp(name)
Definition Rtypes.h:377
@ 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
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
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 TGeoTrd2.
void DoName()
Perform name change.
~TGeoTrd2Editor() override
Destructor.
TGNumberEntry * fEDy2
void SetModel(TObject *obj) override
Connect to the selected object.
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
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:17
Double_t GetDy2() const
Definition TGeoTrd2.h:62
void ComputeBBox() override
compute bounding box for a trd2
Definition TGeoTrd2.cxx:130
Double_t GetDy1() const
Definition TGeoTrd2.h:61
void SetDimensions(Double_t *param) override
set arb8 params in one step :
Definition TGeoTrd2.cxx:728
Double_t GetDx2() const
Definition TGeoTrd2.h:60
static TClass * Class()
Double_t GetDz() const
Definition TGeoTrd2.h:63
Double_t GetDx1() const
Definition TGeoTrd2.h:59
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: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