mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 04:36:31 +02:00
TAChart: Add TChartAxis.Arrow property
git-svn-id: trunk@31726 -
This commit is contained in:
parent
7e525bd5f0
commit
0566afca02
@ -143,6 +143,7 @@ type
|
|||||||
AClipRect: PRect; AMaxZPosition: Integer);
|
AClipRect: PRect; AMaxZPosition: Integer);
|
||||||
published
|
published
|
||||||
property Alignment default calLeft;
|
property Alignment default calLeft;
|
||||||
|
property Arrow;
|
||||||
property AxisPen: TChartAxisPen read FAxisPen write SetAxisPen;
|
property AxisPen: TChartAxisPen read FAxisPen write SetAxisPen;
|
||||||
property Group: Integer read FGroup write SetGroup default 0;
|
property Group: Integer read FGroup write SetGroup default 0;
|
||||||
// Inverts the axis scale from increasing to decreasing.
|
// Inverts the axis scale from increasing to decreasing.
|
||||||
@ -400,10 +401,7 @@ begin
|
|||||||
fixedCoord := TChartAxisMargins(FAxisRect)[Alignment];
|
fixedCoord := TChartAxisMargins(FAxisRect)[Alignment];
|
||||||
v := 0;
|
v := 0;
|
||||||
FHelper.BeginDrawing;
|
FHelper.BeginDrawing;
|
||||||
if AxisPen.Visible then begin;
|
FHelper.DrawAxisLine(AxisPen, fixedCoord);
|
||||||
FHelper.FDrawer.Pen := AxisPen;
|
|
||||||
FHelper.DrawAxisLine(fixedCoord);
|
|
||||||
end;
|
|
||||||
axisTransf := @GetTransform.AxisToGraph;
|
axisTransf := @GetTransform.AxisToGraph;
|
||||||
for i := 0 to High(FMarkValues) do begin
|
for i := 0 to High(FMarkValues) do begin
|
||||||
pv := v;
|
pv := v;
|
||||||
@ -575,6 +573,10 @@ begin
|
|||||||
FLastMark := Max(FirstLastSize(i) - rmax + c, FLastMark);
|
FLastMark := Max(FirstLastSize(i) - rmax + c, FLastMark);
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
|
if Arrow.Visible then begin
|
||||||
|
FSize := Max(FHelper.FDrawer.Scale(Arrow.Width), FSize);
|
||||||
|
FLastMark := Max(FHelper.FDrawer.Scale(Arrow.Length), FLastMark);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -124,11 +124,13 @@ type
|
|||||||
|
|
||||||
TChartBasicAxis = class(TCollectionItem)
|
TChartBasicAxis = class(TCollectionItem)
|
||||||
strict private
|
strict private
|
||||||
|
FArrow: TChartArrow;
|
||||||
FGrid: TChartAxisGridPen;
|
FGrid: TChartAxisGridPen;
|
||||||
FMarks: TChartAxisMarks;
|
FMarks: TChartAxisMarks;
|
||||||
FTickColor: TColor;
|
FTickColor: TColor;
|
||||||
FTickLength: Integer;
|
FTickLength: Integer;
|
||||||
FVisible: Boolean;
|
FVisible: Boolean;
|
||||||
|
procedure SetArrow(AValue: TChartArrow);
|
||||||
procedure SetGrid(AValue: TChartAxisGridPen);
|
procedure SetGrid(AValue: TChartAxisGridPen);
|
||||||
procedure SetMarks(AValue: TChartAxisMarks);
|
procedure SetMarks(AValue: TChartAxisMarks);
|
||||||
procedure SetTickColor(AValue: TColor);
|
procedure SetTickColor(AValue: TColor);
|
||||||
@ -145,8 +147,10 @@ type
|
|||||||
procedure Assign(ASource: TPersistent); override;
|
procedure Assign(ASource: TPersistent); override;
|
||||||
function TryApplyStripes(
|
function TryApplyStripes(
|
||||||
ADrawer: IChartDrawer; var AIndex: Cardinal): Boolean;
|
ADrawer: IChartDrawer; var AIndex: Cardinal): Boolean;
|
||||||
|
|
||||||
property Alignment: TChartAxisAlignment
|
property Alignment: TChartAxisAlignment
|
||||||
read GetAlignment write SetAlignment;
|
read GetAlignment write SetAlignment;
|
||||||
|
property Arrow: TChartArrow read FArrow write SetArrow;
|
||||||
property Marks: TChartAxisMarks read FMarks write SetMarks;
|
property Marks: TChartAxisMarks read FMarks write SetMarks;
|
||||||
published
|
published
|
||||||
property Grid: TChartAxisGridPen read FGrid write SetGrid;
|
property Grid: TChartAxisGridPen read FGrid write SetGrid;
|
||||||
@ -160,6 +164,8 @@ type
|
|||||||
TAxisDrawHelper = class
|
TAxisDrawHelper = class
|
||||||
strict protected
|
strict protected
|
||||||
procedure BarZ(AX1, AY1, AX2, AY2: Integer); inline;
|
procedure BarZ(AX1, AY1, AX2, AY2: Integer); inline;
|
||||||
|
procedure InternalAxisLine(
|
||||||
|
APen: TChartPen; const AStart, AEnd: TPoint; AAngle: Double);
|
||||||
procedure DrawLabel(ALabelCenter: TPoint; const AText: String); inline;
|
procedure DrawLabel(ALabelCenter: TPoint; const AText: String); inline;
|
||||||
procedure DrawLabelAndTick(
|
procedure DrawLabelAndTick(
|
||||||
ACoord, AFixedCoord: Integer; const AText: String); virtual; abstract;
|
ACoord, AFixedCoord: Integer; const AText: String); virtual; abstract;
|
||||||
@ -181,7 +187,8 @@ type
|
|||||||
procedure BeginDrawing; virtual;
|
procedure BeginDrawing; virtual;
|
||||||
function Clone: TAxisDrawHelper;
|
function Clone: TAxisDrawHelper;
|
||||||
constructor Create; virtual;
|
constructor Create; virtual;
|
||||||
procedure DrawAxisLine(AFixedCoord: Integer); virtual; abstract;
|
procedure DrawAxisLine(
|
||||||
|
APen: TChartPen; AFixedCoord: Integer); virtual; abstract;
|
||||||
procedure DrawMark(
|
procedure DrawMark(
|
||||||
AFixedCoord: Integer; AMark: Double; const AText: String);
|
AFixedCoord: Integer; AMark: Double; const AText: String);
|
||||||
procedure EndDrawing; virtual; abstract;
|
procedure EndDrawing; virtual; abstract;
|
||||||
@ -200,7 +207,7 @@ type
|
|||||||
procedure GridLine(ACoord: Integer); override;
|
procedure GridLine(ACoord: Integer); override;
|
||||||
public
|
public
|
||||||
procedure BeginDrawing; override;
|
procedure BeginDrawing; override;
|
||||||
procedure DrawAxisLine(AFixedCoord: Integer); override;
|
procedure DrawAxisLine(APen: TChartPen; AFixedCoord: Integer); override;
|
||||||
procedure EndDrawing; override;
|
procedure EndDrawing; override;
|
||||||
procedure GetClipRange(out AMin, AMax: Integer); override;
|
procedure GetClipRange(out AMin, AMax: Integer); override;
|
||||||
function GraphToImage(AGraph: Double): Integer; override;
|
function GraphToImage(AGraph: Double): Integer; override;
|
||||||
@ -215,7 +222,7 @@ type
|
|||||||
procedure GridLine(ACoord: Integer); override;
|
procedure GridLine(ACoord: Integer); override;
|
||||||
public
|
public
|
||||||
procedure BeginDrawing; override;
|
procedure BeginDrawing; override;
|
||||||
procedure DrawAxisLine(AFixedCoord: Integer); override;
|
procedure DrawAxisLine(APen: TChartPen; AFixedCoord: Integer); override;
|
||||||
procedure EndDrawing; override;
|
procedure EndDrawing; override;
|
||||||
procedure GetClipRange(out AMin, AMax: Integer); override;
|
procedure GetClipRange(out AMin, AMax: Integer); override;
|
||||||
function GraphToImage(AGraph: Double): Integer; override;
|
function GraphToImage(AGraph: Double): Integer; override;
|
||||||
@ -283,6 +290,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TAxisDrawHelper.InternalAxisLine(
|
||||||
|
APen: TChartPen; const AStart, AEnd: TPoint; AAngle: Double);
|
||||||
|
begin
|
||||||
|
if not APen.Visible and not FAxis.Arrow.Visible then exit;
|
||||||
|
FDrawer.Pen := APen;
|
||||||
|
if APen.Visible then
|
||||||
|
LineZ(Astart, AEnd);
|
||||||
|
if FAxis.Arrow.Visible then
|
||||||
|
FAxis.Arrow.Draw(FDrawer, AEnd + FZOffset, AAngle);
|
||||||
|
end;
|
||||||
|
|
||||||
function TAxisDrawHelper.IsInClipRange(ACoord: Integer): Boolean;
|
function TAxisDrawHelper.IsInClipRange(ACoord: Integer): Boolean;
|
||||||
var
|
var
|
||||||
rmin, rmax: Integer;
|
rmin, rmax: Integer;
|
||||||
@ -309,10 +327,14 @@ begin
|
|||||||
FPrevCoord := FClipRect^.Left;
|
FPrevCoord := FClipRect^.Left;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TAxisDrawHelperX.DrawAxisLine(AFixedCoord: Integer);
|
procedure TAxisDrawHelperX.DrawAxisLine(APen: TChartPen; AFixedCoord: Integer);
|
||||||
|
var
|
||||||
|
p: TPoint;
|
||||||
begin
|
begin
|
||||||
LineZ(
|
p := Point(FClipRect^.Right, AFixedCoord);
|
||||||
Point(FClipRect^.Left, AFixedCoord), Point(FClipRect^.Right, AFixedCoord));
|
if FAxis.Arrow.Visible then
|
||||||
|
p.X += FDrawer.Scale(FAxis.Arrow.Length);
|
||||||
|
InternalAxisLine(APen, Point(FClipRect^.Left, AFixedCoord), p, 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TAxisDrawHelperX.DrawLabelAndTick(
|
procedure TAxisDrawHelperX.DrawLabelAndTick(
|
||||||
@ -361,10 +383,14 @@ begin
|
|||||||
FPrevCoord := FClipRect^.Bottom;
|
FPrevCoord := FClipRect^.Bottom;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TAxisDrawHelperY.DrawAxisLine(AFixedCoord: Integer);
|
procedure TAxisDrawHelperY.DrawAxisLine(APen: TChartPen; AFixedCoord: Integer);
|
||||||
|
var
|
||||||
|
p: TPoint;
|
||||||
begin
|
begin
|
||||||
LineZ(
|
p := Point(AFixedCoord, FClipRect^.Top);
|
||||||
Point(AFixedCoord, FClipRect^.Top), Point(AFixedCoord, FClipRect^.Bottom));
|
if FAxis.Arrow.Visible then
|
||||||
|
p.Y -= FDrawer.Scale(FAxis.Arrow.Length);
|
||||||
|
InternalAxisLine(APen, Point(AFixedCoord, FClipRect^.Bottom), p, -Pi / 2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TAxisDrawHelperY.DrawLabelAndTick(
|
procedure TAxisDrawHelperY.DrawLabelAndTick(
|
||||||
@ -523,6 +549,7 @@ constructor TChartBasicAxis.Create(
|
|||||||
ACollection: TCollection; AChart: TCustomChart);
|
ACollection: TCollection; AChart: TCustomChart);
|
||||||
begin
|
begin
|
||||||
inherited Create(ACollection);
|
inherited Create(ACollection);
|
||||||
|
FArrow := TChartArrow.Create(AChart);
|
||||||
FGrid := TChartAxisGridPen.Create;
|
FGrid := TChartAxisGridPen.Create;
|
||||||
FGrid.OnChange := @StyleChanged;
|
FGrid.OnChange := @StyleChanged;
|
||||||
FGrid.Style := psDot;
|
FGrid.Style := psDot;
|
||||||
@ -533,11 +560,18 @@ end;
|
|||||||
|
|
||||||
destructor TChartBasicAxis.Destroy;
|
destructor TChartBasicAxis.Destroy;
|
||||||
begin
|
begin
|
||||||
|
FreeAndNil(FArrow);
|
||||||
FreeAndNil(FGrid);
|
FreeAndNil(FGrid);
|
||||||
FreeAndNil(FMarks);
|
FreeAndNil(FMarks);
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TChartBasicAxis.SetArrow(AValue: TChartArrow);
|
||||||
|
begin
|
||||||
|
FArrow.Assign(AValue);
|
||||||
|
StyleChanged(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TChartBasicAxis.SetGrid(AValue: TChartAxisGridPen);
|
procedure TChartBasicAxis.SetGrid(AValue: TChartAxisGridPen);
|
||||||
begin
|
begin
|
||||||
FGrid.Assign(AValue);
|
FGrid.Assign(AValue);
|
||||||
|
@ -1012,7 +1012,7 @@ var
|
|||||||
begin
|
begin
|
||||||
if not Visible then exit;
|
if not Visible then exit;
|
||||||
da := ArcTan2(ADrawer.Scale(Width), ADrawer.Scale(Length));
|
da := ArcTan2(ADrawer.Scale(Width), ADrawer.Scale(Length));
|
||||||
pt := Point(-ADrawer.Scale(Length), 0);
|
pt := Point(-ADrawer.Scale(Round(Sqrt(Sqr(Length) + Sqr(Width)))), 0);
|
||||||
ADrawer.Polyline([
|
ADrawer.Polyline([
|
||||||
AEndPos + RotatePoint(pt, AAngle - da), AEndPos,
|
AEndPos + RotatePoint(pt, AAngle - da), AEndPos,
|
||||||
AEndPos + RotatePoint(pt, AAngle + da)], 0, 3);
|
AEndPos + RotatePoint(pt, AAngle + da)], 0, 3);
|
||||||
|
Loading…
Reference in New Issue
Block a user