TAChart: Add TBasicPointSeries.MovePoint overload for graph coordinates

git-svn-id: trunk@38780 -
This commit is contained in:
ask 2012-09-21 11:15:15 +00:00
parent 88ff18a61a
commit ed154f4797
3 changed files with 19 additions and 19 deletions

View File

@ -262,7 +262,7 @@ type
function GetNearestPoint( function GetNearestPoint(
const AParams: TNearestPointParams; const AParams: TNearestPointParams;
out AResults: TNearestPointResults): Boolean; override; out AResults: TNearestPointResults): Boolean; override;
procedure MovePoint(var AIndex: Integer; const ANewPos: TPoint); override; procedure MovePoint(var AIndex: Integer; const ANewPos: TDoublePoint); override;
property MarkPositions: TLinearMarkPositions property MarkPositions: TLinearMarkPositions
read FMarkPositions write SetMarkPositions default lmpOutside; read FMarkPositions write SetMarkPositions default lmpOutside;
property UseReticule: Boolean property UseReticule: Boolean
@ -1055,15 +1055,12 @@ begin
end; end;
procedure TBasicPointSeries.MovePoint( procedure TBasicPointSeries.MovePoint(
var AIndex: Integer; const ANewPos: TPoint); var AIndex: Integer; const ANewPos: TDoublePoint);
var
p: TDoublePoint;
begin begin
if not InRange(AIndex, 0, Count - 1) then exit; if not InRange(AIndex, 0, Count - 1) then exit;
p := FChart.ImageToGraph(ANewPos);
with ListSource do begin with ListSource do begin
AIndex := SetXValue(AIndex, p.X); AIndex := SetXValue(AIndex, ANewPos.X);
SetYValue(AIndex, p.Y); SetYValue(AIndex, ANewPos.Y);
end; end;
end; end;

View File

@ -81,7 +81,8 @@ type
procedure Draw(ADrawer: IChartDrawer); virtual; abstract; procedure Draw(ADrawer: IChartDrawer); virtual; abstract;
function GetGraphBounds: TDoubleRect; virtual; abstract; function GetGraphBounds: TDoubleRect; virtual; abstract;
function IsEmpty: Boolean; virtual; abstract; function IsEmpty: Boolean; virtual; abstract;
procedure MovePoint(var AIndex: Integer; const ANewPos: TPoint); virtual; procedure MovePoint(var AIndex: Integer; const ANewPos: TPoint); overload; inline;
procedure MovePoint(var AIndex: Integer; const ANewPos: TDoublePoint); overload; virtual;
property Active: Boolean read FActive write SetActive default true; property Active: Boolean read FActive write SetActive default true;
property Depth: TChartDistance read FDepth write SetDepth default 0; property Depth: TChartDistance read FDepth write SetDepth default 0;
@ -1581,11 +1582,17 @@ begin
end; end;
procedure TBasicChartSeries.MovePoint( procedure TBasicChartSeries.MovePoint(
var AIndex: Integer; const ANewPos: TPoint); var AIndex: Integer; const ANewPos: TDoublePoint);
begin begin
Unused(AIndex, ANewPos) Unused(AIndex, ANewPos)
end; end;
procedure TBasicChartSeries.MovePoint(
var AIndex: Integer; const ANewPos: TPoint);
begin
MovePoint(AIndex, FChart.ImageToGraph(ANewPos));
end;
procedure TBasicChartSeries.UpdateMargins( procedure TBasicChartSeries.UpdateMargins(
ADrawer: IChartDrawer; var AMargins: TRect); ADrawer: IChartDrawer; var AMargins: TRect);
begin begin

View File

@ -269,7 +269,7 @@ type
function GetNearestPoint( function GetNearestPoint(
const AParams: TNearestPointParams; const AParams: TNearestPointParams;
out AResults: TNearestPointResults): Boolean; override; out AResults: TNearestPointResults): Boolean; override;
procedure MovePoint(var AIndex: Integer; const ANewPos: TPoint); override; procedure MovePoint(var AIndex: Integer; const ANewPos: TDoublePoint); override;
published published
property Active default true; property Active default true;
@ -710,21 +710,17 @@ begin
Result := FPen.Color; Result := FPen.Color;
end; end;
procedure TConstantLine.MovePoint(var AIndex: Integer; const ANewPos: TPoint); procedure TConstantLine.MovePoint(
var AIndex: Integer; const ANewPos: TDoublePoint);
begin begin
Unused(AIndex); Unused(AIndex);
if LineStyle = lsVertical then Position :=
Position := GraphToAxisX(FChart.XImageToGraph(ANewPos.X)) GraphToAxisX(TDoublePointBoolArr(ANewPos)[LineStyle = lsHorizontal]);
else
Position := GraphToAxisX(FChart.YImageToGraph(ANewPos.Y));
end; end;
procedure TConstantLine.SavePosToCoord(var APoint: TDoublePoint); procedure TConstantLine.SavePosToCoord(var APoint: TDoublePoint);
begin begin
if LineStyle = lsVertical then TDoublePointBoolArr(APoint)[LineStyle = lsHorizontal] := Position;
APoint.X := Position
else
APoint.Y := Position;
end; end;
procedure TConstantLine.SetArrow(AValue: TChartArrow); procedure TConstantLine.SetArrow(AValue: TChartArrow);