81 for (
Int_t i = 0; i < fN; i++) {
101 if (!
x || !
y)
return;
102 for (
Int_t i=0; i<fN;i++) {
115 pl.TPolyLine::Copy(*
this);
124 if (
fX)
delete []
fX;
125 if (
fY)
delete []
fY;
133 polyline.TPolyLine::Copy(*
this);
150 for (
Int_t i = 0; i <
fN; i++) {
181 const Int_t big = 9999;
182 if (!
gPad)
return big;
183 const Int_t kMaxDiff = 10;
187 Int_t distance = big;
188 if (
Size() <= 0)
return distance;
190 for (i=0;i<
Size();i++) {
194 if (
d < distance) distance =
d;
196 if (distance < kMaxDiff)
return distance;
199 for (i=0;i<
Size()-1;i++) {
201 if (
d < distance) distance =
d;
250 const Int_t kMaxDiff = 10;
252 static Int_t ipoint, pxp, pyp;
253 static Int_t px1,px2,py1,py2;
254 static Int_t pxold, pyold, px1old, py1old, px2old, py2old;
255 static Int_t dpx, dpy;
256 static std::vector<Int_t>
x,
y;
259 if (!
gPad->IsEditable())
return;
268 px1 =
gPad->XtoAbsPixel(
gPad->GetX1());
269 py1 =
gPad->YtoAbsPixel(
gPad->GetY1());
270 px2 =
gPad->XtoAbsPixel(
gPad->GetX2());
271 py2 =
gPad->YtoAbsPixel(
gPad->GetY2());
275 if (!
x.empty() || !
y.empty())
break;
282 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
283 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
284 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
285 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
290 if (
d < kMaxDiff) ipoint =i;
296 if (ipoint < 0)
return;
300 px2old =
gPad->XtoAbsPixel(
fX[1]);
301 py2old =
gPad->YtoAbsPixel(
fY[1]);
302 }
else if (ipoint ==
fN-1) {
308 px1old =
gPad->XtoAbsPixel(
gPad->XtoPad(
fX[ipoint-1]));
309 py1old =
gPad->YtoAbsPixel(
gPad->YtoPad(
fY[ipoint-1]));
310 px2old =
gPad->XtoAbsPixel(
gPad->XtoPad(
fX[ipoint+1]));
311 py2old =
gPad->YtoAbsPixel(
gPad->YtoPad(
fY[ipoint+1]));
313 pxold =
gPad->XtoAbsPixel(
gPad->XtoPad(
fX[ipoint]));
314 pyold =
gPad->YtoAbsPixel(
gPad->YtoPad(
fY[ipoint]));
326 if (
d < kMaxDiff) middle =
kFALSE;
338 for(i=0;i<np-1;i++) {
339 gVirtualX->DrawLine(
x[i]+dpx,
y[i]+dpy,
x[i+1]+dpx,
y[i+1]+dpy);
342 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
343 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
344 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
345 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
349 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
350 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
351 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
352 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
357 for(i=0;i<np-1;i++) {
358 gVirtualX->DrawLine(
x[i]+dpx,
y[i]+dpy,
x[i+1]+dpx,
y[i+1]+dpy);
361 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
362 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
363 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
364 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
368 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
369 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
370 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
371 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
373 if (px1old)
gVirtualX->DrawLine(px1old, py1old, pxold, pyold);
374 if (px2old)
gVirtualX->DrawLine(pxold, pyold, px2old, py2old);
375 gVirtualX->DrawLine(pxold-4, pyold-4, pxold+4, pyold-4);
376 gVirtualX->DrawLine(pxold+4, pyold-4, pxold+4, pyold+4);
377 gVirtualX->DrawLine(pxold+4, pyold+4, pxold-4, pyold+4);
378 gVirtualX->DrawLine(pxold-4, pyold+4, pxold-4, pyold-4);
385 if (px1old)
gVirtualX->DrawLine(px1old, py1old, pxold, pyold);
386 if (px2old)
gVirtualX->DrawLine(pxold, pyold, px2old, py2old);
387 gVirtualX->DrawLine(pxold-4, pyold-4, pxold+4, pyold-4);
388 gVirtualX->DrawLine(pxold+4, pyold-4, pxold+4, pyold+4);
389 gVirtualX->DrawLine(pxold+4, pyold+4, pxold-4, pyold+4);
390 gVirtualX->DrawLine(pxold-4, pyold+4, pxold-4, pyold-4);
394 for(i=0;i<np-1;i++) {
412 if (!
x.empty() && !
y.empty()) {
419 fX[ipoint] =
gPad->PadtoX(
gPad->AbsPixeltoX(pxold));
420 fY[ipoint] =
gPad->PadtoY(
gPad->AbsPixeltoY(pyold));
447 if (!
x.empty() && !
y.empty()) {
454 fX[ipoint] =
gPad->PadtoX(
gPad->AbsPixeltoX(pxold));
455 fY[ipoint] =
gPad->PadtoY(
gPad->AbsPixeltoY(pyold));
472 printf(
"TPolyLine N=%d\n",
fN);
488 Error(
"Add",
"Attempt to add object of class: %s to a %s",pl->
ClassName(),this->ClassName());
491 npoints += pl->
Size();
495 if (npoints > 1)
SetPoint(npoints-1,0,0);
503 for (
Int_t i=0;i<np;i++) {
533 if (!
gPad ||
n <= 0)
return;
538 if (
gPad->GetLogx()) {
540 for (
Int_t ix=0;ix<
n;ix++) xx[ix] =
gPad->XtoPad(
x[ix]);
542 if (
gPad->GetLogy()) {
544 for (
Int_t iy=0;iy<
n;iy++) yy[iy] =
gPad->YtoPad(
y[iy]);
546 if (option && (*option ==
'f' || *option ==
'F'))
547 gPad->PaintFillArea(
n, xx, yy, option);
549 gPad->PaintPolyLine(
n, xx, yy, option);
563 if (*option ==
'f' || *option ==
'F')
gPad->PaintFillAreaNDC(
n,
x,
y,option);
564 else gPad->PaintPolyLineNDC(
n,
x,
y,option);
573 printf(
"PolyLine N=%d\n",
fN);
595 if (!option || !strstr(option,
"nodraw"))
596 out <<
" polyline->Draw(\"" << TString(option).ReplaceSpecialCppChars() <<
"\");\n";
690 if (
fX)
delete []
fX;
691 if (
fY)
delete []
fY;
718 if (
fX)
delete []
fX;
719 if (
fY)
delete []
fY;
751 b.ReadFastArray(
x,
fN);
752 b.ReadFastArray(
y,
fN);
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).
virtual void Streamer(TBuffer &)
void Copy(TAttFill &attfill) const
Style_t fFillStyle
Fill area style.
Color_t fFillColor
Fill area color.
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
virtual void Streamer(TBuffer &)
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
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.
Collection abstract base class.
Mother of all ROOT objects.
Bool_t TestBit(UInt_t f) const
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
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 Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
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 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".
static TString SavePrimitiveVector(std::ostream &out, const char *prefix, Int_t len, Double_t *arr, Int_t flag=0)
Save array in the output stream "out" as vector.
@ kCanDelete
if object in a list can be deleted
virtual Int_t Size() const
virtual void PaintPolyLine(Int_t n, Double_t *x, Double_t *y, Option_t *option="")
Int_t fLastPoint
The index of the last filled point.
void Copy(TObject &polyline) const override
Copy this to obj.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Computes distance from point (px,py) to the object.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to an event at (px,py).
TClass * IsA() const override
virtual Int_t SetNextPoint(Double_t x, Double_t y)
void Draw(Option_t *option="") override
Default Draw method for all objects.
virtual void PaintPolyLineNDC(Int_t n, Double_t *x, Double_t *y, Option_t *option="")
Double_t * fX
[fN] Array of X coordinates
@ kPolyLineNDC
Polyline coordinates are in NDC space.
void Paint(Option_t *option="") override
This method must be overridden if a class wants to paint itself.
void ls(Option_t *option="") const override
The ls function lists the contents of a class on stdout.
virtual Int_t Merge(TCollection *list)
TPolyLine & operator=(const TPolyLine &)
virtual void SetPoint(Int_t point, Double_t x, Double_t y)
virtual TPolyLine * DrawPolyLine(Int_t n, Double_t *x, Double_t *y, Option_t *option="")
virtual void SetNDC(Bool_t isNDC=kTRUE)
void Streamer(TBuffer &) override
Stream an object of class TObject.
Int_t fN
Number of points.
Double_t * fY
[fN] Array of Y coordinates
void Print(Option_t *option="") const override
This method must be overridden when a class wants to print itself.
virtual void SetPolyLine(Int_t n)
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
const char * Data() const
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Bool_t IsInside(T xp, T yp, Int_t np, T *x, T *y)
Function which returns kTRUE if point xp,yp lies inside the polygon defined by the np points in array...
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.