📄 iplotdataview.pas
字号:
{*******************************************************}
{ }
{ TiPlotDataView }
{ }
{ Copyright (c) 1997,2003 Iocomp Software }
{ }
{*******************************************************}
{$I iInclude.inc}
{$ifdef iVCL}unit iPlotDataView;{$endif}
{$ifdef iCLX}unit QiPlotDataView;{$endif}
interface
uses
{$I iIncludeUses.inc}
{$IFDEF iVCL} Menus, iTypes, iGPFunctions, iPlotObjects, iPlotAxis;{$ENDIF}
{$IFDEF iCLX}QMenus, QiTypes, QiGPFunctions, QiPlotObjects, QiPlotAxis;{$ENDIF}
type
TiPlotZoomBoxEvent = procedure(ARect : TRect) of object;
TiPlotDataViewMode = (ipdvmNone, ipdvmZoomBox, ipdvmSelect, ipdvmScrollZoom);
TiPlotAxesControlStyle = (ipacsXAxis, ipacsYAxis, ipacsBoth);
TiPlotDataView = class(TiPlotLayoutObject)
private
FXAxis : TiPlotXAxis;
FYAxis : TiPlotYAxis;
FMouseDownObject : TiPlotObject;
FMouseDown : Boolean;
FMouseDownX : Integer;
FMouseDownY : Integer;
FMouseMoveX : Integer;
FMouseMoveY : Integer;
FDirectionLock : Boolean;
FDirectionLockXAxis : Boolean;
FTitle : String;
FBackgroundTransparent : Boolean;
FBackgroundColor : TColor;
FGridShow : Boolean;
FAxesControlEnabled : Boolean;
FAxesControlWheelStyle : TiPlotAxesControlStyle;
FAxesControlMouseStyle : TiPlotAxesControlStyle;
FGridYAxisName : String;
FGridXAxisName : String;
FGridLineColor : TColor;
FGridLineShowLeft : Boolean;
FGridLineShowTop : Boolean;
FGridLineShowRight : Boolean;
FGridLineShowBottom : Boolean;
FGridLineShowXMajors : Boolean;
FGridLineShowXMinors : Boolean;
FGridLineShowYMajors : Boolean;
FGridLineShowYMinors : Boolean;
FGridLineMajorStyle : TiPlotGridLineStyle;
FGridLineMinorStyle : TiPlotGridLineStyle;
FGridLineXMajorCustom : Boolean;
FGridLineXMajorColor : TColor;
FGridLineXMajorWidth : Integer;
FGridLineXMajorStyle : TiPlotGridLineStyle;
FGridLineXMinorCustom : Boolean;
FGridLineXMinorColor : TColor;
FGridLineXMinorWidth : Integer;
FGridLineXMinorStyle : TiPlotGridLineStyle;
FGridLineYMajorCustom : Boolean;
FGridLineYMajorColor : TColor;
FGridLineYMajorWidth : Integer;
FGridLineYMajorStyle : TiPlotGridLineStyle;
FGridLineYMinorCustom : Boolean;
FGridLineYMinorColor : TColor;
FGridLineYMinorWidth : Integer;
FGridLineYMinorStyle : TiPlotGridLineStyle;
protected
procedure SetTitle (const Value: String);
procedure SetBackgroundColor (const Value: TColor);
procedure SetBackgroundTransparent(const Value: Boolean);
procedure SetGridShow (const Value: Boolean);
procedure SetAxesControlEnabled (const Value: Boolean);
procedure SetGridXAxisName (const Value: String);
procedure SetGridYAxisName (const Value: String);
procedure SetGridLineColor (const Value: TColor);
procedure SetGridLineShowLeft (const Value: Boolean);
procedure SetGridLineShowTop (const Value: Boolean);
procedure SetGridLineShowRight (const Value: Boolean);
procedure SetGridLineShowBottom (const Value: Boolean);
procedure SetGridLineShowXMajors (const Value: Boolean);
procedure SetGridLineShowXMinors (const Value: Boolean);
procedure SetGridLineShowYMajors (const Value: Boolean);
procedure SetGridLineShowYMinors (const Value: Boolean);
procedure SetGridLineMajorStyle (const Value: TiPlotGridLineStyle);
procedure SetGridLineMinorStyle (const Value: TiPlotGridLineStyle);
procedure SetGridLineXMajorCustom (const Value: Boolean);
procedure SetGridLineXMajorColor (const Value: TColor);
procedure SetGridLineXMajorWidth (const Value: Integer);
procedure SetGridLineXMajorStyle (const Value: TiPlotGridLineStyle);
procedure SetGridLineXMinorCustom (const Value: Boolean);
procedure SetGridLineXMinorColor (const Value: TColor);
procedure SetGridLineXMinorWidth (const Value: Integer);
procedure SetGridLineXMinorStyle (const Value: TiPlotGridLineStyle);
procedure SetGridLineYMajorCustom (const Value: Boolean);
procedure SetGridLineYMajorColor (const Value: TColor);
procedure SetGridLineYMajorWidth (const Value: Integer);
procedure SetGridLineYMajorStyle (const Value: TiPlotGridLineStyle);
procedure SetGridLineYMinorCustom (const Value: Boolean);
procedure SetGridLineYMinorColor (const Value: TColor);
procedure SetGridLineYMinorWidth (const Value: Integer);
procedure SetGridLineYMinorStyle (const Value: TiPlotGridLineStyle);
procedure XAxisNeeded;
procedure YAxisNeeded;
procedure NotificationRemove (Sender: TObject); override;
procedure NotificationRename (Sender: TObject); override;
procedure NotificationSetFocus(Sender: TObject); override;
function GetMousePointer(APoint: TPoint): TCursor; override;
function GetMouseObject(X, Y: Integer): TiPlotObject; override;
function GetMode: TiPlotDataViewMode;
procedure Draw (const Canvas: TCanvas; const BackGroundColor: TColor); override;
procedure DrawGrid (const Canvas: TCanvas; const BackGroundColor: TColor);
procedure DrawBackground(const Canvas: TCanvas; const BackGroundColor: TColor);
procedure DoMouseLeft(MouseData: TiPlotMouseData); override;
procedure DoMouseMove(MouseData: TiPlotMouseData); override;
procedure DoMouseUp (MouseData: TiPlotMouseData); override;
function iMouseWheel(WheelDelta: Integer;Shift: TShiftState; const MousePos: TPoint): Boolean; override;
procedure DoZoom(ARect: TRect);
procedure AddMenuItems(PopupMenu: TPopUpMenu); override;
property Mode : TiPlotDataViewMode read GetMode;
public
constructor Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent); override;
destructor Destroy; override;
function PixelsXToPositionPercent(Value: Integer): Double;
function PixelsYToPositionPercent(Value: Integer): Double;
function PositionPercentToPixelsX(Value: Double ): Integer;
function PositionPercentToPixelsY(Value: Double ): Integer;
published
property Title : String read FTitle write SetTitle;
property BackgroundTransparent : Boolean read FBackgroundTransparent write SetBackgroundTransparent default True;
property BackgroundColor : TColor read FBackgroundColor write SetBackgroundColor default clTeal;
property GridXAxisName : String read FGridXAxisName write SetGridXAxisName;
property GridYAxisName : String read FGridYAxisName write SetGridYAxisName;
property GridShow : Boolean read FGridShow write SetGridShow default True;
property GridLineColor : TColor read FGridLineColor write SetGridLineColor default clGreen;
property GridLineShowLeft : Boolean read FGridLineShowLeft write SetGridLineShowLeft default True;
property GridLineShowRight : Boolean read FGridLineShowRight write SetGridLineShowRight default True;
property GridLineShowTop : Boolean read FGridLineShowTop write SetGridLineShowTop default True;
property GridLineShowBottom : Boolean read FGridLineShowBottom write SetGridLineShowBottom default True;
property GridLineShowXMajors : Boolean read FGridLineShowXMajors write SetGridLineShowXMajors default True;
property GridLineShowXMinors : Boolean read FGridLineShowXMinors write SetGridLineShowXMinors default False;
property GridLineShowYMajors : Boolean read FGridLineShowYMajors write SetGridLineShowYMajors default True;
property GridLineShowYMinors : Boolean read FGridLineShowYMinors write SetGridLineShowYMinors default False;
property GridLineMajorStyle : TiPlotGridLineStyle read FGridLineMajorStyle write SetGridLineMajorStyle default ipglsSolid;
property GridLineMinorStyle : TiPlotGridLineStyle read FGridLineMinorStyle write SetGridLineMinorStyle default ipglsSolid;
property GridLineXMajorCustom : Boolean read FGridLineXMajorCustom write SetGridLineXMajorCustom default False;
property GridLineXMajorColor : TColor read FGridLineXMajorColor write SetGridLineXMajorColor default clGreen;
property GridLineXMajorWidth : Integer read FGridLineXMajorWidth write SetGridLineXMajorWidth default 1;
property GridLineXMajorStyle : TiPlotGridLineStyle read FGridLineXMajorStyle write SetGridLineXMajorStyle default ipglsSolid;
property GridLineXMinorCustom : Boolean read FGridLineXMinorCustom write SetGridLineXMinorCustom default False;
property GridLineXMinorColor : TColor read FGridLineXMinorColor write SetGridLineXMinorColor default clGreen;
property GridLineXMinorWidth : Integer read FGridLineXMinorWidth write SetGridLineXMinorWidth default 1;
property GridLineXMinorStyle : TiPlotGridLineStyle read FGridLineXMinorStyle write SetGridLineXMinorStyle default ipglsSolid;
property GridLineYMajorCustom : Boolean read FGridLineYMajorCustom write SetGridLineYMajorCustom default False;
property GridLineYMajorColor : TColor read FGridLineYMajorColor write SetGridLineYMajorColor default clGreen;
property GridLineYMajorWidth : Integer read FGridLineYMajorWidth write SetGridLineYMajorWidth default 1;
property GridLineYMajorStyle : TiPlotGridLineStyle read FGridLineYMajorStyle write SetGridLineYMajorStyle default ipglsSolid;
property GridLineYMinorCustom : Boolean read FGridLineYMinorCustom write SetGridLineYMinorCustom default False;
property GridLineYMinorColor : TColor read FGridLineYMinorColor write SetGridLineYMinorColor default clGreen;
property GridLineYMinorWidth : Integer read FGridLineYMinorWidth write SetGridLineYMinorWidth default 1;
property GridLineYMinorStyle : TiPlotGridLineStyle read FGridLineYMinorStyle write SetGridLineYMinorStyle default ipglsSolid;
property AxesControlEnabled : Boolean read FAxesControlEnabled write SetAxesControlEnabled;
property AxesControlMouseStyle : TiPlotAxesControlStyle read FAxesControlMouseStyle write FAxesControlMouseStyle;
property AxesControlWheelStyle : TiPlotAxesControlStyle read FAxesControlWheelStyle write FAxesControlWheelStyle;
end;
implementation
uses
{$ifdef iVCL} iPlotDataCursor, iPlotComponent;{$endif}
{$ifdef iCLX}QiPlotDataCursor, QiPlotComponent;{$endif}
type
TiPlotAxisAccess = class(TiPlotAxis )end;
TiPlotDataCursorAccess = class(TiPlotDataCursor)end;
TiPlotObjectAccess = class(TiPlotObject )end;
TiPlotComponentAccess = class(TiPlotComponent )end;
//****************************************************************************************************************************************************
constructor TiPlotDataView.Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent);
begin
inherited;
FBackgroundTransparent := True;
FBackgroundColor := clTeal;
FAxesControlMouseStyle := ipacsBoth;
FGridShow := True;
FGridLineColor := clGreen;
FGridLineShowLeft := True;
FGridLineShowTop := True;
FGridLineShowRight := True;
FGridLineShowBottom := True;
FGridLineShowXMajors := True;
FGridLineShowXMinors := False;
FGridLineShowYMajors := True;
FGridLineShowYMinors := False;
FGridLineXMajorCustom := False;
FGridLineXMajorColor := clGreen;
FGridLineXMajorWidth := 0;
FGridLineXMajorStyle := ipglsSolid;
FGridLineXMinorCustom := False;
FGridLineXMinorColor := clGreen;
FGridLineXMinorWidth := 0;
FGridLineXMinorStyle := ipglsSolid;
FGridLineYMajorCustom := False;
FGridLineYMajorColor := clGreen;
FGridLineYMajorWidth := 0;
FGridLineYMajorStyle := ipglsSolid;
FGridLineYMinorCustom := False;
FGridLineYMinorColor := clGreen;
FGridLineYMinorWidth := 0;
FGridLineYMinorStyle := ipglsSolid;
end;
//****************************************************************************************************************************************************
destructor TiPlotDataView.Destroy;
begin
inherited;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.NotificationRemove(Sender: TObject);
begin
if Sender = FXAxis then FXAxis := nil;
if Sender = FYAxis then FYAxis := nil;
if Sender = FMouseDownObject then FMouseDownObject := nil;
end;
//****************************************************************************************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -