mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 21:35:57 +02:00
TAChart: Fix of TChart.IsPointInViewPort and axis labels if all data values are < 1E-12.
git-svn-id: trunk@60276 -
This commit is contained in:
parent
759d2cc725
commit
a67d32bace
@ -34,6 +34,7 @@ const
|
|||||||
clTAColor = $20000000; // = clDefault, but avoiding dependency on Graphics
|
clTAColor = $20000000; // = clDefault, but avoiding dependency on Graphics
|
||||||
DEFAULT_FONT_SIZE = 10;
|
DEFAULT_FONT_SIZE = 10;
|
||||||
DEFAULT_EPSILON = 1e-6;
|
DEFAULT_EPSILON = 1e-6;
|
||||||
|
RANGE_EPSILON = 1e-12;
|
||||||
|
|
||||||
// Replacement for +INF, Canvas does not work correctly when MaxInt is used.
|
// Replacement for +INF, Canvas does not work correctly when MaxInt is used.
|
||||||
// Any screen coordinates are clipped to range -MAX_COORD ... MAX_COORD.
|
// Any screen coordinates are clipped to range -MAX_COORD ... MAX_COORD.
|
||||||
|
@ -381,7 +381,7 @@ const
|
|||||||
// Arbitrary limit to prevent hangup/OOM in case of bug in CalculateIntervals.
|
// Arbitrary limit to prevent hangup/OOM in case of bug in CalculateIntervals.
|
||||||
MAX_COUNT = 10000;
|
MAX_COUNT = 10000;
|
||||||
var
|
var
|
||||||
start, step, m: Double;
|
start, step, m, eps: Double;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
if AParams.FMin >= AParams.FMax then exit;
|
if AParams.FMin >= AParams.FMax then exit;
|
||||||
@ -394,10 +394,11 @@ begin
|
|||||||
EnsureOrder(AParams.FMin, AParams.FMax);
|
EnsureOrder(AParams.FMin, AParams.FMax);
|
||||||
CalculateIntervals(AParams, start, step);
|
CalculateIntervals(AParams, start, step);
|
||||||
if step <= 0 then exit;
|
if step <= 0 then exit;
|
||||||
|
eps := (AParams.FMax - AParams.FMin) * RANGE_EPSILON;
|
||||||
m := start;
|
m := start;
|
||||||
SetLength(AValues, Trunc(Min((AParams.FMax - m) / step + 2, MAX_COUNT)));
|
SetLength(AValues, Trunc(Min((AParams.FMax - m) / step + 2, MAX_COUNT)));
|
||||||
for i := 0 to High(AValues) do begin
|
for i := 0 to High(AValues) do begin
|
||||||
if IsZero(m) then
|
if IsZero(m, eps) then
|
||||||
m := 0;
|
m := 0;
|
||||||
AValues[i].FValue := m;
|
AValues[i].FValue := m;
|
||||||
if m > AParams.FMax then begin
|
if m > AParams.FMax then begin
|
||||||
|
@ -28,7 +28,8 @@ function InRangeUlps(AX, ALo, AHi: Double; AMaxUlps: Word): Boolean;
|
|||||||
|
|
||||||
function SafeInfinity: Double; inline;
|
function SafeInfinity: Double; inline;
|
||||||
function SafeInRange(AValue, ABound1, ABound2: Double): Boolean;
|
function SafeInRange(AValue, ABound1, ABound2: Double): Boolean;
|
||||||
function SafeInRangeWithBounds(AValue, ABound1, ABound2: Double): Boolean;
|
function SafeInRangeWithBounds(AValue, ABound1, ABound2: Double;
|
||||||
|
AEpsilon: Double = 0.0): Boolean;
|
||||||
function SafeMin(A, B: Double): Double;
|
function SafeMin(A, B: Double): Double;
|
||||||
function SafeNan: Double; inline;
|
function SafeNan: Double; inline;
|
||||||
function SafeEqual(A, B: Double): Boolean;
|
function SafeEqual(A, B: Double): Boolean;
|
||||||
@ -160,11 +161,14 @@ begin
|
|||||||
Result := InRange(AValue, ABound1, ABound2);
|
Result := InRange(AValue, ABound1, ABound2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function SafeInRangeWithBounds(AValue, ABound1, ABound2: Double): Boolean;
|
function SafeInRangeWithBounds(AValue, ABound1, ABound2: Double;
|
||||||
|
AEpsilon: Double = 0.0): Boolean;
|
||||||
begin
|
begin
|
||||||
EnsureOrder(ABound1, ABound2);
|
EnsureOrder(ABound1, ABound2);
|
||||||
|
if AEpsilon = 0.0 then
|
||||||
|
AEpsilon := RANGE_EPSILON * (ABound2 - ABound1);
|
||||||
Result := InRange(AValue, ABound1, ABound2) or
|
Result := InRange(AValue, ABound1, ABound2) or
|
||||||
SameValue(AValue, ABound1) or SameValue(AValue, ABound2);
|
SameValue(AValue, ABound1, AEpsilon) or SameValue(AValue, ABound2, AEpsilon);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function SafeMin(A, B: Double): Double;
|
function SafeMin(A, B: Double): Double;
|
||||||
|
Loading…
Reference in New Issue
Block a user