mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 04:16:06 +02:00
TAChart: Initial implementation of TAggPasDrawer
git-svn-id: trunk@29620 -
This commit is contained in:
parent
0de01bb828
commit
7eff0c879b
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -2385,6 +2385,7 @@ components/tachart/tachartutils.pas svneol=native#text/plain
|
||||
components/tachart/tacustomseries.pas svneol=native#text/plain
|
||||
components/tachart/tacustomsource.pas svneol=native#text/pascal
|
||||
components/tachart/tadbsource.pas svneol=native#text/pascal
|
||||
components/tachart/tadraweraggpas.pas svneol=native#text/pascal
|
||||
components/tachart/tadrawutils.pas svneol=native#text/pascal
|
||||
components/tachart/tafuncseries.pas svneol=native#text/pascal
|
||||
components/tachart/tagraph.lrs svneol=native#text/pascal
|
||||
|
205
components/tachart/tadraweraggpas.pas
Normal file
205
components/tachart/tadraweraggpas.pas
Normal file
@ -0,0 +1,205 @@
|
||||
unit TADrawerAggPas;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FPCanvas, Graphics, Agg_LCL, TADrawUtils;
|
||||
|
||||
type
|
||||
|
||||
{ TAggPasDrawer }
|
||||
|
||||
TAggPasDrawer = class(TFPCanvasDrawer, IChartDrawer, ISimpleTextOut)
|
||||
strict private
|
||||
FCanvas: TAggLCLCanvas;
|
||||
procedure SetBrush(ABrush: TFPCustomBrush);
|
||||
procedure SetFont(AFont: TFPCustomFont);
|
||||
procedure SetPen(APen: TFPCustomPen);
|
||||
strict protected
|
||||
function GetFontAngle: Double; override;
|
||||
procedure SimpleTextOut(AX, AY: Integer; const AText: String); override;
|
||||
function SimpleTextExtent(const AText: String): TPoint; override;
|
||||
public
|
||||
constructor Create(ACanvas: TAggLCLCanvas);
|
||||
public
|
||||
procedure AddToFontOrientation(ADelta: Integer);
|
||||
procedure ClippingStart;
|
||||
procedure ClippingStart(const AClipRect: TRect);
|
||||
procedure ClippingStop;
|
||||
procedure FillRect(AX1, AY1, AX2, AY2: Integer);
|
||||
function GetCanvas: TCanvas;
|
||||
function HasCanvas: Boolean;
|
||||
procedure Line(AX1, AY1, AX2, AY2: Integer);
|
||||
procedure Line(const AP1, AP2: TPoint);
|
||||
procedure Polygon(const APoints: array of TPoint);
|
||||
procedure PrepareSimplePen(AColor: TChartColor);
|
||||
procedure RadialPie(
|
||||
AX1, AY1, AX2, AY2: Integer;
|
||||
AStartAngle16Deg, AAngleLength16Deg: Integer);
|
||||
procedure Rectangle(const ARect: TRect);
|
||||
procedure Rectangle(AX1, AY1, AX2, AY2: Integer);
|
||||
procedure SetBrushParams(AStyle: TFPBrushStyle; AColor: TChartColor);
|
||||
procedure SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
TAChartUtils;
|
||||
|
||||
{ TAggPasDrawer }
|
||||
|
||||
procedure TAggPasDrawer.AddToFontOrientation(ADelta: Integer);
|
||||
begin
|
||||
with FCanvas.Font do
|
||||
AggAngle := AggAngle + OrientToRad(ADelta);
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.ClippingStart(const AClipRect: TRect);
|
||||
begin
|
||||
FCanvas.ClipRect := AClipRect;
|
||||
FCanvas.Clipping := true;
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.ClippingStart;
|
||||
begin
|
||||
FCanvas.Clipping := true;
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.ClippingStop;
|
||||
begin
|
||||
FCanvas.Clipping := false;
|
||||
end;
|
||||
|
||||
constructor TAggPasDrawer.Create(ACanvas: TAggLCLCanvas);
|
||||
begin
|
||||
FCanvas := ACanvas;
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.FillRect(AX1, AY1, AX2, AY2: Integer);
|
||||
begin
|
||||
FCanvas.FillRect(AX1, AY1, AX2, AY2);
|
||||
end;
|
||||
|
||||
function TAggPasDrawer.GetCanvas: TCanvas;
|
||||
begin
|
||||
raise Exception.Create('TAggPasDrawer.GetCanvas');
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TAggPasDrawer.GetFontAngle: Double;
|
||||
begin
|
||||
Result := FCanvas.Font.AggAngle;
|
||||
end;
|
||||
|
||||
function TAggPasDrawer.HasCanvas: Boolean;
|
||||
begin
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.Line(AX1, AY1, AX2, AY2: Integer);
|
||||
begin
|
||||
FCanvas.Line(AX1, AY1, AX2, AY2);
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.Line(const AP1, AP2: TPoint);
|
||||
begin
|
||||
FCanvas.Line(AP1, AP2);
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.Polygon(const APoints: array of TPoint);
|
||||
begin
|
||||
FCanvas.Polygon(APoints, Length(APoints));
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.PrepareSimplePen(AColor: TChartColor);
|
||||
begin
|
||||
with FCanvas.Pen do begin
|
||||
Color := AColor;
|
||||
Style := psSolid;
|
||||
Mode := pmCopy;
|
||||
Width := 1;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.RadialPie(
|
||||
AX1, AY1, AX2, AY2: Integer;
|
||||
AStartAngle16Deg, AAngleLength16Deg: Integer);
|
||||
begin
|
||||
FCanvas.RadialPie(
|
||||
AX1, AY1, AX2, AY2, AStartAngle16Deg, AAngleLength16Deg);
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.Rectangle(AX1, AY1, AX2, AY2: Integer);
|
||||
begin
|
||||
FCanvas.Rectangle(AX1, AY1, AX2, AY2);
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.Rectangle(const ARect: TRect);
|
||||
begin
|
||||
FCanvas.Rectangle(ARect);
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.SetBrush(ABrush: TFPCustomBrush);
|
||||
begin
|
||||
with FCanvas.Brush do begin
|
||||
Style := ABrush.Style;
|
||||
Image := ABrush.Image;
|
||||
Pattern := ABrush.Pattern;
|
||||
if ABrush is TBrush then
|
||||
Color := (ABrush as TBrush).Color;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.SetBrushParams(
|
||||
AStyle: TFPBrushStyle; AColor: TChartColor);
|
||||
begin
|
||||
FCanvas.Brush.Style := AStyle;
|
||||
FCanvas.Brush.Color := AColor;
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.SetFont(AFont: TFPCustomFont);
|
||||
var
|
||||
f: TAggLCLFont;
|
||||
begin
|
||||
f := FCanvas.Font;
|
||||
// This should be: FCanvas.Font.DoCopyProps(AFont);
|
||||
f.LoadFromFile(
|
||||
AFont.Name, f.SizeToAggHeight(AFont.Size), AFont.Bold, AFont.Italic);
|
||||
if AFont is TFont then
|
||||
with TFont(AFont) do begin
|
||||
f.Color := Color;
|
||||
f.AggAngle := OrientToRad(Orientation);
|
||||
end;
|
||||
end;
|
||||
|
||||
type
|
||||
TAggLCLPenCrack = class(TAggLCLPen);
|
||||
|
||||
procedure TAggPasDrawer.SetPen(APen: TFPCustomPen);
|
||||
begin
|
||||
TAggLCLPenCrack(FCanvas.Pen).DoCopyProps(APen);
|
||||
if APen is TPen then
|
||||
FCanvas.Pen.Color := (APen as TPen).Color;
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor);
|
||||
begin
|
||||
FCanvas.Pen.Style := AStyle;
|
||||
FCanvas.Pen.Color := AColor;
|
||||
end;
|
||||
|
||||
function TAggPasDrawer.SimpleTextExtent(const AText: String): TPoint;
|
||||
begin
|
||||
Result := FCanvas.TextExtent(AText);
|
||||
end;
|
||||
|
||||
procedure TAggPasDrawer.SimpleTextOut(AX, AY: Integer; const AText: String);
|
||||
begin
|
||||
FCanvas.TextOut(AX, AY, AText);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user