82 for (
Int_t i = 0; i <
fN; i++) {
102 if (!
x || !
y)
return;
116 pl.TPolyLine::Copy(*
this);
125 if (
fX)
delete []
fX;
126 if (
fY)
delete []
fY;
134 polyline.TPolyLine::Copy(*
this);
151 for (
Int_t i = 0; i <
fN; i++) {
182 const Int_t big = 9999;
183 if (!
gPad)
return big;
184 const Int_t kMaxDiff = 10;
188 Int_t distance = big;
189 if (
Size() <= 0)
return distance;
191 for (i=0;i<
Size();i++) {
195 if (
d < distance) distance =
d;
197 if (distance < kMaxDiff)
return distance;
200 for (i=0;i<
Size()-1;i++) {
202 if (
d < distance) distance =
d;
251 const Int_t kMaxDiff = 10;
253 static Int_t ipoint, pxp, pyp;
254 static Int_t px1,px2,py1,py2;
255 static Int_t pxold, pyold, px1old, py1old, px2old, py2old;
256 static Int_t dpx, dpy;
257 static std::vector<Int_t>
x,
y;
260 if (!
gPad->IsEditable())
return;
269 px1 =
gPad->XtoAbsPixel(
gPad->GetX1());
270 py1 =
gPad->YtoAbsPixel(
gPad->GetY1());
271 px2 =
gPad->XtoAbsPixel(
gPad->GetX2());
272 py2 =
gPad->YtoAbsPixel(
gPad->GetY2());
276 if (!
x.empty() || !
y.empty())
break;
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);
286 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
291 if (
d < kMaxDiff) ipoint =i;
297 if (ipoint < 0)
return;
301 px2old =
gPad->XtoAbsPixel(
fX[1]);
302 py2old =
gPad->YtoAbsPixel(
fY[1]);
303 }
else if (ipoint ==
fN-1) {
309 px1old =
gPad->XtoAbsPixel(
gPad->XtoPad(
fX[ipoint-1]));
310 py1old =
gPad->YtoAbsPixel(
gPad->YtoPad(
fY[ipoint-1]));
311 px2old =
gPad->XtoAbsPixel(
gPad->XtoPad(
fX[ipoint+1]));
312 py2old =
gPad->YtoAbsPixel(
gPad->YtoPad(
fY[ipoint+1]));
314 pxold =
gPad->XtoAbsPixel(
gPad->XtoPad(
fX[ipoint]));
315 pyold =
gPad->YtoAbsPixel(
gPad->YtoPad(
fY[ipoint]));
327 if (
d < kMaxDiff) middle =
kFALSE;
339 for(i=0;i<
np-1;i++) {
340 gVirtualX->DrawLine(
x[i]+dpx,
y[i]+dpy,
x[i+1]+dpx,
y[i+1]+dpy);
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);
346 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);
353 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
358 for(i=0;i<
np-1;i++) {
359 gVirtualX->DrawLine(
x[i]+dpx,
y[i]+dpy,
x[i+1]+dpx,
y[i+1]+dpy);
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);
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);
372 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
374 if (px1old)
gVirtualX->DrawLine(px1old, py1old, pxold, pyold);
375 if (px2old)
gVirtualX->DrawLine(pxold, pyold, px2old, py2old);
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);
379 gVirtualX->DrawLine(pxold-4, pyold+4, pxold-4, pyold-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);
395 for(i=0;i<
np-1;i++) {
413 if (!
x.empty() && !
y.empty()) {
420 fX[ipoint] =
gPad->PadtoX(
gPad->AbsPixeltoX(pxold));
421 fY[ipoint] =
gPad->PadtoY(
gPad->AbsPixeltoY(pyold));
437 dxr = dx/(1 -
gPad->GetLeftMargin() -
gPad->GetRightMargin());
438 dyr = dy/(1 -
gPad->GetBottomMargin() -
gPad->GetTopMargin());
448 if (!
x.empty() && !
y.empty()) {
455 fX[ipoint] =
gPad->PadtoX(
gPad->AbsPixeltoX(pxold));
456 fY[ipoint] =
gPad->PadtoY(
gPad->AbsPixeltoY(pyold));
473 printf(
"TPolyLine N=%d\n",
fN);
489 Error(
"Add",
"Attempt to add object of class: %s to a %s",pl->
ClassName(),this->ClassName());
492 npoints += pl->
Size();
496 if (npoints > 1)
SetPoint(npoints-1,0,0);
534 if (!
gPad ||
n <= 0)
return;
539 if (
gPad->GetLogx()) {
541 for (
Int_t ix=0;ix<
n;ix++) xx[ix] =
gPad->XtoPad(
x[ix]);
543 if (
gPad->GetLogy()) {
545 for (
Int_t iy=0;iy<
n;iy++) yy[iy] =
gPad->YtoPad(
y[iy]);
574 printf(
"PolyLine N=%d\n",
fN);
589 out<<
"pline = new TPolyLine("<<
fN<<
","<<quote<<
fOption<<quote<<
");"<<std::endl;
595 out<<
" pline->SetPoint("<<i<<
","<<
fX[i]<<
","<<
fY[i]<<
");"<<std::endl;
597 out<<
" pline->Draw("<<quote<<
option<<quote<<
");"<<std::endl;
691 if (
fX)
delete []
fX;
692 if (
fY)
delete []
fY;
719 if (
fX)
delete []
fX;
720 if (
fY)
delete []
fY;
752 b.ReadFastArray(
x,
fN);
753 b.ReadFastArray(
y,
fN);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Fill Area Attributes class.
virtual void Streamer(TBuffer &)
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 Streamer(TBuffer &)
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 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.
@ 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
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.
void Copy(TObject &polyline) const override
Copy this polyline to polyline.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Returns closest distance in pixels from point (px, py) to a polyline.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save 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 one event.
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...
TPolyLine()
PolyLine default constructor.
TClass * IsA() const override
~TPolyLine() override
PolyLine default destructor.
virtual void PaintPolyLine(Int_t n, Double_t *x, Double_t *y, Option_t *option="")
Draw this polyline with new coordinates.
void Draw(Option_t *option="") override
Draw this polyline with its current attributes.
Double_t * fX
[fN] Array of X coordinates
void Paint(Option_t *option="") override
Paint this polyline with its current attributes.
void ls(Option_t *option="") const override
List this polyline with its attributes.
TPolyLine & operator=(const TPolyLine &)
assignment operator
void Streamer(TBuffer &) override
Stream a class object.
virtual TPolyLine * DrawPolyLine(Int_t n, Double_t *x, Double_t *y, Option_t *option="")
Draw this polyline with new coordinates.
Int_t fN
Number of points.
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 Int_t SetNextPoint(Double_t x, Double_t y)
Set point following LastPoint to x, y.
void Print(Option_t *option="") const override
Dump this polyline with its attributes.
@ kPolyLineNDC
Polyline coordinates are in NDC space.
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
const char * Data() const
virtual void Streamer(TBuffer &)
Stream a string object.
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.