116 if (!
x || !
y)
return;
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++) {
436 fX[ipoint] =
gPad->PadtoX(
gPad->AbsPixeltoX(pxold));
437 fY[ipoint] =
gPad->PadtoY(
gPad->AbsPixeltoY(pyold));
453 dxr = dx/(1 -
gPad->GetLeftMargin() -
gPad->GetRightMargin());
454 dyr = dy/(1 -
gPad->GetBottomMargin() -
gPad->GetTopMargin());
471 fX[ipoint] =
gPad->PadtoX(
gPad->AbsPixeltoX(pxold));
472 fY[ipoint] =
gPad->PadtoY(
gPad->AbsPixeltoY(pyold));
489 printf(
"TPolyLine N=%d\n",
fN);
505 Error(
"Add",
"Attempt to add object of class: %s to a %s",pl->
ClassName(),this->ClassName());
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 if (*option ==
'f' || *option ==
'F')
gPad->PaintFillAreaNDC(
n,
x,
y,option);
577 else gPad->PaintPolyLineNDC(
n,
x,
y,option);
586 printf(
"PolyLine N=%d\n",
fN);
599 out<<
" Double_t *dum = 0;"<<std::endl;
602 out<<
"pline = new TPolyLine("<<
fN<<
",dum,dum,"<<quote<<
fOption<<quote<<
");"<<std::endl;
608 out<<
" pline->SetPoint("<<i<<
","<<
fX[i]<<
","<<
fY[i]<<
");"<<std::endl;
611 <<quote<<option<<quote<<
");"<<std::endl;
705 if (
fX)
delete []
fX;
706 if (
fY)
delete []
fY;
733 if (
fX)
delete []
fX;
734 if (
fY)
delete []
fY;
758 TObject::Streamer(
b);
759 TAttLine::Streamer(
b);
760 TAttFill::Streamer(
b);
766 b.ReadFastArray(
x,
fN);
767 b.ReadFastArray(
y,
fN);
773 b.CheckByteCount(R__s, R__c, TPolyLine::IsA());
Binding & operator=(OUT(*fun)(void))
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.
TObject & operator=(const TObject &rhs)
TObject assignment operator.
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.
@ kPolyLineNDC
Polyline coordinates are in NDC space.
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
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)