📄 iplotlayoutmanager.pas
字号:
{*******************************************************}
{ }
{ TiPlotLayoutManager }
{ }
{ Copyright (c) 1997,2003 Iocomp Software }
{ }
{*******************************************************}
{$I iInclude.inc}
{$ifdef iVCL}unit iPlotLayoutManager;{$endif}
{$ifdef iCLX}unit QiPlotLayoutManager;{$endif}
interface
uses
{$I iIncludeUses.inc}
{$IFDEF iVCL} iTypes, iGPFunctions, iPlotObjects, iPlotManagers;{$ENDIF}
{$IFDEF iCLX}QiTypes, QiGPFunctions, QiPlotObjects, QiPlotManagers;{$ENDIF}
type
TiQuadSide = (iqsLeft, iqsRight, iqsTop, iqsBottom);
TiInsertDirection = (iidMerge, iidBelow, iidAbove);
TiPlotDataViewLayout = class(TiPlotLayoutObject) end;
TiPlotDataViewHorz = class(TiPlotDataViewLayout) end;
TiPlotDataViewVert = class(TiPlotDataViewLayout) end;
//----------------------------------------------------------------------------
TiPlotLayoutManager = class(TiPlotObjectManagerCustom)
private
FXYAxesReverse : Boolean;
FDataViewHorz : TiPlotDataViewHorz;
FDataViewVert : TiPlotDataViewVert;
FEnabled : Boolean;
FUpdating : Boolean;
FUpdateOccured : Boolean;
FTopList : TStringList;
FBottomList : TStringList;
FLeftList : TStringList;
FRightList : TStringList;
FLeftUniqueCount : Integer;
FRightUniqueCount : Integer;
FBottomUniqueCount : Integer;
FTopUniqueCount : Integer;
protected
function GetItem(Index: Integer): TiPlotLayoutObject;
function GetName : String; override;
function GetUniqueCount(AList : TStringList) : Integer;
procedure DoLayoutChange(Sender : TObject);
procedure RemovingObject(AObject : TiPlotObject); override;
procedure FlipXYAxes;
procedure SetXYAxesReverse(const Value: Boolean);
procedure SetEnabled (const Value: Boolean);
public
constructor Create(AOwner: TWinControl; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent); override;
destructor Destroy; override;
function VisibleCount(AList: TStringList): Integer;
procedure InsertZOrder(NewObject: TiPlotLayoutObject; DesiredZOrder: Integer; InsertDirection: TiInsertDirection);
procedure RemoveZOrder(AObject : TiPlotLayoutObject);
procedure NotificationInsert(Sender : TObject); override;
property Items[Index: Integer]: TiPlotLayoutObject read GetItem;
property XYAxesReverse : Boolean read FXYAxesReverse write SetXYAxesReverse;
property DataViewHorz : TiPlotDataViewHorz read FDataViewHorz;
property DataViewVert : TiPlotDataViewVert read FDataViewVert;
property TopList : TStringList read FTopList;
property BottomList : TStringList read FBottomList;
property LeftList : TStringList read FLeftList;
property RightList : TStringList read FRightList;
property TopUniqueCount : Integer read FTopUniqueCount;
property BottomUniqueCount : Integer read FBottomUniqueCount;
property LeftUniqueCount : Integer read FLeftUniqueCount;
property RightUniqueCount : Integer read FRightUniqueCount;
property Enabled : Boolean read FEnabled write SetEnabled;
end;
implementation
uses
{$ifdef iVCL} iPlotToolBar, iPlotLegend, iPlotAxis, iPlotChannel, iPlotDataView, iPlotLabel;{$endif}
{$ifdef iCLX}QiPlotToolBar, QiPlotLegend, QiPlotAxis, QiPlotChannel, QiPlotDataView, QiPlotLabel;{$endif}
type
TiPlotLayoutAccess = class(TiPlotLayoutObject) end;
//****************************************************************************************************************************************************
constructor TiPlotLayoutManager.Create(AOwner: TWinControl; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent);
begin
inherited;
FTopList := TStringList.Create; FTopList.Sorted := True; FTopList.Duplicates := dupAccept;
FBottomList := TStringList.Create; FBottomList.Sorted := True; FBottomList.Duplicates := dupAccept;
FLeftList := TStringList.Create; FLeftList.Sorted := True; FLeftList.Duplicates := dupAccept;
FRightList := TStringList.Create; FRightList.Sorted := True; FRightList.Duplicates := dupAccept;
FEnabled := False;
FDataViewHorz := TiPlotDataViewHorz.Create(Owner, AOnChange, AOnInsert, AOnRemove, AOnRemove);
with FDataViewHorz do
begin
Horizontal := True;
ZOrder := 1;
Name := 'Data View';
Loaded;
end;
FDataViewVert := TiPlotDataViewVert.Create(Owner, AOnChange, AOnInsert, AOnRemove, AOnRemove);
with FDataViewVert do
begin
Horizontal := False;
ZOrder := 1;
Name := 'Data View';
Loaded;
end;
FEnabled := True;
end;
//****************************************************************************************************************************************************
destructor TiPlotLayoutManager.Destroy;
begin
FDataViewHorz.Free; FDataViewHorz := nil;
FDataViewVert.Free; FDataViewVert := nil;
FTopList.Free; FTopList := nil;
FBottomList.Free; FBottomList := nil;
FLeftList.Free; FLeftList := nil;
FRightList.Free; FRightList := nil;
inherited Destroy;
end;
//****************************************************************************************************************************************************
function TiPlotLayoutManager.GetItem(Index: Integer): TiPlotLayoutObject;
begin
Result := GetObject(Index) as TiPlotLayoutObject;
end;
//****************************************************************************************************************************************************
procedure TiPlotLayoutManager.SetEnabled(const Value: Boolean);
begin
if FEnabled <> Value then
begin
FEnabled := Value;
if FEnabled then DoLayoutChange(Self);
end;
end;
//****************************************************************************************************************************************************
procedure TiPlotLayoutManager.FlipXYAxes;
var
AObject : TiPlotLayoutObject;
AxesList : TStringList;
x : Integer;
begin
AxesList := TStringList.Create;
try
AxesList.Sorted := True;
AxesList.Duplicates := dupAccept;
for x := 0 to Count-1 do
begin
AObject := Items[x] as TiPlotLayoutObject;
if AObject is TiPlotAxis then
begin
AxesList.AddObject(IntToStr(AObject.ZOrder), AObject);
end;
end;
for x := 0 to AxesList.Count-1 do
begin
AObject := AxesList.Objects[x] as TiPlotLayoutObject;
RemoveZOrder(AObject);
if AObject is TiPlotXAxis then AObject.Horizontal := not FXYAxesReverse;
if AObject is TiPlotYAxis then AObject.Horizontal := FXYAxesReverse;
InsertZOrder(AObject, 0, iidMerge);
end;
finally
AxesList.Free;
end;
end;
//****************************************************************************************************************************************************
procedure TiPlotLayoutManager.NotificationInsert(Sender: TObject);
var
iPlotLayoutObject : TiPlotLayoutObject;
begin
if Sender is TiPlotLayoutObject then
begin
iPlotLayoutObject := Sender as TiPlotLayoutObject;
InsertObject(iPlotLayoutObject);
if (iPlotLayoutObject is TiPlotAxis ) or
(iPlotLayoutObject is TiPlotToolBar ) or
(iPlotLayoutObject is TiPlotLegend ) or
(iPlotLayoutObject is TiPlotDataView) or
(iPlotLayoutObject is TiPlotLabel )
then TiPlotLayoutAccess(iPlotLayoutObject).OnLayoutChange := DoLayoutChange;
if iPlotLayoutObject is TiPlotXAxis then iPlotLayoutObject.Horizontal := not FXYAxesReverse;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -