mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-03 20:21:20 +02:00
TAChart: Move GetNearestPoint from TBasicChartSeries to TCustomChartSeries
git-svn-id: trunk@28536 -
This commit is contained in:
parent
831f490467
commit
e83b1a817d
@ -78,6 +78,10 @@ type
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
function GetNearestPoint(
|
||||
ADistFunc: TPointDistFunc; const APoint: TPoint;
|
||||
out AIndex: Integer; out AImg: TPoint; out AValue: TDoublePoint): Boolean;
|
||||
virtual;
|
||||
function GetParentComponent: TComponent; override;
|
||||
function HasParent: Boolean; override;
|
||||
|
||||
@ -291,6 +295,17 @@ begin
|
||||
GetLegendItems(AItems);
|
||||
end;
|
||||
|
||||
function TCustomChartSeries.GetNearestPoint(
|
||||
ADistFunc: TPointDistFunc; const APoint: TPoint; out AIndex: Integer;
|
||||
out AImg: TPoint; out AValue: TDoublePoint): Boolean;
|
||||
begin
|
||||
Unused(ADistFunc, APoint);
|
||||
AIndex := 0;
|
||||
AImg := Point(0, 0);
|
||||
AValue := ZeroDoublePoint;
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
function TCustomChartSeries.GetParentComponent: TComponent;
|
||||
begin
|
||||
Result := FChart;
|
||||
|
@ -79,10 +79,6 @@ type
|
||||
|
||||
public
|
||||
procedure Draw(ACanvas: TCanvas); virtual; abstract;
|
||||
function GetNearestPoint(
|
||||
ADistFunc: TPointDistFunc; const APoint: TPoint;
|
||||
out AIndex: Integer; out AImg: TPoint; out AValue: TDoublePoint): Boolean;
|
||||
virtual;
|
||||
function IsEmpty: Boolean; virtual; abstract;
|
||||
procedure MovePoint(var AIndex: Integer; const ANewPos: TPoint); virtual;
|
||||
|
||||
@ -1154,17 +1150,6 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TBasicChartSeries.GetNearestPoint(
|
||||
ADistFunc: TPointDistFunc; const APoint: TPoint;
|
||||
out AIndex: Integer; out AImg: TPoint; out AValue: TDoublePoint): Boolean;
|
||||
begin
|
||||
Unused(ADistFunc, APoint);
|
||||
AIndex := 0;
|
||||
AImg := Point(0, 0);
|
||||
AValue := ZeroDoublePoint;
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
function TBasicChartSeries.GraphToAxisX(AX: Double): Double;
|
||||
begin
|
||||
Result := AX;
|
||||
|
@ -284,7 +284,7 @@ implementation
|
||||
|
||||
uses
|
||||
ComponentEditors, Forms, GraphMath, Math, PropEdits, SysUtils,
|
||||
TADrawUtils, TASubcomponentsEditor;
|
||||
TACustomSeries, TADrawUtils, TASubcomponentsEditor;
|
||||
|
||||
{$IFOPT R+}{$DEFINE RangeChecking}{$ELSE}{$UNDEF RangeChecking}{$ENDIF}
|
||||
{$IFOPT Q+}{$DEFINE OverflowChecking}{$ELSE}{$UNDEF OverflowChecking}{$ENDIF}
|
||||
@ -812,7 +812,8 @@ begin
|
||||
df := DIST_FUNCS[FChart.ReticuleMode];
|
||||
for i := 0 to FChart.SeriesCount - 1 do
|
||||
if
|
||||
FChart.Series[i].GetNearestPoint(
|
||||
(FChart.Series[i] is TCustomChartSeries) and
|
||||
(FChart.Series[i] as TCustomChartSeries).GetNearestPoint(
|
||||
df, APoint, cur.pointIndex, cur.retPos, cur.value) and
|
||||
PtInRect(FChart.ClipRect, cur.retPos)
|
||||
then begin
|
||||
@ -1015,7 +1016,8 @@ end;
|
||||
procedure TDataPointDragTool.MouseDown(APoint: TPoint);
|
||||
var
|
||||
i, d, bestd, idx: Integer;
|
||||
s, bests: TBasicChartSeries;
|
||||
bests: TBasicChartSeries;
|
||||
s: TCustomChartSeries;
|
||||
affected: TBooleanDynArray;
|
||||
dummy: TDoublePoint;
|
||||
nearest: TPoint;
|
||||
@ -1024,9 +1026,11 @@ begin
|
||||
bests := nil;
|
||||
affected := ParseAffectedSeries;
|
||||
for i := 0 to FChart.SeriesCount - 1 do begin
|
||||
if not affected[i] then continue;
|
||||
s := FChart.Series[i];
|
||||
if not s.GetNearestPoint(@PointDist, APoint, idx, nearest, dummy) then continue;
|
||||
if not affected[i] or not (FChart.Series[i] is TCustomChartSeries) then
|
||||
continue;
|
||||
s := FChart.Series[i] as TCustomChartSeries;
|
||||
if not s.GetNearestPoint(@PointDist, APoint, idx, nearest, dummy) then
|
||||
continue;
|
||||
d := PointDist(APoint, nearest);
|
||||
if d < bestd then begin
|
||||
bestd := d;
|
||||
|
Loading…
Reference in New Issue
Block a user