117 if (!
x || !
y)
return;
138 if (
fX)
delete []
fX;
139 if (
fY)
delete []
fY;
196 const Int_t big = 9999;
197 const Int_t kMaxDiff = 10;
201 Int_t distance = big;
202 if (
Size() <= 0)
return distance;
204 for (i=0;i<
Size();i++) {
208 if (
d < distance) distance =
d;
210 if (distance < kMaxDiff)
return distance;
213 for (i=0;i<
Size()-1;i++) {
215 if (
d < distance) distance =
d;
263 const Int_t kMaxDiff = 10;
265 static Int_t ipoint, pxp, pyp;
266 static Int_t px1,px2,py1,py2;
267 static Int_t pxold, pyold, px1old, py1old, px2old, py2old;
268 static Int_t dpx, dpy;
272 if (!
gPad->IsEditable())
return;
281 px1 =
gPad->XtoAbsPixel(
gPad->GetX1());
282 py1 =
gPad->YtoAbsPixel(
gPad->GetY1());
283 px2 =
gPad->XtoAbsPixel(
gPad->GetX2());
284 py2 =
gPad->YtoAbsPixel(
gPad->GetY2());
295 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
296 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
297 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
298 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
303 if (
d < kMaxDiff) ipoint =i;
309 if (ipoint < 0)
return;
313 px2old =
gPad->XtoAbsPixel(
fX[1]);
314 py2old =
gPad->YtoAbsPixel(
fY[1]);
315 }
else if (ipoint ==
fN-1) {
321 px1old =
gPad->XtoAbsPixel(
gPad->XtoPad(
fX[ipoint-1]));
322 py1old =
gPad->YtoAbsPixel(
gPad->YtoPad(
fY[ipoint-1]));
323 px2old =
gPad->XtoAbsPixel(
gPad->XtoPad(
fX[ipoint+1]));
324 py2old =
gPad->YtoAbsPixel(
gPad->YtoPad(
fY[ipoint+1]));
326 pxold =
gPad->XtoAbsPixel(
gPad->XtoPad(
fX[ipoint]));
327 pyold =
gPad->YtoAbsPixel(
gPad->YtoPad(
fY[ipoint]));
339 if (
d < kMaxDiff) middle =
kFALSE;
351 for(i=0;i<np-1;i++) {
352 gVirtualX->DrawLine(
x[i]+dpx,
y[i]+dpy,
x[i+1]+dpx,
y[i+1]+dpy);
355 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
356 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
357 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
358 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);
365 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
370 for(i=0;i<np-1;i++) {
371 gVirtualX->DrawLine(
x[i]+dpx,
y[i]+dpy,
x[i+1]+dpx,
y[i+1]+dpy);
374 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
375 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
376 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
377 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
381 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
382 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
383 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
384 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
386 if (px1old)
gVirtualX->DrawLine(px1old, py1old, pxold, pyold);
387 if (px2old)
gVirtualX->DrawLine(pxold, pyold, px2old, py2old);
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);
391 gVirtualX->DrawLine(pxold-4, pyold+4, pxold-4, pyold-4);
398 if (px1old)
gVirtualX->DrawLine(px1old, py1old, pxold, pyold);
399 if (px2old)
gVirtualX->DrawLine(pxold, pyold, px2old, py2old);
400 gVirtualX->DrawLine(pxold-4, pyold-4, pxold+4, pyold-4);
401 gVirtualX->DrawLine(pxold+4, pyold-4, pxold+4, pyold+4);
402 gVirtualX->DrawLine(pxold+4, pyold+4, pxold-4, pyold+4);
403 gVirtualX->DrawLine(pxold-4, pyold+4, pxold-4, pyold-4);
407 for(i=0;i<np-1;i++) {
432 fX[ipoint] =
gPad->PadtoX(
gPad->AbsPixeltoX(pxold));
433 fY[ipoint] =
gPad->PadtoY(
gPad->AbsPixeltoY(pyold));
449 dxr = dx/(1 -
gPad->GetLeftMargin() -
gPad->GetRightMargin());
450 dyr = dy/(1 -
gPad->GetBottomMargin() -
gPad->GetTopMargin());
467 fX[ipoint] =
gPad->PadtoX(
gPad->AbsPixeltoX(pxold));
468 fY[ipoint] =
gPad->PadtoY(
gPad->AbsPixeltoY(pyold));
485 printf(
"TPolyLine N=%d\n",
fN);
501 Error(
"Add",
"Attempt to add object of class: %s to a %s",pl->
ClassName(),this->ClassName());
504 npoints += pl->
Size();
508 if (npoints > 1)
SetPoint(npoints-1,0,0);
516 for (
Int_t i=0;i<np;i++) {
551 if (
gPad->GetLogx()) {
553 for (
Int_t ix=0;ix<
n;ix++) xx[ix] =
gPad->XtoPad(
x[ix]);
555 if (
gPad->GetLogy()) {
557 for (
Int_t iy=0;iy<
n;iy++) yy[iy] =
gPad->YtoPad(
y[iy]);
559 if (*option ==
'f' || *option ==
'F')
gPad->PaintFillArea(
n,xx,yy,option);
560 else gPad->PaintPolyLine(
n,xx,yy,option);
561 if (
x != xx)
delete [] xx;
562 if (
y != yy)
delete [] yy;
572 if (*option ==
'f' || *option ==
'F')
gPad->PaintFillAreaNDC(
n,
x,
y,option);
573 else gPad->PaintPolyLineNDC(
n,
x,
y,option);
582 printf(
"PolyLine N=%d\n",
fN);
595 out<<
" Double_t *dum = 0;"<<std::endl;
598 out<<
"pline = new TPolyLine("<<
fN<<
",dum,dum,"<<quote<<
fOption<<quote<<
");"<<std::endl;
604 out<<
" pline->SetPoint("<<i<<
","<<
fX[i]<<
","<<
fY[i]<<
");"<<std::endl;
607 <<quote<<option<<quote<<
");"<<std::endl;
701 if (
fX)
delete []
fX;
702 if (
fY)
delete []
fY;
729 if (
fX)
delete []
fX;
730 if (
fY)
delete []
fY;
754 TObject::Streamer(
b);
755 TAttLine::Streamer(
b);
756 TAttFill::Streamer(
b);
762 b.ReadFastArray(
x,
fN);
763 b.ReadFastArray(
y,
fN);
769 b.CheckByteCount(R__s, R__c, TPolyLine::IsA());
Fill Area Attributes class.
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
virtual void Modify()
Change current fill area attributes if necessary.
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)
Save fill attributes as C++ statement(s) on output stream out.
virtual void Modify()
Change current line attributes if necessary.
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Int_t DistancetoLine(Int_t px, Int_t py, Double_t xp1, Double_t yp1, Double_t xp2, Double_t yp2)
Compute distance from point px,py to a line.
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
Buffer base class used for serializing objects.
Collection abstract base class.
Mother of all ROOT objects.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
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.
@ kCanDelete
if object in a list can be deleted
Defined by an array on N points in a 2-D space.
virtual Int_t Size() const
virtual void Print(Option_t *option="") const
Dump this polyline with its attributes.
Int_t fLastPoint
The index of the last filled point.
virtual Int_t Merge(TCollection *list)
Merge polylines in the collection in this polyline.
virtual void PaintPolyLineNDC(Int_t n, Double_t *x, Double_t *y, Option_t *option="")
Draw this polyline with new coordinates in NDC.
virtual void DrawPolyLine(Int_t n, Double_t *x, Double_t *y, Option_t *option="")
Draw this polyline with new coordinates.
virtual void SetPoint(Int_t point, Double_t x, Double_t y)
Set point number n to (x, y) If n is greater than the current size, the arrays are automatically exte...
virtual ~TPolyLine()
PolyLine default destructor.
TPolyLine()
PolyLine default constructor.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Returns closest distance in pixels from point (px, py) to a polyline.
virtual void PaintPolyLine(Int_t n, Double_t *x, Double_t *y, Option_t *option="")
Draw this polyline with new coordinates.
Double_t * fX
[fN] Array of X coordinates
@ kPolyLineNDC
Polyline coordinates are in NDC space.
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
TPolyLine & operator=(const TPolyLine &)
assignment operator
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Int_t fN
Number of points.
virtual void Draw(Option_t *option="")
Draw this polyline with its current attributes.
virtual void Copy(TObject &polyline) const
Copy this polyline to polyline.
virtual void Paint(Option_t *option="")
Paint this polyline with its current attributes.
Double_t * fY
[fN] Array of Y coordinates
virtual void SetPolyLine(Int_t n)
Resize this polyline to size n.
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
virtual void ls(Option_t *option="") const
List this polyline with its attributes.
virtual Int_t SetNextPoint(Double_t x, Double_t y)
Set point following LastPoint to x, y.
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
const char * Data() const
Short_t Max(Short_t a, Short_t 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)