TAChart: Do not automatically normalize rectangle before expanding it. Add test.

git-svn-id: trunk@29101 -
This commit is contained in:
ask 2011-01-18 08:54:00 +00:00
parent 154d4b002a
commit 21453ac232
3 changed files with 24 additions and 2 deletions

View File

@ -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;

View File

@ -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.

View File

@ -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;