📄 iplotmanagers.pas
字号:
{*******************************************************}
{ }
{ iPlotManagers }
{ }
{ Copyright (c) 1997,2003 Iocomp Software }
{ }
{*******************************************************}
{$I iInclude.inc}
{$ifdef iVCL}unit iPlotManagers;{$endif}
{$ifdef iCLX}unit QiPlotManagers;{$endif}
interface
uses
{$I iIncludeUses.inc}
{$IFDEF iVCL} Menus, iTypes, iGPFunctions, iPlotObjects,{$ENDIF}
{$IFDEF iCLX}QMenus, QiTypes, QiGPFunctions, QiPlotObjects,{$ENDIF}
{$ifdef iVCL} iPlotToolBar, iPlotLegend, iPlotAxis, iPlotChannelCustom, iPlotDataView, iPlotDataCursor, iPlotLimit, iPlotLabel, iPlotAnnotation, iPlotTable;{$endif}
{$ifdef iCLX}QiPlotToolBar, QiPlotLegend, QiPlotAxis, QiPlotChannelCustom, QiPlotDataView, QiPlotDataCursor, QiPlotLimit, QiPlotLabel, QiPlotAnnotation, QiPlotTable;{$endif}
type
TiColorCountObject = class(TObject)
public
Color : TColor;
Count : Integer;
end;
//----------------------------------------------------------------------------
TiPlotObjectManagerCustom = class(TObject)
private
FList : TStringList;
FOwner : TWinControl;
FOnChange : TNotifyEvent;
FOnRemove : TNotifyEvent;
FOnInsert : TNotifyEvent;
FOnRename : TNotifyEvent;
protected
function GetCount: Integer;
function GetObject(Index: Integer): TiPlotObject;
function GetItem (Index: Integer): TiPlotObject;
function CreateObject : TiPlotObject; virtual; abstract;
function GetName : String; virtual; abstract;
procedure DoChange;
procedure RemovingObject(AObject : TiPlotObject); virtual;
property Owner : TWinControl read FOwner;
public
constructor Create(AOwner: TWinControl; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent); virtual;
destructor Destroy; override;
procedure InsertObject(AObject: TiPlotObject);
procedure NotificationRemove (Sender : TObject); virtual;
procedure NotificationInsert (Sender : TObject); virtual; abstract;
procedure NotificationRename (Sender : TObject); virtual;
procedure NotificationSetFocus(Sender : TObject); virtual;
function DoWriteToStream : Boolean;
procedure WriteToStream (Writer: TWriter);
procedure ReadFromStream(Reader: TReader);
procedure Clear; virtual;
procedure Delete(Index: Integer); virtual;
function GetNextName : String;
function GetIndex (AObject : TiPlotObject): Integer;
function GetObjectByName(Value : String ): TiPlotObject;
function GetIndexByName (Value : String ): Integer;
property Items[Index: Integer]: TiPlotObject read GetItem;
property Count : Integer read GetCount;
property OnChange : TNotifyEvent read FOnChange write FOnChange;
property OnInsert : TNotifyEvent read FOnInsert write FOnInsert;
property OnRemove : TNotifyEvent read FOnRemove write FOnRemove;
property OnRename : TNotifyEvent read FOnRename write FOnRename;
end;
//----------------------------------------------------------------------------
TiPlotObjectOwnedManager = class(TiPlotObjectManagerCustom)
public
procedure Clear; override;
// procedure Delete (Index : Integer); override;
procedure NotificationRemove(Sender : TObject); override;
end;
//----------------------------------------------------------------------------
TiPlotToolBarManager = class(TiPlotObjectOwnedManager)
private
function GetItem(Index: Integer): TiPlotToolBar;
protected
function CreateObject : TiPlotObject; override;
function GetName : String; override;
public
procedure NotificationInsert(Sender : TObject); override;
property Items[Index: Integer]: TiPlotToolBar read GetItem;
end;
//----------------------------------------------------------------------------
TiPlotLegendManager = class(TiPlotObjectOwnedManager)
private
function GetItem(Index: Integer): TiPlotLegend;
protected
function CreateObject : TiPlotObject; override;
function GetName : String; override;
public
procedure NotificationInsert(Sender : TObject); override;
property Items[Index: Integer]: TiPlotLegend read GetItem;
end;
//----------------------------------------------------------------------------
TiPlotXAxisManager = class(TiPlotObjectOwnedManager)
private
function GetItem(Index: Integer): TiPlotXAxis;
protected
function CreateObject : TiPlotObject; override;
function GetName : String; override;
public
procedure NotificationInsert(Sender : TObject); override;
property Items[Index: Integer]: TiPlotXAxis read GetItem;
end;
//----------------------------------------------------------------------------
TiPlotYAxisManager = class(TiPlotObjectOwnedManager)
private
function GetItem(Index: Integer): TiPlotYAxis;
protected
function CreateObject : TiPlotObject; override;
function GetName : String; override;
public
procedure NotificationInsert(Sender : TObject); override;
property Items[Index: Integer]: TiPlotYAxis read GetItem;
end;
//----------------------------------------------------------------------------
TiPlotChannelManager = class(TiPlotObjectOwnedManager)
private
FXAxisManager : TiPlotXAxisManager;
FYAxisManager : TiPlotYAxisManager;
FChannelClass : TiPlotChannelCustomClass;
function GetItem(Index: Integer): TiPlotChannelCustom;
protected
function GetName : String; override;
public
property XAxisManager : TiPlotXAxisManager read FXAxisManager write FXAxisManager;
property YAxisManager : TiPlotYAxisManager read FYAxisManager write FYAxisManager;
function CreateObject : TiPlotObject; override;
function GetNextChannelColor: TColor;
procedure NotificationInsert(Sender : TObject); override;
procedure NotificationRemove(Sender : TObject); override;
property Items[Index: Integer]: TiPlotChannelCustom read GetItem;
property ChannelClass : TiPlotChannelCustomClass read FChannelClass write FChannelClass;
end;
//----------------------------------------------------------------------------
TiPlotDataViewManager = class(TiPlotObjectOwnedManager)
private
FXAxisManager : TiPlotXAxisManager;
FYAxisManager : TiPlotYAxisManager;
function GetItem(Index: Integer): TiPlotDataView;
protected
function CreateObject : TiPlotObject; override;
function GetName : String; override;
public
property XAxisManager : TiPlotXAxisManager read FXAxisManager write FXAxisManager;
property YAxisManager : TiPlotYAxisManager read FYAxisManager write FYAxisManager;
procedure NotificationInsert(Sender : TObject); override;
procedure NotificationRemove(Sender : TObject); override;
property Items[Index: Integer]: TiPlotDataView read GetItem;
end;
//----------------------------------------------------------------------------
TiPlotDataCursorManager = class(TiPlotObjectOwnedManager)
private
FChannelManager : TiPlotChannelManager;
FDataViewManager : TiPlotDataViewManager;
function GetItem(Index: Integer): TiPlotDataCursor;
protected
function CreateObject : TiPlotObject; override;
function GetName : String; override;
public
property ChannelManager : TiPlotChannelManager read FChannelManager write FChannelManager;
property DataViewManager : TiPlotDataViewManager read FDataViewManager write FDataViewManager;
procedure NotificationInsert(Sender : TObject); override;
procedure NotificationRemove(Sender : TObject); override;
property Items[Index: Integer]: TiPlotDataCursor read GetItem;
end;
//----------------------------------------------------------------------------
TiPlotLimitManager = class(TiPlotObjectOwnedManager)
private
FXAxisManager : TiPlotXAxisManager;
FYAxisManager : TiPlotYAxisManager;
function GetItem(Index: Integer): TiPlotLimit;
protected
function CreateObject : TiPlotObject; override;
function GetName : String; override;
public
property XAxisManager : TiPlotXAxisManager read FXAxisManager write FXAxisManager;
property YAxisManager : TiPlotYAxisManager read FYAxisManager write FYAxisManager;
procedure NotificationInsert(Sender : TObject); override;
procedure NotificationRemove(Sender : TObject); override;
property Items[Index: Integer]: TiPlotLimit read GetItem;
end;
//----------------------------------------------------------------------------
TiPlotLabelManager = class(TiPlotObjectOwnedManager)
private
function GetItem(Index: Integer): TiPlotLabel;
protected
function CreateObject : TiPlotObject; override;
function GetName : String; override;
public
procedure NotificationInsert(Sender : TObject); override;
property Items[Index: Integer]: TiPlotLabel read GetItem;
end;
//----------------------------------------------------------------------------
TiPlotTableManager = class(TiPlotObjectOwnedManager)
private
function GetItem(Index: Integer): TiPlotTable;
protected
function CreateObject : TiPlotObject; override;
function GetName : String; override;
public
procedure NotificationInsert(Sender : TObject); override;
property Items[Index: Integer]: TiPlotTable read GetItem;
end;
//----------------------------------------------------------------------------
TiPlotAnnotationManager = class(TiPlotObjectOwnedManager)
private
function GetItem(Index: Integer): TiPlotAnnotation;
protected
function CreateObject : TiPlotObject; override;
function GetName : String; override;
public
procedure NotificationInsert(Sender : TObject); override;
property Items[Index: Integer]: TiPlotAnnotation read GetItem;
end;
//----------------------------------------------------------------------------
TiPlotObjectManager = class(TiPlotObjectManagerCustom)
protected
function CreateObject : TiPlotObject; override;
function GetName : String; override;
public
procedure NotificationInsert(Sender : TObject); override;
procedure ShutDownSetup;
procedure ClearAllUserSelections;
procedure SetShiftState(Value: TShiftState);
procedure MouseDownFocusObjects (Button: TMouseButton; Shift: TShiftState; X, Y, ScreenX, ScreenY: Integer; PopupMenu : TPopupMenu);
procedure MouseMoveFocusObjects (HintData: TiHintData; Shift: TShiftState; X, Y, ScreenX, ScreenY: Integer; DblClickActive: Boolean);
procedure MouseUpFocusObjects (Button: TMouseButton; Shift: TShiftState; X, Y, ScreenX, ScreenY: Integer; DblClickActive: Boolean);
function MouseWheelFocusObjects(WheelDelta: Integer; Shift: TShiftState; const MousePos: TPoint): Boolean;
procedure KeyDownFocusObjects (var CharCode: Word; Shift: TShiftState);
end;
implementation
type
TWriterAccess = class(TWriter ) end;
TReaderAccess = class(TReader ) end;
TPersistentAccess = class(TPersistent ) end;
TiPlotObjectAccess = class(TiPlotObject )end;
TiPlotDataCursorAccess = class(TiPlotDataCursor)end;
//*************************************************************************************************************************************
{TiPlotObjectManager}
//*************************************************************************************************************************************
constructor TiPlotObjectManagerCustom.Create(AOwner: TWinControl; AOnChange, AOnInsert, AOnRemove, AOnRename : TNotifyEvent);
begin
if not Assigned(AOwner) then raise Exception.Create('Owner must be Assigned');
if not Assigned(AOnChange) then raise Exception.Create('OnChange event handler can not be null');
if not Assigned(AOnInsert) then raise Exception.Create('OnInsert event handler can not be null');
if not Assigned(AOnRemove) then raise Exception.Create('OnRemove event handler can not be null');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -