mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 20:40:40 +02:00
TAChart: Add TBasicChartSeries.MovePoint procedure.
+ Implement MovePoint and GetNearestPoint for TConstantLine series git-svn-id: trunk@25760 -
This commit is contained in:
parent
0106d929e9
commit
5fb8c6c91b
@ -81,6 +81,7 @@ type
|
|||||||
ADistFunc: TPointDistFunc; const APoint: TPoint;
|
ADistFunc: TPointDistFunc; const APoint: TPoint;
|
||||||
out AIndex: Integer; out AImg: TPoint; out AValue: TDoublePoint): Boolean;
|
out AIndex: Integer; out AImg: TPoint; out AValue: TDoublePoint): Boolean;
|
||||||
virtual;
|
virtual;
|
||||||
|
procedure MovePoint(AIndex: Integer; const ANewPos: TPoint); virtual;
|
||||||
function IsEmpty: Boolean; virtual; abstract;
|
function IsEmpty: Boolean; virtual; abstract;
|
||||||
|
|
||||||
property Active: Boolean read FActive write SetActive default true;
|
property Active: Boolean read FActive write SetActive default true;
|
||||||
@ -1123,10 +1124,14 @@ begin
|
|||||||
Result := AY;
|
Result := AY;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBasicChartSeries.MovePoint(AIndex: Integer; const ANewPos: TPoint);
|
||||||
|
begin
|
||||||
|
Unused(AIndex, ANewPos)
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBasicChartSeries.UpdateMargins(
|
procedure TBasicChartSeries.UpdateMargins(
|
||||||
ACanvas: TCanvas; var AMargins: TRect);
|
ACanvas: TCanvas; var AMargins: TRect);
|
||||||
begin
|
begin
|
||||||
// nothing
|
|
||||||
Unused(ACanvas, AMargins);
|
Unused(ACanvas, AMargins);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@ type
|
|||||||
ADistFunc: TPointDistFunc; const APoint: TPoint;
|
ADistFunc: TPointDistFunc; const APoint: TPoint;
|
||||||
out AIndex: Integer; out AImg: TPoint; out AValue: TDoublePoint): Boolean;
|
out AIndex: Integer; out AImg: TPoint; out AValue: TDoublePoint): Boolean;
|
||||||
override;
|
override;
|
||||||
|
procedure MovePoint(AIndex: Integer; const ANewPos: TPoint); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TBarSeries }
|
{ TBarSeries }
|
||||||
@ -226,6 +227,7 @@ type
|
|||||||
FUseBounds: Boolean;
|
FUseBounds: Boolean;
|
||||||
|
|
||||||
function GetSeriesColor: TColor;
|
function GetSeriesColor: TColor;
|
||||||
|
procedure SavePosToCoord(var APoint: TDoublePoint);
|
||||||
procedure SetLineStyle(AValue: TLineStyle);
|
procedure SetLineStyle(AValue: TLineStyle);
|
||||||
procedure SetPen(AValue: TPen);
|
procedure SetPen(AValue: TPen);
|
||||||
procedure SetPos(AValue: Double);
|
procedure SetPos(AValue: Double);
|
||||||
@ -239,6 +241,11 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
procedure Draw(ACanvas: TCanvas); override;
|
procedure Draw(ACanvas: TCanvas); override;
|
||||||
|
function GetNearestPoint(
|
||||||
|
ADistFunc: TPointDistFunc;
|
||||||
|
const APoint: TPoint; out AIndex: Integer; out AImg: TPoint;
|
||||||
|
out AValue: TDoublePoint): Boolean; override;
|
||||||
|
procedure MovePoint(AIndex: Integer; const ANewPos: TPoint); override;
|
||||||
|
|
||||||
published
|
published
|
||||||
property Active default true;
|
property Active default true;
|
||||||
@ -505,16 +512,8 @@ end;
|
|||||||
procedure TConstantLine.GetBounds(var ABounds: TDoubleRect);
|
procedure TConstantLine.GetBounds(var ABounds: TDoubleRect);
|
||||||
begin
|
begin
|
||||||
if not UseBounds then exit;
|
if not UseBounds then exit;
|
||||||
case LineStyle of
|
SavePosToCoord(ABounds.a);
|
||||||
lsHorizontal: begin
|
SavePosToCoord(ABounds.b);
|
||||||
ABounds.a.Y := FPosGraph;
|
|
||||||
ABounds.b.Y := FPosGraph;
|
|
||||||
end;
|
|
||||||
lsVertical: begin
|
|
||||||
ABounds.a.X := FPosGraph;
|
|
||||||
ABounds.b.X := FPosGraph;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TConstantLine.GetLegendItems(AItems: TChartLegendItems);
|
procedure TConstantLine.GetLegendItems(AItems: TChartLegendItems);
|
||||||
@ -522,11 +521,47 @@ begin
|
|||||||
AItems.Add(TLegendItemLine.Create(Pen, Title));
|
AItems.Add(TLegendItemLine.Create(Pen, Title));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TConstantLine.GetNearestPoint(ADistFunc: TPointDistFunc;
|
||||||
|
const APoint: TPoint; out AIndex: Integer; out AImg: TPoint; out
|
||||||
|
AValue: TDoublePoint): Boolean;
|
||||||
|
begin
|
||||||
|
Result := true;
|
||||||
|
AIndex := -1;
|
||||||
|
AImg := APoint;
|
||||||
|
// Return the actual nearest point of the line.
|
||||||
|
if LineStyle = lsVertical then begin
|
||||||
|
AValue.Y := FChart.YImageToGraph(APoint.Y);
|
||||||
|
AImg.X := FChart.XGraphToImage(Position);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
AValue.X := FChart.XImageToGraph(APoint.X);
|
||||||
|
AImg.Y := FChart.YGraphToImage(Position);
|
||||||
|
end;
|
||||||
|
SavePosToCoord(AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
function TConstantLine.GetSeriesColor: TColor;
|
function TConstantLine.GetSeriesColor: TColor;
|
||||||
begin
|
begin
|
||||||
Result := FPen.Color;
|
Result := FPen.Color;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TConstantLine.MovePoint(AIndex: Integer; const ANewPos: TPoint);
|
||||||
|
begin
|
||||||
|
Unused(AIndex);
|
||||||
|
if LineStyle = lsVertical then
|
||||||
|
Position := FChart.XImageToGraph(ANewPos.X)
|
||||||
|
else
|
||||||
|
Position := FChart.YImageToGraph(ANewPos.Y);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TConstantLine.SavePosToCoord(var APoint: TDoublePoint);
|
||||||
|
begin
|
||||||
|
if LineStyle = lsVertical then
|
||||||
|
APoint.X := Position
|
||||||
|
else
|
||||||
|
APoint.Y := Position;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TConstantLine.SetLineStyle(AValue: TLineStyle);
|
procedure TConstantLine.SetLineStyle(AValue: TLineStyle);
|
||||||
begin
|
begin
|
||||||
if FLineStyle = AValue then exit;
|
if FLineStyle = AValue then exit;
|
||||||
@ -633,6 +668,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBasicPointSeries.MovePoint(AIndex: Integer; const ANewPos: TPoint);
|
||||||
|
var
|
||||||
|
p: TDoublePoint;
|
||||||
|
begin
|
||||||
|
if not InRange(AIndex, 0, Count - 1) then exit;
|
||||||
|
p := FChart.ImageToGraph(ANewPos);
|
||||||
|
with ListSource.Item[AIndex]^ do begin
|
||||||
|
X := p.X;
|
||||||
|
Y := p.Y;
|
||||||
|
end;
|
||||||
|
UpdateParentChart;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBasicPointSeries.SetUseReticule(AValue: Boolean);
|
procedure TBasicPointSeries.SetUseReticule(AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
if FUseReticule = AValue then exit;
|
if FUseReticule = AValue then exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user