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
34};
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
110{
111}
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();
142
143 val = fLine->GetX2();
144 fEndPointX->SetNumber(val);
145
146 val = fLine->GetY1();
148
149 val = fLine->GetY2();
150 fEndPointY->SetNumber(val);
151
154
157
159
161}
162
163////////////////////////////////////////////////////////////////////////////////
164/// Slot connected to the line start point.
165
167{
168 if (fAvoidSignal) return;
172 Update();
173}
174////////////////////////////////////////////////////////////////////////////////
175/// Slot connected to the line EndPoint.
176
178{
179 if (fAvoidSignal) return;
183 Update();
184}
185
186////////////////////////////////////////////////////////////////////////////////
187/// Slot so set the line vertical
188
190{
191 if (fAvoidSignal) return;
192 if (fVertical->GetState() == kButtonDown) {
195 } else {
197 }
198 Update();
199}
200
201////////////////////////////////////////////////////////////////////////////////
202/// Slot so set the line horizontal
203
205{
206 if (fAvoidSignal) return;
207 if (fHorizontal->GetState() == kButtonDown) {
210 } else {
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
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
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
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
ELineWid
@ kLine_HORIZONTAL
@ kLine_VERTICAL
@ kLine_ENDX
@ kLine_STAY
@ kLine_STAX
@ kLine_ENDY
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:445
virtual EButtonState GetState() const
Definition TGButton.h:112
Selects different options.
Definition TGButton.h:264
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set check button state.
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
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.
virtual Double_t GetNumber() const
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
@ kNEAAnyNumber
Attributes of number entry field.
@ kNESRealThree
Fixed fraction real, three digit.
@ kNELNoLimits
Limit selection of number entry field.
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
ROOT GUI Window base class.
Definition TGWindow.h:23
Base frame for implementing GUI - a service class.
Definition TGedFrame.h:27
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.
virtual void SetModel(TObject *obj)
Pick up the used line attributes.
TGNumberEntry * fEndPointX
end point x coordinate
Definition TLineEditor.h:28
virtual void DoLineVertical()
Slot so set the line vertical.
TLine * fLine
line object
Definition TLineEditor.h:25
virtual ~TLineEditor()
Destructor of line editor.
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
virtual void SetY2(Double_t y2)
Definition TLine.h:68
virtual void SetX2(Double_t x2)
Definition TLine.h:66
Bool_t IsVertical()
Check whether this line is to be drawn vertically.
Definition TLine.cxx:455
void SetVertical(Bool_t set=kTRUE)
Force the line to be drawn vertically.
Definition TLine.cxx:495
Bool_t IsHorizontal()
Check whether this line is to be drawn horizontally.
Definition TLine.cxx:447
Double_t GetY1() const
Definition TLine.h:52
Double_t GetX2() const
Definition TLine.h:51
void Paint(Option_t *option="") override
Paint this line with its current attributes.
Definition TLine.cxx:388
virtual void SetX1(Double_t x1)
Definition TLine.h:65
virtual void SetY1(Double_t y1)
Definition TLine.h:67
Double_t GetX1() const
Definition TLine.h:50
void SetHorizontal(Bool_t set=kTRUE)
Force the line to be drawn horizontally.
Definition TLine.cxx:474
Double_t GetY2() const
Definition TLine.h:53
Mother of all ROOT objects.
Definition TObject.h:41
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition TObject.cxx:423
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