93 for (
Int_t i=0; i<
fN;i++) {
fX[i] = x[i];
fY[i] = y[i];}
116 if (!x || !y)
return;
117 for (
Int_t i=0; i<
fN;i++) {
fX[i] = x[i];
fY[i] = y[i];}
144 if (
fX)
delete []
fX;
145 if (
fY)
delete []
fY;
200 const Int_t big = 9999;
201 const Int_t kMaxDiff = 10;
205 Int_t distance = big;
206 if (
Size() <= 0)
return distance;
208 for (i=0;i<
Size();i++) {
212 if (d < distance) distance =
d;
214 if (distance < kMaxDiff)
return distance;
217 for (i=0;i<
Size()-1;i++) {
219 if (d < distance) distance =
d;
267 const Int_t kMaxDiff = 10;
269 static Int_t ipoint, pxp, pyp;
270 static Int_t px1,px2,py1,py2;
271 static Int_t pxold, pyold, px1old, py1old, px2old, py2old;
272 static Int_t dpx, dpy;
276 if (!
gPad->IsEditable())
return;
285 px1 =
gPad->XtoAbsPixel(
gPad->GetX1());
286 py1 =
gPad->YtoAbsPixel(
gPad->GetY1());
287 px2 =
gPad->XtoAbsPixel(
gPad->GetX2());
288 py2 =
gPad->YtoAbsPixel(
gPad->GetY2());
299 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
300 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
301 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
302 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
307 if (d < kMaxDiff) ipoint =i;
313 if (ipoint < 0)
return;
317 px2old =
gPad->XtoAbsPixel(
fX[1]);
318 py2old =
gPad->YtoAbsPixel(
fY[1]);
319 }
else if (ipoint ==
fN-1) {
325 px1old =
gPad->XtoAbsPixel(
gPad->XtoPad(
fX[ipoint-1]));
326 py1old =
gPad->YtoAbsPixel(
gPad->YtoPad(
fY[ipoint-1]));
327 px2old =
gPad->XtoAbsPixel(
gPad->XtoPad(
fX[ipoint+1]));
328 py2old =
gPad->YtoAbsPixel(
gPad->YtoPad(
fY[ipoint+1]));
330 pxold =
gPad->XtoAbsPixel(
gPad->XtoPad(
fX[ipoint]));
331 pyold =
gPad->YtoAbsPixel(
gPad->YtoPad(
fY[ipoint]));
343 if (d < kMaxDiff) middle =
kFALSE;
355 for(i=0;i<np-1;i++) {
356 gVirtualX->DrawLine(x[i]+dpx,
y[i]+dpy, x[i+1]+dpx,
y[i+1]+dpy);
359 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
360 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
361 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
362 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
366 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
367 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);
374 for(i=0;i<np-1;i++) {
375 gVirtualX->DrawLine(x[i]+dpx,
y[i]+dpy, x[i+1]+dpx,
y[i+1]+dpy);
378 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
379 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
380 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
381 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
385 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
386 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
387 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
388 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
390 if (px1old)
gVirtualX->DrawLine(px1old, py1old, pxold, pyold);
391 if (px2old)
gVirtualX->DrawLine(pxold, pyold, px2old, py2old);
392 gVirtualX->DrawLine(pxold-4, pyold-4, pxold+4, pyold-4);
393 gVirtualX->DrawLine(pxold+4, pyold-4, pxold+4, pyold+4);
394 gVirtualX->DrawLine(pxold+4, pyold+4, pxold-4, pyold+4);
395 gVirtualX->DrawLine(pxold-4, pyold+4, pxold-4, pyold-4);
402 if (px1old)
gVirtualX->DrawLine(px1old, py1old, pxold, pyold);
403 if (px2old)
gVirtualX->DrawLine(pxold, pyold, px2old, py2old);
404 gVirtualX->DrawLine(pxold-4, pyold-4, pxold+4, pyold-4);
405 gVirtualX->DrawLine(pxold+4, pyold-4, pxold+4, pyold+4);
406 gVirtualX->DrawLine(pxold+4, pyold+4, pxold-4, pyold+4);
407 gVirtualX->DrawLine(pxold-4, pyold+4, pxold-4, pyold-4);
411 for(i=0;i<np-1;i++) {
432 fX[i] =
gPad->PadtoX(
gPad->AbsPixeltoX(x[i]+dpx));
436 fX[ipoint] =
gPad->PadtoX(
gPad->AbsPixeltoX(pxold));
437 fY[ipoint] =
gPad->PadtoY(
gPad->AbsPixeltoY(pyold));
447 xmin =
gPad->GetUxmin();
448 xmax =
gPad->GetUxmax();
449 ymin =
gPad->GetUymin();
450 ymax =
gPad->GetUymax();
453 dxr = dx/(1 -
gPad->GetLeftMargin() -
gPad->GetRightMargin());
454 dyr = dy/(1 -
gPad->GetBottomMargin() -
gPad->GetTopMargin());
458 gPad->Range(xmin - dxr*
gPad->GetLeftMargin(),
459 ymin - dyr*
gPad->GetBottomMargin(),
460 xmax + dxr*
gPad->GetRightMargin(),
461 ymax + dyr*
gPad->GetTopMargin());
462 gPad->RangeAxis(xmin, ymin, xmax, ymax);
467 fX[i] =
gPad->PadtoX(
gPad->AbsPixeltoX(x[i]+dpx));
471 fX[ipoint] =
gPad->PadtoX(
gPad->AbsPixeltoX(pxold));
472 fY[ipoint] =
gPad->PadtoY(
gPad->AbsPixeltoY(pyold));
489 printf(
"TPolyLine N=%d\n",
fN);
508 npoints += pl->
Size();
512 if (npoints > 1)
SetPoint(npoints-1,0,0);
520 for (
Int_t i=0;i<np;i++) {
555 if (
gPad->GetLogx()) {
557 for (
Int_t ix=0;ix<
n;ix++) xx[ix] =
gPad->XtoPad(x[ix]);
559 if (
gPad->GetLogy()) {
561 for (
Int_t iy=0;iy<
n;iy++) yy[iy] =
gPad->YtoPad(y[iy]);
563 if (*option ==
'f' || *option ==
'F')
gPad->PaintFillArea(n,xx,yy,option);
564 else gPad->PaintPolyLine(n,xx,yy,option);
565 if (x != xx)
delete [] xx;
566 if (y != yy)
delete [] yy;
576 gPad->PaintPolyLineNDC(n,x,y,option);
585 printf(
"PolyLine N=%d\n",
fN);
598 out<<
" Double_t *dum = 0;"<<std::endl;
601 out<<
"pline = new TPolyLine("<<
fN<<
",dum,dum,"<<quote<<
fOption<<quote<<
");"<<std::endl;
607 out<<
" pline->SetPoint("<<i<<
","<<
fX[i]<<
","<<
fY[i]<<
");"<<std::endl;
610 <<quote<<option<<quote<<
");"<<std::endl;
641 if (!
fX || !
fY || n >=
fN) {
648 memset(&savex[
fN],0,(newN-fN)*
sizeof(
Double_t));
653 memset(&savey[
fN],0,(newN-fN)*
sizeof(
Double_t));
704 if (
fX)
delete []
fX;
705 if (
fY)
delete []
fY;
732 if (
fX)
delete []
fX;
733 if (
fY)
delete []
fY;
747 void TPolyLine::Streamer(
TBuffer &
b)
757 TObject::Streamer(b);
758 TAttLine::Streamer(b);
759 TAttFill::Streamer(b);
TPolyLine()
PolyLine default constructor.
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
Polyline coordinates are in NDC space.
Int_t fN
Number of points.
Buffer base class used for serializing objects.
Double_t * fY
[fN] Array of Y coordinates
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
TPolyLine & operator=(const TPolyLine &)
assignment operator
Short_t Min(Short_t a, Short_t b)
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 Int_t Merge(TCollection *list)
Merge polylines in the collection in this polyline.
virtual void Modify()
Change current line attributes if necessary.
Int_t fLastPoint
The index of the last filled point.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
if object in a list can be deleted
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Fill Area Attributes class.
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
virtual void Copy(TObject &object) const
Copy this to obj.
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.
virtual void Modify()
Change current fill area attributes if necessary.
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
TObject & operator=(const TObject &rhs)
TObject assignment operator.
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...
virtual void Draw(Option_t *option="")
Draw this polyline with its current attributes.
virtual void ls(Option_t *option="") const
List this polyline with its attributes.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Collection abstract base class.
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 Error(const char *method, const char *msgfmt,...) const
Issue error message.
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
virtual void PaintPolyLine(Int_t n, Double_t *x, Double_t *y, Option_t *option="")
Draw this polyline with new coordinates.
virtual void SetPolyLine(Int_t n)
Resize this polyline to size n.
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
virtual ~TPolyLine()
PolyLine default destructor.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Int_t Size() const
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Returns closest distance in pixels from point (px, py) to a polyline.
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 Print(Option_t *option="") const
Dump this polyline with its attributes.
Binding & operator=(OUT(*fun)(void))
Mother of all ROOT objects.
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
Color_t fFillColor
Fill area color.
Short_t Max(Short_t a, Short_t b)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Defined by an array on N points in a 2-D space.
virtual Int_t SetNextPoint(Double_t x, Double_t y)
Set point following LastPoint to x, y.
virtual void Paint(Option_t *option="")
Paint this polyline with its current attributes.
Double_t * fX
[fN] Array of X coordinates
virtual void Copy(TObject &polyline) const
Copy this polyline to 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 Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
Style_t fFillStyle
Fill area style.
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
const char * Data() const