mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 17:29:31 +02:00
TAChart: Pass correct point index and value to OnDrawReticule event handler.
Based on fix by Jorge López. git-svn-id: trunk@25524 -
This commit is contained in:
parent
07e6bb0f2b
commit
f607c5ba28
@ -608,9 +608,12 @@ const
|
|||||||
DIST_FUNCS: array [TReticuleMode] of TPointDistFunc = (
|
DIST_FUNCS: array [TReticuleMode] of TPointDistFunc = (
|
||||||
nil, @PointDistX, @PointDistY, @PointDist);
|
nil, @PointDistX, @PointDistY, @PointDist);
|
||||||
var
|
var
|
||||||
i, pointIndex, bestSeries: Integer;
|
cur, best: record
|
||||||
|
pointIndex: Integer;
|
||||||
|
retPos: TPoint;
|
||||||
value: TDoublePoint;
|
value: TDoublePoint;
|
||||||
newRetPos, bestRetPos: TPoint;
|
end;
|
||||||
|
i, bestSeries: Integer;
|
||||||
d, minDist: Double;
|
d, minDist: Double;
|
||||||
df: TPointDistFunc;
|
df: TPointDistFunc;
|
||||||
begin
|
begin
|
||||||
@ -620,20 +623,21 @@ begin
|
|||||||
df := DIST_FUNCS[FChart.ReticuleMode];
|
df := DIST_FUNCS[FChart.ReticuleMode];
|
||||||
for i := 0 to FChart.SeriesCount - 1 do
|
for i := 0 to FChart.SeriesCount - 1 do
|
||||||
if
|
if
|
||||||
FChart.Series[i].GetNearestPoint(df, APoint, pointIndex, newRetPos, value) and
|
FChart.Series[i].GetNearestPoint(
|
||||||
PtInRect(FChart.ClipRect, newRetPos)
|
df, APoint, cur.pointIndex, cur.retPos, cur.value) and
|
||||||
|
PtInRect(FChart.ClipRect, cur.retPos)
|
||||||
then begin
|
then begin
|
||||||
d := df(APoint, newRetPos);
|
d := df(APoint, cur.retPos);
|
||||||
if d < minDist then begin
|
if d < minDist then begin
|
||||||
bestRetPos := newRetPos;
|
|
||||||
bestSeries := i;
|
bestSeries := i;
|
||||||
|
best := cur;
|
||||||
minDist := d;
|
minDist := d;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if (minDist < Infinity) and (bestRetPos <> FChart.ReticulePos) then begin
|
if (minDist < Infinity) and (best.retPos <> FChart.ReticulePos) then begin
|
||||||
FChart.ReticulePos := bestRetPos;
|
FChart.ReticulePos := best.retPos;
|
||||||
if Assigned(FChart.OnDrawReticule) then
|
if Assigned(FChart.OnDrawReticule) then
|
||||||
FChart.OnDrawReticule(FChart, bestSeries, pointIndex, value);
|
FChart.OnDrawReticule(FChart, bestSeries, best.pointIndex, best.value);
|
||||||
end;
|
end;
|
||||||
{$ifdef OverflowChecking}{$Q+}{$endif}{$ifdef RangeChecking}{$R+}{$endif}
|
{$ifdef OverflowChecking}{$Q+}{$endif}{$ifdef RangeChecking}{$R+}{$endif}
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user