📄 qiplotdatacursor.pas
字号:
{*******************************************************}
{ }
{ TiPlotDataCursor }
{ }
{ Copyright (c) 1997,2003 Iocomp Software }
{ }
{*******************************************************}
{$I iInclude.inc}
{$ifdef iVCL}unit iPlotDataCursor;{$endif}
{$ifdef iCLX}unit QiPlotDataCursor;{$endif}
interface
uses
{$I iIncludeUses.inc}
{$IFDEF iVCL} Menus, iTypes, iGPFunctions, iPlotObjects, iPlotChannelCustom, iPlotDataView;{$ENDIF}
{$IFDEF iCLX}QMenus, QiTypes, QiGPFunctions, QiPlotObjects, QiPlotChannelCustom, QiPlotDataView;{$ENDIF}
type
TiPlotDataCursor = class(TiPlotManagerObject)
private
FMouseDownXPixels : Integer;
FMouseDownYPixels : Integer;
FMouseDownX : Integer;
FMouseDownY : Integer;
FMouseDownHint : Boolean;
FMouseDownPointer1 : Boolean;
FMouseDownPointer2 : Boolean;
FPointer1Rect : TRect;
FPointer2Rect : TRect;
FPointer1Show : Boolean;
FPointer2Show : Boolean;
FPointer1Orientation : TiOrientation;
FPointer2Orientation : TiOrientation;
FHintRect : TRect;
FHintOrientation : TiOrientation;
FHintShowing : Boolean;
FChannel : TiPlotChannelCustom;
FDataView : TiPlotDataView;
FChannelName : String;
FStyle : TiPlotDataCursorStyle;
FUseChannelColor : Boolean;
FPointer1Position : Double;
FPointer2Position : Double;
FPointerPenWidth : Integer;
FChannelShowAllInLegend : Boolean;
FChannelAllowAll : Boolean;
FColor : TColor;
FFont : TFont;
FHintShow : Boolean;
FHintHideOnRelease : Boolean;
FHintOrientationSide : TiOrientationSide;
FHintHeight : Integer;
FHintWidth : Integer;
FHintPosition : Double;
FCursorDisplayText : String;
FValueX : Double;
FValueY : Double;
FStatus : TiPlotDataPointStatus;
FScopeStyle : Boolean;
FMenuItemCaptionValueXY : String;
FMenuItemCaptionValueX : String;
FMenuItemCaptionValueY : String;
FMenuItemCaptionDeltaX : String;
FMenuItemCaptionDeltaY : String;
FMenuItemCaptionInverseDeltaX : String;
FMenuItemVisibleDeltaX : Boolean;
FMenuItemVisibleDeltaY : Boolean;
FMenuItemVisibleValueXY : Boolean;
FMenuItemVisibleInverseDeltaX : Boolean;
FMenuItemVisibleValueX : Boolean;
FMenuItemVisibleValueY : Boolean;
FMenuUserCanChangeOptions : Boolean;
protected
procedure SetChannelName (const Value: String);
procedure SetStyle (const Value: TiPlotDataCursorStyle);
procedure SetUseChannelColor (const Value: Boolean);
procedure SetColor (const Value: TColor);
procedure SetFont (const Value: TFont);
procedure SetHintHideOnRelease (const Value: Boolean);
procedure SetHintShow (const Value: Boolean);
procedure SetHintOrientationSide (const Value: TiOrientationSide);
procedure SetHintPosition (const Value: Double);
procedure SetPointer1Position (const Value: Double);
procedure SetPointer2Position (const Value: Double);
procedure SetPointerPenWidth (const Value: Integer);
procedure SetChannelAllowAll (const Value: Boolean);
procedure SetChannelShowAllInLegend(const Value: Boolean);
procedure SetScopeStyle (const Value: Boolean);
procedure AllChannelsMenuItemClick (Sender: TObject);
procedure ChannelNameMenuItemClick (Sender: TObject);
procedure FlipMenuItemClick (Sender: TObject);
procedure UseChannelColorMenuItemClick (Sender: TObject);
procedure HideHintOnReleaseMenuItemClick (Sender: TObject);
procedure StyleValueXYMenuItemClick (Sender: TObject);
procedure StyleValueXMenuItemClick (Sender: TObject);
procedure StyleValueYMenuItemClick (Sender: TObject);
procedure StyleDeltaXMenuItemClick (Sender: TObject);
procedure StyleDeltaYMenuItemClick (Sender: TObject);
procedure StyleInverseDeltaXMenuItemClick(Sender: TObject);
procedure SetData(XValue, YValue: Double; Status: TiPlotDataPointStatus);
function GetChannel: TiPlotChannelCustom;
procedure NotificationRemove (Sender : TObject); override;
procedure NotificationRename (Sender : TObject); override;
procedure NotificationSetFocus(Sender: TObject); override;
procedure DoMouseLeft(MouseData: TiPlotMouseData); override;
procedure DoMouseMove(MouseData: TiPlotMouseData); override;
procedure DoMouseUp (MouseData: TiPlotMouseData); override;
procedure DoSetFocus; override;
function iMouseHitTest(MouseData: TiPlotMouseData): Boolean; override;
function GetMousePointer(APoint: TPoint): TCursor; override;
procedure iKeyDown (var CharCode: Word; Shift: TShiftState); override;
function GetPointer1Pixels: Integer;
function GetPointer2Pixels: Integer;
procedure SetVisible (const Value: Boolean); override;
procedure SetXYAxesReversed(const Value: Boolean); override;
procedure AddMenuItems(PopupMenu: TPopUpMenu); override;
procedure DoUpdate;
property DataView : TiPlotDataView read FDataView write FDataView;
procedure DoSetup;
procedure Draw (const Canvas: TCanvas; const BackGroundColor: TColor); override;
procedure DrawPointer(const Canvas: TCanvas; Position: Double; Orientation: TiOrientation; var PointerRect: TRect);
procedure DrawHint (const Canvas: TCanvas; const BackGroundColor: TColor);
property CursorDisplayText : String read FCursorDisplayText write FCursorDisplayText;
property Pointer1Pixels : Integer read GetPointer1Pixels;
property Pointer2Pixels : Integer read GetPointer2Pixels;
property Channel : TiPlotChannelCustom read GetChannel;
property ScopeStyle : Boolean read FScopeStyle write SetScopeStyle;
public
constructor Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent); override;
destructor Destroy; override;
property ValueX : Double read FValueX;
property ValueY : Double read FValueY;
property Status : TiPlotDataPointStatus read FStatus;
published
property ChannelName : String read FChannelName write SetChannelName;
property ChannelAllowAll : Boolean read FChannelAllowAll write SetChannelAllowAll;
property ChannelShowAllInLegend : Boolean read FChannelShowAllInLegend write SetChannelShowAllInLegend;
property Style : TiPlotDataCursorStyle read FStyle write SetStyle;
property Font : TFont read FFont write SetFont;
property Color : TColor read FColor write SetColor;
property UseChannelColor : Boolean read FUseChannelColor write SetUseChannelColor;
property HintShow : Boolean read FHintShow write SetHintShow;
property HintHideOnRelease : Boolean read FHintHideOnRelease write SetHintHideOnRelease;
property HintOrientationSide : TiOrientationSide read FHintOrientationSide write SetHintOrientationSide;
property HintPosition : Double read FHintPosition write SetHintPosition;
property Pointer1Position : Double read FPointer1Position write SetPointer1Position;
property Pointer2Position : Double read FPointer2Position write SetPointer2Position;
property PointerPenWidth : Integer read FPointerPenWidth write SetPointerPenWidth;
property MenuUserCanChangeOptions : Boolean read FMenuUserCanChangeOptions write FMenuUserCanChangeOptions default True;
property MenuItemVisibleValueXY : Boolean read FMenuItemVisibleValueXY write FMenuItemVisibleValueXY;
property MenuItemVisibleValueX : Boolean read FMenuItemVisibleValueX write FMenuItemVisibleValueX;
property MenuItemVisibleValueY : Boolean read FMenuItemVisibleValueY write FMenuItemVisibleValueY;
property MenuItemVisibleDeltaX : Boolean read FMenuItemVisibleDeltaX write FMenuItemVisibleDeltaX;
property MenuItemVisibleDeltaY : Boolean read FMenuItemVisibleDeltaY write FMenuItemVisibleDeltaY;
property MenuItemVisibleInverseDeltaX : Boolean read FMenuItemVisibleInverseDeltaX write FMenuItemVisibleInverseDeltaX;
property MenuItemCaptionValueXY : String read FMenuItemCaptionValueXY write FMenuItemCaptionValueXY;
property MenuItemCaptionValueX : String read FMenuItemCaptionValueX write FMenuItemCaptionValueX;
property MenuItemCaptionValueY : String read FMenuItemCaptionValueY write FMenuItemCaptionValueY;
property MenuItemCaptionDeltaX : String read FMenuItemCaptionDeltaX write FMenuItemCaptionDeltaX;
property MenuItemCaptionDeltaY : String read FMenuItemCaptionDeltaY write FMenuItemCaptionDeltaY;
property MenuItemCaptionInverseDeltaX : String read FMenuItemCaptionInverseDeltaX write FMenuItemCaptionInverseDeltaX;
end;
implementation
uses
{$ifdef iVCL} iPlotComponent, iPlotAxis, iPlot, iXYPlot;{$endif}
{$ifdef iCLX}QiPlotComponent, QiPlotAxis, QiPlot, QiXYPlot;{$endif}
const
SelectionMargin = 5;
type
TiPlotChannelCustomAccess = class(TiPlotChannelCustom)end;
TiPlotLayoutAccess = class(TiPlotLayoutObject )end;
TiPlotComponentAccess = class(TiPlotComponent )end;
//****************************************************************************************************************************************************
constructor TiPlotDataCursor.Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent);
begin
inherited Create(AOwner, AOnChange, AOnInsert, AOnRemove, AOnRename);
Visible := False;
Enabled := True;
FUseChannelColor := True;
FHintShow := True;
FHintPosition := 50;
FPointer1Position := 50;
FPointer2Position := 60;
FPointerPenWidth := 1;
FColor := clYellow;
FChannelAllowAll := True;
FChannelShowAllInLegend := True;
FMenuUserCanChangeOptions := True;
FMenuItemVisibleValueXY := True;
FMenuItemVisibleValueX := True;
FMenuItemVisibleValueY := True;
FMenuItemVisibleDeltaX := True;
FMenuItemVisibleDeltaY := True;
FMenuItemVisibleInverseDeltaX := True;
FMenuItemCaptionValueXY := 'Value X-Y';
FMenuItemCaptionValueX := 'Value X';
FMenuItemCaptionValueY := 'Value Y';
FMenuItemCaptionDeltaX := 'Period';
FMenuItemCaptionDeltaY := 'Peak-Peak';
FMenuItemCaptionInverseDeltaX := 'Frequency';
FFont := TFont.Create; FFont.OnChange := TriggerChange;
DoSetup;
end;
//****************************************************************************************************************************************************
destructor TiPlotDataCursor.Destroy;
begin
FFont.Free;
inherited;
end;
//****************************************************************************************************************************************************
function TiPlotDataCursor.GetChannel: TiPlotChannelCustom;
begin
if not Assigned(FChannel) then FChannel := (Owner as TiPlotComponent).GetChannelByName(ChannelName);
Result := FChannel;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataCursor.NotificationRemove(Sender: TObject);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -