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
35
37
38////////////////////////////////////////////////////////////////////////////////
39/// Constructor for trd2 editor
40
42 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
43{
44 fShape = nullptr;
45 fDxi1 = fDxi2 = fDyi1 = fDyi2 = fDzi = 0.0;
46 fNamei = "";
49
50 // TextEntry for shape name
51 MakeTitle("Name");
52 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTRD2_NAME);
54 fShapeName->SetToolTipText("Enter the box name");
55 fShapeName->Associate(this);
57
59 MakeTitle("Trd2 dimensions");
61
62 // Number entry for dx1
65 f1->AddFrame(new TGLabel(f1, "DX1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
66 fEDx1 = new TGNumberEntry(f1, 0., 5, kTRD2_X1);
69 nef->SetToolTipText("Enter the half-length in X1");
70 fEDx1->Associate(this);
71 f1->AddFrame(fEDx1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
72 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
73
74 // Number entry for dx2
76 f1->AddFrame(new TGLabel(f1, "DX2"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
77 fEDx2 = new TGNumberEntry(f1, 0., 5, kTRD2_X2);
80 nef->SetToolTipText("Enter the half-length in X2");
81 fEDx2->Associate(this);
82 f1->AddFrame(fEDx2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
83 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
84
85 // Number entry for dy1
88 f2->AddFrame(new TGLabel(f2, "DY1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
89 fEDy1 = new TGNumberEntry(f2, 0., 5, kTRD2_Y1);
92 nef->SetToolTipText("Enter the half-length in Y1");
93 fEDy1->Associate(this);
94 f2->AddFrame(fEDy1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
95 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
96
97 // Number entry for dy2
99 f2->AddFrame(new TGLabel(f2, "DY2"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
100 fEDy2 = new TGNumberEntry(f2, 0., 5, kTRD2_Y2);
103 nef->SetToolTipText("Enter the half-length in Y2");
104 fEDy2->Associate(this);
105 f2->AddFrame(fEDy2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
106 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
107
108 // Number entry for dz
109 TGCompositeFrame *f3 =
111 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
112 fEDz = new TGNumberEntry(f3, 0., 5, kTRD2_Z);
115 nef->SetToolTipText("Enter the half-length in Z");
116 fEDz->Associate(this);
117 f3->AddFrame(fEDz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
118 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
119
120 compxyz->Resize(150, 30);
121 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
122
123 // Delayed draw
125 fDelayed = new TGCheckButton(f1, "Delayed draw");
126 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
127 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
128
129 // Buttons
130 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
131 fApply = new TGTextButton(f1, "Apply");
132 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
133 fApply->Associate(this);
134 fUndo = new TGTextButton(f1, "Undo");
135 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
136 fUndo->Associate(this);
137 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
139}
140
141////////////////////////////////////////////////////////////////////////////////
142/// Destructor.
143
145{
147 TIter next(GetList());
148 while ((el = (TGFrameElement *)next())) {
149 if (el->fFrame->IsComposite())
151 }
152 Cleanup();
153}
154
155////////////////////////////////////////////////////////////////////////////////
156/// Connect signals to slots.
157
159{
160 fApply->Connect("Clicked()", "TGeoTrd2Editor", this, "DoApply()");
161 fUndo->Connect("Clicked()", "TGeoTrd2Editor", this, "DoUndo()");
162 fShapeName->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
163 fEDx1->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDx1()");
164 fEDx2->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDx2()");
165 fEDy1->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDy1()");
166 fEDy2->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDy2()");
167 fEDz->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDz()");
168 fEDx1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
169 fEDx2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
170 fEDy1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
171 fEDy2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
172 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()");
173 fInit = kFALSE;
174}
175
176////////////////////////////////////////////////////////////////////////////////
177/// Connect to the selected object.
178
180{
181 if (obj == nullptr || (obj->IsA() != TGeoTrd2::Class())) {
183 return;
184 }
185 fShape = (TGeoTrd2 *)obj;
186 fDxi1 = fShape->GetDx1();
187 fDxi2 = fShape->GetDx2();
188 fDyi1 = fShape->GetDy1();
189 fDyi2 = fShape->GetDy2();
190 fDzi = fShape->GetDz();
191 const char *sname = fShape->GetName();
192 if (!strcmp(sname, fShape->ClassName()))
193 fShapeName->SetText("-no_name");
194 else {
196 fNamei = sname;
197 }
205
206 if (fInit)
208 SetActive();
209}
210
211////////////////////////////////////////////////////////////////////////////////
212/// Check if shape drawing is delayed.
213
215{
216 return (fDelayed->GetState() == kButtonDown);
217}
218
219////////////////////////////////////////////////////////////////////////////////
220/// Perform name change.
221
223{
224 DoModified();
225}
226
227////////////////////////////////////////////////////////////////////////////////
228/// Slot for applying modifications.
229
231{
232 const char *name = fShapeName->GetText();
233 if (strcmp(name, fShape->GetName()))
240 Double_t param[5];
241 param[0] = dx1;
242 param[1] = dx2;
243 param[2] = dy1;
244 param[3] = dy2;
245 param[4] = dz;
246 fShape->SetDimensions(param);
248 fUndo->SetEnabled();
250 if (fPad) {
252 fShape->Draw();
253 fPad->GetView()->ShowAxis();
254 } else
255 Update();
256 }
257}
258
259////////////////////////////////////////////////////////////////////////////////
260/// Slot for signaling modifications.
261
266
267////////////////////////////////////////////////////////////////////////////////
268/// Slot for undoing last operation.
269
281
282////////////////////////////////////////////////////////////////////////////////
283/// Slot for dx1.
284
286{
289 if (dx1 < 0) {
290 dx1 = 0;
292 }
293 if (dx1 < 1.e-6 && dx2 < 1.e-6) {
294 dx1 = 0.1;
296 }
297 DoModified();
298 if (!IsDelayed())
299 DoApply();
300}
301
302////////////////////////////////////////////////////////////////////////////////
303/// Slot for dx2.
304
306{
309 if (dx2 < 0) {
310 dx2 = 0;
312 }
313 if (dx1 < 1.e-6 && dx2 < 1.e-6) {
314 dx2 = 0.1;
316 }
317 DoModified();
318 if (!IsDelayed())
319 DoApply();
320}
321
322////////////////////////////////////////////////////////////////////////////////
323/// Slot for dy1.
324
326{
329 if (dy1 < 0) {
330 dy1 = 0;
332 }
333 if (dy1 < 1.e-6 && dy2 < 1.e-6) {
334 dy1 = 0.1;
336 }
337 DoModified();
338 if (!IsDelayed())
339 DoApply();
340}
341
342////////////////////////////////////////////////////////////////////////////////
343/// Slot for dy2.
344
346{
349 if (dy2 < 0) {
350 dy2 = 0;
352 }
353 if (dy1 < 1.e-6 && dy2 < 1.e-6) {
354 dy2 = 0.1;
356 }
357 DoModified();
358 if (!IsDelayed())
359 DoApply();
360}
361
362////////////////////////////////////////////////////////////////////////////////
363/// Slot for dz.
364
366{
368 if (dz <= 0) {
369 dz = 0.1;
370 fEDz->SetNumber(dz);
371 }
372 DoModified();
373 if (!IsDelayed())
374 DoApply();
375}
@ 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:108
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ 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:453
Selects different options.
Definition TGButton.h:264
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
virtual TList * GetList() const
Definition TGFrame.h:312
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:959
TGCompositeFrame(const TGCompositeFrame &)=delete
virtual void SetSize(const TGDimension &s)
Definition TGFrame.h:254
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
TGDimension GetSize() const
Definition TGFrame.h:232
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:94
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.
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:129
Double_t GetDy1() const
Definition TGeoTrd2.h:61
void SetDimensions(Double_t *param) override
set arb8 params in one step :
Definition TGeoTrd2.cxx:727
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:149
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:226
virtual TClass * IsA() const
Definition TObject.h:246
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:865
virtual Bool_t IsPaintingShape() const =0
virtual TView * GetView() const =0
TF1 * f1
Definition legend1.C:11