mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 20:29:35 +02:00
TAChart: Add export to G-code format to fpvectorial demo
git-svn-id: trunk@30400 -
This commit is contained in:
parent
30246e2658
commit
35ce2fc218
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user