61 line.TLine::Copy(*
this);
69 src.TLine::Copy(*
this);
91 if (!
gPad)
return 9999;
134 if (!
gPad || !
gPad->IsEditable())
return;
136 constexpr Int_t kMaxDiff = 20;
137 static Int_t px1,px2,py1,py2,pxold,pyold;
138 static Double_t oldX1, oldY1, oldX2, oldY2;
139 static Int_t selectPoint;
141 auto &parent = *
gPad;
143 Bool_t opaque = parent.OpaqueMoving();
151 x1 = (1. * _x1 / parent.GetWw() - parent.GetAbsXlowNDC()) / parent.GetAbsWNDC();
152 y1 = ((1 - 1. * _y1 / parent.GetWh()) - parent.GetAbsYlowNDC()) / parent.GetAbsHNDC();
153 x2 = (1. * _x2 / parent.GetWw() - parent.GetAbsXlowNDC()) / parent.GetAbsWNDC();
154 y2 = ((1 - 1. * _y2 / parent.GetWh()) - parent.GetAbsYlowNDC()) / parent.GetAbsHNDC();
156 x1 = parent.AbsPixeltoX(_x1);
157 y1 = parent.AbsPixeltoY(_y1);
158 x2 = parent.AbsPixeltoX(_x2);
159 y2 = parent.AbsPixeltoY(_y2);
162 auto pp = parent.GetPainter();
163 pp->SetAttLine(*
this);
165 pp->DrawLineNDC(x1, y1, x2, y2);
167 pp->DrawLine(x1, y1, x2, y2);
170 x1 = parent.PadtoX(x1);
171 x2 = parent.PadtoX(x2);
172 y1 = parent.PadtoY(y1);
173 y2 = parent.PadtoY(y2);
213 px1 = parent.UtoAbsPixel(
GetX1());
214 py1 = parent.VtoAbsPixel(
GetY1());
215 px2 = parent.UtoAbsPixel(
GetX2());
216 py2 = parent.VtoAbsPixel(
GetY2());
218 px1 = parent.XtoAbsPixel(parent.XtoPad(
GetX1()));
219 py1 = parent.YtoAbsPixel(parent.YtoPad(
GetY1()));
220 px2 = parent.XtoAbsPixel(parent.XtoPad(
GetX2()));
221 py2 = parent.YtoAbsPixel(parent.YtoPad(
GetY2()));
225 if (abs(px1 - px) + abs(py1 - py) < kMaxDiff) {
228 }
else if (abs(px2 - px) + abs(py2 - py) < kMaxDiff) {
235 parent.SetCursor(
kMove);
243 action(0, px1, py1, px2, py2);
244 if (selectPoint == 1) {
247 }
else if (selectPoint == 2) {
250 }
else if (selectPoint == 3) {
258 action(!opaque ? 0 : selectPoint, px1, py1, px2, py2);
260 if (selectPoint == 1) {
263 parent.ShowGuidelines(
this, event,
GetY1() >
GetY2() ?
'2' :
'3',
true);
265 parent.ShowGuidelines(
this, event,
GetY1() >
GetY2() ?
'1' :
'4',
true);
266 }
else if (selectPoint == 2) {
269 parent.ShowGuidelines(
this, event,
GetY1() >
GetY2() ?
'4' :
'1',
true);
271 parent.ShowGuidelines(
this, event,
GetY1() >
GetY2() ?
'3' :
'2',
true);
272 }
else if (selectPoint == 3) {
273 parent.ShowGuidelines(
this, event,
'i',
true);
275 parent.ModifiedUpdate();
281 if (
gROOT->IsEscaped()) {
288 parent.ShowGuidelines(
this, event);
289 parent.ModifiedUpdate();
294 parent.ShowGuidelines(
this, event);
296 action(selectPoint, px1, py1, px2, py2);
297 parent.ModifiedUpdate();
308 event = parent.GetCanvasImp()->RequestLocator(px, py);
327 Error(
"GetSlope",
"This line is vertical. The slope in undefined");
342 Error(
"GetYIntercept",
"This line is vertical. The Y-Intercept in undefined");
376 gPad->PaintLine(x1,y1,x2,y2);
406 SavePrimitiveConstructor(out,
Class(),
"line",
TString::Format(
"%g, %g, %g, %g",
fX1,
fY1,
fX2,
fY2),
kFALSE);
411 out <<
" line->SetNDC();\n";
414 out <<
" line->SetBit(TLine::kVertical);\n";
417 out <<
" line->SetBit(TLine::kHorizontal);\n";
462 else fX2 =
gPad->AbsPixeltoX(px1-
l);
483 else fY2 =
gPad->AbsPixeltoY(py1+
l);
504 R__b >> x1;
fX1 = x1;
505 R__b >> y1;
fY1 = y1;
506 R__b >> x2;
fX2 = x2;
507 R__b >> y2;
fY2 = y2;
int Int_t
Signed integer 4 bytes (int).
short Version_t
Class version identifier (short).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
const char Option_t
Option string (const char).
Abstract base class for elements drawn in the editor.
Double_t GetYCoord(const Int_t y, Bool_t is_ndc=kFALSE)
Double_t GetXCoord(const Int_t x, Bool_t is_ndc=kFALSE)
virtual void Streamer(TBuffer &)
virtual Color_t GetLineColor() const
Return the line color.
virtual Width_t GetLineWidth() const
Return the line width.
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
virtual Style_t GetLineStyle() const
Return the line style.
void Copy(TAttLine &attline) const
Int_t DistancetoLine(Int_t px, Int_t py, Double_t xp1, Double_t yp1, Double_t xp2, Double_t yp2)
Buffer base class used for serializing objects.
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
@ kLineNDC
Use NDC coordinates.
@ kHorizontal
Line is horizontal.
@ kVertical
Line is vertical.
void ls(Option_t *option="") const override
List this line with its attributes.
virtual void SetY2(Double_t y2)
Double_t fY1
Y of 1st point.
Double_t fX1
X of 1st point.
Double_t GetYIntercept() const
Get the Y-Intercept of this TLine.
virtual void SetX2(Double_t x2)
Bool_t IsVertical()
Check whether this line is to be drawn vertically.
virtual TLine * DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
void SetBBoxY1(const Int_t y) override
Set top of BoundingBox to a value (resize in y direction on top).
void SetVertical(Bool_t set=kTRUE)
Force the line to be drawn vertically.
virtual void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Double_t GetSlope() const
Get the slope of this TLine.
void SetBBoxCenterY(const Int_t y) override
Set Y coordinate of the center of the BoundingBox.
void SetBBoxX2(const Int_t x) override
Set right hand side of BoundingBox to a value (resize in x direction on right).
virtual TLine * DrawLineNDC(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates in NDC.
Bool_t IsHorizontal()
Check whether this line is to be drawn horizontally.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
void Copy(TObject &line) const override
Copy this line to line.
void Print(Option_t *option="") const override
Dump this line with its attributes.
Double_t fX2
X of 2nd point.
void SetBBoxX1(const Int_t x) override
Set left hand side of BoundingBox to a value (resize in x direction on left).
void Paint(Option_t *option="") override
Paint this line with its current attributes.
void SetBBoxY2(const Int_t y) override
Set bottom of BoundingBox to a value (resize in y direction on bottom).
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a line.
virtual void SetX1(Double_t x1)
TLine & operator=(const TLine &src)
Assignment operator.
Double_t fY2
Y of 2nd point.
virtual void PaintLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2)
Draw this line with new coordinates in NDC.
void Streamer(TBuffer &) override
Stream an object of class TLine.
void SetBBoxCenterX(const Int_t x) override
Set X coordinate of the center of the BoundingBox.
TClass * IsA() const override
virtual void SetY1(Double_t y1)
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Rectangle_t GetBBox() override
Return the bounding Box of the Line.
void SetHorizontal(Bool_t set=kTRUE)
Force the line to be drawn horizontally.
Bool_t TestBit(UInt_t f) const
virtual const char * GetName() const
Returns name of object.
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Copy(TObject &object) const
Copy this to obj.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
static void SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option=nullptr)
Save invocation of primitive Draw() method Skipped if option contains "nodraw" string.
TObject()
TObject constructor.
static void SavePrimitiveConstructor(std::ostream &out, TClass *cl, const char *variable_name, const char *constructor_agrs="", Bool_t empty_line=kTRUE)
Save object constructor in the output stream "out".
@ kCanDelete
if object in a list can be deleted
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Double_t Infinity()
Returns an infinity as defined by the IEEE standard.
Rectangle structure (maps to the X11 XRectangle structure).