TAChart: Add export to G-code format to fpvectorial demo

git-svn-id: trunk@30400 -
This commit is contained in:
ask 2011-04-20 11:18:19 +00:00
parent 30246e2658
commit 35ce2fc218
3 changed files with 38 additions and 14 deletions

View File

@ -43,15 +43,24 @@ object Form1: TForm1
ClientHeight = 42
ClientWidth = 422
TabOrder = 1
object Button1: TButton
object btnSVG: TButton
Left = 8
Height = 25
Top = 8
Width = 75
Caption = 'Button1'
OnClick = Button1Click
Caption = 'Save as SVG'
OnClick = btnSVGClick
TabOrder = 0
end
object btnGCode: TButton
Left = 92
Height = 25
Top = 8
Width = 95
Caption = 'Save as G-code'
OnClick = btnGCodeClick
TabOrder = 1
end
end
object RandomChartSource1: TRandomChartSource
PointsNumber = 11

View File

@ -15,12 +15,14 @@ type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
btnSVG: TButton;
btnGCode: TButton;
Chart1: TChart;
Chart1LineSeries1: TLineSeries;
Panel1: TPanel;
RandomChartSource1: TRandomChartSource;
procedure Button1Click(Sender: TObject);
procedure btnGCodeClick(Sender: TObject);
procedure btnSVGClick(Sender: TObject);
end;
var
@ -31,20 +33,33 @@ implementation
{$R *.lfm}
uses
FPVectorial, SVGVectorialWriter, TADrawerFPVectorial;
FPVectorial, SVGVectorialWriter, avisocncgcodewriter, TADrawerFPVectorial;
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
procedure SaveAs(AChart: TChart; AFormat: TvVectorialFormat);
const
ext: array [TvVectorialFormat] of String = (
'pdf', 'ps', 'svg', 'cdr', 'wmf', 'dxf', 'gcode5', 'gcode6');
var
d: TvVectorialDocument;
begin
d := TvVectorialDocument.Create;
d.Width := Chart1.Width;
d.Height := Chart1.Height;
with Chart1 do
d.Width := AChart.Width;
d.Height := AChart.Height;
with AChart do
Draw(TFPVectorialDrawer.Create(d), Rect(0, 0, Width, Height));
d.WriteToFile('test.svg', vfSVG);
d.WriteToFile('test.' + ext[AFormat], AFormat);
end;
{ TForm1 }
procedure TForm1.btnGCodeClick(Sender: TObject);
begin
SaveAs(Chart1, vfGCodeAvisoCNCPrototipoV5);
end;
procedure TForm1.btnSVGClick(Sender: TObject);
begin
SaveAs(Chart1, vfSVG);
end;
end.

View File

@ -146,7 +146,7 @@ end;
procedure TFPVectorialDrawer.Line(const AP1, AP2: TPoint);
begin
Line(AP1.X, AP1.Y, AP2.Y, AP2.Y);
Line(AP1.X, AP1.Y, AP2.X, AP2.Y);
end;
procedure TFPVectorialDrawer.LineTo(AX, AY: Integer);