Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TLineEditor.cxx
Go to the documentation of this file.
1// @(#)root/ged:$Id$
2// Author: Ilka Antcheva 24/04/06
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, 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 TLineEditor
13 \ingroup ged
14
15Implements GUI for editing line attributes: shape, size, angle.
16
17*/
18
19
20#include "TLineEditor.h"
21#include "TGLabel.h"
22#include "TGNumberEntry.h"
23#include "TLine.h"
24
25
34
35
36////////////////////////////////////////////////////////////////////////////////
37/// Constructor of line GUI.
38
40 Int_t height, UInt_t options, Pixel_t back)
41 : TGedFrame(p, width, height, options | kVerticalFrame, back)
42{
43 fLine = 0;
44
45 MakeTitle("Points");
46
47 TGCompositeFrame *f3 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
48 AddFrame(f3, new TGLayoutHints(kLHintsTop, 1, 1, 3, 0));
49
50 TGCompositeFrame *f3a = new TGCompositeFrame(f3, 80, 20);
51 f3->AddFrame(f3a, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
52
53 TGLabel *fStartPointXLabel = new TGLabel(f3a, "Start X:");
54 f3a->AddFrame(fStartPointXLabel, new TGLayoutHints(kLHintsNormal, 8, 0, 5, 5));
55
56 TGLabel *fStartPointYLabel = new TGLabel(f3a, "Y:");
57 f3a->AddFrame(fStartPointYLabel, new TGLayoutHints(kLHintsNormal, 37, 0, 5, 5));
58
59 TGLabel *fEndPointXLabel = new TGLabel(f3a, "End X:");
60 f3a->AddFrame(fEndPointXLabel, new TGLayoutHints(kLHintsNormal, 10, 0, 5, 5));
61
62 TGLabel *fEndPointYLabel = new TGLabel(f3a, "Y:");
63 f3a->AddFrame(fEndPointYLabel, new TGLayoutHints(kLHintsNormal, 37, 0, 5, 5));
64
65 TGCompositeFrame *f3b = new TGCompositeFrame(f3, 80, 20, kFixedWidth);
66 f3->AddFrame(f3b, new TGLayoutHints(kLHintsNormal, 8, 0, 0, 0));
67
68 fStartPointX = new TGNumberEntry(f3b, 0.0, 8, kLine_STAX,
72 fStartPointX->GetNumberEntry()->SetToolTipText("Set start point X coordinate of Line.");
73 f3b->AddFrame(fStartPointX, new TGLayoutHints(kLHintsExpandX, 1, 1, 1, 1));
74
75 fStartPointY = new TGNumberEntry(f3b, 0.0, 8, kLine_STAY,
79 fStartPointY->GetNumberEntry()->SetToolTipText("Set start point Y coordinate of Line.");
80 f3b->AddFrame(fStartPointY, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
81
82 fEndPointX = new TGNumberEntry(f3b, 0.0, 8, kLine_ENDX,
86 fEndPointX->GetNumberEntry()->SetToolTipText("Set end point X xoordinate of Line.");
87 f3b->AddFrame(fEndPointX, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
88
89 fEndPointY = new TGNumberEntry(f3b, 0.0, 8, kLine_ENDY,
93 fEndPointY->GetNumberEntry()->SetToolTipText("Set end point Y coordinate of Line.");
94 f3b->AddFrame(fEndPointY, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
95
96 fVertical = new TGCheckButton(this,"Vertical",kLine_VERTICAL);
97 fVertical->SetToolTipText("Set vertical");
98 AddFrame(fVertical, new TGLayoutHints(kLHintsTop, 8, 1, 5, 0));
99
100 fHorizontal = new TGCheckButton(this,"Horizontal",kLine_HORIZONTAL);
101 fHorizontal->SetToolTipText("Set horizontal");
102 AddFrame(fHorizontal, new TGLayoutHints(kLHintsTop, 8, 1, 3, 0));
103}
104
105////////////////////////////////////////////////////////////////////////////////
106/// Destructor of line editor.
107
111
112////////////////////////////////////////////////////////////////////////////////
113/// Connect signals to slots.
114
116{
117 fStartPointX->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoStartPoint()");
118 (fStartPointX->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoStartPoint()");
119 fStartPointY->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoStartPoint()");
120 (fStartPointY->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoStartPoint()");
121 fEndPointX->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoEndPoint()");
122 (fEndPointX->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoEndPoint()");
123 fEndPointY->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoEndPoint()");
124 (fEndPointY->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoEndPoint()");
125 fVertical->Connect("Clicked()","TLineEditor",this,"DoLineVertical()");
126 fHorizontal->Connect("Clicked()","TLineEditor",this,"DoLineHorizontal()");
127
128 fInit = kFALSE;
129}
130
131////////////////////////////////////////////////////////////////////////////////
132/// Pick up the used line attributes.
133
135{
136 fLine = (TLine *)obj;
138
139 Float_t val = fLine->GetX1();
140 fStartPointX->SetNumber(val);
141
142 val = fLine->GetX2();
143 fEndPointX->SetNumber(val);
144
145 val = fLine->GetY1();
146 fStartPointY->SetNumber(val);
147
148 val = fLine->GetY2();
149 fEndPointY->SetNumber(val);
150
151 if (fLine->IsHorizontal()) fHorizontal->SetState(kButtonDown, kFALSE);
152 else fHorizontal->SetState(kButtonUp, kFALSE);
153
154 if (fLine->IsVertical()) fVertical->SetState(kButtonDown, kFALSE);
155 else fVertical->SetState(kButtonUp, kFALSE);
156
158
160}
161
162////////////////////////////////////////////////////////////////////////////////
163/// Slot connected to the line start point.
164
166{
167 if (fAvoidSignal) return;
168 fLine->SetX1((Double_t)fStartPointX->GetNumber());
169 fLine->SetY1((Double_t)fStartPointY->GetNumber());
170 fLine->Paint(fLine->GetDrawOption());
171 Update();
172}
173////////////////////////////////////////////////////////////////////////////////
174/// Slot connected to the line EndPoint.
175
177{
178 if (fAvoidSignal) return;
179 fLine->SetX2((Double_t)fEndPointX->GetNumber());
180 fLine->SetY2((Double_t)fEndPointY->GetNumber());
181 fLine->Paint(fLine->GetDrawOption());
182 Update();
183}
184
185////////////////////////////////////////////////////////////////////////////////
186/// Slot so set the line vertical
187
189{
190 if (fAvoidSignal) return;
191 if (fVertical->GetState() == kButtonDown) {
192 fLine->SetVertical();
193 fHorizontal->SetState(kButtonUp, kFALSE);
194 } else {
195 fLine->SetVertical(kFALSE);
196 }
197 Update();
198}
199
200////////////////////////////////////////////////////////////////////////////////
201/// Slot so set the line horizontal
202
204{
205 if (fAvoidSignal) return;
206 if (fHorizontal->GetState() == kButtonDown) {
207 fLine->SetHorizontal();
208 fVertical->SetState(kButtonUp, kFALSE);
209 } else {
210 fLine->SetHorizontal(kFALSE);
211 }
212 Update();
213}
@ kVerticalFrame
Definition GuiTypes.h:382
@ kFixedWidth
Definition GuiTypes.h:388
@ kHorizontalFrame
Definition GuiTypes.h:383
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
@ kLHintsNormal
Definition TGLayout.h:32
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
ELineWid
@ kLine_HORIZONTAL
@ kLine_VERTICAL
@ kLine_ENDX
@ kLine_STAY
@ kLine_STAX
@ kLine_ENDY
Selects different options.
Definition TGButton.h:264
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
TGCompositeFrame(const TGCompositeFrame &)=delete
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.
@ kNEAAnyNumber
Attributes of number entry field.
@ kNESRealThree
Fixed fraction real, three digit.
@ kNELNoLimits
Limit selection of number entry field.
ROOT GUI Window base class.
Definition TGWindow.h:23
TGedFrame(const TGedFrame &)=delete
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
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition TGedFrame.cxx:71
Bool_t fAvoidSignal
flag for executing slots
Definition TGedFrame.h:50
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGNumberEntry * fEndPointX
end point x coordinate
Definition TLineEditor.h:28
virtual void DoLineVertical()
Slot so set the line vertical.
~TLineEditor() override
Destructor of line editor.
void SetModel(TObject *obj) override
Pick up the used line attributes.
TLine * fLine
line object
Definition TLineEditor.h:25
TGCheckButton * fHorizontal
set the line horizontal
Definition TLineEditor.h:31
virtual void DoStartPoint()
Slot connected to the line start point.
TLineEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of line GUI.
TGNumberEntry * fEndPointY
end point y coordinate
Definition TLineEditor.h:29
TGCheckButton * fVertical
set the line vertical
Definition TLineEditor.h:30
virtual void DoEndPoint()
Slot connected to the line EndPoint.
TGNumberEntry * fStartPointX
start point x coordinate
Definition TLineEditor.h:26
TGNumberEntry * fStartPointY
start point y coordinate
Definition TLineEditor.h:27
virtual void DoLineHorizontal()
Slot so set the line horizontal.
Use the TLine constructor to create a simple line.
Definition TLine.h:22
Mother of all ROOT objects.
Definition TObject.h:42