📄 qiplotaxis.pas
字号:
procedure WriteSpan (Writer: TWriter);
procedure ReadSpan (Reader: TReader);
procedure WriteLabelSeperation(Writer: TWriter);
procedure ReadLabelSeperation (Reader: TReader);
procedure WriteTitleMargin (Writer: TWriter);
procedure ReadTitleMargin (Reader: TReader);
procedure NotificationSetFocus(Sender: TObject); override;
procedure NotificationRemove (Sender: TObject); override;
procedure NotificationRename (Sender: TObject); override;
procedure TrackingEnabledMenuItemClick (Sender : TObject);
procedure UpdateResumeValuesMenuItemClick(Sender : TObject);
procedure ZoomToFitClick (Sender : TObject);
procedure CalcTicks (const Canvas: TCanvas);
procedure CalcTickPixels;
procedure ClearTickList;
procedure CalcScaleRect (const Canvas: TCanvas);
procedure CalcLinearTicks (const Canvas: TCanvas; MaxMajorTicks: Integer; var MajorCount: Integer; var MajorStepValue: Double);
procedure CalcPrice32Ticks (const Canvas: TCanvas; MaxMajorTicks: Integer; var MajorCount: Integer; var MajorStepValue: Double);
procedure CalcDateTimeTicks(const Canvas: TCanvas; MaxMajorTicks: Integer; var MajorCount: Integer; var MajorStepValue: Double);
procedure CalcLog10Ticks (const Canvas: TCanvas; MaxMajorTicks: Integer);
procedure AddTick(Value : Double; Style : TiPlotTickType);
function GetSpanLength : Integer;
function GetMousePointer(APoint: TPoint) : TCursor; override;
function GetActualMode : TiPlotAxisMode;
function PointOnScale(Value : Double) : Boolean;
procedure Draw (const Canvas: TCanvas; const BackGroundColor: TColor); override;
procedure DrawSetup (const Canvas: TCanvas); override;
procedure DrawLines (const Canvas: TCanvas; const BackGroundColor: TColor);
procedure DrawScaleLine (Canvas: TCanvas);
procedure DrawTitle (Canvas: TCanvas);
procedure DrawScaleMajorTick(Canvas: TCanvas; iPlotTickObject: TiPlotTickObject);
procedure DrawScaleMinorTick(Canvas: TCanvas; iPlotTickObject: TiPlotTickObject);
procedure DrawScaleTick (Canvas: TCanvas; PositionPixels, StartOffset, StopOffset: Integer);
procedure DrawScaleLabel (Canvas: TCanvas; iPlotTickObject: TiPlotTickObject);
procedure DrawGridLines (Canvas: TCanvas; ARect: TRect; ShowMajors, ShowMinors : Boolean; MajorStyle, MinorStyle : TiPlotGridLineStyle;
MajorColor, MinorColor: TColor; MajorWidth, MinorWidth: Integer);
procedure AddMenuItems(PopupMenu: TPopUpMenu); override;
procedure DoMouseHint(MouseData: TiPlotMouseData; var HintData: TiHintData); override;
procedure DoMouseLeft(MouseData: TiPlotMouseData); override;
procedure DoMouseMove(MouseData: TiPlotMouseData); override;
procedure DoMouseUp (MouseData: TiPlotMouseData); override;
procedure iKeyDown (var CharCode: Word; Shift: TShiftState); override;
function iMouseWheel(WheelDelta: Integer;Shift: TShiftState; const MousePos: TPoint): Boolean; override;
function iMouseHitTest(MouseData: TiPlotMouseData): Boolean; override;
function GetRequiredWidth (const Canvas: TCanvas): Integer; override;
function GetRequiredLengthGaurd (const Canvas: TCanvas): Integer; override;
function GetRequiredLabelLength (const Canvas: TCanvas; AFont: TFont): Integer;
function GetRequiredLegendLength(const Canvas: TCanvas; AFont: TFont): Integer;
function GetRequiredCursorLength(const Canvas: TCanvas; AFont: TFont): Integer;
function PixelsToPositionDouble(Value: Double): Double;
procedure ZoomRect (ARect : TRect);
procedure ScrollPercentByReference(RefMin, RefSpan, RefMax, Percent: Double);
procedure ZoomPercentByReference (RefMin, RefSpan, RefMax, Percent: Double);
property ScaleRect : TRect read FScaleRect;
property FocusRect : TRect read FFocusRect;
property CartesianRefAxis : TiPlotAxis read GetCartesianRefAxis;
property AlignRefAxis : TiPlotAxis read GetAlignRefAxis;
property TickObject[Index: Integer] : TiPlotTickObject read GetTickObject;
function GetText (const Value: Double; const FormatStyle: TiPlotTextFormat; const DateTimeFormat: String; const PrecisionStyle: TiPrecisionStyle;
const Precision: Integer; const MinLengthAutoAdjust: Boolean; var MinLength: Double): String;
public
constructor Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent); override;
destructor Destroy; override;
function GetLabelText (const Value: Double): String;
function GetCursorText (const Value: Double): String;
function GetCursorValueText(const Value: Double): String;
function GetLegendText (const Value: Double): String;
procedure SetMinSpan(NewMin, NewSpan: Double);
procedure NewTrackingData(Value: Double);
procedure ResetFirstAlign;
procedure UpdateResumeValues;
procedure Zoom(Value : Double);
procedure ZoomToFit;
procedure ZoomToFitFast;
procedure TickListClear;
function TickListAdd(Position: Double; ALabel: String; Style : TiPlotTickType): Integer;
property TickListCustom : Boolean read FTickListCustom write SetTickListCustom;
property TickListCount : Integer read GetTickListCount;
property TickListItemLabel [Index: Integer] : String read GetTickListItemLabel write SetTickListItemLabel;
property TickListItemPosition[Index: Integer] : Double read GetTickListItemPosition write SetTickListItemPosition;
property TickListItemStyle [Index: Integer] : TiPlotTickType read GetTickListItemStyle write SetTickListItemStyle;
function PositionToPixels (const Value: Double ): Integer;
function WidthToPixels (const Value: Double ): Integer;
function PixelsToPosition (const Value: Integer): Double;
function PercentToPosition(const Value: Double) : Double;
function PositionToPercent(const Value: Double) : Double;
function ValueOnScale (const Value: Double ): Boolean;
property MinPixels : Integer read GetMinPixels;
property MaxPixels : Integer read GetMaxPixels;
property Mode : TiPlotAxisMode read FMode write SetMode;
property Max : Double read GetMax;
published
property Min : Double read FMin write SetMin;
property Span : Double read FSpan write SetSpan;
property DesiredStart : Double read FDesiredStart write SetDesiredStart;
property DesiredIncrement : Double read FDesiredIncrement write SetDesiredIncrement;
property ReverseScale : Boolean read FReverseScale write SetReverseScale default False;
property InnerMargin : Integer read FInnerMargin write SetInnerMargin default 5;
property OuterMargin : Integer read FOuterMargin write SetOuterMargin default 5;
property Title : String read FTitle write SetTitle;
property TitleMargin : Double read FTitleMargin write SetTitleMargin;
property TitleFont : TFont read FTitleFont write SetTitleFont;
property TitleShow : Boolean read FTitleShow write SetTitleShow default False;
property TitleRotated : Boolean read FTitleRotated write SetTitleRotated default False;
property MajorLength : Integer read FMajorLength write SetMajorLength default 7;
property MinorLength : Integer read FMinorLength write SetMinorLength default 3;
property MinorCount : Integer read FMinorCount write SetMinorCount default 1;
property LabelsVisible : Boolean read FLabelsVisible write SetLabelsVisible default True;
property LabelsMargin : Double read FLabelsMargin write SetLabelsMargin;
property LabelsFont : TFont read FLabelsFont write SetLabelsFont;
property LabelSeparation : Double read FLabelSeparation write SetLabelSeparation;
property LabelsRotation : TiRotationAngle read FLabelsRotation write SetLabelsRotation;
property LabelsPrecision : Integer read FLabelsPrecision write SetLabelsPrecision default 3;
property LabelsPrecisionStyle : TiPrecisionStyle read FLabelsPrecisionStyle write SetLabelsPrecisionStyle default ipsSignificantDigits;
property LabelsFormatStyle : TiPlotTextFormat read FLabelsFormatStyle write SetLabelsFormatStyle default iptfValue;
property DateTimeFormat : String read FDateTimeFormat write SetDateTimeFormat;
property LabelsMinLength : Double read FLabelsMinLength write SetLabelsMinLength;
property LabelsMinLengthAutoAdjust : Boolean read FLabelsMinLengthAutoAdjust write SetLabelsMinLengthAutoAdjust default False;
property ScaleLineShow : Boolean read FScaleLineShow write SetScaleLineShow;
property ScaleLinesShow : Boolean read FScaleLinesShow write SetScaleLinesShow default True;
property ScaleLinesColor : TColor read FScaleLinesColor write SetScaleLinesColor default clWhite;
property StackingEndsMargin : Double read FStackingEndsMargin write SetStackingEndsMargin;
property ScaleType : TiPlotScaleType read FScaleType write SetScaleType default ipstLinear;
property TrackingEnabled : Boolean read FTrackingEnabled write SetTrackingEnabled default True;
property TrackingStyle : TiPlotTrackingStyle read FTrackingStyle write SetTrackingStyle;
property TrackingAlignFirstStyle : TiPlotAlignFirstStyle read FTrackingAlignFirstStyle write SetTrackingAlignFirstStyle default ipafsMin;
property TrackingScrollCompressMax : Double read FTrackingScrollCompressMax write SetTrackingScrollCompressMax;
property CursorUseDefaultFormat : Boolean read FCursorUseDefaultFormat write SetCursorUseDefaultFormat default True;
property CursorFormatStyle : TiPlotTextFormat read FCursorFormatStyle write SetCursorFormatStyle default iptfValue;
property CursorDateTimeFormat : String read FCursorDateTimeFormat write SetCursorDateTimeFormat;
property CursorPrecisionStyle : TiPrecisionStyle read FCursorPrecisionStyle write SetCursorPrecisionStyle default ipsSignificantDigits;
property CursorPrecision : Integer read FCursorPrecision write SetCursorPrecision;
property CursorMinLength : Double read FCursorMinLength write SetCursorMinLength;
property CursorMinLengthAutoAdjust : Boolean read FCursorMinLengthAutoAdjust write SetCursorMinLengthAutoAdjust default False;
property LegendUseDefaultFormat : Boolean read FLegendUseDefaultFormat write SetLegendUseDefaultFormat default True;
property LegendFormatStyle : TiPlotTextFormat read FLegendFormatStyle write SetLegendFormatStyle default iptfValue;
property LegendDateTimeFormat : String read FLegendDateTimeFormat write SetLegendDateTimeFormat;
property LegendPrecisionStyle : TiPrecisionStyle read FLegendPrecisionStyle write SetLegendPrecisionStyle default ipsSignificantDigits;
property LegendPrecision : Integer read FLegendPrecision write SetLegendPrecision;
property LegendMinLength : Double read FLegendMinLength write SetLegendMinLength;
property LegendMinLengthAutoAdjust : Boolean read FLegendMinLengthAutoAdjust write SetLegendMinLengthAutoAdjust default False;
property CursorScaler : Double read FCursorScaler write SetCursorScaler;
property ScrollMinMaxEnabled : Boolean read FScrollMinMaxEnabled write SetScrollMinMaxEnabled;
property ScrollMax : Double read FScrollMax write SetScrollMax;
property ScrollMin : Double read FScrollMin write SetScrollMin;
property RestoreValuesOnResume : Boolean read FRestoreValuesOnResume write SetRestoreValuesOnResume;
property MasterUIInput : Boolean read FMasterUIInput write SetMasterUIInput;
property CartesianStyle : TiPlotCartesianStyle read FCartesianStyle write SetCartesianStyle;
property CartesianChildRefAxisName : String read FCartesianChildRefAxisName write SetCartesianChildRefAxisName;
property CartesianChildRefValue : Double read FCartesianChildRefValue write SetCartesianChildRefValue;
property AlignRefAxisName : String read FAlignRefAxisName write SetAlignRefAxisName;
property GridLinesVisible : Boolean read FGridLinesVisible write SetGridLinesVisible;
property ForceStacking;
end;
TiPlotXAxis = class(TiPlotAxis)
public
constructor Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent); override;
end;
TiPlotYAxis = class(TiPlotAxis)
public
constructor Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent); override;
end;
implementation
uses
{$ifdef iVCL} iPlotChannelCustom, iPlotDataView, iPlotLimit, iPlot, iXYPlot, iPlotManagers, iPlotComponent;{$endif}
{$ifdef iCLX}QiPlotChannelCustom, QiPlotDataView, QiPlotLimit, QiPlot, QiXYPlot, QiPlotManagers, QiPlotComponent;{$endif}
type
TiPlotChannelCustomAccess = class(TiPlotChannelCustom)end;
TiPlotDataViewAccess = class(TiPlotDataView )end;
TiPlotLimitAccess = class(TiPlotLimit )end;
TiPlotComponentAccess = class(TiPlotComponent )end;
//****************************************************************************************************************************************************
constructor TiPlotXAxis.Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent);
begin
inherited Create(AOwner, AOnChange, AOnInsert, AOnRemove, AOnRename);
if AOwner is TiPlot then
TrackingStyle := iptsScrollSmooth
else
TrackingStyle := iptsScaleMinMax;
TrackingAlignFirstStyle := ipafsAuto;
end;
//****************************************************************************************************************************************************
constructor TiPlotYAxis.Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent);
begin
inherited Create(AOwner, AOnChange, AOnInsert, AOnRemove, AOnRename);
TrackingStyle := iptsScaleMinMax;
TrackingAlignFirstStyle := ipafsNone;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -