2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file plotgerb.cpp
|
|
|
|
* @brief Functions to plot a board in GERBER RS274X format.
|
|
|
|
*/
|
2009-01-10 08:03:07 +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
|
2011-09-30 18:15:37 +00:00
|
|
|
* format 3.4 uses the native Pcbnew units (1/10000 inch).
|
2009-01-10 08:03:07 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <plot_common.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <pcbplot.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <wxBasePcbFrame.h>
|
|
|
|
#include <layers_id_colors_and_visibility.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <protos.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-01 05:27:31 +00:00
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
bool PCB_BASE_FRAME::ExportToGerberFile( const wxString& aFullFileName, int aLayer,
|
2012-01-03 17:14:17 +00:00
|
|
|
bool aPlotOriginIsAuxAxis, EDA_DRAW_MODE_T aTraceMode )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-09-29 16:49:40 +00:00
|
|
|
FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) );
|
2010-01-01 13:30:39 +00:00
|
|
|
if( output_file == NULL )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
PCB_PLOT_PARAMS plot_opts = GetPlotSettings();
|
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
wxPoint offset;
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
// Calculate scaling from Pcbnew units (in 0.1 mil or 0.0001 inch) to gerber units
|
2012-04-05 18:27:56 +00:00
|
|
|
double scale = plot_opts.m_PlotScale;
|
2009-02-26 00:37:04 +00:00
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
if( aPlotOriginIsAuxAxis )
|
2011-09-23 13:57:12 +00:00
|
|
|
{
|
2011-12-31 05:44:00 +00:00
|
|
|
offset = GetOriginAxisPosition();
|
2011-09-23 13:57:12 +00:00
|
|
|
}
|
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
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
LOCALE_IO toggle;
|
|
|
|
|
2009-08-29 10:20:48 +00:00
|
|
|
PLOTTER* plotter = new GERBER_PLOTTER();
|
2011-12-31 05:44:00 +00:00
|
|
|
|
|
|
|
// No mirror and scaling for gerbers!
|
2012-05-03 18:37:56 +00:00
|
|
|
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
|
|
|
|
plotter->SetDefaultLineWidth( plot_opts.m_PlotLineWidth );
|
|
|
|
plotter->SetCreator( wxT( "PCBNEW-RS274X" ) );
|
|
|
|
plotter->SetFilename( aFullFileName );
|
2008-03-22 05:55:06 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
if( plotter->StartPlot( output_file ) )
|
2010-03-31 16:59:32 +00:00
|
|
|
{
|
2011-08-19 13:08:24 +00:00
|
|
|
// Skip NPTH pads on copper layers
|
|
|
|
// ( only if hole size == pad size ):
|
2011-09-29 16:49:40 +00:00
|
|
|
if( (aLayer >= LAYER_N_BACK) && (aLayer <= LAYER_N_FRONT) )
|
2012-04-05 18:27:56 +00:00
|
|
|
plot_opts.m_SkipNPTH_Pads = true;
|
|
|
|
|
|
|
|
SetPlotSettings( plot_opts );
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2010-03-31 16:59:32 +00:00
|
|
|
// Sheet refs on gerber CAN be useful... and they're always 1:1
|
2012-04-05 18:27:56 +00:00
|
|
|
if( plot_opts.m_PlotFrameRef )
|
2010-03-31 16:59:32 +00:00
|
|
|
PlotWorkSheet( plotter, GetScreen() );
|
2009-06-29 05:30:08 +00:00
|
|
|
|
2011-09-29 16:49:40 +00:00
|
|
|
Plot_Layer( plotter, aLayer, aTraceMode );
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2012-05-03 18:37:56 +00:00
|
|
|
plotter->EndPlot();
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
plot_opts.m_SkipNPTH_Pads = false;
|
|
|
|
|
|
|
|
SetPlotSettings( plot_opts );
|
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"));
|
|
|
|
}
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
delete plotter;
|
2010-01-01 13:30:39 +00:00
|
|
|
|
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|