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//////////////////////////////////////////////////////////////////////////
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
32
40};
41
42
43////////////////////////////////////////////////////////////////////////////////
44/// Constructor of line GUI.
45
47 Int_t height, UInt_t options, Pixel_t back)
48 : TGedFrame(p, width, height, options | kVerticalFrame, back)
49{
50 fLine = 0;
51
52 MakeTitle("Points");
53
54 TGCompositeFrame *f3 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
55 AddFrame(f3, new TGLayoutHints(kLHintsTop, 1, 1, 3, 0));
56
57 TGCompositeFrame *f3a = new TGCompositeFrame(f3, 80, 20);
58 f3->AddFrame(f3a, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
59
60 TGLabel *fStartPointXLabel = new TGLabel(f3a, "Start X:");
61 f3a->AddFrame(fStartPointXLabel, new TGLayoutHints(kLHintsNormal, 8, 0, 5, 5));
62
63 TGLabel *fStartPointYLabel = new TGLabel(f3a, "Y:");
64 f3a->AddFrame(fStartPointYLabel, new TGLayoutHints(kLHintsNormal, 37, 0, 5, 5));
65
66 TGLabel *fEndPointXLabel = new TGLabel(f3a, "End X:");
67 f3a->AddFrame(fEndPointXLabel, new TGLayoutHints(kLHintsNormal, 10, 0, 5, 5));
68
69 TGLabel *fEndPointYLabel = new TGLabel(f3a, "Y:");
70 f3a->AddFrame(fEndPointYLabel, new TGLayoutHints(kLHintsNormal, 37, 0, 5, 5));
71
72 TGCompositeFrame *f3b = new TGCompositeFrame(f3, 80, 20, kFixedWidth);
73 f3->AddFrame(f3b, new TGLayoutHints(kLHintsNormal, 8, 0, 0, 0));
74
75 fStartPointX = new TGNumberEntry(f3b, 0.0, 8, kLine_STAX,
79 fStartPointX->GetNumberEntry()->SetToolTipText("Set start point X coordinate of Line.");
80 f3b->AddFrame(fStartPointX, new TGLayoutHints(kLHintsExpandX, 1, 1, 1, 1));
81
82 fStartPointY = new TGNumberEntry(f3b, 0.0, 8, kLine_STAY,
86 fStartPointY->GetNumberEntry()->SetToolTipText("Set start point Y coordinate of Line.");
87 f3b->AddFrame(fStartPointY, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
88
89 fEndPointX = new TGNumberEntry(f3b, 0.0, 8, kLine_ENDX,
93 fEndPointX->GetNumberEntry()->SetToolTipText("Set end point X xoordinate of Line.");
94 f3b->AddFrame(fEndPointX, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
95
96 fEndPointY = new TGNumberEntry(f3b, 0.0, 8, kLine_ENDY,
100 fEndPointY->GetNumberEntry()->SetToolTipText("Set end point Y coordinate of Line.");
101 f3b->AddFrame(fEndPointY, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
102
103 fVertical = new TGCheckButton(this,"Vertical",kLine_VERTICAL);
104 fVertical->SetToolTipText("Set vertical");
105 AddFrame(fVertical, new TGLayoutHints(kLHintsTop, 8, 1, 5, 0));
106
107 fHorizontal = new TGCheckButton(this,"Horizontal",kLine_HORIZONTAL);
108 fHorizontal->SetToolTipText("Set horizontal");
109 AddFrame(fHorizontal, new TGLayoutHints(kLHintsTop, 8, 1, 3, 0));
110}
111
112////////////////////////////////////////////////////////////////////////////////
113/// Destructor of line editor.
114
116{
117}
118
119////////////////////////////////////////////////////////////////////////////////
120/// Connect signals to slots.
121
123{
124 fStartPointX->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoStartPoint()");
125 (fStartPointX->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoStartPoint()");
126 fStartPointY->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoStartPoint()");
127 (fStartPointY->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoStartPoint()");
128 fEndPointX->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoEndPoint()");
129 (fEndPointX->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoEndPoint()");
130 fEndPointY->Connect("ValueSet(Long_t)", "TLineEditor", this, "DoEndPoint()");
131 (fEndPointY->GetNumberEntry())->Connect("ReturnPressed()", "TLineEditor", this, "DoEndPoint()");
132 fVertical->Connect("Clicked()","TLineEditor",this,"DoLineVertical()");
133 fHorizontal->Connect("Clicked()","TLineEditor",this,"DoLineHorizontal()");
134
135 fInit = kFALSE;
136}
137
138////////////////////////////////////////////////////////////////////////////////
139/// Pick up the used line attributes.
140
142{
143 fLine = (TLine *)obj;
145
146 Float_t val = fLine->GetX1();
148
149 val = fLine->GetX2();
150 fEndPointX->SetNumber(val);
151
152 val = fLine->GetY1();
154
155 val = fLine->GetY2();
156 fEndPointY->SetNumber(val);
157
160
163
165
167}
168
169////////////////////////////////////////////////////////////////////////////////
170/// Slot connected to the line start point.
171
173{
174 if (fAvoidSignal) return;
178 Update();
179}
180////////////////////////////////////////////////////////////////////////////////
181/// Slot connected to the line EndPoint.
182
184{
185 if (fAvoidSignal) return;
189 Update();
190}
191
192////////////////////////////////////////////////////////////////////////////////
193/// Slot so set the line vertical
194
196{
197 if (fAvoidSignal) return;
198 if (fVertical->GetState() == kButtonDown) {
201 } else {
203 }
204 Update();
205}
206
207////////////////////////////////////////////////////////////////////////////////
208/// Slot so set the line horizontal
209
211{
212 if (fAvoidSignal) return;
213 if (fHorizontal->GetState() == kButtonDown) {
216 } else {
218 }
219 Update();
220}
@ 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
const Bool_t kFALSE
Definition RtypesCore.h:92
double Double_t
Definition RtypesCore.h:59
float Float_t
Definition RtypesCore.h:57
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
@ kLHintsNormal
Definition TGLayout.h:39
@ kLHintsTop
Definition TGLayout.h:34
@ kLHintsExpandX
Definition TGLayout.h:37
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:398
virtual EButtonState GetState() const
Definition TGButton.h:112
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1102
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:54
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:57
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.
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: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:442
void SetVertical(Bool_t set=kTRUE)
Force the line to be drawn vertically.
Definition TLine.cxx:482
Bool_t IsHorizontal()
Check whether this line is to be drawn horizontally.
Definition TLine.cxx:434
Double_t GetY1() const
Definition TLine.h:52
Double_t GetX2() const
Definition TLine.h:51
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:461
virtual void Paint(Option_t *option="")
Paint this line with its current attributes.
Definition TLine.cxx:375
Double_t GetY2() const
Definition TLine.h:53
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:343
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:866