mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 13:56:09 +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
|
ClientHeight = 42
|
||||||
ClientWidth = 422
|
ClientWidth = 422
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
object Button1: TButton
|
object btnSVG: TButton
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 75
|
Width = 75
|
||||||
Caption = 'Button1'
|
Caption = 'Save as SVG'
|
||||||
OnClick = Button1Click
|
OnClick = btnSVGClick
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
|
object btnGCode: TButton
|
||||||
|
Left = 92
|
||||||
|
Height = 25
|
||||||
|
Top = 8
|
||||||
|
Width = 95
|
||||||
|
Caption = 'Save as G-code'
|
||||||
|
OnClick = btnGCodeClick
|
||||||
|
TabOrder = 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object RandomChartSource1: TRandomChartSource
|
object RandomChartSource1: TRandomChartSource
|
||||||
PointsNumber = 11
|
PointsNumber = 11
|
||||||
|
@ -15,12 +15,14 @@ type
|
|||||||
{ TForm1 }
|
{ TForm1 }
|
||||||
|
|
||||||
TForm1 = class(TForm)
|
TForm1 = class(TForm)
|
||||||
Button1: TButton;
|
btnSVG: TButton;
|
||||||
|
btnGCode: TButton;
|
||||||
Chart1: TChart;
|
Chart1: TChart;
|
||||||
Chart1LineSeries1: TLineSeries;
|
Chart1LineSeries1: TLineSeries;
|
||||||
Panel1: TPanel;
|
Panel1: TPanel;
|
||||||
RandomChartSource1: TRandomChartSource;
|
RandomChartSource1: TRandomChartSource;
|
||||||
procedure Button1Click(Sender: TObject);
|
procedure btnGCodeClick(Sender: TObject);
|
||||||
|
procedure btnSVGClick(Sender: TObject);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -31,20 +33,33 @@ implementation
|
|||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
FPVectorial, SVGVectorialWriter, TADrawerFPVectorial;
|
FPVectorial, SVGVectorialWriter, avisocncgcodewriter, TADrawerFPVectorial;
|
||||||
|
|
||||||
{ TForm1 }
|
procedure SaveAs(AChart: TChart; AFormat: TvVectorialFormat);
|
||||||
|
const
|
||||||
procedure TForm1.Button1Click(Sender: TObject);
|
ext: array [TvVectorialFormat] of String = (
|
||||||
|
'pdf', 'ps', 'svg', 'cdr', 'wmf', 'dxf', 'gcode5', 'gcode6');
|
||||||
var
|
var
|
||||||
d: TvVectorialDocument;
|
d: TvVectorialDocument;
|
||||||
begin
|
begin
|
||||||
d := TvVectorialDocument.Create;
|
d := TvVectorialDocument.Create;
|
||||||
d.Width := Chart1.Width;
|
d.Width := AChart.Width;
|
||||||
d.Height := Chart1.Height;
|
d.Height := AChart.Height;
|
||||||
with Chart1 do
|
with AChart do
|
||||||
Draw(TFPVectorialDrawer.Create(d), Rect(0, 0, Width, Height));
|
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;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -146,7 +146,7 @@ end;
|
|||||||
|
|
||||||
procedure TFPVectorialDrawer.Line(const AP1, AP2: TPoint);
|
procedure TFPVectorialDrawer.Line(const AP1, AP2: TPoint);
|
||||||
begin
|
begin
|
||||||
Line(AP1.X, AP1.Y, AP2.Y, AP2.Y);
|
Line(AP1.X, AP1.Y, AP2.X, AP2.Y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPVectorialDrawer.LineTo(AX, AY: Integer);
|
procedure TFPVectorialDrawer.LineTo(AX, AY: Integer);
|
||||||
|
Loading…
Reference in New Issue
Block a user