From f607c5ba287e643606dbbd49c7d5c755351db1cb Mon Sep 17 00:00:00 2001 From: ask Date: Thu, 20 May 2010 00:43:08 +0000 Subject: [PATCH] =?UTF-8?q?TAChart:=20Pass=20correct=20point=20index=20and?= =?UTF-8?q?=20value=20to=20OnDrawReticule=20event=20handler.=20Based=20on?= =?UTF-8?q?=20fix=20by=20Jorge=20L=C3=B3pez.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: trunk@25524 - --- components/tachart/tatools.pas | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/components/tachart/tatools.pas b/components/tachart/tatools.pas index e57c0e1d1b..c97c5c905f 100644 --- a/components/tachart/tatools.pas +++ b/components/tachart/tatools.pas @@ -608,9 +608,12 @@ const DIST_FUNCS: array [TReticuleMode] of TPointDistFunc = ( nil, @PointDistX, @PointDistY, @PointDist); var - i, pointIndex, bestSeries: Integer; - value: TDoublePoint; - newRetPos, bestRetPos: TPoint; + cur, best: record + pointIndex: Integer; + retPos: TPoint; + value: TDoublePoint; + end; + i, bestSeries: Integer; d, minDist: Double; df: TPointDistFunc; begin @@ -620,20 +623,21 @@ begin df := DIST_FUNCS[FChart.ReticuleMode]; for i := 0 to FChart.SeriesCount - 1 do if - FChart.Series[i].GetNearestPoint(df, APoint, pointIndex, newRetPos, value) and - PtInRect(FChart.ClipRect, newRetPos) + FChart.Series[i].GetNearestPoint( + df, APoint, cur.pointIndex, cur.retPos, cur.value) and + PtInRect(FChart.ClipRect, cur.retPos) then begin - d := df(APoint, newRetPos); + d := df(APoint, cur.retPos); if d < minDist then begin - bestRetPos := newRetPos; bestSeries := i; + best := cur; minDist := d; end; end; - if (minDist < Infinity) and (bestRetPos <> FChart.ReticulePos) then begin - FChart.ReticulePos := bestRetPos; + if (minDist < Infinity) and (best.retPos <> FChart.ReticulePos) then begin + FChart.ReticulePos := best.retPos; if Assigned(FChart.OnDrawReticule) then - FChart.OnDrawReticule(FChart, bestSeries, pointIndex, value); + FChart.OnDrawReticule(FChart, bestSeries, best.pointIndex, best.value); end; {$ifdef OverflowChecking}{$Q+}{$endif}{$ifdef RangeChecking}{$R+}{$endif} end;