📄 teengine.pas
字号:
Procedure Assign(Source:TPersistent); override;
// (pending to move Centered to "published" after removing Axis.GridCentered)
property Centered:Boolean read FCentered write SetCentered default False;
published
property DrawEvery:Integer read FDrawEvery write SetDrawEvery default 1;
property ZPosition:Double read FZ write SetZ stored IsZStored;
end;
TAxisTicks=Array of Integer;
TChartAxis=class;
TAxisItems=class;
TAxisItem=class(TTeeCustomShape)
private
FValue : Double;
FText : String;
IAxisItems : TAxisItems;
procedure SetText(const Value: String);
procedure SetValue(const Value: Double);
public
procedure Repaint;
published
property Bevel;
property BevelWidth;
property Color;
property Font;
property Gradient;
property Picture;
property Shadow;
property ShapeStyle;
property Text:String read FText write SetText;
property Transparency;
property Transparent default True;
property Value:Double read FValue write SetValue;
end;
TAxisItems=class {$IFDEF CLR}sealed{$ENDIF} (TList)
private
FAuto : Boolean;
FFormat : TTeeShape;
IAxis : TChartAxis;
function Get(Index:Integer):TAxisItem;
public
Constructor Create(Axis:TChartAxis);
Destructor Destroy; override;
Function Add(const Value: Double):TAxisItem; overload;
Function Add(const Value: Double; const Text:String):TAxisItem; overload;
Procedure CopyFrom(Source:TAxisItems);
Procedure Clear; override;
property Automatic:Boolean read FAuto write FAuto default True;
property Format:TTeeShape read FFormat;
property Item[Index:Integer]:TAxisItem read Get; default;
end;
TPenLineMode=(lmLine, lmCylinder, lmRectangle);
TChartAxisPen=class {$IFDEF CLR}sealed{$ENDIF} (TChartPen)
private
FLineMode : TPenLineMode;
procedure SetLineMode(const Value:TPenLineMode);
public
Constructor Create(OnChangeEvent:TNotifyEvent);
published
property LineMode:TPenLineMode read FLineMode write SetLineMode default lmLine;
property Width default 2;
end;
TAxisDrawLabelEvent=procedure(Sender:TChartAxis; var X,Y,Z:Integer; var Text:String;
var DrawLabel:Boolean) of object;
// internal event, used at TGridBandTool class (only)
TAxisDrawGrids=procedure(Sender:TChartAxis) of object;
TChartAxis=class(TCollectionItem)
private
{ Scales }
FAutomatic : Boolean;
FAutomaticMaximum : Boolean;
FAutomaticMinimum : Boolean;
FDesiredIncrement : Double;
FMaximumValue : Double;
FMinimumValue : Double;
FLogarithmic : Boolean;
FLogarithmicBase : Double;
FMaximumOffset : Integer;
FMinimumOffset : Integer;
FMaximumRound : Boolean;
FMinimumRound : Boolean;
{ Axis }
FAxis : TChartAxisPen;
FPosAxis : Integer;
FZPosition : Double;
{ title }
FAxisTitle : TChartAxisTitle;
FTitleSize : Integer;
FPosTitle : Integer;
{ grid }
FGrid : TAxisGridPen;
{ labels }
FLabelsAlign : TAxisLabelAlign;
FLabelsAlternate : Boolean;
FLabelsAngle : Integer;
FItems : TAxisItems;
FLabelsOnAxis : Boolean;
FLabelsSeparation : Integer;
FLabelsSize : Integer;
FLabelStyle : TAxisLabelStyle;
FLabelsExponent : Boolean;
FLabelsMultiLine : Boolean;
FRoundFirstLabel : Boolean;
FPosLabels : Integer;
FAxisValuesFormat : String;
FDateTimeFormat : String;
FExactDateTime : Boolean;
{ ticks }
FMinorGrid : TChartHiddenPen;
FMinorTickCount : Integer;
FMinorTickLength : Integer;
FMinorTicks : TDarkGrayPen;
FTicks : TDarkGrayPen;
FTicksInner : TDarkGrayPen;
FTickInnerLength : Integer;
FTickLength : Integer;
FTickOnLabelsOnly : Boolean;
{ other }
FInverted : Boolean;
FHorizontal : Boolean;
FOtherSide : Boolean;
FParentChart : TCustomAxisPanel;
FVisible : Boolean;
FStartPosition : Double;
FEndPosition : Double;
FPositionPercent : Double;
FPosUnits : TTeeUnits;
// Events
FOnDrawLabel : TAxisDrawLabelEvent;
FMaster : TChartAxis;
{ internal }
IAxisDateTime : Boolean;
IAxisLogSizeRange : TChartValue;
IAxisSizeRange : TChartValue;
ICenterPos : Integer;
IDepthAxis : Boolean;
ILogMax : Double;
ILogMin : Double;
IMaximum : Double;
IMinimum : Double;
IRange : TChartValue;
IRangeLog : Double;
IRangeZero : Boolean;
ISeriesList : TCustomSeriesList;
IsVisible : Boolean;
IZPos : Integer;
Procedure CalcRoundScales;
Function DepthAxisAlign:Integer;
Function DepthAxisPos:Integer;
Function InflateAxisPos(Value:Integer; Amount:Integer):Integer;
Procedure InflateAxisRect(var R:TRect; const Value:Integer);
Function RoundLogPower(const Value:Double):Double;
Procedure SetAutomatic(Value:Boolean);
Procedure SetAutomaticMinimum(Value:Boolean);
Procedure SetAutomaticMaximum(Value:Boolean);
Procedure SetAutoMinMax(var Variable:Boolean; Var2,Value:Boolean);
Procedure SetAxis(Value:TChartAxisPen);
procedure SetAxisTitle(Value:TChartAxisTitle);
Procedure SetDateTimeFormat(Const Value:String);
Procedure SetDesiredIncrement(Const Value:Double);
Procedure SetExactDateTime(Value:Boolean);
Procedure SetGrid(Value:TAxisGridPen);
procedure SetGridCentered(Value:Boolean);
Procedure SetLabels(Value:Boolean);
Procedure SetLabelsAlign(Value:TAxisLabelAlign);
Procedure SetLabelsAlternate(Value:Boolean);
Procedure SetLabelsAngle(const Value:Integer);
Procedure SetLabelsFont(Value:TTeeFont);
Procedure SetLabelsMultiLine(Value:Boolean);
Procedure SetLabelsOnAxis(Value:Boolean);
Procedure SetLabelsSeparation(Value:Integer);
Procedure SetLabelsSize(Value:Integer);
Procedure SetLabelStyle(Value:TAxisLabelStyle);
Procedure SetLogarithmic(Value:Boolean);
Procedure SetLogarithmicBase(const Value:Double);
Procedure SetMaximum(Const Value:Double);
Procedure SetMinimum(Const Value:Double);
Procedure SetMaximumRound(Const Value:Boolean);
Procedure SetMinimumRound(Const Value:Boolean);
Procedure SetMinorGrid(Value:TChartHiddenPen);
Procedure SetMinorTickCount(Value:Integer);
Procedure SetMinorTickLength(Value:Integer);
Procedure SetMinorTicks(Value:TDarkGrayPen);
procedure SetStartPosition(Const Value:Double);
procedure SetEndPosition(Const Value:Double);
procedure SetPositionPercent(Const Value:Double);
procedure SetPosUnits(const Value: TTeeUnits);
procedure SetRoundFirstLabel(Value:Boolean);
Procedure SetTickLength(Value:Integer);
Procedure SetTickInnerLength(Value:Integer);
Procedure SetTicks(Value:TDarkGrayPen);
Procedure SetTicksInner(Value:TDarkGrayPen);
procedure SetTickOnLabelsOnly(Value:Boolean);
Procedure SetTitleSize(Value:Integer);
Procedure SetValuesFormat(Const Value:String);
Procedure SetVisible(Value:Boolean);
Function ApplyPosition(APos:Integer; Const R:TRect):Integer;
Function CalcDateTimeIncrement(MaxNumLabels:Integer):Double;
Function CalcLabelsIncrement(MaxNumLabels:Integer):Double;
Procedure CalcRect(var R:TRect; InflateChartRectangle:Boolean);
Function CalcZPos:Integer;
Procedure DrawGridLine(tmp:Integer);
Function GetGridCentered:Boolean;
Function GetLabels:Boolean;
Function GetLabelsFont:TTeeFont;
Function GetRectangleEdge(Const R:TRect):Integer;
Procedure IncDecDateTime( Increment:Boolean;
var Value:Double;
Const AnIncrement:Double;
tmpWhichDateTime:TDateTimeStep);
Function LogXPosValue(Const Value:TChartValue):Integer;
Function LogYPosValue(Const Value:TChartValue):Integer;
Function InternalCalcDepthPosValue(Const Value:TChartValue):Integer;
Procedure InternalCalcRange;
Procedure InternalCalcPositions;
Function InternalCalcSize( tmpFont:TTeeFont;
tmpAngle:Integer;
Const tmpText:String;
tmpSize:Integer):Integer;
Function InternalLabelSize(Const Value:Double; IsWidth:Boolean):Integer;
function IsAxisValuesFormatStored:Boolean;
function IsLogBaseStored: Boolean;
Function IsMaxStored:Boolean;
Function IsMinStored:Boolean;
Function IsPosStored:Boolean;
Function IsStartStored:Boolean;
Function IsEndStored:Boolean;
Function IsCustom:Boolean;
function IsZStored: Boolean;
Procedure RecalcSizeCenter;
procedure SetHorizontal(const Value: Boolean);
procedure SetOtherSide(const Value: Boolean);
procedure SetLabelsExponent(Value: Boolean);
Procedure SetCalcPosValue;
procedure SetMaximumOffset(const Value: Integer);
procedure SetMinimumOffset(const Value: Integer);
procedure SetZPosition(const Value: Double);
Function XPosValue(Const Value:TChartValue):Integer;
Function YPosValue(Const Value:TChartValue):Integer;
Function XPosValueCheck(Const Value:TChartValue):Integer;
Function YPosValueCheck(Const Value:TChartValue):Integer;
protected
IHideBackGrid : Boolean;
IHideSideGrid : Boolean;
OnDrawGrids : TAxisDrawGrids;
Function AxisRect:TRect;
Procedure DrawGrids(NumTicks:Integer);
Procedure DrawTitle(x,y:Integer);
Function InternalCalcLabelStyle:TAxisLabelStyle; virtual;
Procedure InternalSetInverted(Value:Boolean);
Procedure InternalSetMaximum(Const Value:Double);
Procedure InternalSetMinimum(Const Value:Double);
Procedure SetInverted(Value:Boolean); virtual;
Function SizeLabels:Integer;
Function SizeTickAxis:Integer;
public
IStartPos : Integer;
IEndPos : Integer;
IAxisSize : Integer;
CalcXPosValue : TAxisCalcPos;
CalcYPosValue : TAxisCalcPos;
CalcPosValue : TAxisCalcPos;
Tick : TAxisTicks;
{$IFDEF D5}
Constructor Create(Chart:TCustomAxisPanel); reintroduce; overload;
{$ENDIF}
Constructor Create(Collection:TCollection); {$IFDEF D5}overload;{$ENDIF} override;
Destructor Destroy; override;
Procedure AdjustMaxMin;
Procedure AdjustMaxMinRect(Const Rect:TRect);
procedure Assign(Source: TPersistent); override;
Function CalcIncrement:Double;
Function CalcLabelStyle:TAxisLabelStyle;
Procedure CalcMinMax(out AMin,AMax:Double);
Function CalcPosPoint(Value:Integer):Double;
Function CalcSizeValue(Const Value:Double):Integer;
Function CalcXYIncrement(MaxLabelSize:Integer):Double;
Procedure CustomDraw( APosLabels,APosTitle,APosAxis:Integer;
GridVisible:Boolean);
Procedure CustomDrawMinMax( APosLabels,
APosTitle,
APosAxis:Integer;
GridVisible:Boolean;
Const AMinimum,AMaximum,AIncrement:Double);
Procedure CustomDrawMinMaxStartEnd( APosLabels,
APosTitle,
APosAxis:Integer;
GridVisible:Boolean;
Const AMinimum,AMaximum,AIncrement:Double;
AStartPos,AEndPos:Integer);
Procedure CustomDrawStartEnd( APosLabels,APosTitle,APosAxis:Integer;
GridVisible:Boolean; AStartPos,AEndPos:Integer);
Function Clicked(x,y:Integer):Boolean;
Procedure Draw(CalcPosAxis:Boolean);
procedure DrawAxisLabel(x,y,Angle:Integer; Const St:String; Format:TTeeCustomShape=nil;
z:Integer=0);
Function IsDateTime:Boolean;
Function LabelWidth(Const Value:Double):Integer;
Function LabelHeight(Const Value:Double):Integer;
Function LabelValue(Const Value:Double):String; virtual;
Function MaxLabelsWidth:Integer;
Procedure Scroll(Const Offset:Double; CheckLimits:Boolean=False);
Procedure SetMinMax(AMin,AMax:Double);
{ public }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -