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
26
35
36
37////////////////////////////////////////////////////////////////////////////////
38/// Constructor of line GUI.
39
41 Int_t height, UInt_t options, Pixel_t back)
42 : TGedFrame(p, width, height, options | kVerticalFrame, back)
43{
44 fLine = 0;
45
46 MakeTitle("Points");
47
48 TGCompositeFrame *f3 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
49 AddFrame(f3, new TGLayoutHints(kLHintsTop, 1, 1, 3, 0));
50
51 TGCompositeFrame *f3a = new TGCompositeFrame(f3, 80, 20);
52 f3->AddFrame(f3a, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
53
54 TGLabel *fStartPointXLabel = new TGLabel(f3a, "Start X:");
55 f3a->AddFrame(fStartPointXLabel, new TGLayoutHints(kLHintsNormal, 8, 0, 5, 5));
56
57 TGLabel *fStartPointYLabel = new TGLabel(f3a, "Y:");
58 f3a->AddFrame(fStartPointYLabel, new TGLayoutHints(kLHintsNormal, 37, 0, 5, 5));
59
60 TGLabel *fEndPointXLabel = new TGLabel(f3a, "End X:");
61 f3a->AddFrame(fEndPointXLabel, new TGLayoutHints(kLHintsNormal, 10, 0, 5, 5));
62
63 TGLabel *fEndPointYLabel = new TGLabel(f3a, "Y:");
64 f3a->AddFrame(fEndPointYLabel, new TGLayoutHints(kLHintsNormal, 37, 0, 5, 5));
65
66 TGCompositeFrame *f3b = new TGCompositeFrame(f3, 80, 20, kFixedWidth);
67 f3->AddFrame(f3b, new TGLayoutHints(kLHintsNormal, 8, 0, 0, 0));
68
69 fStartPointX = new TGNumberEntry(f3b, 0.0, 8, kLine_STAX,
73 fStartPointX->GetNumberEntry()->SetToolTipText("Set start point X coordinate of Line.");
74 f3b->AddFrame(fStartPointX, new TGLayoutHints(kLHintsExpandX, 1, 1, 1, 1));
75
76 fStartPointY = new TGNumberEntry(f3b, 0.0, 8, kLine_STAY,
80 fStartPointY->GetNumberEntry()->SetToolTipText("Set start point Y coordinate of Line.");
81 f3b->AddFrame(fStartPointY, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
82
83 fEndPointX = new TGNumberEntry(f3b, 0.0, 8, kLine_ENDX,
87 fEndPointX->GetNumberEntry()->SetToolTipText("Set end point X xoordinate of Line.");
88 f3b->AddFrame(fEndPointX, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
89
90 fEndPointY = new TGNumberEntry(f3b, 0.0, 8, kLine_ENDY,
94 fEndPointY->GetNumberEntry()->SetToolTipText("Set end point Y coordinate of Line.");
95 f3b->AddFrame(fEndPointY, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
96
97 fVertical = new TGCheckButton(this,"Vertical",kLine_VERTICAL);
98 fVertical->SetToolTipText("Set vertical");
99 AddFrame(fVertical, new TGLayoutHints(kLHintsTop, 8, 1, 5, 0));
100
101 fHorizontal = new TGCheckButton(this,"Horizontal",kLine_HORIZONTAL);
102 fHorizontal->SetToolTipText("Set horizontal");
103 AddFrame(fHorizontal, new TGLayoutHints(kLHintsTop, 8, 1, 3, 0));
104}
105
106////////////////////////////////////////////////////////////////////////////////
107/// Destructor of line editor.
108
112
113////////////////////////////////////////////////////////////////////////////////
114/// Connect signals to slots.
115
117{
118 fStartPointX->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoStartPoint()");
119 (fStartPointX->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoStartPoint()");
120 fStartPointY->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoStartPoint()");
121 (fStartPointY->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoStartPoint()");
122 fEndPointX->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoEndPoint()");
123 (fEndPointX->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoEndPoint()");
124 fEndPointY->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoEndPoint()");
125 (fEndPointY->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoEndPoint()");
126 fVertical->Connect("Clicked()","TLineEditor",this,"DoLineVertical()");
127 fHorizontal->Connect("Clicked()","TLineEditor",this,"DoLineHorizontal()");
128
129 fInit = kFALSE;
130}
131
132////////////////////////////////////////////////////////////////////////////////
133/// Pick up the used line attributes.
134
136{
137 fLine = (TLine *)obj;
139
140 Float_t val = fLine->GetX1();
141 fStartPointX->SetNumber(val);
142
143 val = fLine->GetX2();
144 fEndPointX->SetNumber(val);
145
146 val = fLine->GetY1();
147 fStartPointY->SetNumber(val);
148
149 val = fLine->GetY2();
150 fEndPointY->SetNumber(val);
151
152 if (fLine->IsHorizontal()) fHorizontal->SetState(kButtonDown, kFALSE);
153 else fHorizontal->SetState(kButtonUp, kFALSE);
154
155 if (fLine->IsVertical()) fVertical->SetState(kButtonDown, kFALSE);
156 else fVertical->SetState(kButtonUp, kFALSE);
157
159
161}
162
163////////////////////////////////////////////////////////////////////////////////
164/// Slot connected to the line start point.
165
167{
168 if (fAvoidSignal) return;
169 fLine->SetX1((Double_t)fStartPointX->GetNumber());
170 fLine->SetY1((Double_t)fStartPointY->GetNumber());
171 fLine->Paint(fLine->GetDrawOption());
172 Update();
173}
174////////////////////////////////////////////////////////////////////////////////
175/// Slot connected to the line EndPoint.
176
178{
179 if (fAvoidSignal) return;
180 fLine->SetX2((Double_t)fEndPointX->GetNumber());
181 fLine->SetY2((Double_t)fEndPointY->GetNumber());
182 fLine->Paint(fLine->GetDrawOption());
183 Update();
184}
185
186////////////////////////////////////////////////////////////////////////////////
187/// Slot so set the line vertical
188
190{
191 if (fAvoidSignal) return;
192 if (fVertical->GetState() == kButtonDown) {
193 fLine->SetVertical();
194 fHorizontal->SetState(kButtonUp, kFALSE);
195 } else {
196 fLine->SetVertical(kFALSE);
197 }
198 Update();
199}
200
201////////////////////////////////////////////////////////////////////////////////
202/// Slot so set the line horizontal
203
205{
206 if (fAvoidSignal) return;
207 if (fHorizontal->GetState() == kButtonDown) {
208 fLine->SetHorizontal();
209 fVertical->SetState(kButtonUp, kFALSE);
210 } else {
211 fLine->SetHorizontal(kFALSE);
212 }
213 Update();
214}
@ kVerticalFrame
Definition GuiTypes.h:381
@ kFixedWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
@ 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
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
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:1117
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:95
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition TGedFrame.cxx:72
Bool_t fAvoidSignal
flag for executing slots
Definition TGedFrame.h:50
Implements GUI for editing line attributes: shape, size, angle.
Definition TLineEditor.h:22
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:41