mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 11:29:27 +02:00
TAChart: Do not automatically normalize rectangle before expanding it. Add test.
git-svn-id: trunk@29101 -
This commit is contained in:
parent
154d4b002a
commit
21453ac232
@ -451,14 +451,12 @@ end;
|
||||
|
||||
procedure ExpandRect(var ARect: TDoubleRect; const APoint: TDoublePoint);
|
||||
begin
|
||||
NormalizeRect(ARect);
|
||||
UpdateMinMax(APoint.X, ARect.a.X, ARect.b.X);
|
||||
UpdateMinMax(APoint.Y, ARect.a.Y, ARect.b.Y);
|
||||
end;
|
||||
|
||||
procedure ExpandRect(var ARect: TRect; const APoint: TPoint);
|
||||
begin
|
||||
NormalizeRect(ARect);
|
||||
UpdateMinMax(APoint.X, ARect.Left, ARect.Right);
|
||||
UpdateMinMax(APoint.Y, ARect.Top, ARect.Bottom);
|
||||
end;
|
||||
|
@ -349,6 +349,7 @@ begin
|
||||
ext.a := AxisToGraph(a);
|
||||
ext.b := AxisToGraph(b);
|
||||
end;
|
||||
NormalizeRect(ext);
|
||||
if LineType = ltFromOrigin then
|
||||
ExpandRect(ext, AxisToGraph(ZeroDoublePoint));
|
||||
// Do not draw anything if the series extent does not intersect CurrentExtent.
|
||||
|
@ -46,7 +46,9 @@ type
|
||||
private
|
||||
procedure AssertEquals(const Expected, Actual: TDoublePoint); overload;
|
||||
procedure AssertEquals(const Expected, Actual: TPoint); overload;
|
||||
procedure AssertEquals(const Expected, Actual: TRect); overload;
|
||||
published
|
||||
procedure TestExpandRect;
|
||||
procedure TestLineIntersectsLine;
|
||||
procedure TestLineIntersectsRect;
|
||||
procedure TestPointOnLine;
|
||||
@ -147,6 +149,27 @@ begin
|
||||
AssertEquals(Expected.Y, Actual.Y);
|
||||
end;
|
||||
|
||||
procedure TGeometryTest.AssertEquals(const Expected, Actual: TRect);
|
||||
begin
|
||||
AssertEquals(Expected.TopLeft, Actual.TopLeft);
|
||||
AssertEquals(Expected.BottomRight, Actual.BottomRight);
|
||||
end;
|
||||
|
||||
procedure TGeometryTest.TestExpandRect;
|
||||
var
|
||||
r: TRect;
|
||||
begin
|
||||
r := Rect(0, 0, 0, 0);
|
||||
ExpandRect(r, Point(1, 2));
|
||||
AssertEquals(Rect(0, 0, 1, 2), r);
|
||||
ExpandRect(r, Point(-5, -6));
|
||||
AssertEquals(Rect(-5, -6, 1, 2), r);
|
||||
|
||||
r := Rect(100, 100, 0, 0);
|
||||
ExpandRect(r, Point(3, 1));
|
||||
AssertEquals(Rect(3, 1, 3, 1), r);
|
||||
end;
|
||||
|
||||
procedure TGeometryTest.TestLineIntersectsLine;
|
||||
var
|
||||
p1, p2: TPoint;
|
||||
|
Loading…
Reference in New Issue
Block a user