kicad/pcbnew/plotgerb.cpp

81 lines
2.4 KiB
C++
Raw Normal View History

/*********************************************************/
/****Function to plot a board in GERBER RS274X format ****/
/*********************************************************/
/* Creates the output files, one per board layer:
* filenames are like xxxc.PHO and use the RS274X format
* Units = inches
* format 3.4, Leading zero omitted, Abs format
* format 3.4 uses the native pcbnew units (1/10000 inch).
*/
#include "fctsys.h"
#include "common.h"
#include "plot_common.h"
#include "confirm.h"
#include "pcbnew.h"
#include "pcbplot.h"
#include "trigo.h"
#include "protos.h"
/********************************************************************************/
2008-03-22 05:55:06 +00:00
void WinEDA_BasePcbFrame::Genere_GERBER( const wxString& FullFileName, int Layer,
2009-06-29 05:30:08 +00:00
bool PlotOriginIsAuxAxis,
GRTraceMode trace_mode )
/********************************************************************************/
/* Creates the output files, one per board layer:
* filenames are like xxxc.PHO and use the RS274X format
* Units = inches
* format 3.4, Leading zero omitted, Abs format
* format 3.4 uses the native pcbnew units (1/10000 inch).
*/
{
wxPoint offset;
2008-03-22 05:55:06 +00:00
EraseMsgBox();
/* Calculate scaling from pcbnew units (in 0.1 mil or 0.0001 inch) to gerber units */
double scale = g_pcb_plot_options.Scale;
2009-02-26 00:37:04 +00:00
2008-03-22 05:55:06 +00:00
if( PlotOriginIsAuxAxis )
offset = m_Auxiliary_Axis_Position;
2009-06-29 05:30:08 +00:00
else
{
2009-06-29 05:30:08 +00:00
offset.x = 0;
offset.y = 0;
}
2008-03-22 05:55:06 +00:00
2009-06-29 05:30:08 +00:00
FILE* output_file = wxFopen( FullFileName, wxT( "wt" ) );
if( output_file == NULL )
2008-03-22 05:55:06 +00:00
{
wxString msg = _( "unable to create file " ) + FullFileName;
DisplayError( this, msg );
return;
}
SetLocaleTo_C_standard();
2009-06-29 05:30:08 +00:00
Plotter* plotter = new Gerber_Plotter();
/* No mirror and scaling for gerbers! */
2009-06-29 05:30:08 +00:00
plotter->set_viewport( offset, scale, 0 );
plotter->set_default_line_width( g_pcb_plot_options.PlotLine_Width );
2009-06-29 05:30:08 +00:00
plotter->set_creator( wxT( "PCBNEW-RS274X" ) );
plotter->set_filename( FullFileName );
2008-03-22 05:55:06 +00:00
Affiche_1_Parametre( this, 0, _( "File" ), FullFileName, CYAN );
2009-06-29 05:30:08 +00:00
plotter->start_plot( output_file );
// Sheet refs on gerber CAN be useful... and they're always 1:1
if( g_pcb_plot_options.Plot_Frame_Ref )
2009-06-29 05:30:08 +00:00
PlotWorkSheet( plotter, GetScreen() );
Plot_Layer( plotter, Layer, trace_mode );
2008-03-22 05:55:06 +00:00
plotter->end_plot();
delete plotter;
SetLocaleTo_Default();
}