80 for (
Int_t i = 0; i <
fN; i++) {
100 if (!
x || !
y)
return;
114 pl.TPolyLine::Copy(*
this);
123 if (
fX)
delete []
fX;
124 if (
fY)
delete []
fY;
132 polyline.TPolyLine::Copy(*
this);
149 for (
Int_t i = 0; i <
fN; i++) {
180 const Int_t big = 9999;
181 if (!
gPad)
return big;
182 const Int_t kMaxDiff = 10;
186 Int_t distance = big;
187 if (
Size() <= 0)
return distance;
189 for (i=0;i<
Size();i++) {
193 if (
d < distance) distance =
d;
195 if (distance < kMaxDiff)
return distance;
198 for (i=0;i<
Size()-1;i++) {
200 if (
d < distance) distance =
d;
251 if (!
gPad || !
gPad->IsEditable())
return;
253 auto &parent = *
gPad;
255 constexpr Int_t kMaxDiff = 10;
256 Bool_t opaque = parent.OpaqueMoving();
263 auto paint_hollow = [
this, &parent] () {
266 parent.PaintPolyLineNDC(
Size(),
fX,
fY,
"ipolyline");
269 std::vector<Double_t> xx, yy;
270 if (parent.GetLogx()) {
273 xx[ix] = parent.XtoPad(
x[ix]);
276 if (parent.GetLogy()) {
279 yy[iy] = parent.YtoPad(
y[iy]);
282 parent.PaintPolyLine(
Size(),
x,
y,
"ipolyline");
288 pntx = parent.UtoAbsPixel(
fX[i]);
289 pnty = parent.VtoAbsPixel(
fY[i]);
291 pntx = parent.XtoAbsPixel(parent.XtoPad(
fX[i]));
292 pnty = parent.YtoAbsPixel(parent.YtoPad(
fY[i]));
299 Double_t wndc = parent.GetAbsWNDC();
301 Double_t hndc = parent.GetAbsHNDC();
302 fX[i] = ww > 0 && wndc > 0 ? (pntx / ww - parent.GetAbsXlowNDC()) / wndc : 0.;
303 fY[i] = wh > 0 && hndc > 0 ? ((1. - pnty / wh) - parent.GetAbsYlowNDC()) / hndc : 0.;
305 fX[i] = parent.PadtoX(parent.AbsPixeltoX(pntx));
306 fY[i] = parent.PadtoY(parent.AbsPixeltoY(pnty));
319 Int_t minDiff = kMaxDiff, ipoint = -1;
320 for (
Int_t i = 0; i <
np; i++) {
322 get_point(i, pxp, pyp);
323 if ((i == 0) && inter) {
324 inter->sdx = pxp - px;
325 inter->sdy = pyp - py;
332 inter->sdx = pxp - px;
333 inter->sdy = pyp - py;
338 parent.SetCursor(
kMove);
340 parent.SetCursor(
kHand);
342 inter->ipoint = ipoint;
350 if (inter->ipoint < 0) {
351 Int_t pxp0 = 0, pyp0 = 0, pxp = 0, pyp = 0;
353 for (
Int_t i = 0; i <
np; i++) {
354 get_point(i, pxp, pyp);
359 set_point(i, px + inter->sdx + pxp - pxp0, py + inter->sdy + pyp - pyp0);
363 set_point(inter->ipoint, px + inter->sdx, py + inter->sdy);
374 parent.UpdateAsync();
380 parent.UpdateAsync();
382 parent.FreeInteractive(
this);
394 printf(
"TPolyLine N=%d\n",
fN);
410 Error(
"Add",
"Attempt to add object of class: %s to a %s",pl->
ClassName(),this->ClassName());
413 npoints += pl->
Size();
417 if (npoints > 1)
SetPoint(npoints-1,0,0);
452 if (!
gPad ||
n <= 0)
return;
455 std::vector<Double_t> xx, yy;
456 if (
gPad->GetLogx()) {
458 for (
Int_t ix = 0; ix <
n; ix++)
459 xx[ix] =
gPad->XtoPad(
x[ix]);
462 if (
gPad->GetLogy()) {
464 for (
Int_t iy = 0; iy <
n; iy++)
465 yy[iy] =
gPad->YtoPad(
y[iy]);
493 printf(
"PolyLine N=%d\n",
fN);
610 if (
fX)
delete []
fX;
611 if (
fY)
delete []
fY;
638 if (
fX)
delete []
fX;
639 if (
fY)
delete []
fY;
671 b.ReadFastArray(
x,
fN);
672 b.ReadFastArray(
y,
fN);
short Version_t
Class version identifier (short)
float Float_t
Float 4 bytes (float)
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char)
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 ModifyOn(TVirtualPad &pad)
Change current line attributes on specified pad.
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.
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
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.
@ kPolyLineNDC
Polyline coordinates are in NDC space.
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.
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
const char * Data() const
virtual void Streamer(TBuffer &)
Stream a string object.
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.
Helper class to store interactive parameters for individual objects Should be used via MakeInteractiv...
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 Abs(Short_t d)
Returns the absolute value of parameter Short_t d.