2011-09-20 15:07:52 +00:00
|
|
|
/**
|
2012-09-24 16:03:03 +00:00
|
|
|
* @file plot_board_layers.cpp
|
|
|
|
* @brief Functions to plot one board layer (silkscreen layers or other layers).
|
|
|
|
* Silkscreen layers have specific requirement for pads (not filled) and texts
|
|
|
|
* (with option to remove them from some copper areas (pads...)
|
2011-09-20 15:07:52 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2020-06-21 18:47:58 +00:00
|
|
|
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-09-24 16:03:03 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
2018-01-28 18:12:26 +00:00
|
|
|
#include <plotter.h>
|
2012-02-19 04:02:19 +00:00
|
|
|
#include <base_struct.h>
|
2018-01-28 21:02:31 +00:00
|
|
|
#include <draw_graphic_text.h>
|
2018-04-20 00:20:48 +00:00
|
|
|
#include <geometry/geometry_utils.h>
|
2012-02-19 04:02:19 +00:00
|
|
|
#include <trigo.h>
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2013-05-02 18:06:58 +00:00
|
|
|
#include <macros.h>
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_edge_mod.h>
|
|
|
|
#include <class_pcb_text.h>
|
|
|
|
#include <class_zone.h>
|
|
|
|
#include <class_drawsegment.h>
|
2017-10-31 15:38:10 +00:00
|
|
|
#include <class_pcb_target.h>
|
2012-02-19 04:02:19 +00:00
|
|
|
#include <class_dimension.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbplot.h>
|
2018-05-17 05:49:38 +00:00
|
|
|
#include <gbr_metadata.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-11-05 20:20:34 +00:00
|
|
|
// Local
|
|
|
|
/* Plot a solder mask layer.
|
|
|
|
* Solder mask layers have a minimum thickness value and cannot be drawn like standard layers,
|
|
|
|
* unless the minimum thickness is 0.
|
|
|
|
*/
|
|
|
|
static void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter,
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt,
|
2012-11-05 20:20:34 +00:00
|
|
|
int aMinThickness );
|
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
/* Creates the plot for silkscreen layers
|
2012-09-24 16:03:03 +00:00
|
|
|
* Silkscreen layers have specific requirement for pads (not filled) and texts
|
|
|
|
* (with option to remove them from some copper areas (pads...)
|
2012-09-24 06:39:59 +00:00
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
|
2012-09-24 06:39:59 +00:00
|
|
|
const PCB_PLOT_PARAMS& aPlotOpt )
|
|
|
|
{
|
|
|
|
BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt );
|
2014-06-24 16:17:18 +00:00
|
|
|
itemplotter.SetLayerSet( aLayerMask );
|
2012-09-24 06:39:59 +00:00
|
|
|
|
|
|
|
// Plot edge layer and graphic items
|
|
|
|
itemplotter.PlotBoardGraphicItems();
|
2007-12-11 20:28:13 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Plot footprint outlines :
|
2012-09-21 08:20:38 +00:00
|
|
|
itemplotter.Plot_Edges_Modules();
|
2007-12-11 20:28:13 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Plot pads (creates pads outlines, for pads on silkscreen layers)
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET layersmask_plotpads = aLayerMask;
|
|
|
|
|
2010-09-24 16:36:20 +00:00
|
|
|
// Calculate the mask layers of allowed layers for pads
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-09-12 11:11:30 +00:00
|
|
|
if( !aPlotOpt.GetPlotPadsOnSilkLayer() ) // Do not plot pads on silk screen layers
|
2014-06-24 16:17:18 +00:00
|
|
|
layersmask_plotpads.set( B_SilkS, false ).set( F_SilkS, false );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( layersmask_plotpads.any() )
|
2007-12-11 20:28:13 +00:00
|
|
|
{
|
2012-08-29 16:59:50 +00:00
|
|
|
for( MODULE* Module = aBoard->m_Modules; Module; Module = Module->Next() )
|
2007-12-11 20:28:13 +00:00
|
|
|
{
|
2016-09-19 11:01:36 +00:00
|
|
|
aPlotter->StartBlock( NULL );
|
|
|
|
|
2017-06-23 11:56:28 +00:00
|
|
|
for( D_PAD* pad = Module->PadsList(); pad; pad = pad->Next() )
|
2007-12-11 20:28:13 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
// See if the pad is on this layer
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET masklayer = pad->GetLayerSet();
|
|
|
|
if( !( masklayer & layersmask_plotpads ).any() )
|
2010-01-18 15:11:35 +00:00
|
|
|
continue;
|
2008-05-05 19:50:59 +00:00
|
|
|
|
2017-02-20 17:48:27 +00:00
|
|
|
COLOR4D color = COLOR4D::BLACK;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
if( layersmask_plotpads[B_SilkS] )
|
2017-08-04 12:43:02 +00:00
|
|
|
color = aBoard->Colors().GetLayerColor( B_SilkS );
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( layersmask_plotpads[F_SilkS] )
|
2017-08-04 12:43:02 +00:00
|
|
|
color = ( color == COLOR4D::BLACK) ? aBoard->Colors().GetLayerColor( F_SilkS ) : color;
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
itemplotter.PlotPad( pad, color, SKETCH );
|
2007-12-11 20:28:13 +00:00
|
|
|
}
|
2016-09-19 11:01:36 +00:00
|
|
|
|
|
|
|
aPlotter->EndBlock( NULL );
|
2007-12-11 20:28:13 +00:00
|
|
|
}
|
2009-11-04 19:08:08 +00:00
|
|
|
}
|
2007-12-11 20:28:13 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Plot footprints fields (ref, value ...)
|
2012-08-29 16:59:50 +00:00
|
|
|
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
|
2007-12-11 20:28:13 +00:00
|
|
|
{
|
2012-09-21 08:20:38 +00:00
|
|
|
if( ! itemplotter.PlotAllTextsModule( module ) )
|
2007-12-11 20:28:13 +00:00
|
|
|
{
|
2015-11-17 16:18:00 +00:00
|
|
|
wxLogMessage( _( "Your BOARD has a bad layer number for footprint %s" ),
|
2012-09-20 18:58:41 +00:00
|
|
|
GetChars( module->GetReference() ) );
|
2007-12-11 20:28:13 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-12 02:44:46 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Plot filled areas
|
2016-09-19 11:01:36 +00:00
|
|
|
aPlotter->StartBlock( NULL );
|
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
for( int ii = 0; ii < aBoard->GetAreaCount(); ii++ )
|
2008-09-27 19:26:29 +00:00
|
|
|
{
|
2012-08-29 16:59:50 +00:00
|
|
|
ZONE_CONTAINER* edge_zone = aBoard->GetArea( ii );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !aLayerMask[ edge_zone->GetLayer() ] )
|
2008-10-07 12:10:24 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-09-21 08:20:38 +00:00
|
|
|
itemplotter.PlotFilledAreas( edge_zone );
|
2008-09-27 19:26:29 +00:00
|
|
|
}
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
aPlotter->EndBlock( NULL );
|
|
|
|
|
2018-05-12 19:37:43 +00:00
|
|
|
// Plot segments used to fill zone areas (deprecated, but here for very old boards
|
2009-11-20 14:55:20 +00:00
|
|
|
// compatibility):
|
2018-05-12 19:37:43 +00:00
|
|
|
for( SEGZONE* seg = aBoard->m_SegZoneDeprecated; seg; seg = seg->Next() )
|
2009-05-01 16:46:56 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !aLayerMask[ seg->GetLayer() ] )
|
2009-05-01 16:46:56 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
aPlotter->ThickSegment( seg->GetStart(), seg->GetEnd(), seg->GetWidth(),
|
2016-09-19 11:01:36 +00:00
|
|
|
itemplotter.GetPlotMode(), NULL );
|
2009-05-01 16:46:56 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
|
2015-03-25 13:07:05 +00:00
|
|
|
const PCB_PLOT_PARAMS& aPlotOpt )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2012-09-24 06:39:59 +00:00
|
|
|
PCB_PLOT_PARAMS plotOpt = aPlotOpt;
|
2012-11-05 20:20:34 +00:00
|
|
|
int soldermask_min_thickness = aBoard->GetDesignSettings().m_SolderMaskMinWidth;
|
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
// Set a default color and the text mode for this layer
|
2012-09-12 11:11:30 +00:00
|
|
|
aPlotter->SetColor( aPlotOpt.GetColor() );
|
|
|
|
aPlotter->SetTextMode( aPlotOpt.GetTextMode() );
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
// Specify that the contents of the "Edges Pcb" layer are to be plotted
|
|
|
|
// in addition to the contents of the currently specified layer.
|
2014-08-10 14:15:02 +00:00
|
|
|
LSET layer_mask( aLayer );
|
2009-06-29 05:30:08 +00:00
|
|
|
|
2012-09-12 11:11:30 +00:00
|
|
|
if( !aPlotOpt.GetExcludeEdgeLayer() )
|
2014-06-24 16:17:18 +00:00
|
|
|
layer_mask.set( Edge_Cuts );
|
2007-12-11 20:28:13 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( IsCopperLayer( aLayer ) )
|
2009-06-29 05:30:08 +00:00
|
|
|
{
|
2012-08-29 16:59:50 +00:00
|
|
|
// Skip NPTH pads on copper layers ( only if hole size == pad size ):
|
2012-09-24 06:39:59 +00:00
|
|
|
// Drill mark will be plotted,
|
|
|
|
// if drill mark is SMALL_DRILL_SHAPE or FULL_DRILL_SHAPE
|
2014-05-17 19:29:15 +00:00
|
|
|
if( plotOpt.GetFormat() == PLOT_FORMAT_DXF )
|
|
|
|
{
|
|
|
|
plotOpt.SetSkipPlotNPTH_Pads( false );
|
|
|
|
PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
plotOpt.SetSkipPlotNPTH_Pads( true );
|
|
|
|
PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
|
|
|
|
}
|
2014-06-24 16:17:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch( aLayer )
|
|
|
|
{
|
|
|
|
case B_Mask:
|
|
|
|
case F_Mask:
|
|
|
|
plotOpt.SetSkipPlotNPTH_Pads( false );
|
|
|
|
// Disable plot pad holes
|
|
|
|
plotOpt.SetDrillMarksType( PCB_PLOT_PARAMS::NO_DRILL_SHAPE );
|
2009-06-25 20:45:27 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// Plot solder mask:
|
|
|
|
if( soldermask_min_thickness == 0 )
|
|
|
|
{
|
|
|
|
if( plotOpt.GetFormat() == PLOT_FORMAT_DXF )
|
|
|
|
PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
|
|
|
|
else
|
|
|
|
PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
PlotSolderMaskLayer( aBoard, aPlotter, layer_mask, plotOpt,
|
|
|
|
soldermask_min_thickness );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2014-11-13 08:00:28 +00:00
|
|
|
case B_Adhes:
|
|
|
|
case F_Adhes:
|
2014-06-24 16:17:18 +00:00
|
|
|
case B_Paste:
|
|
|
|
case F_Paste:
|
|
|
|
plotOpt.SetSkipPlotNPTH_Pads( false );
|
|
|
|
// Disable plot pad holes
|
|
|
|
plotOpt.SetDrillMarksType( PCB_PLOT_PARAMS::NO_DRILL_SHAPE );
|
2012-11-05 20:20:34 +00:00
|
|
|
|
2014-05-17 19:29:15 +00:00
|
|
|
if( plotOpt.GetFormat() == PLOT_FORMAT_DXF )
|
|
|
|
PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
|
|
|
|
else
|
|
|
|
PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
|
2014-06-24 16:17:18 +00:00
|
|
|
break;
|
2012-11-05 20:20:34 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
case F_SilkS:
|
|
|
|
case B_SilkS:
|
2017-07-30 18:27:03 +00:00
|
|
|
if( plotOpt.GetFormat() == PLOT_FORMAT_DXF && plotOpt.GetDXFPlotPolygonMode() )
|
2017-07-25 09:49:16 +00:00
|
|
|
// PlotLayerOutlines() is designed only for DXF plotters.
|
|
|
|
// and must not be used for other plot formats
|
2014-06-24 16:17:18 +00:00
|
|
|
PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
|
|
|
|
else
|
|
|
|
PlotSilkScreen( aBoard, aPlotter, layer_mask, plotOpt );
|
2009-06-25 20:45:27 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// Gerber: Subtract soldermask from silkscreen if enabled
|
|
|
|
if( aPlotter->GetPlotterType() == PLOT_FORMAT_GERBER
|
|
|
|
&& plotOpt.GetSubtractMaskFromSilk() )
|
|
|
|
{
|
|
|
|
if( aLayer == F_SilkS )
|
|
|
|
layer_mask = LSET( F_Mask );
|
|
|
|
else
|
|
|
|
layer_mask = LSET( B_Mask );
|
2014-05-17 19:29:15 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// Create the mask to subtract by creating a negative layer polarity
|
|
|
|
aPlotter->SetLayerPolarity( false );
|
2009-06-25 20:45:27 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// Disable plot pad holes
|
|
|
|
plotOpt.SetDrillMarksType( PCB_PLOT_PARAMS::NO_DRILL_SHAPE );
|
2010-12-06 22:18:39 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// Plot the mask
|
|
|
|
PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
|
|
|
|
}
|
|
|
|
break;
|
2010-12-06 22:18:39 +00:00
|
|
|
|
2014-11-13 08:00:28 +00:00
|
|
|
// These layers are plotted like silk screen layers.
|
|
|
|
// Mainly, pads on these layers are not filled.
|
|
|
|
// This is not necessary the best choice.
|
|
|
|
case Dwgs_User:
|
|
|
|
case Cmts_User:
|
|
|
|
case Eco1_User:
|
|
|
|
case Eco2_User:
|
|
|
|
case Edge_Cuts:
|
|
|
|
case Margin:
|
|
|
|
case F_CrtYd:
|
|
|
|
case B_CrtYd:
|
|
|
|
case F_Fab:
|
|
|
|
case B_Fab:
|
2014-11-14 07:25:17 +00:00
|
|
|
plotOpt.SetSkipPlotNPTH_Pads( false );
|
|
|
|
plotOpt.SetDrillMarksType( PCB_PLOT_PARAMS::NO_DRILL_SHAPE );
|
|
|
|
|
2017-07-30 18:27:03 +00:00
|
|
|
if( plotOpt.GetFormat() == PLOT_FORMAT_DXF && plotOpt.GetDXFPlotPolygonMode() )
|
2017-07-25 09:49:16 +00:00
|
|
|
// PlotLayerOutlines() is designed only for DXF plotters.
|
|
|
|
// and must not be used for other plot formats
|
2014-11-14 07:25:17 +00:00
|
|
|
PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
|
|
|
|
else
|
|
|
|
PlotSilkScreen( aBoard, aPlotter, layer_mask, plotOpt );
|
2014-06-24 16:17:18 +00:00
|
|
|
break;
|
2014-11-13 08:00:28 +00:00
|
|
|
|
|
|
|
default:
|
2014-11-14 07:25:17 +00:00
|
|
|
plotOpt.SetSkipPlotNPTH_Pads( false );
|
|
|
|
plotOpt.SetDrillMarksType( PCB_PLOT_PARAMS::NO_DRILL_SHAPE );
|
|
|
|
|
2017-07-30 18:27:03 +00:00
|
|
|
if( plotOpt.GetFormat() == PLOT_FORMAT_DXF && plotOpt.GetDXFPlotPolygonMode() )
|
2017-07-25 09:49:16 +00:00
|
|
|
// PlotLayerOutlines() is designed only for DXF plotters.
|
|
|
|
// and must not be used for other plot formats
|
2014-11-13 08:00:28 +00:00
|
|
|
PlotLayerOutlines( aBoard, aPlotter, layer_mask, plotOpt );
|
|
|
|
else
|
2014-11-14 07:25:17 +00:00
|
|
|
PlotStandardLayer( aBoard, aPlotter, layer_mask, plotOpt );
|
2014-11-13 08:00:28 +00:00
|
|
|
break;
|
2010-12-06 22:05:12 +00:00
|
|
|
}
|
2007-12-11 20:28:13 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-06-29 05:30:08 +00:00
|
|
|
|
2012-03-24 14:25:30 +00:00
|
|
|
/* Plot a copper layer or mask.
|
|
|
|
* Silk screen layers are not plotted here.
|
2009-06-28 16:50:42 +00:00
|
|
|
*/
|
2012-08-29 16:59:50 +00:00
|
|
|
void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-09-21 08:20:38 +00:00
|
|
|
BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
itemplotter.SetLayerSet( aLayerMask );
|
2012-09-21 08:20:38 +00:00
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
EDA_DRAW_MODE_T plotMode = aPlotOpt.GetPlotMode();
|
2007-12-11 20:28:13 +00:00
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
// Plot edge layer and graphic items
|
|
|
|
itemplotter.PlotBoardGraphicItems();
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2019-08-13 07:54:32 +00:00
|
|
|
// Draw footprint texts:
|
2012-09-20 18:58:41 +00:00
|
|
|
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
|
|
|
|
{
|
2012-09-21 08:20:38 +00:00
|
|
|
if( ! itemplotter.PlotAllTextsModule( module ) )
|
2012-09-20 18:58:41 +00:00
|
|
|
{
|
2015-11-17 16:18:00 +00:00
|
|
|
wxLogMessage( _( "Your BOARD has a bad layer number for footprint %s" ),
|
2019-08-13 07:54:32 +00:00
|
|
|
module->GetReference() );
|
2012-09-20 18:58:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2017-04-25 09:06:24 +00:00
|
|
|
for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !aLayerMask[ item->GetLayer() ] )
|
2012-09-20 18:58:41 +00:00
|
|
|
continue;
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2012-09-21 08:20:38 +00:00
|
|
|
itemplotter.Plot_1_EdgeModule( (EDGE_MODULE*) item );
|
2009-06-28 16:50:42 +00:00
|
|
|
break;
|
2007-12-11 20:28:13 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
default:
|
2009-06-29 05:30:08 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-22 20:50:30 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Plot footprint pads
|
2012-08-29 16:59:50 +00:00
|
|
|
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2016-09-19 11:01:36 +00:00
|
|
|
aPlotter->StartBlock( NULL );
|
|
|
|
|
2017-04-25 09:06:24 +00:00
|
|
|
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( (pad->GetLayerSet() & aLayerMask) == 0 )
|
2009-06-28 16:50:42 +00:00
|
|
|
continue;
|
2009-03-18 15:38:16 +00:00
|
|
|
|
2009-11-04 19:08:08 +00:00
|
|
|
wxSize margin;
|
2012-01-07 06:02:38 +00:00
|
|
|
double width_adj = 0;
|
2012-01-23 04:33:36 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( ( aLayerMask & LSET::AllCuMask() ).any() )
|
2012-09-24 06:39:59 +00:00
|
|
|
width_adj = itemplotter.getFineWidthAdj();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
static const LSET speed( 4, B_Mask, F_Mask, B_Paste, F_Paste );
|
|
|
|
|
|
|
|
LSET anded = ( speed & aLayerMask );
|
|
|
|
|
|
|
|
if( anded == LSET( F_Mask ) || anded == LSET( B_Mask ) )
|
|
|
|
{
|
|
|
|
margin.x = margin.y = pad->GetSolderMaskMargin();
|
|
|
|
}
|
|
|
|
else if( anded == LSET( F_Paste ) || anded == LSET( B_Paste ) )
|
|
|
|
{
|
|
|
|
margin = pad->GetSolderPasteMargin();
|
|
|
|
}
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2016-12-18 12:03:15 +00:00
|
|
|
// Now offset the pad size by margin + width_adj
|
2018-05-16 16:26:43 +00:00
|
|
|
// this is easy for most shapes, but not for a trapezoid or a custom shape
|
2012-09-25 07:49:29 +00:00
|
|
|
wxSize padPlotsSize;
|
2016-12-18 12:03:15 +00:00
|
|
|
wxSize extraSize = margin * 2;
|
|
|
|
extraSize.x += width_adj;
|
|
|
|
extraSize.y += width_adj;
|
2020-06-21 18:47:58 +00:00
|
|
|
|
|
|
|
// Store these parameters that can be modified to plot inflated/deflated pads shape
|
2016-12-18 12:03:15 +00:00
|
|
|
wxSize deltaSize = pad->GetDelta(); // has meaning only for trapezoidal pads
|
2020-06-21 18:47:58 +00:00
|
|
|
PAD_SHAPE_T padShape = pad->GetShape();
|
|
|
|
double padCornerRadius = pad->GetRoundRectCornerRadius();
|
2016-12-18 12:03:15 +00:00
|
|
|
|
|
|
|
if( pad->GetShape() == PAD_SHAPE_TRAPEZOID )
|
|
|
|
{ // The easy way is to use BuildPadPolygon to calculate
|
|
|
|
// size and delta of the trapezoidal pad after offseting:
|
|
|
|
wxPoint coord[4];
|
|
|
|
pad->BuildPadPolygon( coord, extraSize/2, 0.0 );
|
|
|
|
// Calculate the size and delta from polygon corners coordinates:
|
|
|
|
// coord[0] is the lower left
|
|
|
|
// coord[1] is the upper left
|
|
|
|
// coord[2] is the upper right
|
|
|
|
// coord[3] is the lower right
|
|
|
|
|
|
|
|
// the size is the distance between middle of segments
|
|
|
|
// (left/right or top/bottom)
|
|
|
|
// size X is the dist between left and right middle points:
|
|
|
|
padPlotsSize.x = ( ( -coord[0].x + coord[3].x ) // the lower segment X length
|
|
|
|
+ ( -coord[1].x + coord[2].x ) ) // the upper segment X length
|
|
|
|
/ 2; // the Y size is the half sum
|
|
|
|
// size Y is the dist between top and bottom middle points:
|
|
|
|
padPlotsSize.y = ( ( coord[0].y - coord[1].y ) // the left segment Y lenght
|
|
|
|
+ ( coord[3].y - coord[2].y ) ) // the right segment Y lenght
|
|
|
|
/ 2; // the Y size is the half sum
|
|
|
|
|
|
|
|
// calculate the delta ( difference of lenght between 2 opposite edges )
|
|
|
|
// The delta.x is the delta along the X axis, therefore the delta of Y lenghts
|
|
|
|
wxSize delta;
|
|
|
|
|
|
|
|
if( coord[0].y != coord[3].y )
|
|
|
|
delta.x = coord[0].y - coord[3].y;
|
|
|
|
else
|
|
|
|
delta.y = coord[1].x - coord[0].x;
|
|
|
|
|
|
|
|
pad->SetDelta( delta );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
padPlotsSize = pad->GetSize() + extraSize;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Don't draw a null size item :
|
2012-09-25 07:49:29 +00:00
|
|
|
if( padPlotsSize.x <= 0 || padPlotsSize.y <= 0 )
|
2009-06-28 16:50:42 +00:00
|
|
|
continue;
|
|
|
|
|
2017-02-20 17:48:27 +00:00
|
|
|
COLOR4D color = COLOR4D::BLACK;
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( pad->GetLayerSet()[B_Cu] )
|
2017-08-04 12:43:02 +00:00
|
|
|
color = aBoard->Colors().GetItemColor( LAYER_PAD_BK );
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( pad->GetLayerSet()[F_Cu] )
|
2017-08-04 12:43:02 +00:00
|
|
|
color = color.LegacyMix( aBoard->Colors().GetItemColor( LAYER_PAD_FR ) );
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2012-09-25 07:49:29 +00:00
|
|
|
// Temporary set the pad size to the required plot size:
|
|
|
|
wxSize tmppadsize = pad->GetSize();
|
2016-12-18 12:03:15 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
switch( pad->GetShape() )
|
2009-06-29 05:30:08 +00:00
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_CIRCLE:
|
|
|
|
case PAD_SHAPE_OVAL:
|
2018-05-16 16:26:43 +00:00
|
|
|
pad->SetSize( padPlotsSize );
|
2018-05-29 16:51:44 +00:00
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
if( aPlotOpt.GetSkipPlotNPTH_Pads() &&
|
2018-03-27 11:42:51 +00:00
|
|
|
( pad->GetSize() == pad->GetDrillSize() ) &&
|
|
|
|
( pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED ) )
|
2018-05-29 16:51:44 +00:00
|
|
|
break;
|
2018-05-29 11:45:45 +00:00
|
|
|
|
|
|
|
itemplotter.PlotPad( pad, color, plotMode );
|
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_RECT:
|
2020-06-21 18:47:58 +00:00
|
|
|
if( margin.x > 0 )
|
|
|
|
{
|
|
|
|
pad->SetShape( PAD_SHAPE_ROUNDRECT );
|
|
|
|
pad->SetSize( padPlotsSize );
|
|
|
|
pad->SetRoundRectCornerRadius( margin.x );
|
|
|
|
}
|
|
|
|
// Fall through
|
|
|
|
|
|
|
|
case PAD_SHAPE_TRAPEZOID:
|
2016-04-06 18:15:49 +00:00
|
|
|
case PAD_SHAPE_ROUNDRECT:
|
2018-05-29 11:45:45 +00:00
|
|
|
pad->SetSize( padPlotsSize );
|
2012-09-25 07:49:29 +00:00
|
|
|
itemplotter.PlotPad( pad, color, plotMode );
|
2009-06-29 05:30:08 +00:00
|
|
|
break;
|
2018-05-16 16:26:43 +00:00
|
|
|
|
|
|
|
case PAD_SHAPE_CUSTOM:
|
|
|
|
// inflate/deflate a custom shape is a bit complex.
|
|
|
|
// so build a similar pad shape, and inflate/deflate the polygonal shape
|
|
|
|
{
|
|
|
|
D_PAD dummy( *pad );
|
|
|
|
SHAPE_POLY_SET shape;
|
|
|
|
pad->MergePrimitivesAsPolygon( &shape, 64 );
|
2019-05-09 14:23:18 +00:00
|
|
|
// shape polygon can have holes linked to the main outline.
|
|
|
|
// So use InflateWithLinkedHoles(), not Inflate() that can create
|
|
|
|
// bad shapes if margin.x is < 0
|
|
|
|
shape.InflateWithLinkedHoles( margin.x, ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF,
|
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2018-05-16 16:26:43 +00:00
|
|
|
dummy.DeletePrimitivesList();
|
|
|
|
dummy.AddPrimitive( shape, 0 );
|
|
|
|
dummy.MergePrimitivesAsPolygon();
|
|
|
|
|
2019-06-07 08:50:40 +00:00
|
|
|
// Be sure the anchor pad is not bigger than the deflated shape
|
|
|
|
// because this anchor will be added to the pad shape when plotting
|
|
|
|
// the pad. So now the polygonal shape is built, we can clamp the anchor size
|
|
|
|
if( margin.x < 0 ) // we expect margin.x = margin.y for custom pads
|
|
|
|
dummy.SetSize( padPlotsSize );
|
|
|
|
|
2018-05-16 16:26:43 +00:00
|
|
|
itemplotter.PlotPad( &dummy, color, plotMode );
|
|
|
|
}
|
|
|
|
break;
|
2009-06-29 05:30:08 +00:00
|
|
|
}
|
2012-09-25 07:49:29 +00:00
|
|
|
|
2020-06-21 18:47:58 +00:00
|
|
|
// Restore the pad parameters modified by the plot code
|
2012-09-25 07:49:29 +00:00
|
|
|
pad->SetSize( tmppadsize ); // Restore the pad size
|
2016-12-18 12:03:15 +00:00
|
|
|
pad->SetDelta( deltaSize );
|
2020-06-21 18:47:58 +00:00
|
|
|
pad->SetShape( padShape );
|
|
|
|
pad->SetRoundRectCornerRadius( padCornerRadius );
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
2016-09-19 11:01:36 +00:00
|
|
|
|
|
|
|
aPlotter->EndBlock( NULL );
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
// Plot vias on copper layers, and if aPlotOpt.GetPlotViaOnMaskLayer() is true,
|
|
|
|
// plot them on solder mask
|
2016-09-19 11:01:36 +00:00
|
|
|
|
|
|
|
GBR_METADATA gbr_metadata;
|
|
|
|
|
|
|
|
bool isOnCopperLayer = ( aLayerMask & LSET::AllCuMask() ).any();
|
|
|
|
|
|
|
|
if( isOnCopperLayer )
|
|
|
|
{
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_VIAPAD );
|
|
|
|
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_NET );
|
|
|
|
}
|
|
|
|
|
|
|
|
aPlotter->StartBlock( NULL );
|
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2014-06-06 09:44:21 +00:00
|
|
|
const VIA* Via = dyn_cast<const VIA*>( track );
|
2007-12-11 20:28:13 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
if( !Via )
|
|
|
|
continue;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
// vias are not plotted if not on selected layer, but if layer
|
|
|
|
// is SOLDERMASK_LAYER_BACK or SOLDERMASK_LAYER_FRONT,vias are drawn,
|
|
|
|
// only if they are on the corresponding external copper layer
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET via_mask_layer = Via->GetLayerSet();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
if( aPlotOpt.GetPlotViaOnMaskLayer() )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( via_mask_layer[B_Cu] )
|
|
|
|
via_mask_layer.set( B_Mask );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( via_mask_layer[F_Cu] )
|
|
|
|
via_mask_layer.set( F_Mask );
|
2012-09-24 06:39:59 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !( via_mask_layer & aLayerMask ).any() )
|
2012-09-24 06:39:59 +00:00
|
|
|
continue;
|
2007-12-11 20:28:13 +00:00
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
int via_margin = 0;
|
|
|
|
double width_adj = 0;
|
2009-11-20 14:55:20 +00:00
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
// If the current layer is a solder mask, use the global mask
|
|
|
|
// clearance for vias
|
2014-06-24 16:17:18 +00:00
|
|
|
if( aLayerMask[B_Mask] || aLayerMask[F_Mask] )
|
2012-09-24 06:39:59 +00:00
|
|
|
via_margin = aBoard->GetDesignSettings().m_SolderMaskMargin;
|
2012-01-23 04:33:36 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( ( aLayerMask & LSET::AllCuMask() ).any() )
|
2012-09-24 06:39:59 +00:00
|
|
|
width_adj = itemplotter.getFineWidthAdj();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
int diameter = Via->GetWidth() + 2 * via_margin + width_adj;
|
2007-12-11 20:28:13 +00:00
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
// Don't draw a null size item :
|
|
|
|
if( diameter <= 0 )
|
|
|
|
continue;
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2016-10-23 17:43:31 +00:00
|
|
|
// Some vias can be not connected (no net).
|
|
|
|
// Set the m_NotInNet for these vias to force a empty net name in gerber file
|
|
|
|
gbr_metadata.m_NetlistMetadata.m_NotInNet = Via->GetNetname().IsEmpty();
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
gbr_metadata.SetNetName( Via->GetNetname() );
|
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
COLOR4D color = aBoard->Colors().GetItemColor( LAYER_VIAS + Via->GetViaType() );
|
2012-09-24 06:39:59 +00:00
|
|
|
// Set plot color (change WHITE to LIGHTGRAY because
|
|
|
|
// the white items are not seen on a white paper or screen
|
|
|
|
aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY);
|
2016-09-19 11:01:36 +00:00
|
|
|
aPlotter->FlashPadCircle( Via->GetStart(), diameter, plotMode, &gbr_metadata );
|
2007-12-11 20:28:13 +00:00
|
|
|
}
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
aPlotter->EndBlock( NULL );
|
|
|
|
aPlotter->StartBlock( NULL );
|
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR );
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Plot tracks (not vias) :
|
2012-08-29 16:59:50 +00:00
|
|
|
for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
if( track->Type() == PCB_VIA_T )
|
2009-06-28 16:50:42 +00:00
|
|
|
continue;
|
2008-05-05 19:50:59 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !aLayerMask[track->GetLayer()] )
|
2009-06-28 16:50:42 +00:00
|
|
|
continue;
|
2008-05-05 19:50:59 +00:00
|
|
|
|
2016-10-23 17:43:31 +00:00
|
|
|
// Some track segments can be not connected (no net).
|
|
|
|
// Set the m_NotInNet for these segments to force a empty net name in gerber file
|
|
|
|
gbr_metadata.m_NetlistMetadata.m_NotInNet = track->GetNetname().IsEmpty();
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
gbr_metadata.SetNetName( track->GetNetname() );
|
2013-01-13 00:04:00 +00:00
|
|
|
int width = track->GetWidth() + itemplotter.getFineWidthAdj();
|
2012-09-24 06:39:59 +00:00
|
|
|
aPlotter->SetColor( itemplotter.getColor( track->GetLayer() ) );
|
2016-09-19 11:01:36 +00:00
|
|
|
aPlotter->ThickSegment( track->GetStart(), track->GetEnd(), width, plotMode, &gbr_metadata );
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
2008-12-22 21:06:44 +00:00
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
aPlotter->EndBlock( NULL );
|
|
|
|
|
2018-05-12 19:37:43 +00:00
|
|
|
// Plot zones (deprecated, for very old boards compatibility):
|
|
|
|
for( TRACK* track = aBoard->m_SegZoneDeprecated; track; track = track->Next() )
|
2007-12-11 20:28:13 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !aLayerMask[track->GetLayer()] )
|
2009-06-28 16:50:42 +00:00
|
|
|
continue;
|
2007-12-11 20:28:13 +00:00
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
int width = track->GetWidth() + itemplotter.getFineWidthAdj();
|
2012-09-24 06:39:59 +00:00
|
|
|
aPlotter->SetColor( itemplotter.getColor( track->GetLayer() ) );
|
2016-09-19 11:01:36 +00:00
|
|
|
aPlotter->ThickSegment( track->GetStart(), track->GetEnd(), width, plotMode, NULL );
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
2007-12-11 20:28:13 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Plot filled ares
|
2016-09-19 11:01:36 +00:00
|
|
|
aPlotter->StartBlock( NULL );
|
2012-08-29 16:59:50 +00:00
|
|
|
for( int ii = 0; ii < aBoard->GetAreaCount(); ii++ )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2012-09-21 08:20:38 +00:00
|
|
|
ZONE_CONTAINER* zone = aBoard->GetArea( ii );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !aLayerMask[zone->GetLayer()] )
|
2009-06-28 16:50:42 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-09-21 08:20:38 +00:00
|
|
|
itemplotter.PlotFilledAreas( zone );
|
2009-06-29 05:30:08 +00:00
|
|
|
}
|
2016-09-19 11:01:36 +00:00
|
|
|
aPlotter->EndBlock( NULL );
|
2012-09-24 06:39:59 +00:00
|
|
|
|
|
|
|
// Adding drill marks, if required and if the plotter is able to plot them:
|
|
|
|
if( aPlotOpt.GetDrillMarksType() != PCB_PLOT_PARAMS::NO_DRILL_SHAPE )
|
|
|
|
itemplotter.PlotDrillMarks();
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
// Seems like we want to plot from back to front?
|
2017-03-13 03:19:33 +00:00
|
|
|
static const PCB_LAYER_ID plot_seq[] = {
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
B_Adhes, // 32
|
|
|
|
F_Adhes,
|
|
|
|
B_Paste,
|
|
|
|
F_Paste,
|
|
|
|
B_SilkS,
|
|
|
|
B_Mask,
|
|
|
|
F_Mask,
|
|
|
|
Dwgs_User,
|
|
|
|
Cmts_User,
|
|
|
|
Eco1_User,
|
|
|
|
Eco2_User,
|
|
|
|
Edge_Cuts,
|
|
|
|
Margin,
|
|
|
|
|
|
|
|
F_CrtYd, // CrtYd & Body are footprint only
|
|
|
|
B_CrtYd,
|
|
|
|
F_Fab,
|
|
|
|
B_Fab,
|
|
|
|
|
|
|
|
B_Cu,
|
|
|
|
In30_Cu,
|
|
|
|
In29_Cu,
|
|
|
|
In28_Cu,
|
|
|
|
In27_Cu,
|
|
|
|
In26_Cu,
|
|
|
|
In25_Cu,
|
|
|
|
In24_Cu,
|
|
|
|
In23_Cu,
|
|
|
|
In22_Cu,
|
|
|
|
In21_Cu,
|
|
|
|
In20_Cu,
|
|
|
|
In19_Cu,
|
|
|
|
In18_Cu,
|
|
|
|
In17_Cu,
|
|
|
|
In16_Cu,
|
|
|
|
In15_Cu,
|
|
|
|
In14_Cu,
|
|
|
|
In13_Cu,
|
|
|
|
In12_Cu,
|
|
|
|
In11_Cu,
|
|
|
|
In10_Cu,
|
|
|
|
In9_Cu,
|
|
|
|
In8_Cu,
|
|
|
|
In7_Cu,
|
|
|
|
In6_Cu,
|
|
|
|
In5_Cu,
|
|
|
|
In4_Cu,
|
|
|
|
In3_Cu,
|
|
|
|
In2_Cu,
|
|
|
|
In1_Cu,
|
|
|
|
F_Cu,
|
|
|
|
|
|
|
|
F_SilkS,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-05-17 19:29:15 +00:00
|
|
|
/* Plot outlines of copper, for copper layer
|
|
|
|
*/
|
2015-07-27 19:45:57 +00:00
|
|
|
void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter,
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt )
|
2014-05-17 19:29:15 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt );
|
2014-06-24 16:17:18 +00:00
|
|
|
itemplotter.SetLayerSet( aLayerMask );
|
2014-05-17 19:29:15 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
SHAPE_POLY_SET outlines;
|
2014-05-17 19:29:15 +00:00
|
|
|
|
2019-01-06 16:43:12 +00:00
|
|
|
for( LSEQ seq = aLayerMask.Seq( plot_seq, arrayDim( plot_seq ) ); seq; ++seq )
|
2014-05-17 19:29:15 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layer = *seq;
|
2014-05-17 19:29:15 +00:00
|
|
|
|
|
|
|
outlines.RemoveAllContours();
|
|
|
|
aBoard->ConvertBrdLayerToPolygonalContours( layer, outlines );
|
|
|
|
|
2015-12-15 20:21:25 +00:00
|
|
|
outlines.Simplify( SHAPE_POLY_SET::PM_FAST );
|
2014-05-17 19:29:15 +00:00
|
|
|
|
|
|
|
// Plot outlines
|
|
|
|
std::vector< wxPoint > cornerList;
|
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
// Now we have one or more basic polygons: plot each polygon
|
|
|
|
for( int ii = 0; ii < outlines.OutlineCount(); ii++ )
|
2014-05-17 19:29:15 +00:00
|
|
|
{
|
2015-09-09 15:51:02 +00:00
|
|
|
for(int kk = 0; kk <= outlines.HoleCount (ii); kk++ )
|
|
|
|
{
|
|
|
|
cornerList.clear();
|
|
|
|
const SHAPE_LINE_CHAIN& path = (kk == 0) ? outlines.COutline( ii ) : outlines.CHole( ii, kk - 1 );
|
|
|
|
|
|
|
|
for( int jj = 0; jj < path.PointCount(); jj++ )
|
|
|
|
cornerList.push_back( wxPoint( path.CPoint( jj ).x , path.CPoint( jj ).y ) );
|
2014-05-17 19:29:15 +00:00
|
|
|
|
|
|
|
|
2015-09-09 15:51:02 +00:00
|
|
|
// Ensure the polygon is closed
|
|
|
|
if( cornerList[0] != cornerList[cornerList.size() - 1] )
|
|
|
|
cornerList.push_back( cornerList[0] );
|
2014-05-17 19:29:15 +00:00
|
|
|
|
2015-09-09 15:51:02 +00:00
|
|
|
aPlotter->PlotPoly( cornerList, NO_FILL );
|
|
|
|
}
|
2014-05-17 19:29:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Plot pad holes
|
|
|
|
if( aPlotOpt.GetDrillMarksType() != PCB_PLOT_PARAMS::NO_DRILL_SHAPE )
|
|
|
|
{
|
2018-01-26 19:48:56 +00:00
|
|
|
int smallDrill = (aPlotOpt.GetDrillMarksType() == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE)
|
|
|
|
? SMALL_DRILL : INT_MAX;
|
|
|
|
|
2014-05-17 19:29:15 +00:00
|
|
|
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
|
|
|
|
{
|
2017-04-25 09:06:24 +00:00
|
|
|
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
|
2014-05-17 19:29:15 +00:00
|
|
|
{
|
|
|
|
wxSize hole = pad->GetDrillSize();
|
|
|
|
|
|
|
|
if( hole.x == 0 || hole.y == 0 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( hole.x == hole.y )
|
2018-01-26 19:48:56 +00:00
|
|
|
{
|
|
|
|
hole.x = std::min( smallDrill, hole.x );
|
2014-05-17 19:29:15 +00:00
|
|
|
aPlotter->Circle( pad->GetPosition(), hole.x, NO_FILL );
|
2018-01-26 19:48:56 +00:00
|
|
|
}
|
2014-05-17 19:29:15 +00:00
|
|
|
else
|
|
|
|
{
|
2018-01-26 19:48:56 +00:00
|
|
|
// Note: small drill marks have no significance when applied to slots
|
2014-05-17 19:29:15 +00:00
|
|
|
wxPoint drl_start, drl_end;
|
|
|
|
int width;
|
|
|
|
pad->GetOblongDrillGeometry( drl_start, drl_end, width );
|
|
|
|
aPlotter->ThickSegment( pad->GetPosition() + drl_start,
|
2016-09-19 11:01:36 +00:00
|
|
|
pad->GetPosition() + drl_end, width, SKETCH, NULL );
|
2014-05-17 19:29:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Plot vias holes
|
|
|
|
for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
|
|
|
|
{
|
2014-06-06 09:44:21 +00:00
|
|
|
const VIA* via = dyn_cast<const VIA*>( track );
|
2014-05-17 19:29:15 +00:00
|
|
|
|
|
|
|
if( via && via->IsOnLayer( layer ) ) // via holes can be not through holes
|
|
|
|
{
|
|
|
|
aPlotter->Circle( via->GetPosition(), via->GetDrillValue(), NO_FILL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-05 20:20:34 +00:00
|
|
|
/* Plot a solder mask layer.
|
|
|
|
* Solder mask layers have a minimum thickness value and cannot be drawn like standard layers,
|
|
|
|
* unless the minimum thickness is 0.
|
2012-12-03 14:27:34 +00:00
|
|
|
* Currently the algo is:
|
|
|
|
* 1 - build all pad shapes as polygons with a size inflated by
|
|
|
|
* mask clearance + (min width solder mask /2)
|
|
|
|
* 2 - Merge shapes
|
|
|
|
* 3 - deflate result by (min width solder mask /2)
|
2015-12-15 20:21:25 +00:00
|
|
|
* 4 - ORing result by all pad shapes as polygons with a size inflated by
|
2012-12-03 14:27:34 +00:00
|
|
|
* mask clearance only (because deflate sometimes creates shape artifacts)
|
2013-03-18 19:36:07 +00:00
|
|
|
* 5 - draw result as polygons
|
2012-12-03 14:27:34 +00:00
|
|
|
*
|
2020-06-21 18:47:58 +00:00
|
|
|
* We have 2 algos:
|
|
|
|
* the initial algo, that create polygons for every shape, inflate and deflate polygons
|
|
|
|
* with Min Thickness/2, and merges the result.
|
|
|
|
* Drawback: pads attributes are lost (annoying in Gerber)
|
|
|
|
* the new algo:
|
|
|
|
* create initial polygons for every shape (pad or polygon),
|
|
|
|
* inflate and deflate polygons
|
|
|
|
* with Min Thickness/2, and merges the result (like initial algo)
|
|
|
|
* remove all initial polygons.
|
|
|
|
* The remaining polygons are areas with thickness < min thickness
|
|
|
|
* plot all initial shapes by flashing (or using regions) for pad and polygons
|
|
|
|
* (shapes will be better) and remaining polygons to
|
|
|
|
* remove areas with thickness < min thickness from final mask
|
|
|
|
*
|
|
|
|
* TODO: remove old code after more testing.
|
2012-11-05 20:20:34 +00:00
|
|
|
*/
|
2020-06-21 18:47:58 +00:00
|
|
|
#define NEW_ALGO 1
|
|
|
|
extern void KeepPolyInside( bool aInside );
|
|
|
|
|
2012-11-05 20:20:34 +00:00
|
|
|
void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter,
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt,
|
2012-11-05 20:20:34 +00:00
|
|
|
int aMinThickness )
|
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layer = aLayerMask[B_Mask] ? B_Mask : F_Mask;
|
2019-01-23 03:50:41 +00:00
|
|
|
|
|
|
|
// We remove 1nm as we expand both sides of the shapes, so allowing for
|
|
|
|
// a strictly greater than or equal comparison in the shape separation (boolean add)
|
|
|
|
// means that we will end up with separate shapes that then are shrunk
|
|
|
|
int inflate = aMinThickness/2 - 1;
|
2012-11-05 20:20:34 +00:00
|
|
|
|
|
|
|
BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt );
|
2014-06-24 16:17:18 +00:00
|
|
|
itemplotter.SetLayerSet( aLayerMask );
|
2012-11-05 20:20:34 +00:00
|
|
|
|
2019-08-13 07:54:32 +00:00
|
|
|
// Plot edge layer and graphic items.
|
2020-06-21 18:47:58 +00:00
|
|
|
// They do not have a solder Mask margin, because they graphic items
|
2015-08-01 10:20:23 +00:00
|
|
|
// on this layer (like logos), not actually areas around pads.
|
2020-06-21 18:47:58 +00:00
|
|
|
|
|
|
|
// Normal mode to generate polygons from shapes with arcs, if any:
|
|
|
|
DisableArcRadiusCorrection( false );
|
|
|
|
|
2012-11-05 20:20:34 +00:00
|
|
|
itemplotter.PlotBoardGraphicItems();
|
|
|
|
|
|
|
|
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
|
|
|
|
{
|
2017-04-25 09:06:24 +00:00
|
|
|
for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
|
2012-11-05 20:20:34 +00:00
|
|
|
{
|
2019-08-13 07:54:32 +00:00
|
|
|
itemplotter.PlotAllTextsModule( module );
|
|
|
|
|
2013-09-18 19:21:11 +00:00
|
|
|
if( layer != item->GetLayer() )
|
2012-11-05 20:20:34 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_MODULE_EDGE_T:
|
|
|
|
itemplotter.Plot_1_EdgeModule( (EDGE_MODULE*) item );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Build polygons for each pad shape.
|
|
|
|
// the size of the shape on solder mask should be:
|
|
|
|
// size of pad + clearance around the pad.
|
|
|
|
// clearance = solder mask clearance + extra margin
|
|
|
|
// extra margin is half the min width for solder mask
|
|
|
|
// This extra margin is used to merge too close shapes
|
|
|
|
// (distance < aMinThickness), and will be removed when creating
|
|
|
|
// the actual shapes
|
2020-06-21 18:47:58 +00:00
|
|
|
|
|
|
|
// Will contain shapes inflated by inflate value that will be merged and deflated by
|
|
|
|
// inflate value to build final polygons
|
|
|
|
// After calculations the remaining polygons are polygons to plot
|
|
|
|
SHAPE_POLY_SET areas;
|
|
|
|
// Will contain exact shapes of all items on solder mask
|
|
|
|
SHAPE_POLY_SET initialPolys;
|
|
|
|
|
|
|
|
#if NEW_ALGO
|
|
|
|
// Generate polygons with arcs inside the shape or exact shape
|
|
|
|
// to minimize shape changes created by arc to segment size correction.
|
|
|
|
DisableArcRadiusCorrection( true );
|
|
|
|
#endif
|
2012-11-05 20:20:34 +00:00
|
|
|
|
|
|
|
/* calculates the coeff to compensate radius reduction of holes clearance
|
|
|
|
* due to the segment approx ( 1 /cos( PI/circleToSegmentsCount )
|
|
|
|
*/
|
2019-01-04 01:21:10 +00:00
|
|
|
int circleToSegmentsCount = ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF;
|
2018-04-20 00:20:48 +00:00
|
|
|
double correction = GetCircletoPolyCorrectionFactor( circleToSegmentsCount );
|
2012-11-05 20:20:34 +00:00
|
|
|
|
|
|
|
// Plot pads
|
2013-05-01 19:01:14 +00:00
|
|
|
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
|
2012-11-05 20:20:34 +00:00
|
|
|
{
|
2020-06-21 18:47:58 +00:00
|
|
|
// add shapes with their exact mask layer size in initialPolys
|
2013-05-01 19:01:14 +00:00
|
|
|
module->TransformPadsShapesWithClearanceToPolygon( layer,
|
2018-07-30 10:52:03 +00:00
|
|
|
initialPolys, 0, circleToSegmentsCount, correction );
|
2020-06-21 18:47:58 +00:00
|
|
|
// add shapes inflated by aMinThickness/2 in areas
|
2013-05-01 19:01:14 +00:00
|
|
|
module->TransformPadsShapesWithClearanceToPolygon( layer,
|
2018-07-30 10:52:03 +00:00
|
|
|
areas, inflate, circleToSegmentsCount, correction );
|
2012-11-05 20:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Plot vias on solder masks, if aPlotOpt.GetPlotViaOnMaskLayer() is true,
|
|
|
|
if( aPlotOpt.GetPlotViaOnMaskLayer() )
|
|
|
|
{
|
2012-12-03 14:27:34 +00:00
|
|
|
// The current layer is a solder mask,
|
|
|
|
// use the global mask clearance for vias
|
|
|
|
int via_clearance = aBoard->GetDesignSettings().m_SolderMaskMargin;
|
|
|
|
int via_margin = via_clearance + inflate;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2012-11-05 20:20:34 +00:00
|
|
|
for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
|
|
|
|
{
|
2014-06-06 09:44:21 +00:00
|
|
|
const VIA* via = dyn_cast<const VIA*>( track );
|
2012-11-05 20:20:34 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
if( !via )
|
|
|
|
continue;
|
2012-11-05 20:20:34 +00:00
|
|
|
|
|
|
|
// vias are plotted only if they are on the corresponding
|
|
|
|
// external copper layer
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET via_set = via->GetLayerSet();
|
2012-11-05 20:20:34 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( via_set[B_Cu] )
|
|
|
|
via_set.set( B_Mask );
|
2012-11-05 20:20:34 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( via_set[F_Cu] )
|
|
|
|
via_set.set( F_Mask );
|
2012-11-05 20:20:34 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !( via_set & aLayerMask ).any() )
|
2012-11-05 20:20:34 +00:00
|
|
|
continue;
|
|
|
|
|
2020-06-21 18:47:58 +00:00
|
|
|
// add shapes with their exact mask layer size in initialPolys
|
2012-12-03 14:27:34 +00:00
|
|
|
via->TransformShapeWithClearanceToPolygon( initialPolys, via_clearance,
|
2020-06-21 18:47:58 +00:00
|
|
|
circleToSegmentsCount, correction );
|
|
|
|
// add shapes inflated by aMinThickness/2 in areas
|
|
|
|
via->TransformShapeWithClearanceToPolygon( areas, via_margin,
|
|
|
|
circleToSegmentsCount, correction );
|
2012-11-05 20:20:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-01 10:20:23 +00:00
|
|
|
// Add filled zone areas.
|
|
|
|
#if 0 // Set to 1 if a solder mask margin must be applied to zones on solder mask
|
|
|
|
int zone_margin = aBoard->GetDesignSettings().m_SolderMaskMargin;
|
|
|
|
#else
|
|
|
|
int zone_margin = 0;
|
|
|
|
#endif
|
|
|
|
|
2012-11-05 20:20:34 +00:00
|
|
|
for( int ii = 0; ii < aBoard->GetAreaCount(); ii++ )
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* zone = aBoard->GetArea( ii );
|
|
|
|
|
|
|
|
if( zone->GetLayer() != layer )
|
|
|
|
continue;
|
|
|
|
|
2020-06-21 18:47:58 +00:00
|
|
|
// add shapes inflated by aMinThickness/2 in areas
|
2015-07-27 19:45:57 +00:00
|
|
|
zone->TransformOutlinesShapeWithClearanceToPolygon( areas,
|
2015-08-01 10:20:23 +00:00
|
|
|
inflate+zone_margin, false );
|
2020-06-21 18:47:58 +00:00
|
|
|
// add shapes with their exact mask layer size in initialPolys
|
2014-12-01 14:54:33 +00:00
|
|
|
zone->TransformOutlinesShapeWithClearanceToPolygon( initialPolys,
|
2015-08-01 10:20:23 +00:00
|
|
|
zone_margin, false );
|
2012-11-05 20:20:34 +00:00
|
|
|
}
|
|
|
|
|
2020-06-21 18:47:58 +00:00
|
|
|
// Merge all polygons: After deflating, not merged (not overlapping) polygons
|
|
|
|
// will have the initial shape (with perhaps small changes due to deflating transform)
|
|
|
|
areas.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
|
|
|
areas.Inflate( -inflate, circleToSegmentsCount );
|
|
|
|
|
|
|
|
|
|
|
|
// Restore normal option to build polygons from item shapes:
|
|
|
|
DisableArcRadiusCorrection( false );
|
|
|
|
|
|
|
|
#if !NEW_ALGO
|
2014-12-01 14:54:33 +00:00
|
|
|
// To avoid a lot of code, use a ZONE_CONTAINER
|
|
|
|
// to handle and plot polygons, because our polygons look exactly like
|
|
|
|
// filled areas in zones
|
|
|
|
// Note, also this code is not optimized: it creates a lot of copy/duplicate data
|
|
|
|
// However it is not complex, and fast enough for plot purposes (copy/convert data
|
|
|
|
// is only a very small calculation time for these calculations)
|
|
|
|
ZONE_CONTAINER zone( aBoard );
|
2019-01-04 01:21:10 +00:00
|
|
|
zone.SetArcSegmentCount( ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF );
|
2014-12-01 14:54:33 +00:00
|
|
|
zone.SetMinThickness( 0 ); // trace polygons only
|
|
|
|
zone.SetLayer ( layer );
|
|
|
|
|
2015-12-15 20:21:25 +00:00
|
|
|
areas.BooleanAdd( initialPolys, SHAPE_POLY_SET::PM_FAST );
|
2015-07-27 19:45:57 +00:00
|
|
|
areas.Inflate( -inflate, circleToSegmentsCount );
|
2014-12-01 14:54:33 +00:00
|
|
|
|
|
|
|
// Combine the current areas to initial areas. This is mandatory because
|
|
|
|
// inflate/deflate transform is not perfect, and we want the initial areas perfectly kept
|
2015-12-15 20:21:25 +00:00
|
|
|
areas.BooleanAdd( initialPolys, SHAPE_POLY_SET::PM_FAST );
|
|
|
|
areas.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
2012-11-05 20:20:34 +00:00
|
|
|
|
2017-12-04 18:06:47 +00:00
|
|
|
zone.SetFilledPolysList( areas );
|
2014-12-01 14:54:33 +00:00
|
|
|
|
2012-11-05 20:20:34 +00:00
|
|
|
itemplotter.PlotFilledAreas( &zone );
|
2020-06-21 18:47:58 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
// Remove initial shapes: each shape will be added later, as flashed item or region
|
|
|
|
// with a suitable attribute.
|
|
|
|
// Do not merge pads is mandatory in Gerber files: They must be indentified as pads
|
|
|
|
|
|
|
|
// we deflate areas in polygons, to avoid after subtracting initial shapes
|
|
|
|
// having small artifacts due to approximations during polygon transforms
|
2020-12-13 17:53:17 +00:00
|
|
|
// *Do not use* here the option PM_STRICTLY_SIMPLE that can create very long calculation
|
|
|
|
// time in many cases
|
|
|
|
areas.BooleanSubtract( initialPolys, SHAPE_POLY_SET::PM_FAST);
|
|
|
|
|
|
|
|
// Ensure the remaining polygons are strictly simple to be sure Inflate and Fracture
|
|
|
|
// are using the cleaned polygons and no holes linked to main outlines in polygons
|
|
|
|
// for Simplify()
|
|
|
|
areas.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
2020-06-21 18:47:58 +00:00
|
|
|
|
|
|
|
// Slightly inflate polygons to avoid any gap between them and other shapes,
|
|
|
|
// These gaps are created by arc to segments approximations
|
|
|
|
areas.Inflate( Millimeter2iu( 0.002 ),6 );
|
|
|
|
|
|
|
|
// Now, only polygons with a too small thickness are stored in areas.
|
|
|
|
areas.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
|
|
|
|
|
|
|
// Plot each initial shape (pads and polygons on mask layer), with suitable attributes:
|
|
|
|
PlotStandardLayer( aBoard, aPlotter, aLayerMask, aPlotOpt );
|
|
|
|
|
|
|
|
// Add shapes corresponding to areas having too small thickness.
|
|
|
|
std::vector<wxPoint> cornerList;
|
|
|
|
|
|
|
|
for( int ii = 0; ii < areas.OutlineCount(); ii++ )
|
|
|
|
{
|
|
|
|
cornerList.clear();
|
|
|
|
const SHAPE_LINE_CHAIN& path = areas.COutline( ii );
|
|
|
|
|
|
|
|
// polygon area in mm^2 :
|
|
|
|
double curr_area = path.Area() / ( IU_PER_MM * IU_PER_MM );
|
|
|
|
|
|
|
|
// Skip very small polygons: they are certainly artifacts created by
|
|
|
|
// arc approximations and polygon transforms
|
|
|
|
// (inflate/deflate transforms)
|
|
|
|
constexpr double poly_min_area_mm2 = 0.01; // 0.01 mm^2 gives a good filtering
|
|
|
|
|
|
|
|
if( curr_area < poly_min_area_mm2 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for( int jj = 0; jj < path.PointCount(); jj++ )
|
|
|
|
cornerList.emplace_back( (wxPoint) path.CPoint( jj ) );
|
|
|
|
|
|
|
|
// Ensure the polygon is closed
|
|
|
|
if( cornerList[0] != cornerList[cornerList.size() - 1] )
|
|
|
|
cornerList.push_back( cornerList[0] );
|
|
|
|
|
|
|
|
aPlotter->PlotPoly( cornerList, FILLED_SHAPE );
|
|
|
|
}
|
|
|
|
#endif
|
2012-11-05 20:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
/** Set up most plot options for plotting a board (especially the viewport)
|
|
|
|
* Important thing:
|
|
|
|
* page size is the 'drawing' page size,
|
|
|
|
* paper size is the physical page size
|
|
|
|
*/
|
2012-09-24 16:03:03 +00:00
|
|
|
static void initializePlotter( PLOTTER *aPlotter, BOARD * aBoard,
|
2013-03-18 19:36:07 +00:00
|
|
|
PCB_PLOT_PARAMS *aPlotOpts )
|
2012-08-29 16:59:50 +00:00
|
|
|
{
|
|
|
|
PAGE_INFO pageA4( wxT( "A4" ) );
|
2012-09-24 16:03:03 +00:00
|
|
|
const PAGE_INFO& pageInfo = aBoard->GetPageSettings();
|
2012-08-29 16:59:50 +00:00
|
|
|
const PAGE_INFO* sheet_info;
|
|
|
|
double paperscale; // Page-to-paper ratio
|
|
|
|
wxSize paperSizeIU;
|
2012-09-24 16:03:03 +00:00
|
|
|
wxSize pageSizeIU( pageInfo.GetSizeIU() );
|
2012-08-29 16:59:50 +00:00
|
|
|
bool autocenter = false;
|
|
|
|
|
|
|
|
/* Special options: to fit the sheet to an A4 sheet replace
|
|
|
|
the paper size. However there is a difference between
|
|
|
|
the autoscale and the a4paper option:
|
|
|
|
- Autoscale fits the board to the paper size
|
|
|
|
- A4paper fits the original paper size to an A4 sheet
|
|
|
|
- Both of them fit the board to an A4 sheet
|
|
|
|
*/
|
|
|
|
if( aPlotOpts->GetA4Output() ) // Fit paper to A4
|
|
|
|
{
|
|
|
|
sheet_info = &pageA4;
|
|
|
|
paperSizeIU = pageA4.GetSizeIU();
|
|
|
|
paperscale = (double) paperSizeIU.x / pageSizeIU.x;
|
|
|
|
autocenter = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-24 16:03:03 +00:00
|
|
|
sheet_info = &pageInfo;
|
2012-08-29 16:59:50 +00:00
|
|
|
paperSizeIU = pageSizeIU;
|
|
|
|
paperscale = 1;
|
|
|
|
|
|
|
|
// Need autocentering only if scale is not 1:1
|
|
|
|
autocenter = (aPlotOpts->GetScale() != 1.0);
|
|
|
|
}
|
|
|
|
|
2012-09-24 16:03:03 +00:00
|
|
|
EDA_RECT bbox = aBoard->ComputeBoundingBox();
|
|
|
|
wxPoint boardCenter = bbox.Centre();
|
|
|
|
wxSize boardSize = bbox.GetSize();
|
2012-08-29 16:59:50 +00:00
|
|
|
|
|
|
|
double compound_scale;
|
|
|
|
|
|
|
|
/* Fit to 80% of the page if asked; it could be that the board is empty,
|
|
|
|
* in this case regress to 1:1 scale */
|
|
|
|
if( aPlotOpts->GetAutoScale() && boardSize.x > 0 && boardSize.y > 0 )
|
|
|
|
{
|
|
|
|
double xscale = (paperSizeIU.x * 0.8) / boardSize.x;
|
|
|
|
double yscale = (paperSizeIU.y * 0.8) / boardSize.y;
|
|
|
|
|
|
|
|
compound_scale = std::min( xscale, yscale ) * paperscale;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
compound_scale = aPlotOpts->GetScale() * paperscale;
|
|
|
|
|
|
|
|
|
|
|
|
/* For the plot offset we have to keep in mind the auxiliary origin
|
|
|
|
too: if autoscaling is off we check that plot option (i.e. autoscaling
|
|
|
|
overrides auxiliary origin) */
|
|
|
|
wxPoint offset( 0, 0);
|
|
|
|
|
|
|
|
if( autocenter )
|
|
|
|
{
|
|
|
|
offset.x = KiROUND( boardCenter.x - ( paperSizeIU.x / 2.0 ) / compound_scale );
|
|
|
|
offset.y = KiROUND( boardCenter.y - ( paperSizeIU.y / 2.0 ) / compound_scale );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( aPlotOpts->GetUseAuxOrigin() )
|
2013-08-03 05:15:23 +00:00
|
|
|
offset = aBoard->GetAuxOrigin();
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Configure the plotter object with all the stuff computed and
|
|
|
|
most of that taken from the options */
|
|
|
|
aPlotter->SetPageSettings( *sheet_info );
|
2012-09-24 06:39:59 +00:00
|
|
|
|
2016-06-05 11:49:25 +00:00
|
|
|
aPlotter->SetViewport( offset, IU_PER_MILS/10, compound_scale,
|
2012-08-29 16:59:50 +00:00
|
|
|
aPlotOpts->GetMirror() );
|
2014-07-04 14:22:38 +00:00
|
|
|
// has meaning only for gerber plotter. Must be called only after SetViewport
|
|
|
|
aPlotter->SetGerberCoordinatesFormat( aPlotOpts->GetGerberPrecision() );
|
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
aPlotter->SetDefaultLineWidth( aPlotOpts->GetLineWidth() );
|
|
|
|
aPlotter->SetCreator( wxT( "PCBNEW" ) );
|
2012-09-20 18:58:41 +00:00
|
|
|
aPlotter->SetColorMode( false ); // default is plot in Black and White.
|
2012-08-29 16:59:50 +00:00
|
|
|
aPlotter->SetTextMode( aPlotOpts->GetTextMode() );
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Prefill in black an area a little bigger than the board to prepare for the
|
|
|
|
* negative plot */
|
2012-09-24 06:39:59 +00:00
|
|
|
static void FillNegativeKnockout( PLOTTER *aPlotter, const EDA_RECT &aBbbox )
|
2012-08-29 16:59:50 +00:00
|
|
|
{
|
2012-09-24 06:39:59 +00:00
|
|
|
const int margin = 5 * IU_PER_MM; // Add a 5 mm margin around the board
|
2012-08-29 16:59:50 +00:00
|
|
|
aPlotter->SetNegative( true );
|
2012-09-24 06:39:59 +00:00
|
|
|
aPlotter->SetColor( WHITE ); // Which will be plotted as black
|
|
|
|
EDA_RECT area = aBbbox;
|
|
|
|
area.Inflate( margin );
|
|
|
|
aPlotter->Rect( area.GetOrigin(), area.GetEnd(), FILLED_SHAPE );
|
2012-08-29 16:59:50 +00:00
|
|
|
aPlotter->SetColor( BLACK );
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Calculate the effective size of HPGL pens and set them in the
|
|
|
|
* plotter object */
|
|
|
|
static void ConfigureHPGLPenSizes( HPGL_PLOTTER *aPlotter,
|
|
|
|
PCB_PLOT_PARAMS *aPlotOpts )
|
|
|
|
{
|
|
|
|
/* Compute pen_dim (the value is given in mils) in pcb units,
|
|
|
|
with plot scale (if Scale is 2, pen diameter value is always m_HPGLPenDiam
|
2012-09-24 06:39:59 +00:00
|
|
|
so apparent pen diam is actually pen diam / Scale */
|
2012-08-29 16:59:50 +00:00
|
|
|
int pen_diam = KiROUND( aPlotOpts->GetHPGLPenDiameter() * IU_PER_MILS /
|
|
|
|
aPlotOpts->GetScale() );
|
|
|
|
|
|
|
|
// Set HPGL-specific options and start
|
|
|
|
aPlotter->SetPenSpeed( aPlotOpts->GetHPGLPenSpeed() );
|
|
|
|
aPlotter->SetPenNumber( aPlotOpts->GetHPGLPenNum() );
|
|
|
|
aPlotter->SetPenDiameter( pen_diam );
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Open a new plotfile using the options (and especially the format)
|
|
|
|
* specified in the options and prepare the page for plotting.
|
|
|
|
* Return the plotter object if OK, NULL if the file is not created
|
|
|
|
* (or has a problem)
|
|
|
|
*/
|
2013-02-06 15:21:37 +00:00
|
|
|
PLOTTER* StartPlotBoard( BOARD *aBoard, PCB_PLOT_PARAMS *aPlotOpts,
|
2014-06-19 06:26:53 +00:00
|
|
|
int aLayer,
|
2012-08-29 16:59:50 +00:00
|
|
|
const wxString& aFullFileName,
|
|
|
|
const wxString& aSheetDesc )
|
|
|
|
{
|
|
|
|
// Create the plotter driver and set the few plotter specific
|
|
|
|
// options
|
2013-02-06 15:21:37 +00:00
|
|
|
PLOTTER* plotter = NULL;
|
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
switch( aPlotOpts->GetFormat() )
|
|
|
|
{
|
|
|
|
case PLOT_FORMAT_DXF:
|
2019-06-13 00:28:22 +00:00
|
|
|
DXF_PLOTTER* DXF_plotter;
|
|
|
|
DXF_plotter = new DXF_PLOTTER();
|
2019-07-10 14:47:12 +00:00
|
|
|
DXF_plotter->SetUnits(
|
|
|
|
static_cast<DXF_PLOTTER::DXF_UNITS>( aPlotOpts->GetDXFPlotUnits() ) );
|
2019-06-13 00:28:22 +00:00
|
|
|
|
|
|
|
plotter = DXF_plotter;
|
2012-08-29 16:59:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PLOT_FORMAT_POST:
|
|
|
|
PS_PLOTTER* PS_plotter;
|
|
|
|
PS_plotter = new PS_PLOTTER();
|
|
|
|
PS_plotter->SetScaleAdjust( aPlotOpts->GetFineScaleAdjustX(),
|
2012-09-15 12:13:03 +00:00
|
|
|
aPlotOpts->GetFineScaleAdjustY() );
|
2013-02-06 15:21:37 +00:00
|
|
|
plotter = PS_plotter;
|
2012-08-29 16:59:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PLOT_FORMAT_PDF:
|
2013-02-06 15:21:37 +00:00
|
|
|
plotter = new PDF_PLOTTER();
|
2012-08-29 16:59:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PLOT_FORMAT_HPGL:
|
|
|
|
HPGL_PLOTTER* HPGL_plotter;
|
|
|
|
HPGL_plotter = new HPGL_PLOTTER();
|
|
|
|
|
|
|
|
/* HPGL options are a little more convoluted to compute, so
|
2018-04-08 10:28:59 +00:00
|
|
|
they're split in another function */
|
2012-08-29 16:59:50 +00:00
|
|
|
ConfigureHPGLPenSizes( HPGL_plotter, aPlotOpts );
|
2013-02-06 15:21:37 +00:00
|
|
|
plotter = HPGL_plotter;
|
2012-08-29 16:59:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PLOT_FORMAT_GERBER:
|
2013-02-06 15:21:37 +00:00
|
|
|
plotter = new GERBER_PLOTTER();
|
2012-08-29 16:59:50 +00:00
|
|
|
break;
|
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
case PLOT_FORMAT_SVG:
|
2013-02-06 15:21:37 +00:00
|
|
|
plotter = new SVG_PLOTTER();
|
2012-09-15 12:13:03 +00:00
|
|
|
break;
|
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
default:
|
|
|
|
wxASSERT( false );
|
2013-02-06 15:21:37 +00:00
|
|
|
return NULL;
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
|
|
|
|
2012-09-25 07:49:29 +00:00
|
|
|
// Compute the viewport and set the other options
|
2013-12-06 18:31:15 +00:00
|
|
|
|
|
|
|
// page layout is not mirrored, so temporary change mirror option
|
|
|
|
// just to plot the page layout
|
|
|
|
PCB_PLOT_PARAMS plotOpts = *aPlotOpts;
|
|
|
|
|
|
|
|
if( plotOpts.GetPlotFrameRef() && plotOpts.GetMirror() )
|
|
|
|
plotOpts.SetMirror( false );
|
|
|
|
|
|
|
|
initializePlotter( plotter, aBoard, &plotOpts );
|
2012-08-29 16:59:50 +00:00
|
|
|
|
2013-02-06 15:21:37 +00:00
|
|
|
if( plotter->OpenFile( aFullFileName ) )
|
2012-09-25 07:49:29 +00:00
|
|
|
{
|
2015-03-25 13:07:05 +00:00
|
|
|
plotter->ClearHeaderLinesList();
|
|
|
|
|
2014-06-19 06:26:53 +00:00
|
|
|
// For the Gerber "file function" attribute, set the layer number
|
2014-10-31 18:59:37 +00:00
|
|
|
if( plotter->GetPlotterType() == PLOT_FORMAT_GERBER )
|
|
|
|
{
|
2018-12-08 16:46:41 +00:00
|
|
|
bool useX2mode = plotOpts.GetUseGerberX2format();
|
2015-03-25 13:07:05 +00:00
|
|
|
|
2018-12-08 16:46:41 +00:00
|
|
|
GERBER_PLOTTER* gbrplotter = static_cast <GERBER_PLOTTER*> ( plotter );
|
2018-12-09 09:23:07 +00:00
|
|
|
gbrplotter->UseX2format( useX2mode );
|
2018-12-08 16:46:41 +00:00
|
|
|
gbrplotter->UseX2NetAttributes( plotOpts.GetIncludeGerberNetlistInfo() );
|
|
|
|
|
2018-12-09 09:23:07 +00:00
|
|
|
// Attributes can be added using X2 format or as comment (X1 format)
|
2018-12-08 16:46:41 +00:00
|
|
|
AddGerberX2Attribute( plotter, aBoard, aLayer, not useX2mode );
|
2014-10-31 18:59:37 +00:00
|
|
|
}
|
2014-06-19 06:26:53 +00:00
|
|
|
|
2013-02-06 15:21:37 +00:00
|
|
|
plotter->StartPlot();
|
2012-10-13 18:54:33 +00:00
|
|
|
|
2012-09-25 07:49:29 +00:00
|
|
|
// Plot the frame reference if requested
|
|
|
|
if( aPlotOpts->GetPlotFrameRef() )
|
2013-12-06 18:31:15 +00:00
|
|
|
{
|
2013-02-06 15:21:37 +00:00
|
|
|
PlotWorkSheet( plotter, aBoard->GetTitleBlock(),
|
2012-09-25 07:49:29 +00:00
|
|
|
aBoard->GetPageSettings(),
|
|
|
|
1, 1, // Only one page
|
|
|
|
aSheetDesc, aBoard->GetFileName() );
|
|
|
|
|
2013-12-06 18:31:15 +00:00
|
|
|
if( aPlotOpts->GetMirror() )
|
2014-06-19 06:26:53 +00:00
|
|
|
initializePlotter( plotter, aBoard, aPlotOpts );
|
2013-12-06 18:31:15 +00:00
|
|
|
}
|
|
|
|
|
2012-09-25 07:49:29 +00:00
|
|
|
/* When plotting a negative board: draw a black rectangle
|
|
|
|
* (background for plot board in white) and switch the current
|
|
|
|
* color to WHITE; note the color inversion is actually done
|
|
|
|
* in the driver (if supported) */
|
|
|
|
if( aPlotOpts->GetNegative() )
|
2012-08-29 16:59:50 +00:00
|
|
|
{
|
2012-09-25 07:49:29 +00:00
|
|
|
EDA_RECT bbox = aBoard->ComputeBoundingBox();
|
2013-02-06 15:21:37 +00:00
|
|
|
FillNegativeKnockout( plotter, bbox );
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
2012-09-25 07:49:29 +00:00
|
|
|
|
2013-02-06 15:21:37 +00:00
|
|
|
return plotter;
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
|
|
|
|
2013-02-06 15:21:37 +00:00
|
|
|
delete plotter;
|
2012-08-29 16:59:50 +00:00
|
|
|
return NULL;
|
|
|
|
}
|