mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-23 11:19:10 +02:00
TAChart: Add TDiaLink.Routing property
git-svn-id: trunk@41873 -
This commit is contained in:
parent
60998aab45
commit
de54ab0d89
@ -234,11 +234,15 @@ type
|
||||
property Width: TDiaPosition read FWidth write SetWidth;
|
||||
end;
|
||||
|
||||
TDiaLinkRouting = (dlrStraight, dlrXThenY, dlrYThenX);
|
||||
|
||||
TDiaLink = class(TDiaElement)
|
||||
private
|
||||
FFinish: TDiaEndPoint;
|
||||
FRouting: TDiaLinkRouting;
|
||||
FStart: TDiaEndPoint;
|
||||
procedure SetFinish(AValue: TDiaEndPoint);
|
||||
procedure SetRouting(AValue: TDiaLinkRouting);
|
||||
procedure SetStart(AValue: TDiaEndPoint);
|
||||
protected
|
||||
procedure SetOwner(AValue: TDiagram); override;
|
||||
@ -251,6 +255,7 @@ type
|
||||
published
|
||||
property Start: TDiaEndPoint read FStart write SetStart;
|
||||
property Finish: TDiaEndPoint read FFinish write SetFinish;
|
||||
property Routing: TDiaLinkRouting read FRouting write SetRouting;
|
||||
end;
|
||||
|
||||
operator =(const A, B: TDiaPosition): Boolean; overload; inline;
|
||||
@ -409,6 +414,13 @@ begin
|
||||
FFinish.SetOwner(AValue);
|
||||
end;
|
||||
|
||||
procedure TDiaLink.SetRouting(AValue: TDiaLinkRouting);
|
||||
begin
|
||||
if FRouting = AValue then exit;
|
||||
FRouting := AValue;
|
||||
Notify(Self);
|
||||
end;
|
||||
|
||||
procedure TDiaLink.SetStart(AValue: TDiaEndPoint);
|
||||
begin
|
||||
if FStart = AValue then exit;
|
||||
|
@ -85,7 +85,7 @@ procedure DrawDiaLink(ASelf: TDiaLink);
|
||||
var
|
||||
id: IChartDrawer;
|
||||
var
|
||||
startPos, endPos: TPoint;
|
||||
startPos, endPos, p: TPoint;
|
||||
d: TDiaDecorator;
|
||||
begin
|
||||
if (ASelf.Start.Connector = nil) or (ASelf.Finish.Connector = nil) then exit;
|
||||
@ -96,12 +96,25 @@ begin
|
||||
id.Pen := (d as TDiaPenDecorator).Pen;
|
||||
startPos := ToImage(ASelf.Start.Connector.ActualPos);
|
||||
endPos := ToImage(ASelf.Finish.Connector.ActualPos);
|
||||
id.Line(startPos, endPos);
|
||||
case ASelf.Routing of
|
||||
dlrStraight: begin
|
||||
id.Line(startPos, endPos);
|
||||
p := startPos;
|
||||
end;
|
||||
dlrXThenY: begin
|
||||
p := Point(endPos.X, startPos.Y);
|
||||
id.Polyline([startPos, p, endPos], 0, 3);
|
||||
end;
|
||||
dlrYThenX: begin
|
||||
p := Point(startPos.X, endPos.Y);
|
||||
id.Polyline([startPos, p, endPos], 0, 3);
|
||||
end;
|
||||
end;
|
||||
if ASelf.Start.Shape <> depsNone then
|
||||
with startPos - endPos do
|
||||
with p - endPos do
|
||||
DrawEndPoint(id, ASelf.Start, startPos, ArcTan2(Y, X));
|
||||
if ASelf.Finish.Shape <> depsNone then
|
||||
with endPos - startPos do
|
||||
with endPos - p do
|
||||
DrawEndPoint(id, ASelf.Finish, endPos, ArcTan2(Y, X));
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user