Logo ROOT   6.16/01
Reference Guide
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//////////////////////////////////////////////////////////////////////////
13// //
14// TLineEditor //
15// //
16// Implements GUI for editing line attributes: shape, size, angle. // //
17// //
18//////////////////////////////////////////////////////////////////////////
19//Begin_Html
20/*
21<img src="gif/TLineEditor.gif">
22*/
23//End_Html
24
25
26#include "TLineEditor.h"
27#include "TGLabel.h"
28#include "TGNumberEntry.h"
29#include "TLine.h"
30#include "TVirtualPad.h"
31
33
41};
42
43
44////////////////////////////////////////////////////////////////////////////////
45/// Constructor of line GUI.
46
48 Int_t height, UInt_t options, Pixel_t back)
49 : TGedFrame(p, width, height, options | kVerticalFrame, back)
50{
51 fLine = 0;
52
53 MakeTitle("Points");
54
55 TGCompositeFrame *f3 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
56 AddFrame(f3, new TGLayoutHints(kLHintsTop, 1, 1, 3, 0));
57
58 TGCompositeFrame *f3a = new TGCompositeFrame(f3, 80, 20);
59 f3->AddFrame(f3a, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
60
61 TGLabel *fStartPointXLabel = new TGLabel(f3a, "Start X:");
62 f3a->AddFrame(fStartPointXLabel, new TGLayoutHints(kLHintsNormal, 8, 0, 5, 5));
63
64 TGLabel *fStartPointYLabel = new TGLabel(f3a, "Y:");
65 f3a->AddFrame(fStartPointYLabel, new TGLayoutHints(kLHintsNormal, 37, 0, 5, 5));
66
67 TGLabel *fEndPointXLabel = new TGLabel(f3a, "End X:");
68 f3a->AddFrame(fEndPointXLabel, new TGLayoutHints(kLHintsNormal, 10, 0, 5, 5));
69
70 TGLabel *fEndPointYLabel = new TGLabel(f3a, "Y:");
71 f3a->AddFrame(fEndPointYLabel, new TGLayoutHints(kLHintsNormal, 37, 0, 5, 5));
72
73 TGCompositeFrame *f3b = new TGCompositeFrame(f3, 80, 20, kFixedWidth);
74 f3->AddFrame(f3b, new TGLayoutHints(kLHintsNormal, 8, 0, 0, 0));
75
76 fStartPointX = new TGNumberEntry(f3b, 0.0, 8, kLine_STAX,
80 fStartPointX->GetNumberEntry()->SetToolTipText("Set start point X coordinate of Line.");
81 f3b->AddFrame(fStartPointX, new TGLayoutHints(kLHintsExpandX, 1, 1, 1, 1));
82
83 fStartPointY = new TGNumberEntry(f3b, 0.0, 8, kLine_STAY,
87 fStartPointY->GetNumberEntry()->SetToolTipText("Set start point Y coordinate of Line.");
88 f3b->AddFrame(fStartPointY, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
89
90 fEndPointX = new TGNumberEntry(f3b, 0.0, 8, kLine_ENDX,
94 fEndPointX->GetNumberEntry()->SetToolTipText("Set end point X xoordinate of Line.");
95 f3b->AddFrame(fEndPointX, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
96
97 fEndPointY = new TGNumberEntry(f3b, 0.0, 8, kLine_ENDY,
101 fEndPointY->GetNumberEntry()->SetToolTipText("Set end point Y coordinate of Line.");
102 f3b->AddFrame(fEndPointY, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
103
104 fVertical = new TGCheckButton(this,"Vertical",kLine_VERTICAL);
105 fVertical->SetToolTipText("Set vertical");
106 AddFrame(fVertical, new TGLayoutHints(kLHintsTop, 8, 1, 5, 0));
107
108 fHorizontal = new TGCheckButton(this,"Horizontal",kLine_HORIZONTAL);
109 fHorizontal->SetToolTipText("Set horizontal");
110 AddFrame(fHorizontal, new TGLayoutHints(kLHintsTop, 8, 1, 3, 0));
111}
112
113////////////////////////////////////////////////////////////////////////////////
114/// Destructor of line editor.
115
117{
118}
119
120////////////////////////////////////////////////////////////////////////////////
121/// Connect signals to slots.
122
124{
125 fStartPointX->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoStartPoint()");
126 (fStartPointX->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoStartPoint()");
127 fStartPointY->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoStartPoint()");
128 (fStartPointY->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoStartPoint()");
129 fEndPointX->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoEndPoint()");
130 (fEndPointX->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoEndPoint()");
131 fEndPointY->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoEndPoint()");
132 (fEndPointY->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoEndPoint()");
133 fVertical->Connect("Clicked()","TLineEditor",this,"DoLineVertical()");
134 fHorizontal->Connect("Clicked()","TLineEditor",this,"DoLineHorizontal()");
135
136 fInit = kFALSE;
137}
138
139////////////////////////////////////////////////////////////////////////////////
140/// Pick up the used line attributes.
141
143{
144 fLine = (TLine *)obj;
146
147 Float_t val = fLine->GetX1();
149
150 val = fLine->GetX2();
151 fEndPointX->SetNumber(val);
152
153 val = fLine->GetY1();
155
156 val = fLine->GetY2();
157 fEndPointY->SetNumber(val);
158
161
164
166
168}
169
170////////////////////////////////////////////////////////////////////////////////
171/// Slot connected to the line start point.
172
174{
175 if (fAvoidSignal) return;
179 Update();
180}
181////////////////////////////////////////////////////////////////////////////////
182/// Slot connected to the line EndPoint.
183
185{
186 if (fAvoidSignal) return;
190 Update();
191}
192
193////////////////////////////////////////////////////////////////////////////////
194/// Slot so set the line vertical
195
197{
198 if (fAvoidSignal) return;
199 if (fVertical->GetState() == kButtonDown) {
202 } else {
204 }
205 Update();
206}
207
208////////////////////////////////////////////////////////////////////////////////
209/// Slot so set the line horizontal
210
212{
213 if (fAvoidSignal) return;
214 if (fHorizontal->GetState() == kButtonDown) {
217 } else {
219 }
220 Update();
221}
ULong_t Pixel_t
Definition: GuiTypes.h:39
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
double Double_t
Definition: RtypesCore.h:55
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:363
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kButtonDown
Definition: TGButton.h:54
@ kButtonUp
Definition: TGButton.h:53
@ kVerticalFrame
Definition: TGFrame.h:59
@ kFixedWidth
Definition: TGFrame.h:65
@ kHorizontalFrame
Definition: TGFrame.h:60
@ kLHintsNormal
Definition: TGLayout.h:39
@ kLHintsTop
Definition: TGLayout.h:34
@ kLHintsExpandX
Definition: TGLayout.h:37
ELineWid
Definition: TLineEditor.cxx:34
@ kLine_HORIZONTAL
Definition: TLineEditor.cxx:40
@ kLine_VERTICAL
Definition: TLineEditor.cxx:39
@ kLine_ENDX
Definition: TLineEditor.cxx:37
@ kLine_STAY
Definition: TLineEditor.cxx:36
@ kLine_STAX
Definition: TLineEditor.cxx:35
@ kLine_ENDY
Definition: TLineEditor.cxx:38
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:395
virtual EButtonState GetState() const
Definition: TGButton.h:112
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1200
TGCompositeFrame(const TGCompositeFrame &)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void SetNumber(Double_t val)
TGNumberEntryField * GetNumberEntry() const
virtual Double_t GetNumber() const
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
Bool_t fInit
Definition: TGedFrame.h:53
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:73
Bool_t fAvoidSignal
Definition: TGedFrame.h:56
virtual void ConnectSignals2Slots()
Connect signals to slots.
virtual void SetModel(TObject *obj)
Pick up the used line attributes.
TLineEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of line GUI.
Definition: TLineEditor.cxx:47
TGNumberEntry * fEndPointX
Definition: TLineEditor.h:35
virtual void DoLineVertical()
Slot so set the line vertical.
TLine * fLine
Definition: TLineEditor.h:32
virtual ~TLineEditor()
Destructor of line editor.
TGCheckButton * fHorizontal
Definition: TLineEditor.h:38
virtual void DoStartPoint()
Slot connected to the line start point.
TGNumberEntry * fEndPointY
Definition: TLineEditor.h:36
TGCheckButton * fVertical
Definition: TLineEditor.h:37
virtual void DoEndPoint()
Slot connected to the line EndPoint.
TGNumberEntry * fStartPointX
Definition: TLineEditor.h:33
TGNumberEntry * fStartPointY
Definition: TLineEditor.h:34
virtual void DoLineHorizontal()
Slot so set the line horizontal.
A simple line.
Definition: TLine.h:23
virtual void SetY2(Double_t y2)
Definition: TLine.h:67
virtual void SetX2(Double_t x2)
Definition: TLine.h:65
Bool_t IsVertical()
Check whether this line is to be drawn vertically.
Definition: TLine.cxx:436
void SetVertical(Bool_t set=kTRUE)
Force the line to be drawn vertically.
Definition: TLine.cxx:476
Bool_t IsHorizontal()
Check whether this line is to be drawn horizontally.
Definition: TLine.cxx:428
Double_t GetY1() const
Definition: TLine.h:51
Double_t GetX2() const
Definition: TLine.h:50
virtual void SetX1(Double_t x1)
Definition: TLine.h:64
virtual void SetY1(Double_t y1)
Definition: TLine.h:66
Double_t GetX1() const
Definition: TLine.h:49
void SetHorizontal(Bool_t set=kTRUE)
Force the line to be drawn horizontally.
Definition: TLine.cxx:455
virtual void Paint(Option_t *option="")
Paint this line with its current attributes.
Definition: TLine.cxx:371
Double_t GetY2() const
Definition: TLine.h:52
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition: TObject.cxx:341
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:867