2009-04-05 20:49:15 +00:00
|
|
|
|
2009-01-10 08:03:07 +00:00
|
|
|
/*********************************************************/
|
|
|
|
/****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).
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "plot_common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbnew.h"
|
|
|
|
#include "pcbplot.h"
|
|
|
|
#include "trigo.h"
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
#include "protos.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/********************************************************************************/
|
2011-03-01 19:26:17 +00:00
|
|
|
bool PCB_BASE_FRAME::Genere_GERBER( const wxString& FullFileName, int Layer,
|
|
|
|
bool PlotOriginIsAuxAxis, GRTraceMode trace_mode )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************************************/
|
2007-11-01 05:27:31 +00:00
|
|
|
|
2008-10-25 10:21:46 +00:00
|
|
|
/* 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).
|
2007-11-01 05:27:31 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-01-01 13:30:39 +00:00
|
|
|
FILE* output_file = wxFopen( FullFileName, wxT( "wt" ) );
|
|
|
|
if( output_file == NULL )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
wxPoint offset;
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2009-01-10 08:03:07 +00:00
|
|
|
/* Calculate scaling from pcbnew units (in 0.1 mil or 0.0001 inch) to gerber units */
|
2010-12-11 18:40:39 +00:00
|
|
|
double scale = g_PcbPlotOptions.m_PlotScale;
|
2009-02-26 00:37:04 +00:00
|
|
|
|
2008-03-22 05:55:06 +00:00
|
|
|
if( PlotOriginIsAuxAxis )
|
2009-06-28 16:50:42 +00:00
|
|
|
offset = m_Auxiliary_Axis_Position;
|
2009-06-29 05:30:08 +00:00
|
|
|
else
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2009-06-29 05:30:08 +00:00
|
|
|
offset.x = 0;
|
|
|
|
offset.y = 0;
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2008-12-22 21:06:44 +00:00
|
|
|
SetLocaleTo_C_standard();
|
2009-08-29 10:20:48 +00:00
|
|
|
PLOTTER* plotter = new GERBER_PLOTTER();
|
2009-06-28 16:50:42 +00:00
|
|
|
/* No mirror and scaling for gerbers! */
|
2009-06-29 05:30:08 +00:00
|
|
|
plotter->set_viewport( offset, scale, 0 );
|
2010-12-11 18:40:39 +00:00
|
|
|
plotter->set_default_line_width( g_PcbPlotOptions.m_PlotLineWidth );
|
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
|
|
|
|
2010-03-31 16:59:32 +00:00
|
|
|
if( plotter->start_plot( output_file ) )
|
|
|
|
{
|
|
|
|
// Sheet refs on gerber CAN be useful... and they're always 1:1
|
2010-12-11 18:40:39 +00:00
|
|
|
if( g_PcbPlotOptions.m_PlotFrameRef )
|
2010-03-31 16:59:32 +00:00
|
|
|
PlotWorkSheet( plotter, GetScreen() );
|
2009-06-29 05:30:08 +00:00
|
|
|
|
2010-12-11 18:40:39 +00:00
|
|
|
Plot_Layer( plotter, Layer, trace_mode );
|
2010-03-31 16:59:32 +00:00
|
|
|
plotter->end_plot();
|
|
|
|
}
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2010-03-31 16:59:32 +00:00
|
|
|
else // error in start_plot( ): failed opening a temporary file
|
|
|
|
{
|
|
|
|
wxMessageBox( _("Error when creating %s file: unable to create a temporary file"));
|
|
|
|
}
|
2009-06-28 16:50:42 +00:00
|
|
|
delete plotter;
|
2008-12-22 21:06:44 +00:00
|
|
|
SetLocaleTo_Default();
|
2010-01-01 13:30:39 +00:00
|
|
|
|
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|