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
35
37
38////////////////////////////////////////////////////////////////////////////////
39/// Constructor for trd1 editor
40
42 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
43{
44 fShape = nullptr;
45 fDxi1 = fDxi2 = fDyi = fDzi = 0.0;
46 fNamei = "";
49
50 // TextEntry for shape name
51 MakeTitle("Name");
52 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTRD1_NAME);
54 fShapeName->SetToolTipText("Enter the box name");
55 fShapeName->Associate(this);
57
59 MakeTitle("Trd1 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, kTRD1_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, kTRD1_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 dy
88 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
89 fEDy = new TGNumberEntry(f2, 0., 5, kTRD1_Y);
92 nef->SetToolTipText("Enter the half-length in Y");
93 fEDy->Associate(this);
94 f2->AddFrame(fEDy, 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 dz
100 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
101 fEDz = new TGNumberEntry(f3, 0., 5, kTRD1_Z);
104 nef->SetToolTipText("Enter the half-length in Z");
105 fEDz->Associate(this);
106 f3->AddFrame(fEDz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
107 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
108
109 compxyz->Resize(150, 30);
110 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
111
112 // Delayed draw
114 fDelayed = new TGCheckButton(f1, "Delayed draw");
115 f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
116 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
117
118 // Buttons
119 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
120 fApply = new TGTextButton(f1, "Apply");
121 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
122 fApply->Associate(this);
123 fUndo = new TGTextButton(f1, "Undo");
124 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
125 fUndo->Associate(this);
126 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
128}
129
130////////////////////////////////////////////////////////////////////////////////
131/// Destructor
132
134{
136 TIter next(GetList());
137 while ((el = (TGFrameElement *)next())) {
138 if (el->fFrame->IsComposite())
140 }
141 Cleanup();
142}
143
144////////////////////////////////////////////////////////////////////////////////
145/// Connect signals to slots.
146
148{
149 fApply->Connect("Clicked()", "TGeoTrd1Editor", this, "DoApply()");
150 fUndo->Connect("Clicked()", "TGeoTrd1Editor", this, "DoUndo()");
151 fShapeName->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
152 fEDx1->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDx1()");
153 fEDx2->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDx2()");
154 fEDy->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDy()");
155 fEDz->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDz()");
156 fEDx1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
157 fEDx2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
158 fEDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
159 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()");
160 fInit = kFALSE;
161}
162
163////////////////////////////////////////////////////////////////////////////////
164/// Connect to the selected object.
165
167{
168 if (obj == nullptr || (obj->IsA() != TGeoTrd1::Class())) {
170 return;
171 }
172 fShape = (TGeoTrd1 *)obj;
173 fDxi1 = fShape->GetDx1();
174 fDxi2 = fShape->GetDx2();
175 fDyi = fShape->GetDy();
176 fDzi = fShape->GetDz();
177 const char *sname = fShape->GetName();
178 if (!strcmp(sname, fShape->ClassName()))
179 fShapeName->SetText("-no_name");
180 else {
182 fNamei = sname;
183 }
190
191 if (fInit)
193 SetActive();
194}
195
196////////////////////////////////////////////////////////////////////////////////
197/// Check if shape drawing is delayed.
198
200{
201 return (fDelayed->GetState() == kButtonDown);
202}
203
204////////////////////////////////////////////////////////////////////////////////
205/// Perform name change.
206
208{
209 DoModified();
210}
211
212////////////////////////////////////////////////////////////////////////////////
213/// Slot for applying modifications.
214
216{
217 const char *name = fShapeName->GetText();
218 if (strcmp(name, fShape->GetName()))
224 Double_t param[4];
225 param[0] = dx1;
226 param[1] = dx2;
227 param[2] = dy;
228 param[3] = dz;
229 fShape->SetDimensions(param);
231 fUndo->SetEnabled();
233 if (fPad) {
235 fShape->Draw();
236 fPad->GetView()->ShowAxis();
237 } else
238 Update();
239 }
240}
241
242////////////////////////////////////////////////////////////////////////////////
243/// Slot for signaling modifications.
244
249
250////////////////////////////////////////////////////////////////////////////////
251/// Slot for undoing last operation.
252
263
264////////////////////////////////////////////////////////////////////////////////
265/// Slot for dx1.
266
268{
271 if (dx1 < 0) {
272 dx1 = 0;
274 }
275 if (dx1 < 1.e-6 && dx2 < 1.e-6) {
276 dx1 = 0.1;
278 }
279 DoModified();
280 if (!IsDelayed())
281 DoApply();
282}
283
284////////////////////////////////////////////////////////////////////////////////
285/// Slot for dx2.
286
288{
291 if (dx2 < 0) {
292 dx2 = 0;
294 }
295 if (dx1 < 1.e-6 && dx2 < 1.e-6) {
296 dx2 = 0.1;
298 }
299 DoModified();
300 if (!IsDelayed())
301 DoApply();
302}
303
304////////////////////////////////////////////////////////////////////////////////
305/// Slot for dy.
306
308{
310 if (dy <= 0) {
311 dy = 0.1;
312 fEDy->SetNumber(dy);
313 }
314 DoModified();
315 if (!IsDelayed())
316 DoApply();
317}
318
319////////////////////////////////////////////////////////////////////////////////
320/// Slot for dz.
321
323{
325 if (dz <= 0) {
326 dz = 0.1;
327 fEDz->SetNumber(dz);
328 }
329 DoModified();
330 if (!IsDelayed())
331 DoApply();
332}
@ 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
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: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 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.
A trapezoid with only X varying with Z.
Definition TGeoTrd1.h:17
void ComputeBBox() override
compute bounding box for a trd1
Definition TGeoTrd1.cxx:130
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
set trd1 params in one step :
Definition TGeoTrd1.cxx:695
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: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