diff --git a/components/tachart/tadraweraggpas.pas b/components/tachart/tadraweraggpas.pas index d4429b5ccb..61965917f9 100644 --- a/components/tachart/tadraweraggpas.pas +++ b/components/tachart/tadraweraggpas.pas @@ -51,11 +51,10 @@ type procedure LineTo(AX, AY: Integer); override; procedure MoveTo(AX, AY: Integer); override; procedure Polygon( - const APoints: array of TPoint; - AStartIndex: Integer = 0; ANumPts: Integer = -1); override; + const APoints: array of TPoint; AStartIndex, ANumPts: Integer); override; procedure Polyline( - const APoints: array of TPoint; AStartIndex: Integer = 0; - ANumPts: Integer = -1; AEndPoint: Boolean = false); + const APoints: array of TPoint; AStartIndex, ANumPts: Integer; + AEndPoint: Boolean = false); procedure PrepareSimplePen(AColor: TChartColor); procedure RadialPie( AX1, AY1, AX2, AY2: Integer; @@ -147,8 +146,6 @@ procedure TAggPasDrawer.Polygon( begin FCanvas.Polygon(APoints, false, AStartIndex, ANumPts); FCanvas.Polyline(APoints, AStartIndex, ANumPts); - if ANumPts < 0 then - ANumPts := Length(APoints); FCanvas.Line(APoints[ANumPts - 1], APoints[0]) end; diff --git a/components/tachart/tadrawerbgra.pas b/components/tachart/tadrawerbgra.pas index 604410b2fa..9f342d3171 100644 --- a/components/tachart/tadrawerbgra.pas +++ b/components/tachart/tadrawerbgra.pas @@ -58,11 +58,10 @@ type procedure LineTo(AX, AY: Integer); override; procedure MoveTo(AX, AY: Integer); override; procedure Polygon( - const APoints: array of TPoint; - AStartIndex: Integer = 0; ANumPts: Integer = -1); override; + const APoints: array of TPoint; AStartIndex, ANumPts: Integer); override; procedure Polyline( - const APoints: array of TPoint; AStartIndex: Integer = 0; - ANumPts: Integer = -1; AEndPoint: Boolean = false); + const APoints: array of TPoint; AStartIndex, ANumPts: Integer; + AEndPoint: Boolean = false); procedure PrepareSimplePen(AColor: TChartColor); procedure RadialPie( AX1, AY1, AX2, AY2: Integer; @@ -84,8 +83,7 @@ function PointsToPointsF( var i: Integer; begin - if ANumPts = -1 then - ANumPts := Length(APoints) - AStartIndex; + Assert(ANumPts >= 0); SetLength(Result, ANumPts); for i := 0 to ANumPts - 1 do with APoints[i + AStartIndex] do @@ -180,7 +178,7 @@ begin end; procedure TBGRABitmapDrawer.Polygon( - const APoints: array of TPoint; AStartIndex: Integer; ANumPts: Integer); + const APoints: array of TPoint; AStartIndex, ANumPts: Integer); var bt: TBGRACustomBitmap; begin @@ -201,7 +199,7 @@ end; procedure TBGRABitmapDrawer.Polyline( const APoints: array of TPoint; - AStartIndex: Integer; ANumPts: Integer; AEndPoint: Boolean); + AStartIndex, ANumPts: Integer; AEndPoint: Boolean); begin Unused(AEndPoint); FCanvas.DrawPolyLineAntialias( diff --git a/components/tachart/tadrawercanvas.pas b/components/tachart/tadrawercanvas.pas index e45f261687..5779ec3f22 100644 --- a/components/tachart/tadrawercanvas.pas +++ b/components/tachart/tadrawercanvas.pas @@ -58,11 +58,10 @@ type procedure LineTo(AX, AY: Integer); override; procedure MoveTo(AX, AY: Integer); override; procedure Polygon( - const APoints: array of TPoint; - AStartIndex: Integer = 0; ANumPts: Integer = -1); override; + const APoints: array of TPoint; AStartIndex, ANumPts: Integer); override; procedure Polyline( - const APoints: array of TPoint; AStartIndex: Integer = 0; - ANumPts: Integer = -1; AEndPoint: Boolean = false); + const APoints: array of TPoint; + AStartIndex, ANumPts: Integer; AEndPoint: Boolean = false); procedure PrepareSimplePen(AColor: TChartColor); procedure RadialPie( AX1, AY1, AX2, AY2: Integer; diff --git a/components/tachart/tadrawerfpcanvas.pas b/components/tachart/tadrawerfpcanvas.pas index 4a903c3e7f..b07a77bc67 100644 --- a/components/tachart/tadrawerfpcanvas.pas +++ b/components/tachart/tadrawerfpcanvas.pas @@ -61,11 +61,10 @@ type procedure LineTo(AX, AY: Integer); override; procedure MoveTo(AX, AY: Integer); override; procedure Polygon( - const APoints: array of TPoint; - AStartIndex: Integer = 0; ANumPts: Integer = -1); override; + const APoints: array of TPoint; AStartIndex, ANumPts: Integer); override; procedure Polyline( - const APoints: array of TPoint; AStartIndex: Integer = 0; - ANumPts: Integer = -1; AEndPoint: Boolean = false); + const APoints: array of TPoint; AStartIndex, ANumPts: Integer; + AEndPoint: Boolean = false); procedure PrepareSimplePen(AColor: TChartColor); procedure RadialPie( AX1, AY1, AX2, AY2: Integer; @@ -187,9 +186,9 @@ begin end; procedure TFPCanvasDrawer.Polygon( - const APoints: array of TPoint; AStartIndex: Integer; ANumPts: Integer); + const APoints: array of TPoint; AStartIndex, ANumPts: Integer); begin - if (ANumPts < 0) and (AStartIndex = 0) then + if (ANumPts = Length(APoints)) and (AStartIndex = 0) then FCanvas.Polygon(APoints) else FCanvas.Polygon(CopyPoints(APoints, AStartIndex, ANumPts)); @@ -197,10 +196,10 @@ end; procedure TFPCanvasDrawer.Polyline( const APoints: array of TPoint; - AStartIndex: Integer; ANumPts: Integer; AEndPoint: Boolean); + AStartIndex, ANumPts: Integer; AEndPoint: Boolean); begin Unused(AEndPoint); - if (ANumPts < 0) and (AStartIndex = 0) then + if (ANumPts = Length(APoints)) and (AStartIndex = 0) then FCanvas.Polyline(APoints) else FCanvas.Polyline(CopyPoints(APoints, AStartIndex, ANumPts)); diff --git a/components/tachart/tadraweropengl.pas b/components/tachart/tadraweropengl.pas index 7bfd36ee22..edccde4b21 100644 --- a/components/tachart/tadraweropengl.pas +++ b/components/tachart/tadraweropengl.pas @@ -55,8 +55,7 @@ type procedure LineTo(AX, AY: Integer); override; procedure MoveTo(AX, AY: Integer); override; procedure Polygon( - const APoints: array of TPoint; - AStartIndex: Integer = 0; ANumPts: Integer = -1); override; + const APoints: array of TPoint; AStartIndex, ANumPts: Integer); override; procedure Polyline( const APoints: array of TPoint; AStartIndex: Integer = 0; ANumPts: Integer = -1; AEndPoint: Boolean = false); @@ -155,13 +154,11 @@ procedure TOpenGLDrawer.InternalPolyline( var i: Integer; begin - if ANumPts < 0 then - ANumPts := Length(APoints); glBegin(AMode); ChartGLColor(FPenColor); glLineWidth(FPenWidth); for i := AStartIndex to AStartIndex + ANumPts - 1 do - glVertex2i(APoints[i].X, APoints[i].Y); + glVertex2iv(@APoints[i]); glEnd(); end; @@ -191,22 +188,20 @@ begin end; procedure TOpenGLDrawer.Polygon( - const APoints: array of TPoint; AStartIndex: Integer; ANumPts: Integer); + const APoints: array of TPoint; AStartIndex, ANumPts: Integer); var i: Integer; begin - if ANumPts < 0 then - ANumPts := Length(APoints); glBegin(GL_POLYGON); ChartGLColor(FBrushColor); for i := AStartIndex to AStartIndex + ANumPts - 1 do - glVertex2i(APoints[i].X, APoints[i].Y); + glVertex2iv(@APoints[i]); glEnd(); InternalPolyline(APoints, AStartIndex, ANumPts, GL_LINE_LOOP); end; procedure TOpenGLDrawer.Polyline( - const APoints: array of TPoint; AStartIndex: Integer; ANumPts: Integer; + const APoints: array of TPoint; AStartIndex, ANumPts: Integer; AEndPoint: Boolean); begin Unused(AEndPoint); diff --git a/components/tachart/tadrawersvg.pas b/components/tachart/tadrawersvg.pas index 444b55dfc6..f7a9a78b2b 100644 --- a/components/tachart/tadrawersvg.pas +++ b/components/tachart/tadrawersvg.pas @@ -71,11 +71,10 @@ type procedure LineTo(AX, AY: Integer); override; procedure MoveTo(AX, AY: Integer); override; procedure Polygon( - const APoints: array of TPoint; - AStartIndex: Integer = 0; ANumPts: Integer = -1); override; + const APoints: array of TPoint; AStartIndex, ANumPts: Integer); override; procedure Polyline( - const APoints: array of TPoint; AStartIndex: Integer = 0; - ANumPts: Integer = -1; AEndPoint: Boolean = false); + const APoints: array of TPoint; AStartIndex, ANumPts: Integer; + AEndPoint: Boolean = false); procedure PrepareSimplePen(AColor: TChartColor); procedure RadialPie( AX1, AY1, AX2, AY2: Integer; @@ -235,7 +234,7 @@ begin end; procedure TSVGDrawer.Polygon( - const APoints: array of TPoint; AStartIndex: Integer; ANumPts: Integer); + const APoints: array of TPoint; AStartIndex, ANumPts: Integer); begin WriteFmt( '', @@ -243,7 +242,7 @@ begin end; procedure TSVGDrawer.Polyline( - const APoints: array of TPoint; AStartIndex: Integer; ANumPts: Integer; + const APoints: array of TPoint; AStartIndex, ANumPts: Integer; AEndPoint: Boolean); begin Unused(AEndPoint); diff --git a/components/tachart/tadrawutils.pas b/components/tachart/tadrawutils.pas index 0ff8d20709..2b3de60077 100644 --- a/components/tachart/tadrawutils.pas +++ b/components/tachart/tadrawutils.pas @@ -84,11 +84,10 @@ type procedure MoveTo(AX, AY: Integer); procedure MoveTo(const AP: TPoint); procedure Polygon( - const APoints: array of TPoint; - AStartIndex: Integer = 0; ANumPts: Integer = -1); + const APoints: array of TPoint; AStartIndex, ANumPts: Integer); procedure Polyline( - const APoints: array of TPoint; AStartIndex: Integer = 0; - ANumPts: Integer = -1; AEndPoint: Boolean = false); + const APoints: array of TPoint; + AStartIndex, ANumPts: Integer; AEndPoint: Boolean = false); procedure PrepareSimplePen(AColor: TChartColor); procedure RadialPie( AX1, AY1, AX2, AY2: Integer; @@ -137,8 +136,7 @@ type procedure MoveTo(AX, AY: Integer); virtual; abstract; procedure MoveTo(const AP: TPoint); procedure Polygon( - const APoints: array of TPoint; - AStartIndex: Integer = 0; ANumPts: Integer = -1); virtual; abstract; + const APoints: array of TPoint; AStartIndex, ANumPts: Integer); virtual; abstract; function Scale(ADistance: Integer): Integer; virtual; procedure SetDoChartColorToFPColorFunc(AValue: TChartColorToFPColorFunc); procedure SetGetFontOrientationFunc(AValue: TGetFontOrientationFunc); @@ -300,7 +298,7 @@ var d: TPoint; begin d := Point(ADepth, -ADepth); - Polygon([AP1, AP1 + d, AP2 + d, AP2]); + Polygon([AP1, AP1 + d, AP2 + d, AP2], 0, 4); end; procedure TBasicDrawer.LineTo(const AP: TPoint); diff --git a/components/tachart/tageometry.pas b/components/tachart/tageometry.pas index a33b7e3bc1..a7171654f6 100644 --- a/components/tachart/tageometry.pas +++ b/components/tachart/tageometry.pas @@ -96,8 +96,7 @@ function CopyPoints( var i: Integer; begin - if ANumPts = -1 then - ANumPts := Length(APoints) - AStartIndex; + Assert(ANumPts >= 0); SetLength(Result, ANumPts); for i := 0 to ANumPts - 1 do Result[i] := APoints[i + AStartIndex]; diff --git a/components/tachart/taradialseries.pas b/components/tachart/taradialseries.pas index f4cdfb0ef1..bde6ffc03a 100644 --- a/components/tachart/taradialseries.pas +++ b/components/tachart/taradialseries.pas @@ -401,7 +401,7 @@ begin pts[i] := FChart.GraphToImage(GraphPoint(i)); ADrawer.Pen := LinePen; ADrawer.SetBrushParams(bsClear, clTAColor); - ADrawer.Polygon(pts); + ADrawer.Polygon(pts, 0, Length(pts)); end; function TPolarSeries.Extent: TDoubleRect; diff --git a/components/tachart/tatypes.pas b/components/tachart/tatypes.pas index 41bb76468a..48491f599e 100644 --- a/components/tachart/tatypes.pas +++ b/components/tachart/tatypes.pas @@ -580,7 +580,7 @@ begin ADrawer.Brush := LabelBrush; if IsMarginRequired then begin ADrawer.Pen := Frame; - ADrawer.Polygon(labelPoly); + ADrawer.Polygon(labelPoly, 0, Length(labelPoly)); end; ptText := RotatePoint(-ptText div 2, LabelAngle) + ALabelCenter;