TAChart: New property VectorCoordKind of TFieldSeries

git-svn-id: trunk@64381 -
This commit is contained in:
wp 2021-01-12 22:50:02 +00:00
parent 227b974139
commit 3a149d4551

View File

@ -11,7 +11,7 @@
unit TAMultiSeries;
{$H+}
{$WARN 6058 off : Call to subroutine "$1" marked as inline is not inlined}
interface
uses
@ -230,11 +230,15 @@ type
property Source;
end;
TVectorCoordKind = (vckCenterDir, vckStartEnd);
TFieldSeries = class(TBasicPointSeries)
private
FArrow: TChartArrow;
FPen: TPen;
FCoordKind: TVectorCoordKind;
procedure SetArrow(AValue: TChartArrow);
procedure SetCoordKind(AValue: TVectorCoordKind);
procedure SetPen(AValue: TPen);
protected
procedure AfterAdd; override;
@ -272,6 +276,7 @@ type
property Pen: TPen read FPen write SetPen;
property Source;
property ToolTargets default [nptPoint, nptXList, nptYList, nptCustom];
property VectorCoordKind: TVectorCoordKind read FCoordKind write SetCoordKind default vckCenterDir;
end;
implementation
@ -1972,7 +1977,10 @@ end;
function TFieldSeries.GetVector(AIndex: Integer): TDoublePoint;
begin
with Source.Item[AIndex]^ do
Result := DoublePoint(XList[0], YList[0]);
case FCoordKind of
vckCenterDir: Result := DoublePoint(XList[0], YList[0]);
vckStartEnd: Result := DoublePoint(XList[0]-X, YList[0]-Y);
end;
end;
function TFieldSeries.GetVectorPoints(AIndex: Integer;
@ -1984,10 +1992,20 @@ begin
if isNaN(X) or IsNaN(Y) or IsNaN(XList[0]) or IsNaN(YList[0]) then
exit(false)
else begin
dx := XList[0] * 0.5;
dy := YList[0] * 0.5;
AStartPt := DoublePoint(X - dx, Y - dy);
AEndPt := DoublePoint(X + dx, Y + dy);
case FCoordKind of
vckCenterDir:
begin
dx := XList[0] * 0.5;
dy := YList[0] * 0.5;
AStartPt := DoublePoint(X - dx, Y - dy);
AEndPt := DoublePoint(X + dx, Y + dy);
end;
vckStartEnd:
begin
AStartPt := DoublePoint(X, Y);
AEndPt := DoublePoint(XList[0], YList[0]);
end;
end;
Result := true;
end;
end;
@ -2057,6 +2075,15 @@ begin
UpdateParentChart;
end;
procedure TFieldSeries.SetCoordKind(AValue: TVectorCoordkind);
begin
if AValue <> FCoordKind then
begin
FCoordKind := AValue;
UpdateParentChart;
end;
end;
procedure TFieldSeries.SetPen(AValue: TPen);
begin
FPen.Assign(AValue);
@ -2065,8 +2092,18 @@ end;
procedure TFieldSeries.SetVector(AIndex: Integer; const AValue: TDoublePoint);
begin
with ListSource.Item[AIndex]^ do begin
XList[0] := AValue.X;
YList[0] := AValue.Y;
case FCoordKind of
vckCenterDir:
begin
XList[0] := AValue.X;
YList[0] := AValue.Y;
end;
vckStartEnd:
begin
XList[0] := X + AValue.X;
YList[0] := Y + AValue.Y;
end;
end;
end;
end;