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
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
66 f3->AddFrame(f3b, new TGLayoutHints(kLHintsNormal, 8, 0, 0, 0));
67
72 fStartPointX->GetNumberEntry()->SetToolTipText("Set start point X coordinate of Line.");
73 f3b->AddFrame(fStartPointX, new TGLayoutHints(kLHintsExpandX, 1, 1, 1, 1));
74
79 fStartPointY->GetNumberEntry()->SetToolTipText("Set start point Y coordinate of Line.");
80 f3b->AddFrame(fStartPointY, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
81
86 fEndPointX->GetNumberEntry()->SetToolTipText("Set end point X xoordinate of Line.");
87 f3b->AddFrame(fEndPointX, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
88
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();
141
142 val = fLine->GetX2();
143 fEndPointX->SetNumber(val);
144
145 val = fLine->GetY1();
147
148 val = fLine->GetY2();
149 fEndPointY->SetNumber(val);
150
153
156
158
160}
161
162////////////////////////////////////////////////////////////////////////////////
163/// Slot connected to the line start point.
164
173////////////////////////////////////////////////////////////////////////////////
174/// Slot connected to the line EndPoint.
175
184
185////////////////////////////////////////////////////////////////////////////////
186/// Slot so set the line vertical
187
189{
190 if (fAvoidSignal) return;
191 if (fVertical->GetState() == kButtonDown) {
194 } else {
196 }
197 Update();
198}
199
200////////////////////////////////////////////////////////////////////////////////
201/// Slot so set the line horizontal
202
204{
205 if (fAvoidSignal) return;
206 if (fHorizontal->GetState() == kButtonDown) {
209 } else {
211 }
212 Update();
213}
@ 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
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
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
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:439
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:289
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.
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: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
virtual void SetY2(Double_t y2)
Definition TLine.h:70
virtual void SetX2(Double_t x2)
Definition TLine.h:68
Bool_t IsVertical()
Check whether this line is to be drawn vertically.
Definition TLine.cxx:489
void SetVertical(Bool_t set=kTRUE)
Force the line to be drawn vertically.
Definition TLine.cxx:528
Bool_t IsHorizontal()
Check whether this line is to be drawn horizontally.
Definition TLine.cxx:481
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:418
virtual void SetX1(Double_t x1)
Definition TLine.h:67
virtual void SetY1(Double_t y1)
Definition TLine.h:69
Double_t GetX1() const
Definition TLine.h:50
void SetHorizontal(Bool_t set=kTRUE)
Force the line to be drawn horizontally.
Definition TLine.cxx:507
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:441
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