📄 qiplotannotation.pas
字号:
{*******************************************************}
{ }
{ TiPlotAnnotation }
{ }
{ Copyright (c) 1997,2003 Iocomp Software }
{ }
{*******************************************************}
{$I iInclude.inc}
{$ifdef iVCL}unit iPlotAnnotation;{$endif}
{$ifdef iCLX}unit QiPlotAnnotation;{$endif}
interface
uses
{$I iIncludeUses.inc}
{$IFDEF iVCL} iTypes, iGPFunctions, iPlotObjects, iPlotDataView, iPlotChannelCustom, iPlotAxis, ImgList;{$ENDIF}
{$IFDEF iCLX}QiTypes, QiGPFunctions, QiPlotObjects, QiPlotDataView, QiPlotChannelCustom, QiPlotAxis, QImgList;{$ENDIF}
type
TiPlotReferenceType = (iprtDataView, iprtChannel, iprtXChannelYDataView, iprtXDataViewYChannel);
TiPlotAnnotationStyle = (ipasText, ipasLine, ipasRectangle, ipasLineX, ipasLineY, ipasImage, ipasTextRectangle, ipasEllipse, ipasTextBox);
TiPlotAnnotationSelectStyle = (ipassNone, ipassMove,ipassSizeTopLeft,ipassSizeTopRight,ipassSizeBottomLeft,ipassSizeBottomRight);
TiPlotAnnotation = class(TiPlotObject)
private
FStyle : TiPlotAnnotationStyle;
FReference : TiPlotReferenceType;
FSelectStyle : TiPlotAnnotationSelectStyle;
FSizeTopLeftRect : TRect;
FSizeTopRightRect : TRect;
FSizeBottomLeftRect : TRect;
FSizeBottomRightRect : TRect;
FX : Double;
FY : Double;
FY2 : Double;
FX2 : Double;
FWidth : Double;
FHeight : Double;
FPenColor : TColor;
FPenWidth : Integer;
FPenStyle : TPenStyle;
FBrushColor : TColor;
FBrushStyle : TBrushStyle;
FText : String;
FFont : TFont;
FChannelName : String;
FDataView : TiPlotDataView;
FChannel : TiPlotChannelCustom;
FTextRotation : TiRotationAngle;
FShowing : Boolean;
FDrawRect : TRect;
FClickRect : TRect;
FRectChange : Boolean;
FUserCanMove : Boolean;
FUserCanSize : Boolean;
FClipToAxes : Boolean;
FMouseDownXPos : Double;
FMouseDownYPos : Double;
FMouseDown : Boolean;
FMouseDownX : Integer;
FMouseDownY : Integer;
FMouseDownWidth : Double;
FMouseDownHeight : Double;
FMouseDownPositionPixelsX : Integer;
FMouseDownPositionPixelsY : Integer;
FMouseDownRect : TRect;
FImageListIndex : Integer;
FImageIndex : Integer;
FTextHorzAlignment : TiAlignmentHorizontal;
FTextVertAlignment : TiAlignmentVertical;
FTextHorzMargin : Double;
FTextVertMargin : Double;
FShowFocusRect : Boolean;
FMouseDownXValue : Double;
FMouseDownYValue : Double;
FMouseDownX2Value : Double;
FMouseDownY2Value : Double;
FOuterMargin : Integer;
function GetXMax: Integer;
function GetXMin: Integer;
function GetYMax: Integer;
function GetYMin: Integer;
protected
procedure SetBrushColor (const Value: TColor);
procedure SetBrushStyle (const Value: TBrushStyle);
procedure SetHeight (const Value: Double);
procedure SetReference (const Value: TiPlotReferenceType);
procedure SetPenColor (const Value: TColor);
procedure SetPenStyle (const Value: TPenStyle);
procedure SetPenWidth (const Value: Integer);
procedure SetStyle (const Value: TiPlotAnnotationStyle);
procedure SetWidth (const Value: Double);
procedure SetX (const Value: Double);
procedure SetY (const Value: Double);
procedure SetX2 (const Value: Double);
procedure SetY2 (const Value: Double);
procedure SetFont (const Value: TFont);
procedure SetText (const Value: String);
procedure SetChannelName (const Value: String);
procedure SetTextRotation (const Value: TiRotationAngle);
procedure SetUserCanMove (const Value: Boolean);
procedure SetUserCanSize (const Value: Boolean);
procedure SetClipToAxes (const Value: Boolean);
procedure SetImageListIndex (const Value: Integer);
procedure SetImageIndex (const Value: Integer);
procedure SetTextHorzAlignment(const Value: TiAlignmentHorizontal);
procedure SetTextVertAlignment(const Value: TiAlignmentVertical);
procedure SetTextHorzMargin (const Value: Double);
procedure SetTextVertMargin (const Value: Double);
procedure SetShowFocusRect (const Value: Boolean);
procedure SetOuterMargin (const Value: Integer);
procedure NotificationRemove (Sender: TObject); override;
procedure NotificationSetFocus(Sender: TObject); override;
procedure NotificationRename (Sender: TObject); override;
procedure DoMouseLeft(MouseData: TiPlotMouseData); override;
procedure DoMouseMove(MouseData: TiPlotMouseData); override;
procedure DoMouseUp (MouseData: TiPlotMouseData); override;
function GetChannel: TiPlotChannelCustom;
function GetMousePointer(APoint: TPoint): TCursor; override;
function iMouseHitTest(MouseData: TiPlotMouseData): Boolean; override;
procedure Draw (const Canvas: TCanvas; const BackGroundColor: TColor); override;
procedure SetupRectangle(ARect: TRect);
function MousePointToXPos(APoint: TPoint): Double;
function MousePointToYPos(APoint: TPoint): Double;
function IsMoveable: Boolean;
function IsSizeable: Boolean;
property DataView : TiPlotDataView read FDataView write FDataView;
property Channel : TiPlotChannelCustom read GetChannel;
public
constructor Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent); override;
destructor Destroy; override;
function PositionXToPixels (Value: Double ): Integer;
function PositionYToPixels (Value: Double ): Integer;
function PixelsXToPosition (Value: Integer): Double;
function PixelsYToPosition (Value: Integer): Double;
published
property Style : TiPlotAnnotationStyle read FStyle write SetStyle;
property Reference : TiPlotReferenceType read FReference write SetReference;
property X : Double read FX write SetX;
property Y : Double read FY write SetY;
property X2 : Double read FX2 write SetX2;
property Y2 : Double read FY2 write SetY2;
property Width : Double read FWidth write SetWidth;
property Height : Double read FHeight write SetHeight;
property PenColor : TColor read FPenColor write SetPenColor;
property PenStyle : TPenStyle read FPenStyle write SetPenStyle;
property PenWidth : Integer read FPenWidth write SetPenWidth;
property BrushColor : TColor read FBrushColor write SetBrushColor;
property BrushStyle : TBrushStyle read FBrushStyle write SetBrushStyle;
property Text : String read FText write SetText;
property TextRotation : TiRotationAngle read FTextRotation write SetTextRotation;
property TextHorzAlignment : TiAlignmentHorizontal read FTextHorzAlignment write SetTextHorzAlignment;
property TextVertAlignment : TiAlignmentVertical read FTextVertAlignment write SetTextVertAlignment;
property TextHorzMargin : Double read FTextHorzMargin write SetTextHorzMargin;
property TextVertMargin : Double read FTextVertMargin write SetTextVertMargin;
property Font : TFont read FFont write SetFont;
property OuterMargin : Integer read FOuterMargin write SetOuterMargin;
property ImageListIndex : Integer read FImageListIndex write SetImageListIndex;
property ImageIndex : Integer read FImageIndex write SetImageIndex;
property ChannelName : String read FChannelName write SetChannelName;
property UserCanMove : Boolean read FUserCanMove write SetUserCanMove;
property UserCanSize : Boolean read FUserCanSize write SetUserCanSize;
property ClipToAxes : Boolean read FClipToAxes write SetClipToAxes;
property ShowFocusRect : Boolean read FShowFocusRect write SetShowFocusRect;
end;
implementation
uses
{$ifdef iVCL} iPlotComponent;{$endif}
{$ifdef iCLX}QiPlotComponent;{$endif}
type
TiPlotChannelCustomAccess = class(TiPlotChannelCustom)end;
TiPlotAxisAccess = class(TiPlotAxis) end;
TiPlotComponentAccess = class(TiPlotComponent )end;
//****************************************************************************************************************************************************
constructor TiPlotAnnotation.Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent);
begin
inherited Create(AOwner, AOnChange, AOnInsert, AOnRemove, AOnRename);
FFont := TFont.Create;
Font.Name := 'Arial';
FFont.OnChange := TriggerChange;
FFont.Color := clWhite;
FTextHorzMargin := 1;
FTextVertMargin := 1;
FShowFocusRect := True;
FBrushColor := clWhite;
FPenColor := clWhite;
end;
//****************************************************************************************************************************************************
destructor TiPlotAnnotation.Destroy;
begin
FFont.Free;
inherited;
end;
//****************************************************************************************************************************************************
function TiPlotAnnotation.GetChannel: TiPlotChannelCustom;
begin
if not Assigned(FChannel) then FChannel := (Owner as TiPlotComponent).GetChannelByName(ChannelName);
Result := FChannel;
end;
//****************************************************************************************************************************************************
procedure TiPlotAnnotation.NotificationRemove(Sender: TObject);
begin
if Sender = FDataView then FDataView := nil;
if Sender = FChannel then FChannel := nil;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -