2
*****************************************************************************
4
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
5
* for details about the copyright. *
7
* This program is distributed in the hope that it will be useful, *
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
11
*****************************************************************************
13
Authors: Alexander Klenin
23
Classes, FPCanvas, Agg_LCL, TAChartUtils, TADrawUtils;
29
TAggPasDrawer = class(TBasicDrawer, IChartDrawer)
31
FCanvas: TAggLCLCanvas;
32
procedure SetBrush(ABrush: TFPCustomBrush);
33
procedure SetFont(AFont: TFPCustomFont);
34
procedure SetPen(APen: TFPCustomPen);
36
function GetFontAngle: Double; override;
37
function SimpleTextExtent(const AText: String): TPoint; override;
38
procedure SimpleTextOut(AX, AY: Integer; const AText: String); override;
40
constructor Create(ACanvas: TAggLCLCanvas);
42
procedure AddToFontOrientation(ADelta: Integer);
43
procedure ClippingStart;
44
procedure ClippingStart(const AClipRect: TRect);
45
procedure ClippingStop;
46
procedure Ellipse(AX1, AY1, AX2, AY2: Integer);
47
procedure FillRect(AX1, AY1, AX2, AY2: Integer);
48
function GetBrushColor: TChartColor;
49
procedure Line(AX1, AY1, AX2, AY2: Integer);
50
procedure Line(const AP1, AP2: TPoint);
51
procedure LineTo(AX, AY: Integer); override;
52
procedure MoveTo(AX, AY: Integer); override;
54
const APoints: array of TPoint; AStartIndex, ANumPts: Integer); override;
56
const APoints: array of TPoint; AStartIndex, ANumPts: Integer);
57
procedure PrepareSimplePen(AColor: TChartColor);
59
AX1, AY1, AX2, AY2: Integer;
60
AStartAngle16Deg, AAngleLength16Deg: Integer);
61
procedure Rectangle(const ARect: TRect);
62
procedure Rectangle(AX1, AY1, AX2, AY2: Integer);
63
procedure SetBrushColor(AColor: TChartColor);
64
procedure SetBrushParams(AStyle: TFPBrushStyle; AColor: TChartColor);
65
procedure SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor);
75
procedure TAggPasDrawer.AddToFontOrientation(ADelta: Integer);
78
AggAngle := AggAngle + OrientToRad(ADelta);
81
procedure TAggPasDrawer.ClippingStart(const AClipRect: TRect);
83
FCanvas.ClipRect := AClipRect;
84
FCanvas.Clipping := true;
87
procedure TAggPasDrawer.ClippingStart;
89
FCanvas.Clipping := true;
92
procedure TAggPasDrawer.ClippingStop;
94
FCanvas.Clipping := false;
97
constructor TAggPasDrawer.Create(ACanvas: TAggLCLCanvas);
103
procedure TAggPasDrawer.Ellipse(AX1, AY1, AX2, AY2: Integer);
105
FCanvas.Ellipse(AX1, AY1, AX2, AY2);
108
procedure TAggPasDrawer.FillRect(AX1, AY1, AX2, AY2: Integer);
110
FCanvas.FillRect(AX1, AY1, AX2, AY2);
113
function TAggPasDrawer.GetBrushColor: TChartColor;
115
Result := FCanvas.Brush.Color;
118
function TAggPasDrawer.GetFontAngle: Double;
120
Result := FCanvas.Font.AggAngle;
123
procedure TAggPasDrawer.Line(AX1, AY1, AX2, AY2: Integer);
125
FCanvas.Line(AX1, AY1, AX2, AY2);
128
procedure TAggPasDrawer.Line(const AP1, AP2: TPoint);
130
FCanvas.Line(AP1, AP2);
133
procedure TAggPasDrawer.LineTo(AX, AY: Integer);
135
FCanvas.LineTo(AX, AY);
138
procedure TAggPasDrawer.MoveTo(AX, AY: Integer);
140
FCanvas.MoveTo(AX, AY);
143
procedure TAggPasDrawer.Polygon(
144
const APoints: array of TPoint; AStartIndex, ANumPts: Integer);
146
if ANumPts <= 0 then exit;
147
FCanvas.Polygon(APoints, false, AStartIndex, ANumPts);
148
FCanvas.Polyline(APoints, AStartIndex, ANumPts);
149
FCanvas.Line(APoints[ANumPts - 1], APoints[0])
152
procedure TAggPasDrawer.Polyline(
153
const APoints: array of TPoint; AStartIndex, ANumPts: Integer);
155
FCanvas.Polyline(APoints, AStartIndex, ANumPts);
158
procedure TAggPasDrawer.PrepareSimplePen(AColor: TChartColor);
160
with FCanvas.Pen do begin
168
procedure TAggPasDrawer.RadialPie(
169
AX1, AY1, AX2, AY2: Integer;
170
AStartAngle16Deg, AAngleLength16Deg: Integer);
173
AX1, AY1, AX2, AY2, AStartAngle16Deg, AAngleLength16Deg);
176
procedure TAggPasDrawer.Rectangle(AX1, AY1, AX2, AY2: Integer);
178
FCanvas.Rectangle(AX1, AY1, AX2, AY2);
181
procedure TAggPasDrawer.Rectangle(const ARect: TRect);
183
FCanvas.Rectangle(ARect);
186
procedure TAggPasDrawer.SetBrush(ABrush: TFPCustomBrush);
188
with FCanvas.Brush do begin
189
Style := ABrush.Style;
190
Image := ABrush.Image;
191
Pattern := ABrush.Pattern;
192
FPColor := ABrush.FPColor;
196
procedure TAggPasDrawer.SetBrushColor(AColor: TChartColor);
198
FCanvas.Brush.Color := AColor;
201
procedure TAggPasDrawer.SetBrushParams(
202
AStyle: TFPBrushStyle; AColor: TChartColor);
204
FCanvas.Brush.Color := AColor;
205
FCanvas.Brush.Style := AStyle;
208
procedure TAggPasDrawer.SetFont(AFont: TFPCustomFont);
210
DEFAULT_FONT_SIZE = 10; // Just a random value.
216
fontSize := IfThen(AFont.Size = 0, DEFAULT_FONT_SIZE, AFont.Size);
217
// This should be: FCanvas.Font.DoCopyProps(AFont);
219
AFont.Name, f.SizeToAggHeight(fontSize), AFont.Bold, AFont.Italic);
220
f.FPColor := AFont.FPColor;
221
f.AggAngle := OrientToRad(-FGetFontOrientationFunc(AFont));
225
TAggLCLPenCrack = class(TAggLCLPen);
227
procedure TAggPasDrawer.SetPen(APen: TFPCustomPen);
229
TAggLCLPenCrack(FCanvas.Pen).DoCopyProps(APen);
230
FCanvas.Pen.FPColor := APen.FPColor;
233
procedure TAggPasDrawer.SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor);
235
FCanvas.Pen.Style := AStyle;
236
FCanvas.Pen.Color := AColor;
239
function TAggPasDrawer.SimpleTextExtent(const AText: String): TPoint;
241
Result := FCanvas.TextExtent(AText);
244
procedure TAggPasDrawer.SimpleTextOut(AX, AY: Integer; const AText: String);
246
FCanvas.TextOut(AX, AY, AText);
250
// Suppress incorrect "TAGeometry is unused" hint
251
Unused(DoublePoint(0, 0));