mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 12:19:28 +02:00
TAChart: Add TDiaCenterElement
git-svn-id: trunk@41895 -
This commit is contained in:
parent
399b2b89d9
commit
449a06ba80
@ -122,6 +122,7 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
function DiaPoint(AX, AY: TDiaBoxSide): TDiaPoint; inline;
|
||||||
procedure Add(AConnector: TDiaConnector);
|
procedure Add(AConnector: TDiaConnector);
|
||||||
procedure Changed(ASender: TDiaObject); override;
|
procedure Changed(ASender: TDiaObject); override;
|
||||||
procedure Draw; virtual;
|
procedure Draw; virtual;
|
||||||
@ -160,6 +161,22 @@ type
|
|||||||
property Value: Double read FValue write SetValue;
|
property Value: Double read FValue write SetValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TDiaCenterElement = class(TDiaElement)
|
||||||
|
strict private
|
||||||
|
FActualPos: TDiaPoint;
|
||||||
|
FLeft: TDiaPosition;
|
||||||
|
FTop: TDiaPosition;
|
||||||
|
procedure SetLeft(AValue: TDiaPosition);
|
||||||
|
procedure SetTop(AValue: TDiaPosition);
|
||||||
|
public
|
||||||
|
constructor Create;
|
||||||
|
procedure Changed(ASender: TDiaObject); override;
|
||||||
|
public
|
||||||
|
property ActualPos: TDiaPoint read FActualPos;
|
||||||
|
property Left: TDiaPosition read FLeft write SetLeft;
|
||||||
|
property Top: TDiaPosition read FTop write SetTop;
|
||||||
|
end;
|
||||||
|
|
||||||
TDiaBox = class(TDiaElement)
|
TDiaBox = class(TDiaElement)
|
||||||
strict private
|
strict private
|
||||||
FBottom: TDiaPosition;
|
FBottom: TDiaPosition;
|
||||||
@ -216,6 +233,11 @@ type
|
|||||||
property Position: TDiaPosition read FPosition write SetPosition;
|
property Position: TDiaPosition read FPosition write SetPosition;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TDiaCenterConnector = class(TDiaConnector)
|
||||||
|
public
|
||||||
|
procedure Changed(ASender: TDiaObject); override;
|
||||||
|
end;
|
||||||
|
|
||||||
TDiaBoxConnector = class(TDiaConnector)
|
TDiaBoxConnector = class(TDiaConnector)
|
||||||
private
|
private
|
||||||
FSide: TDiaBoxSide;
|
FSide: TDiaBoxSide;
|
||||||
@ -285,6 +307,16 @@ const
|
|||||||
DEFAULT_DPI = 72;
|
DEFAULT_DPI = 72;
|
||||||
CM_PER_INCH = 2.54;
|
CM_PER_INCH = 2.54;
|
||||||
|
|
||||||
|
function XY(const AX, AY: TDiaPoint): TDiaPoint;
|
||||||
|
var
|
||||||
|
u: TDiaUnits;
|
||||||
|
begin
|
||||||
|
for u in TDiaUnits do begin
|
||||||
|
Result.X[u] := AX.X[u];
|
||||||
|
Result.Y[u] := AY.Y[u];
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function DiaPos(
|
function DiaPos(
|
||||||
AValue: Double; AUnits: TDiaUnits;
|
AValue: Double; AUnits: TDiaUnits;
|
||||||
AReverse: Boolean; APercentage: Boolean): TDiaPosition;
|
AReverse: Boolean; APercentage: Boolean): TDiaPosition;
|
||||||
@ -313,6 +345,39 @@ begin
|
|||||||
Result := TDiaPosition.Equals(A, B);
|
Result := TDiaPosition.Equals(A, B);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TDiaCenterElement }
|
||||||
|
|
||||||
|
procedure TDiaCenterElement.Changed(ASender: TDiaObject);
|
||||||
|
var
|
||||||
|
tl, tr, bl, br: TDiaPoint;
|
||||||
|
begin
|
||||||
|
tl := DiaPoint(dbsLeft, dbsTop);
|
||||||
|
tr := DiaPoint(dbsRight, dbsTop);
|
||||||
|
bl := DiaPoint(dbsLeft, dbsBottom);
|
||||||
|
br := DiaPoint(dbsRight, dbsBottom);
|
||||||
|
if Left.Defined and Top.Defined then
|
||||||
|
FActualPos := XY(Left.Calc(tl, tr), Top.Calc(tl, bl));
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TDiaCenterElement.Create;
|
||||||
|
begin
|
||||||
|
FLeft.Init(Self);
|
||||||
|
FTop.Init(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDiaCenterElement.SetLeft(AValue: TDiaPosition);
|
||||||
|
begin
|
||||||
|
if FLeft = AValue then exit;
|
||||||
|
FLeft.Assign(AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDiaCenterElement.SetTop(AValue: TDiaPosition);
|
||||||
|
begin
|
||||||
|
if FTop = AValue then exit;
|
||||||
|
FTop.Assign(AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TDiaPoint }
|
{ TDiaPoint }
|
||||||
|
|
||||||
function TDiaPoint.AsUnits(AUnits: TDiaUnits): TDoublePoint;
|
function TDiaPoint.AsUnits(AUnits: TDiaUnits): TDoublePoint;
|
||||||
@ -453,6 +518,15 @@ begin
|
|||||||
Notify(Self);
|
Notify(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TDiaCenterConnector }
|
||||||
|
|
||||||
|
procedure TDiaCenterConnector.Changed(ASender: TDiaObject);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
if Element is TDiaCenterElement then
|
||||||
|
FActualPos := (Element as TDiaCenterElement).ActualPos;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TDiaBoxConnector }
|
{ TDiaBoxConnector }
|
||||||
|
|
||||||
procedure TDiaBoxConnector.Changed(ASender: TDiaObject);
|
procedure TDiaBoxConnector.Changed(ASender: TDiaObject);
|
||||||
@ -545,23 +619,6 @@ end;
|
|||||||
{ TDiaBox }
|
{ TDiaBox }
|
||||||
|
|
||||||
procedure TDiaBox.Changed(ASender: TDiaObject);
|
procedure TDiaBox.Changed(ASender: TDiaObject);
|
||||||
|
|
||||||
function DiaPoint(AX, AY: TDiaBoxSide): TDiaPoint;
|
|
||||||
begin
|
|
||||||
Result.X := Owner[AX];
|
|
||||||
Result.Y := Owner[AY];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function XY(const AX, AY: TDiaPoint): TDiaPoint;
|
|
||||||
var
|
|
||||||
u: TDiaUnits;
|
|
||||||
begin
|
|
||||||
for u in TDiaUnits do begin
|
|
||||||
Result.X[u] := AX.X[u];
|
|
||||||
Result.Y[u] := AY.Y[u];
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
var
|
||||||
tl, tr, bl, br: TDiaPoint;
|
tl, tr, bl, br: TDiaPoint;
|
||||||
begin
|
begin
|
||||||
@ -753,6 +810,12 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TDiaElement.DiaPoint(AX, AY: TDiaBoxSide): TDiaPoint;
|
||||||
|
begin
|
||||||
|
Result.X := Owner[AX];
|
||||||
|
Result.Y := Owner[AY];
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TDiaElement.Draw;
|
procedure TDiaElement.Draw;
|
||||||
begin
|
begin
|
||||||
//
|
//
|
||||||
|
@ -18,8 +18,7 @@ uses
|
|||||||
|
|
||||||
function MakeBoxSideConnector(
|
function MakeBoxSideConnector(
|
||||||
ABox: TDiaBox; ASide: TDiaBoxSide): TDiaBoxConnector;
|
ABox: TDiaBox; ASide: TDiaBoxSide): TDiaBoxConnector;
|
||||||
function MakeLink(
|
function MakeLink(ADia: TDiagram; AConn1, AConn2: TDiaConnector): TDiaLink;
|
||||||
ADia: TDiagram; AConn1, AConn2: TDiaBoxConnector): TDiaLink;
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -32,8 +31,7 @@ begin
|
|||||||
ABox.Add(Result);
|
ABox.Add(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function MakeLink(
|
function MakeLink(ADia: TDiagram; AConn1, AConn2: TDiaConnector): TDiaLink;
|
||||||
ADia: TDiagram; AConn1, AConn2: TDiaBoxConnector): TDiaLink;
|
|
||||||
begin
|
begin
|
||||||
Result := TDiaLink.Create;
|
Result := TDiaLink.Create;
|
||||||
Result.Start.Connector := AConn1;
|
Result.Start.Connector := AConn1;
|
||||||
|
Loading…
Reference in New Issue
Block a user