2012-09-24 16:03:03 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2024-03-03 10:56:41 +00:00
|
|
|
* Copyright (C) 1992-2024 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
|
|
|
|
*/
|
|
|
|
|
2023-03-29 16:53:28 +00:00
|
|
|
#include <wx/log.h>
|
2020-10-14 01:06:53 +00:00
|
|
|
#include <eda_item.h>
|
2022-03-29 20:08:02 +00:00
|
|
|
#include <layer_ids.h>
|
2018-04-20 00:20:48 +00:00
|
|
|
#include <geometry/geometry_utils.h>
|
2020-06-22 19:35:09 +00:00
|
|
|
#include <geometry/shape_segment.h>
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <math/util.h> // for KiROUND
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
|
|
|
#include <footprint.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <pad.h>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <zone.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <pcb_shape.h>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <pcb_target.h>
|
2021-06-11 16:59:28 +00:00
|
|
|
#include <pcb_dimension.h>
|
2012-02-19 04:02:19 +00:00
|
|
|
#include <pcbplot.h>
|
2021-08-18 20:38:14 +00:00
|
|
|
#include <plotters/plotter_dxf.h>
|
|
|
|
#include <plotters/plotter_hpgl.h>
|
|
|
|
#include <plotters/plotter_gerber.h>
|
|
|
|
#include <plotters/plotters_pslike.h>
|
2020-04-14 12:25:00 +00:00
|
|
|
#include <pcb_painter.h>
|
2018-05-17 05:49:38 +00:00
|
|
|
#include <gbr_metadata.h>
|
2021-01-04 22:26:23 +00:00
|
|
|
#include <advanced_config.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2019-07-13 22:34:09 +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-11-05 20:20:34 +00:00
|
|
|
*/
|
2019-07-13 22:34:09 +00:00
|
|
|
static void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
|
|
|
|
const PCB_PLOT_PARAMS& aPlotOpt, int aMinThickness );
|
2012-11-05 20:20:34 +00:00
|
|
|
|
2020-10-13 17:46:48 +00:00
|
|
|
|
2022-03-29 20:08:02 +00:00
|
|
|
void PlotBoardLayers( BOARD* aBoard, PLOTTER* aPlotter, const LSEQ& aLayers,
|
|
|
|
const PCB_PLOT_PARAMS& aPlotOptions )
|
|
|
|
{
|
|
|
|
wxCHECK( aBoard && aPlotter && aLayers.size(), /* void */ );
|
|
|
|
|
2024-05-27 19:05:54 +00:00
|
|
|
// if a drill mark must be plotted, the copper layer needs to be plotted
|
|
|
|
// after other layers because the drill mark must be plotted as a filled
|
|
|
|
// white shape *after* all other shapes are plotted
|
|
|
|
bool plot_mark = aPlotOptions.GetDrillMarksType() != DRILL_MARKS::NO_DRILL_SHAPE;
|
|
|
|
|
2022-03-29 20:08:02 +00:00
|
|
|
for( LSEQ seq = aLayers; seq; ++seq )
|
2024-05-27 19:05:54 +00:00
|
|
|
{
|
|
|
|
// copper layers with drill marks will be plotted after all other layers
|
|
|
|
if( *seq <= B_Cu && plot_mark )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
PlotOneBoardLayer( aBoard, aPlotter, *seq, aPlotOptions );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !plot_mark )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for( LSEQ seq = aLayers; seq; ++seq )
|
|
|
|
{
|
|
|
|
if( *seq > B_Cu ) // already plotted
|
|
|
|
continue;
|
|
|
|
|
2022-03-29 20:08:02 +00:00
|
|
|
PlotOneBoardLayer( aBoard, aPlotter, *seq, aPlotOptions );
|
2024-05-27 19:05:54 +00:00
|
|
|
}
|
2022-03-29 20:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-04-30 17:09:40 +00:00
|
|
|
void PlotInteractiveLayer( BOARD* aBoard, PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpt )
|
2022-09-05 22:28:44 +00:00
|
|
|
{
|
|
|
|
for( const FOOTPRINT* fp : aBoard->Footprints() )
|
|
|
|
{
|
2023-04-30 17:09:40 +00:00
|
|
|
if( fp->GetLayer() == F_Cu && !aPlotOpt.m_PDFFrontFPPropertyPopups )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( fp->GetLayer() == B_Cu && !aPlotOpt.m_PDFBackFPPropertyPopups )
|
|
|
|
continue;
|
|
|
|
|
2022-09-05 22:28:44 +00:00
|
|
|
std::vector<wxString> properties;
|
|
|
|
|
|
|
|
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
|
|
|
_( "Reference designator" ),
|
2023-05-05 13:21:56 +00:00
|
|
|
fp->Reference().GetShownText( false ) ) );
|
2022-09-05 22:28:44 +00:00
|
|
|
|
|
|
|
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
|
|
|
_( "Value" ),
|
2023-05-05 13:21:56 +00:00
|
|
|
fp->Value().GetShownText( false ) ) );
|
2022-09-05 22:28:44 +00:00
|
|
|
|
|
|
|
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
|
|
|
_( "Footprint" ),
|
2023-07-04 17:03:20 +00:00
|
|
|
fp->GetFPID().GetUniStringLibItemName() ) );
|
|
|
|
|
|
|
|
for( int i = 0; i < fp->GetFieldCount(); i++ )
|
|
|
|
{
|
|
|
|
PCB_FIELD* field = fp->GetFields().at( i );
|
|
|
|
|
|
|
|
if( field->IsReference() || field->IsValue() || field->IsFootprint() )
|
|
|
|
continue;
|
2022-09-05 22:28:44 +00:00
|
|
|
|
2023-07-04 17:03:20 +00:00
|
|
|
if( field->GetText().IsEmpty() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
|
|
|
field->GetName(),
|
|
|
|
field->GetText() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// These 2 properties are not very useful in a plot file (like a PDF)
|
|
|
|
#if 0
|
2023-06-19 17:08:18 +00:00
|
|
|
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), _( "Library Description" ),
|
|
|
|
fp->GetLibDescription() ) );
|
2022-09-05 22:28:44 +00:00
|
|
|
|
|
|
|
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
|
|
|
_( "Keywords" ),
|
|
|
|
fp->GetKeywords() ) );
|
2023-07-04 17:03:20 +00:00
|
|
|
#endif
|
2024-03-10 12:04:39 +00:00
|
|
|
// Draw items are plotted with a position offset. So we need to move
|
|
|
|
// our boxes (which are not plotted) by the same offset.
|
|
|
|
VECTOR2I offset = -aPlotter->GetPlotOffsetUserUnits();
|
|
|
|
|
|
|
|
// Use a footprint bbox without texts to create the hyperlink area
|
|
|
|
BOX2I bbox = fp->GetBoundingBox( false, false );
|
|
|
|
bbox.Move( offset );
|
|
|
|
aPlotter->HyperlinkMenu( bbox, properties );
|
|
|
|
|
|
|
|
// Use a footprint bbox with visible texts only to create the bookmark area
|
|
|
|
// which is the area to zoom on ft selection
|
|
|
|
// However the bbox need to be inflated for a better look.
|
|
|
|
bbox = fp->GetBoundingBox( true, false );
|
|
|
|
bbox.Move( offset );
|
|
|
|
bbox.Inflate( bbox.GetWidth() /2, bbox.GetHeight() /2 );
|
|
|
|
aPlotter->Bookmark( bbox, fp->GetReference(), _( "Footprints" ) );
|
2022-09-05 22:28:44 +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
|
|
|
{
|
2024-05-20 10:38:39 +00:00
|
|
|
auto plotLayer =
|
|
|
|
[&]( LSET layerMask, PCB_PLOT_PARAMS& plotOpts )
|
|
|
|
{
|
|
|
|
// PlotLayerOutlines() is designed only for DXF plotters.
|
|
|
|
if( plotOpts.GetFormat() == PLOT_FORMAT::DXF && plotOpts.GetDXFPlotPolygonMode() )
|
|
|
|
PlotLayerOutlines( aBoard, aPlotter, layerMask, plotOpts );
|
|
|
|
else
|
|
|
|
PlotStandardLayer( aBoard, aPlotter, layerMask, plotOpts );
|
|
|
|
};
|
|
|
|
|
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
|
2021-01-03 13:59:23 +00:00
|
|
|
aPlotter->SetColor( BLACK );
|
2012-09-12 11:11:30 +00:00
|
|
|
aPlotter->SetTextMode( aPlotOpt.GetTextMode() );
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2019-07-13 22:34:09 +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
|
|
|
|
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 ):
|
2024-05-20 10:38:39 +00:00
|
|
|
// Drill mark will be plotted if drill mark is SMALL_DRILL_SHAPE or FULL_DRILL_SHAPE
|
2019-12-28 00:55:11 +00:00
|
|
|
if( plotOpt.GetFormat() == PLOT_FORMAT::DXF )
|
2024-05-20 10:38:39 +00:00
|
|
|
plotOpt.SetDXFPlotPolygonMode( true );
|
2014-05-17 19:29:15 +00:00
|
|
|
else
|
|
|
|
plotOpt.SetSkipPlotNPTH_Pads( true );
|
2024-05-20 10:38:39 +00:00
|
|
|
|
|
|
|
plotLayer( layer_mask, plotOpt );
|
2014-06-24 16:17:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch( aLayer )
|
|
|
|
{
|
|
|
|
case B_Mask:
|
|
|
|
case F_Mask:
|
|
|
|
// Disable plot pad holes
|
2022-11-12 07:48:25 +00:00
|
|
|
plotOpt.SetDrillMarksType( DRILL_MARKS::NO_DRILL_SHAPE );
|
2009-06-25 20:45:27 +00:00
|
|
|
|
2024-05-20 10:38:39 +00:00
|
|
|
// Use outline mode for DXF
|
|
|
|
plotOpt.SetDXFPlotPolygonMode( true );
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// Plot solder mask:
|
|
|
|
if( soldermask_min_thickness == 0 )
|
|
|
|
{
|
2024-05-20 10:38:39 +00:00
|
|
|
plotLayer( layer_mask, plotOpt );
|
2014-06-24 16:17:18 +00:00
|
|
|
}
|
|
|
|
else
|
2021-06-18 21:07:19 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
PlotSolderMaskLayer( aBoard, aPlotter, layer_mask, plotOpt,
|
|
|
|
soldermask_min_thickness );
|
2021-06-18 21:07:19 +00:00
|
|
|
}
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
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:
|
|
|
|
// Disable plot pad holes
|
2022-11-12 07:48:25 +00:00
|
|
|
plotOpt.SetDrillMarksType( DRILL_MARKS::NO_DRILL_SHAPE );
|
2012-11-05 20:20:34 +00:00
|
|
|
|
2024-05-20 10:38:39 +00:00
|
|
|
// Use outline mode for DXF
|
|
|
|
plotOpt.SetDXFPlotPolygonMode( true );
|
|
|
|
|
|
|
|
plotLayer( layer_mask, plotOpt );
|
2021-06-18 21:07:19 +00:00
|
|
|
|
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:
|
2024-05-20 10:38:39 +00:00
|
|
|
plotLayer( 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
|
2019-12-28 00:55:11 +00:00
|
|
|
if( aPlotter->GetPlotterType() == PLOT_FORMAT::GERBER
|
|
|
|
&& plotOpt.GetSubtractMaskFromSilk() )
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
|
|
|
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
|
2022-11-12 07:48:25 +00:00
|
|
|
plotOpt.SetDrillMarksType( DRILL_MARKS::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 );
|
2023-04-07 09:23:24 +00:00
|
|
|
|
|
|
|
// Disable the negative polarity
|
|
|
|
aPlotter->SetLayerPolarity( true );
|
2014-06-24 16:17:18 +00:00
|
|
|
}
|
2021-06-18 21:07:19 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
break;
|
2010-12-06 22:18:39 +00:00
|
|
|
|
2014-11-13 08:00:28 +00:00
|
|
|
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:
|
|
|
|
default:
|
2024-05-20 10:38:39 +00:00
|
|
|
plotLayer( 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
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/**
|
2024-05-20 10:38:39 +00:00
|
|
|
* Plot any layer EXCEPT a solder-mask with an enforced minimum width.
|
2009-06-28 16:50:42 +00:00
|
|
|
*/
|
2021-07-19 23:56:05 +00:00
|
|
|
void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
|
2020-09-29 20:40:17 +00:00
|
|
|
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 );
|
2023-05-29 15:22:06 +00:00
|
|
|
int maxError = aBoard->GetDesignSettings().m_MaxError;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
itemplotter.SetLayerSet( aLayerMask );
|
2012-09-21 08:20:38 +00:00
|
|
|
|
2020-10-15 23:33:18 +00:00
|
|
|
OUTLINE_MODE plotMode = aPlotOpt.GetPlotMode();
|
2020-05-01 16:24:01 +00:00
|
|
|
bool onCopperLayer = ( LSET::AllCuMask() & aLayerMask ).any();
|
|
|
|
bool onSolderMaskLayer = ( LSET( 2, F_Mask, B_Mask ) & aLayerMask ).any();
|
|
|
|
bool onSolderPasteLayer = ( LSET( 2, F_Paste, B_Paste ) & aLayerMask ).any();
|
2024-05-20 10:38:39 +00:00
|
|
|
bool onFrontFab = ( LSET( F_Fab ) & aLayerMask ).any();
|
2020-05-27 01:14:08 +00:00
|
|
|
bool onBackFab = ( LSET( B_Fab ) & aLayerMask ).any();
|
|
|
|
bool sketchPads = ( onFrontFab || onBackFab ) && aPlotOpt.GetSketchPadsOnFabLayers();
|
2007-12-11 20:28:13 +00:00
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
// Plot edge layer and graphic items
|
2023-06-06 11:30:35 +00:00
|
|
|
for( const BOARD_ITEM* item : aBoard->Drawings() )
|
|
|
|
itemplotter.PlotBoardGraphicItem( item );
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2019-08-13 07:43:36 +00:00
|
|
|
// Draw footprint texts:
|
2021-03-06 09:27:41 +00:00
|
|
|
for( const FOOTPRINT* footprint : aBoard->Footprints() )
|
2020-11-13 00:43:45 +00:00
|
|
|
itemplotter.PlotFootprintTextItems( footprint );
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2019-08-13 07:43:36 +00:00
|
|
|
// Draw footprint other graphic items:
|
2021-03-06 09:27:41 +00:00
|
|
|
for( const FOOTPRINT* footprint : aBoard->Footprints() )
|
2020-11-13 00:43:45 +00:00
|
|
|
itemplotter.PlotFootprintGraphicItems( footprint );
|
2008-11-22 20:50:30 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Plot footprint pads
|
2020-11-13 15:15:52 +00:00
|
|
|
for( FOOTPRINT* footprint : aBoard->Footprints() )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
aPlotter->StartBlock( nullptr );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2020-11-13 00:43:45 +00:00
|
|
|
for( PAD* pad : footprint->Pads() )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2020-10-15 23:33:18 +00:00
|
|
|
OUTLINE_MODE padPlotMode = plotMode;
|
2020-05-01 16:24:01 +00:00
|
|
|
|
|
|
|
if( !( pad->GetLayerSet() & aLayerMask ).any() )
|
|
|
|
{
|
2020-05-27 01:14:08 +00:00
|
|
|
if( sketchPads &&
|
|
|
|
( ( onFrontFab && pad->GetLayerSet().Contains( F_Cu ) ) ||
|
|
|
|
( onBackFab && pad->GetLayerSet().Contains( B_Cu ) ) ) )
|
2021-06-18 21:07:19 +00:00
|
|
|
{
|
2020-05-01 16:24:01 +00:00
|
|
|
padPlotMode = SKETCH;
|
2021-06-18 21:07:19 +00:00
|
|
|
}
|
2020-05-01 16:24:01 +00:00
|
|
|
else
|
2021-06-18 21:07:19 +00:00
|
|
|
{
|
2020-05-01 16:24:01 +00:00
|
|
|
continue;
|
2021-06-18 21:07:19 +00:00
|
|
|
}
|
2020-05-01 16:24:01 +00:00
|
|
|
}
|
2009-03-18 15:38:16 +00:00
|
|
|
|
2023-04-08 14:02:48 +00:00
|
|
|
if( onCopperLayer && !pad->IsOnCopperLayer() )
|
|
|
|
continue;
|
|
|
|
|
2020-07-27 19:41:50 +00:00
|
|
|
/// pads not connected to copper are optionally not drawn
|
2020-09-29 20:40:17 +00:00
|
|
|
if( onCopperLayer && !pad->FlashLayer( aLayerMask ) )
|
2020-07-27 19:41:50 +00:00
|
|
|
continue;
|
|
|
|
|
2020-06-22 19:35:09 +00:00
|
|
|
COLOR4D color = COLOR4D::BLACK;
|
|
|
|
|
2022-10-25 23:06:05 +00:00
|
|
|
// If we're plotting a single layer, the color for that layer can be used directly.
|
|
|
|
if( aLayerMask.count() == 1 )
|
|
|
|
{
|
|
|
|
color = aPlotOpt.ColorSettings()->GetColor( aLayerMask.Seq()[0] );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( ( pad->GetLayerSet() & aLayerMask )[B_Cu] )
|
|
|
|
color = aPlotOpt.ColorSettings()->GetColor( B_Cu );
|
2020-06-22 19:35:09 +00:00
|
|
|
|
2022-10-25 23:06:05 +00:00
|
|
|
if( ( pad->GetLayerSet() & aLayerMask )[F_Cu] )
|
|
|
|
color = color.LegacyMix( aPlotOpt.ColorSettings()->GetColor( F_Cu ) );
|
2020-06-22 19:35:09 +00:00
|
|
|
|
2022-10-25 23:06:05 +00:00
|
|
|
if( sketchPads && aLayerMask[F_Fab] )
|
|
|
|
color = aPlotOpt.ColorSettings()->GetColor( F_Fab );
|
|
|
|
else if( sketchPads && aLayerMask[B_Fab] )
|
|
|
|
color = aPlotOpt.ColorSettings()->GetColor( B_Fab );
|
|
|
|
}
|
2020-06-22 19:35:09 +00:00
|
|
|
|
2024-05-27 19:56:16 +00:00
|
|
|
if( sketchPads &&
|
|
|
|
( ( onFrontFab && pad->GetLayerSet().Contains( F_Cu ) ) ||
|
|
|
|
( onBackFab && pad->GetLayerSet().Contains( B_Cu ) ) ) )
|
|
|
|
{
|
|
|
|
if( aPlotOpt.GetPlotPadNumbers() )
|
|
|
|
itemplotter.PlotPadNumber( pad, color );
|
|
|
|
}
|
|
|
|
|
2022-01-05 01:42:27 +00:00
|
|
|
VECTOR2I margin;
|
2020-06-22 19:35:09 +00:00
|
|
|
int width_adj = 0;
|
2012-01-23 04:33:36 +00:00
|
|
|
|
2020-05-01 16:24:01 +00:00
|
|
|
if( onCopperLayer )
|
2021-03-06 09:27:41 +00:00
|
|
|
width_adj = itemplotter.getFineWidthAdj();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2020-05-01 16:24:01 +00:00
|
|
|
if( onSolderMaskLayer )
|
2021-08-22 22:05:47 +00:00
|
|
|
margin.x = margin.y = pad->GetSolderMaskExpansion();
|
2020-05-01 16:24:01 +00:00
|
|
|
|
|
|
|
if( onSolderPasteLayer )
|
2014-06-24 16:17:18 +00:00
|
|
|
margin = pad->GetSolderPasteMargin();
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2021-02-26 09:36:04 +00:00
|
|
|
// not all shapes can have a different margin for x and y axis
|
|
|
|
// in fact only oval and rect shapes can have different values.
|
|
|
|
// Round shape have always the same x,y margin
|
|
|
|
// so define a unique value for other shapes that do not support different values
|
|
|
|
int mask_clearance = margin.x;
|
|
|
|
|
2016-12-18 12:03:15 +00:00
|
|
|
// Now offset the pad size by margin + width_adj
|
2022-01-05 01:42:27 +00:00
|
|
|
VECTOR2I padPlotsSize = pad->GetSize() + margin * 2 + VECTOR2I( width_adj, width_adj );
|
2020-03-25 15:16:47 +00:00
|
|
|
|
|
|
|
// Store these parameters that can be modified to plot inflated/deflated pads shape
|
2021-05-01 12:22:35 +00:00
|
|
|
PAD_SHAPE padShape = pad->GetShape();
|
2022-03-29 20:08:02 +00:00
|
|
|
VECTOR2I padSize = pad->GetSize();
|
2022-01-05 01:42:27 +00:00
|
|
|
VECTOR2I padDelta = pad->GetDelta(); // has meaning only for trapezoidal pads
|
2024-03-03 10:56:41 +00:00
|
|
|
// CornerRadius and CornerRadiusRatio can be modified
|
|
|
|
// the radius is built from the ratio, so saving/restoring the ratio is enough
|
|
|
|
double padCornerRadiusRatio = pad->GetRoundRectRadiusRatio();
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2021-10-17 09:01:38 +00:00
|
|
|
// Don't draw a 0 sized pad.
|
|
|
|
// Note: a custom pad can have its pad anchor with size = 0
|
|
|
|
if( pad->GetShape() != PAD_SHAPE::CUSTOM
|
|
|
|
&& ( padPlotsSize.x <= 0 || padPlotsSize.y <= 0 ) )
|
2023-06-06 11:30:35 +00:00
|
|
|
{
|
2009-06-28 16:50:42 +00:00
|
|
|
continue;
|
2023-06-06 11:30:35 +00:00
|
|
|
}
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
switch( pad->GetShape() )
|
2009-06-29 05:30:08 +00:00
|
|
|
{
|
2021-05-01 12:22:35 +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() &&
|
2022-11-12 07:48:25 +00:00
|
|
|
( aPlotOpt.GetDrillMarksType() == DRILL_MARKS::NO_DRILL_SHAPE ) &&
|
2018-03-27 11:42:51 +00:00
|
|
|
( pad->GetSize() == pad->GetDrillSize() ) &&
|
2021-05-01 14:46:50 +00:00
|
|
|
( pad->GetAttribute() == PAD_ATTRIB::NPTH ) )
|
2021-06-18 21:07:19 +00:00
|
|
|
{
|
2018-05-29 16:51:44 +00:00
|
|
|
break;
|
2021-06-18 21:07:19 +00:00
|
|
|
}
|
2018-05-29 11:45:45 +00:00
|
|
|
|
2020-05-01 16:24:01 +00:00
|
|
|
itemplotter.PlotPad( pad, color, padPlotMode );
|
2018-05-29 11:45:45 +00:00
|
|
|
break;
|
|
|
|
|
2023-06-02 09:10:48 +00:00
|
|
|
case PAD_SHAPE::RECTANGLE:
|
2020-09-10 11:22:16 +00:00
|
|
|
pad->SetSize( padPlotsSize );
|
|
|
|
|
2021-02-26 09:36:04 +00:00
|
|
|
if( mask_clearance > 0 )
|
2020-03-25 15:16:47 +00:00
|
|
|
{
|
2021-05-01 12:22:35 +00:00
|
|
|
pad->SetShape( PAD_SHAPE::ROUNDRECT );
|
2021-02-26 09:36:04 +00:00
|
|
|
pad->SetRoundRectCornerRadius( mask_clearance );
|
2020-03-25 15:16:47 +00:00
|
|
|
}
|
2020-06-22 19:35:09 +00:00
|
|
|
|
|
|
|
itemplotter.PlotPad( pad, color, padPlotMode );
|
|
|
|
break;
|
2020-04-24 23:44:09 +00:00
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
case PAD_SHAPE::TRAPEZOID:
|
2021-02-26 09:36:04 +00:00
|
|
|
// inflate/deflate a trapezoid is a bit complex.
|
|
|
|
// so if the margin is not null, build a similar polygonal pad shape,
|
|
|
|
// and inflate/deflate the polygonal shape
|
|
|
|
// because inflating/deflating using different values for y and y
|
|
|
|
// we are using only margin.x as inflate/deflate value
|
|
|
|
if( mask_clearance == 0 )
|
2021-06-18 21:07:19 +00:00
|
|
|
{
|
2021-02-26 09:36:04 +00:00
|
|
|
itemplotter.PlotPad( pad, color, padPlotMode );
|
2021-06-18 21:07:19 +00:00
|
|
|
}
|
2021-02-26 09:36:04 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
PAD dummy( *pad );
|
2021-05-01 12:22:35 +00:00
|
|
|
dummy.SetAnchorPadShape( PAD_SHAPE::CIRCLE );
|
|
|
|
dummy.SetShape( PAD_SHAPE::CUSTOM );
|
2021-02-26 09:36:04 +00:00
|
|
|
SHAPE_POLY_SET outline;
|
|
|
|
outline.NewOutline();
|
|
|
|
int dx = padSize.x / 2;
|
|
|
|
int dy = padSize.y / 2;
|
|
|
|
int ddx = padDelta.x / 2;
|
2021-06-21 16:55:33 +00:00
|
|
|
int ddy = padDelta.y / 2;
|
2021-02-26 09:36:04 +00:00
|
|
|
|
|
|
|
outline.Append( -dx - ddy, dy + ddx );
|
|
|
|
outline.Append( dx + ddy, dy - ddx );
|
|
|
|
outline.Append( dx - ddy, -dy + ddx );
|
|
|
|
outline.Append( -dx + ddy, -dy - ddx );
|
|
|
|
|
|
|
|
// Shape polygon can have holes so use InflateWithLinkedHoles(), not Inflate()
|
|
|
|
// which can create bad shapes if margin.x is < 0
|
2023-05-29 15:22:06 +00:00
|
|
|
outline.InflateWithLinkedHoles( mask_clearance,
|
2023-10-05 07:34:24 +00:00
|
|
|
CORNER_STRATEGY::ROUND_ALL_CORNERS, maxError,
|
2021-07-19 23:56:05 +00:00
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2021-02-26 09:36:04 +00:00
|
|
|
dummy.DeletePrimitivesList();
|
|
|
|
dummy.AddPrimitivePoly( outline, 0, true );
|
|
|
|
|
|
|
|
// 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
|
2023-02-19 03:40:07 +00:00
|
|
|
dummy.SetSize( VECTOR2I( 0, 0 ) );
|
2021-02-26 09:36:04 +00:00
|
|
|
|
|
|
|
itemplotter.PlotPad( &dummy, color, padPlotMode );
|
|
|
|
}
|
2020-09-10 11:22:16 +00:00
|
|
|
|
2020-06-22 19:35:09 +00:00
|
|
|
break;
|
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
case PAD_SHAPE::ROUNDRECT:
|
2021-06-21 16:55:33 +00:00
|
|
|
{
|
2023-12-04 11:46:39 +00:00
|
|
|
// rounding is stored as a percent, but we have to update this ratio
|
|
|
|
// to force recalculation of other values after size changing (we do not
|
|
|
|
// really change the rounding percent value)
|
|
|
|
double radius_ratio = pad->GetRoundRectRadiusRatio();
|
2018-05-29 11:45:45 +00:00
|
|
|
pad->SetSize( padPlotsSize );
|
2023-12-04 11:46:39 +00:00
|
|
|
pad->SetRoundRectRadiusRatio( radius_ratio );
|
2021-06-21 16:55:33 +00:00
|
|
|
|
2020-05-01 16:24:01 +00:00
|
|
|
itemplotter.PlotPad( pad, color, padPlotMode );
|
2021-06-21 16:55:33 +00:00
|
|
|
break;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2021-06-21 16:55:33 +00:00
|
|
|
|
|
|
|
case PAD_SHAPE::CHAMFERED_RECT:
|
|
|
|
if( mask_clearance == 0 )
|
|
|
|
{
|
|
|
|
// the size can be slightly inflated by width_adj (PS/PDF only)
|
|
|
|
pad->SetSize( padPlotsSize );
|
|
|
|
itemplotter.PlotPad( pad, color, padPlotMode );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Due to the polygonal shape of a CHAMFERED_RECT pad, the best way is to
|
|
|
|
// convert the pad shape to a full polygon, inflate/deflate the polygon
|
|
|
|
// and use a dummy CUSTOM pad to plot the final shape.
|
|
|
|
PAD dummy( *pad );
|
|
|
|
// Build the dummy pad outline with coordinates relative to the pad position
|
2024-04-18 10:53:38 +00:00
|
|
|
// pad offset and orientation 0. The actual pos, offset and rotation will be
|
|
|
|
// taken in account later by the plot function
|
2022-01-11 00:49:49 +00:00
|
|
|
dummy.SetPosition( VECTOR2I( 0, 0 ) );
|
2024-04-18 10:53:38 +00:00
|
|
|
dummy.SetOffset( VECTOR2I( 0, 0 ) );
|
2022-01-13 13:45:48 +00:00
|
|
|
dummy.SetOrientation( ANGLE_0 );
|
2021-06-21 16:55:33 +00:00
|
|
|
SHAPE_POLY_SET outline;
|
2022-10-21 12:48:45 +00:00
|
|
|
dummy.TransformShapeToPolygon( outline, UNDEFINED_LAYER, 0, maxError,
|
|
|
|
ERROR_INSIDE );
|
2023-05-29 15:22:06 +00:00
|
|
|
outline.InflateWithLinkedHoles( mask_clearance,
|
2023-10-05 07:34:24 +00:00
|
|
|
CORNER_STRATEGY::ROUND_ALL_CORNERS, maxError,
|
2021-07-19 23:56:05 +00:00
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2021-06-21 16:55:33 +00:00
|
|
|
|
|
|
|
// Initialize the dummy pad shape:
|
|
|
|
dummy.SetAnchorPadShape( PAD_SHAPE::CIRCLE );
|
|
|
|
dummy.SetShape( PAD_SHAPE::CUSTOM );
|
|
|
|
dummy.DeletePrimitivesList();
|
|
|
|
dummy.AddPrimitivePoly( outline, 0, true );
|
|
|
|
|
|
|
|
// 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 we set the anchor size to 0
|
2023-02-19 03:40:07 +00:00
|
|
|
dummy.SetSize( VECTOR2I( 0, 0 ) );
|
2024-04-18 10:53:38 +00:00
|
|
|
// Restore pad position and offset
|
2021-06-21 16:55:33 +00:00
|
|
|
dummy.SetPosition( pad->GetPosition() );
|
2024-04-18 10:53:38 +00:00
|
|
|
dummy.SetOffset( pad->GetOffset() );
|
2021-06-21 16:55:33 +00:00
|
|
|
dummy.SetOrientation( pad->GetOrientation() );
|
|
|
|
|
|
|
|
itemplotter.PlotPad( &dummy, color, padPlotMode );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2009-06-29 05:30:08 +00:00
|
|
|
break;
|
2018-05-16 16:26:43 +00:00
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
case PAD_SHAPE::CUSTOM:
|
2019-07-13 22:34:09 +00:00
|
|
|
{
|
2018-05-16 16:26:43 +00:00
|
|
|
// inflate/deflate a custom shape is a bit complex.
|
|
|
|
// so build a similar pad shape, and inflate/deflate the polygonal shape
|
2020-11-12 22:30:02 +00:00
|
|
|
PAD dummy( *pad );
|
2024-02-16 11:26:28 +00:00
|
|
|
dummy.SetParentGroup( nullptr );
|
|
|
|
|
2018-05-16 16:26:43 +00:00
|
|
|
SHAPE_POLY_SET shape;
|
2021-08-23 11:29:38 +00:00
|
|
|
pad->MergePrimitivesAsPolygon( &shape );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2019-07-13 22:34:09 +00:00
|
|
|
// Shape polygon can have holes so use InflateWithLinkedHoles(), not Inflate()
|
|
|
|
// which can create bad shapes if margin.x is < 0
|
2023-05-29 15:22:06 +00:00
|
|
|
shape.InflateWithLinkedHoles( mask_clearance,
|
2023-10-05 07:34:24 +00:00
|
|
|
CORNER_STRATEGY::ROUND_ALL_CORNERS, maxError,
|
2023-05-29 15:22:06 +00:00
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2018-05-16 16:26:43 +00:00
|
|
|
dummy.DeletePrimitivesList();
|
2020-11-14 01:16:02 +00:00
|
|
|
dummy.AddPrimitivePoly( shape, 0, true );
|
2018-05-16 16:26:43 +00:00
|
|
|
|
2019-07-13 22:34:09 +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
|
2021-02-26 09:36:04 +00:00
|
|
|
if( mask_clearance < 0 ) // we expect margin.x = margin.y for custom pads
|
2019-06-07 08:50:40 +00:00
|
|
|
dummy.SetSize( padPlotsSize );
|
|
|
|
|
2020-05-01 16:24:01 +00:00
|
|
|
itemplotter.PlotPad( &dummy, color, padPlotMode );
|
2018-05-16 16:26:43 +00:00
|
|
|
break;
|
2009-06-29 05:30:08 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2012-09-25 07:49:29 +00:00
|
|
|
|
2020-03-25 15:16:47 +00:00
|
|
|
// Restore the pad parameters modified by the plot code
|
2020-06-22 19:35:09 +00:00
|
|
|
pad->SetSize( padSize );
|
|
|
|
pad->SetDelta( padDelta );
|
2020-03-25 15:16:47 +00:00
|
|
|
pad->SetShape( padShape );
|
2024-03-03 10:56:41 +00:00
|
|
|
pad->SetRoundRectRadiusRatio( padCornerRadiusRatio );
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
aPlotter->EndBlock( nullptr );
|
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 );
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
aPlotter->StartBlock( nullptr );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
for( const PCB_TRACK* track : aBoard->Tracks() )
|
2009-06-28 16:50:42 +00:00
|
|
|
{
|
2023-06-24 18:54:50 +00:00
|
|
|
if( track->Type() != PCB_VIA_T )
|
2014-04-25 06:00:04 +00:00
|
|
|
continue;
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2023-06-24 18:54:50 +00:00
|
|
|
const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
|
|
|
|
|
2023-08-04 16:28:36 +00:00
|
|
|
// vias are not plotted if not on selected layer
|
2020-10-13 17:46:48 +00:00
|
|
|
LSET via_mask_layer = via->GetLayerSet();
|
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
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( aLayerMask[B_Mask] || aLayerMask[F_Mask] )
|
2021-08-22 22:05:47 +00:00
|
|
|
via_margin = via->GetSolderMaskExpansion();
|
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
|
|
|
|
2020-10-13 17:46:48 +00:00
|
|
|
int diameter = via->GetWidth() + 2 * via_margin + width_adj;
|
2007-12-11 20:28:13 +00:00
|
|
|
|
2020-07-27 19:41:50 +00:00
|
|
|
/// Vias not connected to copper are optionally not drawn
|
2020-10-13 17:46:48 +00:00
|
|
|
if( onCopperLayer && !via->FlashLayer( aLayerMask ) )
|
2020-07-27 19:41:50 +00:00
|
|
|
continue;
|
|
|
|
|
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
|
2020-10-13 17:46:48 +00:00
|
|
|
gbr_metadata.m_NetlistMetadata.m_NotInNet = via->GetNetname().IsEmpty();
|
2016-10-23 17:43:31 +00:00
|
|
|
|
2020-10-13 17:46:48 +00:00
|
|
|
gbr_metadata.SetNetName( via->GetNetname() );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
COLOR4D color = aPlotOpt.ColorSettings()->GetColor(
|
2020-10-13 17:46:48 +00:00
|
|
|
LAYER_VIAS + static_cast<int>( via->GetViaType() ) );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2019-07-13 22:34:09 +00:00
|
|
|
// Set plot color (change WHITE to LIGHTGRAY because the white items are not seen on a
|
|
|
|
// white paper or screen
|
2020-01-13 01:44:19 +00:00
|
|
|
aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY );
|
2020-10-13 17:46:48 +00:00
|
|
|
aPlotter->FlashPadCircle( via->GetStart(), diameter, plotMode, &gbr_metadata );
|
2007-12-11 20:28:13 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
aPlotter->EndBlock( nullptr );
|
|
|
|
aPlotter->StartBlock( nullptr );
|
2016-09-19 11:01:36 +00:00
|
|
|
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR );
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Plot tracks (not vias) :
|
2021-06-11 21:07:02 +00:00
|
|
|
for( const PCB_TRACK* track : aBoard->Tracks() )
|
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() ) );
|
2020-04-08 15:30:20 +00:00
|
|
|
|
|
|
|
if( track->Type() == PCB_ARC_T )
|
|
|
|
{
|
2023-08-22 13:06:53 +00:00
|
|
|
const PCB_ARC* arc = static_cast<const PCB_ARC*>( track );
|
2022-02-25 01:26:21 +00:00
|
|
|
|
2023-09-13 15:54:57 +00:00
|
|
|
// Too small arcs cannot be really handled: arc center (and arc radius)
|
|
|
|
// cannot be safely computed
|
|
|
|
if( !arc->IsDegenerated( 10 /* in IU */ ) )
|
|
|
|
{
|
|
|
|
aPlotter->ThickArc( arc->GetCenter(), arc->GetArcAngleStart(), arc->GetAngle(),
|
|
|
|
arc->GetRadius(), width, plotMode, &gbr_metadata );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Approximate this very small arc by a segment.
|
|
|
|
aPlotter->ThickSegment( track->GetStart(), track->GetEnd(), width, plotMode,
|
|
|
|
&gbr_metadata );
|
|
|
|
}
|
2020-04-08 15:30:20 +00:00
|
|
|
}
|
|
|
|
else
|
2020-10-13 17:46:48 +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
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
aPlotter->EndBlock( nullptr );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Plot filled ares
|
2021-07-19 23:56:05 +00:00
|
|
|
aPlotter->StartBlock( nullptr );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2020-06-26 02:19:51 +00:00
|
|
|
NETINFO_ITEM nonet( aBoard );
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
for( const ZONE* zone : aBoard->Zones() )
|
2019-07-13 22:34:09 +00:00
|
|
|
{
|
2020-06-24 02:19:08 +00:00
|
|
|
for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
|
|
|
|
{
|
2020-10-13 17:46:48 +00:00
|
|
|
if( !aLayerMask[layer] )
|
2020-06-24 02:19:08 +00:00
|
|
|
continue;
|
2019-07-13 22:34:09 +00:00
|
|
|
|
2022-03-14 15:52:12 +00:00
|
|
|
SHAPE_POLY_SET mainArea = zone->GetFilledPolysList( layer )->CloneDropTriangulation();
|
2020-06-26 02:19:51 +00:00
|
|
|
SHAPE_POLY_SET islands;
|
2019-07-13 22:34:09 +00:00
|
|
|
|
2020-10-13 17:46:48 +00:00
|
|
|
for( int i = mainArea.OutlineCount() - 1; i >= 0; i-- )
|
2020-06-26 02:19:51 +00:00
|
|
|
{
|
|
|
|
if( zone->IsIsland( layer, i ) )
|
|
|
|
{
|
2020-10-13 17:46:48 +00:00
|
|
|
islands.AddOutline( mainArea.CPolygon( i )[0] );
|
|
|
|
mainArea.DeletePolygon( i );
|
2020-06-26 02:19:51 +00:00
|
|
|
}
|
2020-06-24 02:19:08 +00:00
|
|
|
}
|
|
|
|
|
2023-08-07 12:06:46 +00:00
|
|
|
itemplotter.PlotZone( zone, layer, mainArea );
|
2020-06-26 02:19:51 +00:00
|
|
|
|
|
|
|
if( !islands.IsEmpty() )
|
|
|
|
{
|
2020-11-11 23:05:59 +00:00
|
|
|
ZONE dummy( *zone );
|
2020-06-26 02:19:51 +00:00
|
|
|
dummy.SetNet( &nonet );
|
2023-08-07 12:06:46 +00:00
|
|
|
itemplotter.PlotZone( &dummy, layer, islands );
|
2020-06-26 02:19:51 +00:00
|
|
|
}
|
2020-06-24 02:19:08 +00:00
|
|
|
}
|
2009-06-29 05:30:08 +00:00
|
|
|
}
|
2020-10-13 17:46:48 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
aPlotter->EndBlock( nullptr );
|
2012-09-24 06:39:59 +00:00
|
|
|
|
|
|
|
// Adding drill marks, if required and if the plotter is able to plot them:
|
2022-11-12 07:48:25 +00:00
|
|
|
if( aPlotOpt.GetDrillMarksType() != DRILL_MARKS::NO_DRILL_SHAPE )
|
2012-09-24 06:39:59 +00:00
|
|
|
itemplotter.PlotDrillMarks();
|
2009-06-28 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/**
|
2024-05-20 10:38:39 +00:00
|
|
|
* Plot outlines.
|
2014-05-17 19:29:15 +00:00
|
|
|
*/
|
2019-07-13 22:34:09 +00:00
|
|
|
void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, 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
|
|
|
|
2023-12-11 20:07:58 +00:00
|
|
|
for( LSEQ seq = aLayerMask.Seq( aLayerMask.SeqStackupForPlotting() ); 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
|
2022-01-11 00:49:49 +00:00
|
|
|
std::vector<VECTOR2I> cornerList;
|
2014-05-17 19:29:15 +00:00
|
|
|
|
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
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
for( int kk = 0; kk <= outlines.HoleCount(ii); kk++ )
|
2015-09-09 15:51:02 +00:00
|
|
|
{
|
|
|
|
cornerList.clear();
|
2023-03-13 11:25:30 +00:00
|
|
|
const SHAPE_LINE_CHAIN& path = ( kk == 0 ) ? outlines.COutline( ii )
|
|
|
|
: outlines.CHole( ii, kk - 1 );
|
2015-09-09 15:51:02 +00:00
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
aPlotter->PlotPoly( path, FILL_T::NO_FILL );
|
2015-09-09 15:51:02 +00:00
|
|
|
}
|
2014-05-17 19:29:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Plot pad holes
|
2022-11-12 07:48:25 +00:00
|
|
|
if( aPlotOpt.GetDrillMarksType() != DRILL_MARKS::NO_DRILL_SHAPE )
|
2014-05-17 19:29:15 +00:00
|
|
|
{
|
2022-11-12 07:48:25 +00:00
|
|
|
int smallDrill = ( aPlotOpt.GetDrillMarksType() == DRILL_MARKS::SMALL_DRILL_SHAPE )
|
2023-03-13 11:25:30 +00:00
|
|
|
? pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_SmallDrillMarkSize )
|
|
|
|
: INT_MAX;
|
2018-01-26 19:48:56 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
for( FOOTPRINT* footprint : aBoard->Footprints() )
|
2014-05-17 19:29:15 +00:00
|
|
|
{
|
2020-11-13 00:43:45 +00:00
|
|
|
for( PAD* pad : footprint->Pads() )
|
2014-05-17 19:29:15 +00:00
|
|
|
{
|
2022-07-22 22:05:25 +00:00
|
|
|
if( pad->HasHole() )
|
2014-05-17 19:29:15 +00:00
|
|
|
{
|
2022-07-22 22:05:25 +00:00
|
|
|
std::shared_ptr<SHAPE_SEGMENT> slot = pad->GetEffectiveHoleShape();
|
|
|
|
|
|
|
|
if( slot->GetSeg().A == slot->GetSeg().B ) // circular hole
|
|
|
|
{
|
|
|
|
int drill = std::min( smallDrill, slot->GetWidth() );
|
|
|
|
aPlotter->Circle( pad->GetPosition(), drill, FILL_T::NO_FILL );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Note: small drill marks have no significance when applied to slots
|
2023-03-13 11:25:30 +00:00
|
|
|
aPlotter->ThickSegment( slot->GetSeg().A, slot->GetSeg().B,
|
2022-07-22 22:05:25 +00:00
|
|
|
slot->GetWidth(), SKETCH, nullptr );
|
|
|
|
}
|
2014-05-17 19:29:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Plot vias holes
|
2021-06-11 21:07:02 +00:00
|
|
|
for( PCB_TRACK* track : aBoard->Tracks() )
|
2014-05-17 19:29:15 +00:00
|
|
|
{
|
2023-06-24 18:54:50 +00:00
|
|
|
if( track->Type() != PCB_VIA_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
|
2014-05-17 19:29:15 +00:00
|
|
|
|
2023-06-24 18:54:50 +00:00
|
|
|
if( via->IsOnLayer( layer ) ) // via holes can be not through holes
|
2021-07-18 23:08:54 +00:00
|
|
|
aPlotter->Circle( via->GetPosition(), via->GetDrillValue(), FILL_T::NO_FILL );
|
2014-05-17 19:29:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/**
|
|
|
|
* Plot a solder mask layer.
|
|
|
|
*
|
2012-11-05 20:20:34 +00:00
|
|
|
* 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
|
|
|
*
|
2023-03-12 20:56:16 +00:00
|
|
|
* The algorithm is somewhat complicated to allow for min web thickness while also preserving
|
|
|
|
* pad attributes in Gerber.
|
|
|
|
*
|
2023-03-13 11:25:30 +00:00
|
|
|
* 1 - create initial polygons for every shape
|
|
|
|
* 2 - inflate and deflate polygons with Min Thickness/2, and merges the result
|
|
|
|
* 3 - substract all initial polygons from (2), leaving the areas where the thickness was less
|
|
|
|
* than min thickness
|
|
|
|
* 4 - plot all initial shapes by flashing (or using regions), including Gerber attribute data
|
|
|
|
* 5 - plot remaining polygons from (2) (witout any Gerber attributes)
|
2012-11-05 20:20:34 +00:00
|
|
|
*/
|
2020-03-25 15:16:47 +00:00
|
|
|
|
2019-07-13 22:34:09 +00:00
|
|
|
void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
|
|
|
|
const PCB_PLOT_PARAMS& aPlotOpt, int aMinThickness )
|
2012-11-05 20:20:34 +00:00
|
|
|
{
|
2020-10-13 10:55:24 +00:00
|
|
|
int maxError = aBoard->GetDesignSettings().m_MaxError;
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layer = aLayerMask[B_Mask] ? B_Mask : F_Mask;
|
2020-10-10 22:09:00 +00:00
|
|
|
SHAPE_POLY_SET buffer;
|
|
|
|
SHAPE_POLY_SET* boardOutline = nullptr;
|
|
|
|
|
|
|
|
if( aBoard->GetBoardPolygonOutlines( buffer ) )
|
|
|
|
boardOutline = &buffer;
|
2019-01-23 03:50:41 +00:00
|
|
|
|
2021-08-23 10:25:02 +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)
|
2022-03-29 20:08:02 +00:00
|
|
|
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-07-13 22:34:09 +00:00
|
|
|
// Build polygons for each pad shape. The size of the shape on solder mask should be size
|
|
|
|
// of pad + clearance around the pad, where clearance = solder mask clearance + extra margin.
|
|
|
|
// Extra margin is half the min width for solder mask, which is used to merge too-close shapes
|
|
|
|
// (distance < aMinThickness), and will be removed when creating the actual shapes.
|
2020-03-25 15:16:47 +00:00
|
|
|
|
2023-03-13 11:25:30 +00:00
|
|
|
// Will contain shapes inflated by inflate value that will be merged and deflated by inflate
|
|
|
|
// value to build final polygons
|
2020-03-25 15:16:47 +00:00
|
|
|
SHAPE_POLY_SET areas;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-03-25 15:16:47 +00:00
|
|
|
// Will contain exact shapes of all items on solder mask
|
|
|
|
SHAPE_POLY_SET initialPolys;
|
|
|
|
|
2023-03-12 20:56:16 +00:00
|
|
|
auto plotFPTextItem =
|
2023-03-30 11:49:23 +00:00
|
|
|
[&]( const PCB_TEXT& aText )
|
2023-03-12 20:56:16 +00:00
|
|
|
{
|
2023-08-15 15:56:46 +00:00
|
|
|
if( !itemplotter.GetPlotFPText() )
|
|
|
|
return;
|
|
|
|
|
2023-03-12 20:56:16 +00:00
|
|
|
if( !aText.IsVisible() && !itemplotter.GetPlotInvisibleText() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( aText.GetText() == wxT( "${REFERENCE}" ) && !itemplotter.GetPlotReference() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( aText.GetText() == wxT( "${VALUE}" ) && !itemplotter.GetPlotValue() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// add shapes with their exact mask layer size in initialPolys
|
2023-05-28 16:20:11 +00:00
|
|
|
aText.TransformTextToPolySet( initialPolys, 0, maxError, ERROR_OUTSIDE );
|
2023-03-12 20:56:16 +00:00
|
|
|
|
|
|
|
// add shapes inflated by aMinThickness/2 in areas
|
2023-05-28 16:20:11 +00:00
|
|
|
aText.TransformTextToPolySet( areas, inflate, maxError, ERROR_OUTSIDE );
|
2023-03-12 20:56:16 +00:00
|
|
|
};
|
|
|
|
|
2021-08-23 10:25:02 +00:00
|
|
|
// Generate polygons with arcs inside the shape or exact shape to minimize shape changes
|
|
|
|
// created by arc to segment size correction.
|
2020-09-10 23:05:20 +00:00
|
|
|
DISABLE_ARC_RADIUS_CORRECTION disabler;
|
2012-11-05 20:20:34 +00:00
|
|
|
{
|
2021-08-23 10:25:02 +00:00
|
|
|
// Plot footprint pads and graphics
|
|
|
|
for( const FOOTPRINT* footprint : aBoard->Footprints() )
|
2020-09-10 23:05:20 +00:00
|
|
|
{
|
|
|
|
// add shapes with their exact mask layer size in initialPolys
|
2022-10-21 12:48:45 +00:00
|
|
|
footprint->TransformPadsToPolySet( initialPolys, layer, 0, maxError, ERROR_OUTSIDE );
|
2020-09-10 23:05:20 +00:00
|
|
|
// add shapes inflated by aMinThickness/2 in areas
|
2022-10-21 12:48:45 +00:00
|
|
|
footprint->TransformPadsToPolySet( areas, layer, inflate, maxError, ERROR_OUTSIDE );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2023-06-06 15:09:34 +00:00
|
|
|
for( const PCB_FIELD* field : footprint->Fields() )
|
|
|
|
{
|
2024-01-27 23:15:53 +00:00
|
|
|
if( field->IsReference() && !itemplotter.GetPlotReference() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( field->IsValue() && !itemplotter.GetPlotValue() )
|
|
|
|
continue;
|
|
|
|
|
2023-06-06 15:09:34 +00:00
|
|
|
if( field->IsOnLayer( layer ) )
|
|
|
|
plotFPTextItem( static_cast<const PCB_TEXT&>( *field ) );
|
|
|
|
}
|
|
|
|
|
2021-08-23 10:25:02 +00:00
|
|
|
for( const BOARD_ITEM* item : footprint->GraphicalItems() )
|
2020-09-10 23:05:20 +00:00
|
|
|
{
|
2023-03-12 20:56:16 +00:00
|
|
|
if( item->IsOnLayer( layer ) )
|
2021-08-23 10:25:02 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
if( item->Type() == PCB_TEXT_T )
|
2023-03-12 20:56:16 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
plotFPTextItem( static_cast<const PCB_TEXT&>( *item ) );
|
2023-03-12 20:56:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// add shapes with their exact mask layer size in initialPolys
|
|
|
|
item->TransformShapeToPolygon( initialPolys, layer, 0, maxError,
|
|
|
|
ERROR_OUTSIDE );
|
2022-03-29 20:08:02 +00:00
|
|
|
|
2023-03-12 20:56:16 +00:00
|
|
|
// add shapes inflated by aMinThickness/2 in areas
|
|
|
|
item->TransformShapeToPolygon( areas, layer, inflate, maxError,
|
|
|
|
ERROR_OUTSIDE );
|
|
|
|
}
|
2021-08-23 10:25:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-05 20:20:34 +00:00
|
|
|
|
2021-08-23 10:25:02 +00:00
|
|
|
// Plot (untented) vias
|
|
|
|
for( const PCB_TRACK* track : aBoard->Tracks() )
|
|
|
|
{
|
2023-06-24 18:54:50 +00:00
|
|
|
if( track->Type() != PCB_VIA_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
|
2012-11-05 20:20:34 +00:00
|
|
|
|
2021-08-23 10:25:02 +00:00
|
|
|
// Note: IsOnLayer() checks relevant mask layers of untented vias
|
2023-06-24 18:54:50 +00:00
|
|
|
if( !via->IsOnLayer( layer ) )
|
2021-08-23 10:25:02 +00:00
|
|
|
continue;
|
2020-09-10 23:05:20 +00:00
|
|
|
|
2022-10-21 12:48:45 +00:00
|
|
|
int clearance = via->GetSolderMaskExpansion();
|
2022-01-03 14:10:13 +00:00
|
|
|
|
2021-08-23 10:25:02 +00:00
|
|
|
// add shapes with their exact mask layer size in initialPolys
|
2022-10-21 12:48:45 +00:00
|
|
|
via->TransformShapeToPolygon( initialPolys, layer, clearance, maxError, ERROR_OUTSIDE );
|
2022-03-29 20:08:02 +00:00
|
|
|
|
2021-08-23 10:25:02 +00:00
|
|
|
// add shapes inflated by aMinThickness/2 in areas
|
2022-10-21 12:48:45 +00:00
|
|
|
clearance += inflate;
|
|
|
|
via->TransformShapeToPolygon( areas, layer, clearance, maxError, ERROR_OUTSIDE );
|
2012-11-05 20:20:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-10 23:05:20 +00:00
|
|
|
// Add filled zone areas.
|
2021-08-22 22:05:47 +00:00
|
|
|
#if 0 // Set to 1 if a solder mask expansion must be applied to zones on solder mask
|
|
|
|
int zone_margin = aBoard->GetDesignSettings().m_SolderMaskExpansion;
|
2015-08-01 10:20:23 +00:00
|
|
|
#else
|
2020-09-10 23:05:20 +00:00
|
|
|
int zone_margin = 0;
|
2015-08-01 10:20:23 +00:00
|
|
|
#endif
|
|
|
|
|
2021-08-23 10:25:02 +00:00
|
|
|
for( const BOARD_ITEM* item : aBoard->Drawings() )
|
|
|
|
{
|
|
|
|
if( item->IsOnLayer( layer ) )
|
|
|
|
{
|
2023-03-12 20:56:16 +00:00
|
|
|
if( item->Type() == PCB_TEXT_T )
|
|
|
|
{
|
|
|
|
const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item );
|
|
|
|
|
|
|
|
// add shapes with their exact mask layer size in initialPolys
|
2023-05-28 16:20:11 +00:00
|
|
|
text->TransformTextToPolySet( initialPolys, 0, maxError, ERROR_OUTSIDE );
|
2023-03-12 20:56:16 +00:00
|
|
|
|
|
|
|
// add shapes inflated by aMinThickness/2 in areas
|
2023-05-28 16:20:11 +00:00
|
|
|
text->TransformTextToPolySet( areas, inflate, maxError, ERROR_OUTSIDE );
|
2023-03-12 20:56:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// add shapes with their exact mask layer size in initialPolys
|
|
|
|
item->TransformShapeToPolygon( initialPolys, layer, 0, maxError,
|
|
|
|
ERROR_OUTSIDE );
|
|
|
|
|
|
|
|
// add shapes inflated by aMinThickness/2 in areas
|
|
|
|
item->TransformShapeToPolygon( areas, layer, inflate, maxError,
|
|
|
|
ERROR_OUTSIDE );
|
|
|
|
}
|
2021-08-23 10:25:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* zone : aBoard->Zones() )
|
2020-09-10 23:05:20 +00:00
|
|
|
{
|
2021-08-23 10:38:04 +00:00
|
|
|
if( !zone->IsOnLayer( layer ) )
|
2020-09-10 23:05:20 +00:00
|
|
|
continue;
|
2012-11-05 20:20:34 +00:00
|
|
|
|
2020-09-10 23:05:20 +00:00
|
|
|
// add shapes inflated by aMinThickness/2 in areas
|
2022-02-21 15:19:20 +00:00
|
|
|
zone->TransformSmoothedOutlineToPolygon( areas, inflate + zone_margin, maxError,
|
|
|
|
ERROR_OUTSIDE, boardOutline );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-09-10 23:05:20 +00:00
|
|
|
// add shapes with their exact mask layer size in initialPolys
|
2022-02-21 15:19:20 +00:00
|
|
|
zone->TransformSmoothedOutlineToPolygon( initialPolys, zone_margin, maxError,
|
|
|
|
ERROR_OUTSIDE, boardOutline );
|
2020-09-10 23:05:20 +00:00
|
|
|
}
|
2021-08-23 10:38:04 +00:00
|
|
|
}
|
2020-03-25 15:16:47 +00:00
|
|
|
|
2023-03-13 11:25:30 +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)
|
2021-08-23 10:38:04 +00:00
|
|
|
areas.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
2023-10-05 07:34:24 +00:00
|
|
|
areas.Deflate( inflate, CORNER_STRATEGY::CHAMFER_ALL_CORNERS, maxError );
|
2020-03-25 15:16:47 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
// To avoid a lot of code, use a ZONE to handle and plot polygons, because our polygons look
|
|
|
|
// exactly like filled areas in zones.
|
2019-07-13 22:34:09 +00:00
|
|
|
// 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).
|
2020-11-11 23:05:59 +00:00
|
|
|
ZONE zone( aBoard );
|
2014-12-01 14:54:33 +00:00
|
|
|
zone.SetMinThickness( 0 ); // trace polygons only
|
2019-05-22 14:47:38 +00:00
|
|
|
zone.SetLayer( layer );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2019-07-13 22:34:09 +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
|
|
|
|
2023-08-07 12:06:46 +00:00
|
|
|
itemplotter.PlotZone( &zone, layer, areas );
|
2012-11-05 20:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-13 22:34:09 +00:00
|
|
|
/**
|
|
|
|
* Set up most plot options for plotting a board (especially the viewport)
|
2012-08-29 16:59:50 +00:00
|
|
|
* Important thing:
|
|
|
|
* page size is the 'drawing' page size,
|
|
|
|
* paper size is the physical page size
|
|
|
|
*/
|
2021-03-06 09:27:41 +00:00
|
|
|
static void initializePlotter( PLOTTER* aPlotter, const BOARD* aBoard,
|
|
|
|
const 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
|
2023-02-19 03:40:07 +00:00
|
|
|
VECTOR2I paperSizeIU;
|
|
|
|
VECTOR2I pageSizeIU( pageInfo.GetSizeIU( pcbIUScale.IU_PER_MILS ) );
|
2012-08-29 16:59:50 +00:00
|
|
|
bool autocenter = false;
|
|
|
|
|
2019-07-13 22:34:09 +00:00
|
|
|
// 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() )
|
2012-08-29 16:59:50 +00:00
|
|
|
{
|
|
|
|
sheet_info = &pageA4;
|
2022-09-16 23:25:07 +00:00
|
|
|
paperSizeIU = pageA4.GetSizeIU( pcbIUScale.IU_PER_MILS );
|
2012-08-29 16:59:50 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2024-05-06 20:34:40 +00:00
|
|
|
BOX2I bbox = aBoard->ComputeBoundingBox( false, false );
|
2021-12-29 21:30:11 +00:00
|
|
|
VECTOR2I boardCenter = bbox.Centre();
|
|
|
|
VECTOR2I boardSize = bbox.GetSize();
|
2012-08-29 16:59:50 +00:00
|
|
|
|
|
|
|
double compound_scale;
|
|
|
|
|
2019-07-13 22:34:09 +00:00
|
|
|
// Fit to 80% of the page if asked; it could be that the board is empty, in this case
|
|
|
|
// regress to 1:1 scale
|
2012-08-29 16:59:50 +00:00
|
|
|
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
|
2021-06-18 21:07:19 +00:00
|
|
|
{
|
2012-08-29 16:59:50 +00:00
|
|
|
compound_scale = aPlotOpts->GetScale() * paperscale;
|
2021-06-18 21:07:19 +00:00
|
|
|
}
|
2012-08-29 16:59:50 +00:00
|
|
|
|
2019-07-13 22:34:09 +00:00
|
|
|
// 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)
|
2021-12-29 21:30:11 +00:00
|
|
|
VECTOR2I offset( 0, 0);
|
2012-08-29 16:59:50 +00:00
|
|
|
|
|
|
|
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() )
|
2021-11-09 03:36:40 +00:00
|
|
|
offset = aBoard->GetDesignSettings().GetAuxOrigin();
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aPlotter->SetPageSettings( *sheet_info );
|
2012-09-24 06:39:59 +00:00
|
|
|
|
2022-09-16 23:25:07 +00:00
|
|
|
aPlotter->SetViewport( offset, pcbIUScale.IU_PER_MILS/10, compound_scale, aPlotOpts->GetMirror() );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2019-07-13 22:34:09 +00:00
|
|
|
// Has meaning only for gerber plotter. Must be called only after SetViewport
|
2014-07-04 14:22:38 +00:00
|
|
|
aPlotter->SetGerberCoordinatesFormat( aPlotOpts->GetGerberPrecision() );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-04-20 22:02:03 +00:00
|
|
|
// Has meaning only for SVG plotter. Must be called only after SetViewport
|
2022-01-28 17:06:47 +00:00
|
|
|
aPlotter->SetSvgCoordinatesFormat( aPlotOpts->GetSvgPrecision() );
|
2014-07-04 14:22:38 +00:00
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
aPlotter->SetCreator( wxT( "PCBNEW" ) );
|
2022-10-25 02:45:24 +00:00
|
|
|
aPlotter->SetColorMode( !aPlotOpts->GetBlackAndWhite() ); // default is plot in Black and White.
|
2012-08-29 16:59:50 +00:00
|
|
|
aPlotter->SetTextMode( aPlotOpts->GetTextMode() );
|
|
|
|
}
|
|
|
|
|
2019-07-13 22:34:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prefill in black an area a little bigger than the board to prepare for the negative plot
|
|
|
|
*/
|
2022-08-30 23:28:18 +00:00
|
|
|
static void FillNegativeKnockout( PLOTTER *aPlotter, const BOX2I &aBbbox )
|
2012-08-29 16:59:50 +00:00
|
|
|
{
|
2022-09-17 00:45:14 +00:00
|
|
|
const int margin = 5 * pcbIUScale.IU_PER_MM; // Add a 5 mm margin around the board
|
2012-08-29 16:59:50 +00:00
|
|
|
aPlotter->SetNegative( true );
|
2019-07-13 22:34:09 +00:00
|
|
|
aPlotter->SetColor( WHITE ); // Which will be plotted as black
|
2022-08-30 23:28:18 +00:00
|
|
|
|
|
|
|
BOX2I area = aBbbox;
|
2012-09-24 06:39:59 +00:00
|
|
|
area.Inflate( margin );
|
2021-07-18 23:08:54 +00:00
|
|
|
aPlotter->Rect( area.GetOrigin(), area.GetEnd(), FILL_T::FILLED_SHAPE );
|
2012-08-29 16:59:50 +00:00
|
|
|
aPlotter->SetColor( BLACK );
|
|
|
|
}
|
|
|
|
|
2019-07-13 22:34:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate the effective size of HPGL pens and set them in the plotter object
|
|
|
|
*/
|
2021-03-06 09:27:41 +00:00
|
|
|
static void ConfigureHPGLPenSizes( HPGL_PLOTTER *aPlotter, const PCB_PLOT_PARAMS *aPlotOpts )
|
2012-08-29 16:59:50 +00:00
|
|
|
{
|
2019-07-13 22:34:09 +00:00
|
|
|
// Compute penDiam (the value is given in mils) in pcb units, with plot scale (if Scale is 2,
|
|
|
|
// penDiam value is always m_HPGLPenDiam so apparent penDiam is actually penDiam / Scale
|
2022-09-16 23:25:07 +00:00
|
|
|
int penDiam = KiROUND( aPlotOpts->GetHPGLPenDiameter() * pcbIUScale.IU_PER_MILS / aPlotOpts->GetScale() );
|
2012-08-29 16:59:50 +00:00
|
|
|
|
|
|
|
// Set HPGL-specific options and start
|
|
|
|
aPlotter->SetPenSpeed( aPlotOpts->GetHPGLPenSpeed() );
|
|
|
|
aPlotter->SetPenNumber( aPlotOpts->GetHPGLPenNum() );
|
2019-07-13 22:34:09 +00:00
|
|
|
aPlotter->SetPenDiameter( penDiam );
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
|
|
|
|
2019-07-13 22:34:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Open a new plotfile using the options (and especially the format) specified in the options
|
|
|
|
* and prepare the page for plotting.
|
2021-07-19 23:56:05 +00:00
|
|
|
*
|
|
|
|
* @return the plotter object if OK, NULL if the file is not created (or has a problem).
|
2012-08-29 16:59:50 +00:00
|
|
|
*/
|
2021-03-06 09:27:41 +00:00
|
|
|
PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer,
|
2024-05-13 19:03:45 +00:00
|
|
|
const wxString& aLayerName, const wxString& aFullFileName,
|
|
|
|
const wxString& aSheetName, const wxString& aSheetPath )
|
2012-08-29 16:59:50 +00:00
|
|
|
{
|
2019-07-13 22:34:09 +00:00
|
|
|
// Create the plotter driver and set the few plotter specific options
|
2021-07-19 23:56:05 +00:00
|
|
|
PLOTTER* plotter = nullptr;
|
2013-02-06 15:21:37 +00:00
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
switch( aPlotOpts->GetFormat() )
|
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
case PLOT_FORMAT::DXF:
|
2019-06-13 00:28:22 +00:00
|
|
|
DXF_PLOTTER* DXF_plotter;
|
|
|
|
DXF_plotter = new DXF_PLOTTER();
|
2020-10-21 16:29:53 +00:00
|
|
|
DXF_plotter->SetUnits( aPlotOpts->GetDXFPlotUnits() );
|
2019-06-13 00:28:22 +00:00
|
|
|
|
|
|
|
plotter = DXF_plotter;
|
2012-08-29 16:59:50 +00:00
|
|
|
break;
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
case PLOT_FORMAT::POST:
|
2012-08-29 16:59:50 +00:00
|
|
|
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;
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
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;
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
case PLOT_FORMAT::HPGL:
|
2012-08-29 16:59:50 +00:00
|
|
|
HPGL_PLOTTER* HPGL_plotter;
|
|
|
|
HPGL_plotter = new HPGL_PLOTTER();
|
|
|
|
|
2019-07-13 22:34:09 +00:00
|
|
|
// HPGL options are a little more convoluted to compute, so they get their own 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;
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
case PLOT_FORMAT::GERBER:
|
2022-09-30 16:15:56 +00:00
|
|
|
// For Gerber plotter, a valid board layer must be set, in order to create a valid
|
|
|
|
// Gerber header, especially the TF.FileFunction and .FilePolarity data
|
|
|
|
if( aLayer < PCBNEW_LAYER_ID_START || aLayer >= PCB_LAYER_ID_COUNT )
|
|
|
|
{
|
|
|
|
wxLogError( wxString::Format(
|
|
|
|
"Invalid board layer %d, cannot build a valid Gerber file header",
|
|
|
|
aLayer ) );
|
|
|
|
}
|
|
|
|
|
2013-02-06 15:21:37 +00:00
|
|
|
plotter = new GERBER_PLOTTER();
|
2012-08-29 16:59:50 +00:00
|
|
|
break;
|
|
|
|
|
2019-12-28 00:55:11 +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 );
|
2021-07-19 23:56:05 +00:00
|
|
|
return nullptr;
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
KIGFX::PCB_RENDER_SETTINGS* renderSettings = new KIGFX::PCB_RENDER_SETTINGS();
|
|
|
|
renderSettings->LoadColors( aPlotOpts->ColorSettings() );
|
2022-09-16 11:33:56 +00:00
|
|
|
renderSettings->SetDefaultPenWidth( pcbIUScale.mmToIU( 0.0212 ) ); // Hairline at 1200dpi
|
2024-05-13 19:03:45 +00:00
|
|
|
renderSettings->SetLayerName( aLayerName );
|
2022-06-10 13:09:22 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
plotter->SetRenderSettings( renderSettings );
|
|
|
|
|
2012-09-25 07:49:29 +00:00
|
|
|
// Compute the viewport and set the other options
|
2013-12-06 18:31:15 +00:00
|
|
|
|
2019-07-13 22:34:09 +00:00
|
|
|
// page layout is not mirrored, so temporarily change mirror option for the page layout
|
2013-12-06 18:31:15 +00:00
|
|
|
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
|
2019-12-28 00:55:11 +00:00
|
|
|
if( plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
|
2014-10-31 18:59:37 +00:00
|
|
|
{
|
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 );
|
2020-10-10 12:39:54 +00:00
|
|
|
gbrplotter->DisableApertMacros( plotOpts.GetDisableGerberMacros() );
|
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
|
|
|
|
2023-09-29 23:51:57 +00:00
|
|
|
if( plotter->StartPlot( wxT( "1" ) ) )
|
2013-12-06 18:31:15 +00:00
|
|
|
{
|
2023-09-29 23:51:57 +00:00
|
|
|
// Plot the frame reference if requested
|
|
|
|
if( aPlotOpts->GetPlotFrameRef() )
|
|
|
|
{
|
|
|
|
PlotDrawingSheet( plotter, aBoard->GetProject(), aBoard->GetTitleBlock(),
|
|
|
|
aBoard->GetPageSettings(), &aBoard->GetProperties(), wxT( "1" ),
|
|
|
|
1, aSheetName, aSheetPath, aBoard->GetFileName(),
|
|
|
|
renderSettings->GetLayerColor( LAYER_DRAWINGSHEET ) );
|
2012-09-25 07:49:29 +00:00
|
|
|
|
2023-09-29 23:51:57 +00:00
|
|
|
if( aPlotOpts->GetMirror() )
|
|
|
|
initializePlotter( plotter, aBoard, aPlotOpts );
|
|
|
|
}
|
2013-12-06 18:31:15 +00:00
|
|
|
|
2023-09-29 23:51:57 +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() )
|
|
|
|
{
|
2024-05-06 20:34:40 +00:00
|
|
|
BOX2I bbox = aBoard->ComputeBoundingBox( false, false );
|
2023-09-29 23:51:57 +00:00
|
|
|
FillNegativeKnockout( plotter, bbox );
|
|
|
|
}
|
2012-09-25 07:49:29 +00:00
|
|
|
|
2023-09-29 23:51:57 +00:00
|
|
|
return plotter;
|
|
|
|
}
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
delete plotter->RenderSettings();
|
2013-02-06 15:21:37 +00:00
|
|
|
delete plotter;
|
2021-07-19 23:56:05 +00:00
|
|
|
return nullptr;
|
2012-08-29 16:59:50 +00:00
|
|
|
}
|