2013-03-20 10:50:12 -04:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2013-03-20 10:50:12 -04: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-04-05 13:27:56 -05:00
|
|
|
#ifndef PCBPLOT_H_
|
|
|
|
#define PCBPLOT_H_
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2024-07-08 20:58:47 -07:00
|
|
|
#include <lset.h>
|
2024-04-07 18:01:08 -04:00
|
|
|
#include <padstack.h> // for PAD_DRILL_SHAPE
|
2012-04-05 13:27:56 -05:00
|
|
|
#include <pcb_plot_params.h>
|
2020-01-12 20:44:19 -05:00
|
|
|
#include <settings/color_settings.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2023-05-28 17:20:11 +01:00
|
|
|
#include <board.h>
|
|
|
|
#include <board_design_settings.h>
|
2021-08-23 11:25:02 +01:00
|
|
|
#include <board_item.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2023-03-29 12:53:28 -04:00
|
|
|
class EDA_TEXT;
|
2011-09-23 09:57:12 -04:00
|
|
|
class PLOTTER;
|
2020-10-05 00:34:59 +01:00
|
|
|
class PCB_TEXT;
|
2020-11-12 22:30:02 +00:00
|
|
|
class PAD;
|
2020-10-05 00:34:59 +01:00
|
|
|
class PCB_SHAPE;
|
2024-03-24 16:25:03 +00:00
|
|
|
class PCB_TABLE;
|
2021-06-11 17:59:28 +01:00
|
|
|
class PCB_DIMENSION_BASE;
|
2020-11-13 15:15:52 +00:00
|
|
|
class FOOTPRINT;
|
2011-09-23 09:57:12 -04:00
|
|
|
class PCB_TARGET;
|
2020-11-11 23:05:59 +00:00
|
|
|
class ZONE;
|
2013-05-10 15:22:29 -04:00
|
|
|
class REPORTER;
|
2020-10-14 20:46:32 -04:00
|
|
|
class wxFileName;
|
2011-09-23 09:57:12 -04:00
|
|
|
|
2023-08-06 20:20:53 +01:00
|
|
|
namespace KIFONT
|
|
|
|
{
|
|
|
|
class FONT;
|
|
|
|
class METRICS;
|
|
|
|
}
|
|
|
|
|
2016-05-12 15:45:47 -04:00
|
|
|
|
2012-09-15 14:13:03 +02:00
|
|
|
// Define min and max reasonable values for plot/print scale
|
|
|
|
#define PLOT_MIN_SCALE 0.01
|
|
|
|
#define PLOT_MAX_SCALE 100.0
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-09-24 18:03:03 +02:00
|
|
|
|
|
|
|
|
2012-09-21 10:20:38 +02:00
|
|
|
// A helper class to plot board items
|
2014-06-24 11:17:18 -05:00
|
|
|
class BRDITEMS_PLOTTER : public PCB_PLOT_PARAMS
|
2012-09-21 10:20:38 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-06-06 12:30:35 +01:00
|
|
|
BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts ) :
|
|
|
|
PCB_PLOT_PARAMS( aPlotOpts ),
|
|
|
|
m_plotter( aPlotter ),
|
|
|
|
m_board( aBoard )
|
|
|
|
{ }
|
2012-09-21 10:20:38 +02:00
|
|
|
|
2012-09-24 08:39:59 +02:00
|
|
|
/**
|
|
|
|
* @return a 'width adjustment' for the postscript engine
|
|
|
|
* (useful for controlling toner bleeding during direct transfer)
|
2013-03-20 10:50:12 -04:00
|
|
|
* added to track width and via/pads size
|
2012-09-24 08:39:59 +02:00
|
|
|
*/
|
2021-03-06 10:27:41 +01:00
|
|
|
int getFineWidthAdj() const
|
2012-09-24 08:39:59 +02:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
if( GetFormat() == PLOT_FORMAT::POST )
|
2012-09-24 08:39:59 +02:00
|
|
|
return GetWidthAdjust();
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-20 10:50:12 -04:00
|
|
|
|
2012-09-21 10:20:38 +02:00
|
|
|
// Basic functions to plot a board item
|
2025-03-23 20:33:22 +00:00
|
|
|
void SetLayerSet( const LSET& aLayerMask ) { m_layerMask = aLayerMask; }
|
2021-03-06 10:27:41 +01:00
|
|
|
void PlotFootprintGraphicItems( const FOOTPRINT* aFootprint );
|
|
|
|
void PlotFootprintTextItems( const FOOTPRINT* aFootprint );
|
2013-03-20 10:50:12 -04:00
|
|
|
|
2021-06-11 17:59:28 +01:00
|
|
|
void PlotDimension( const PCB_DIMENSION_BASE* aDim );
|
2021-03-06 10:27:41 +01:00
|
|
|
void PlotPcbTarget( const PCB_TARGET* aMire );
|
2023-08-07 13:06:46 +01:00
|
|
|
void PlotZone( const ZONE* aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList );
|
2023-08-06 20:20:53 +01:00
|
|
|
void PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout,
|
2024-08-18 09:57:55 -06:00
|
|
|
const KIFONT::METRICS& aFontMetrics, bool aStrikeout = false );
|
2023-06-06 12:30:35 +01:00
|
|
|
void PlotShape( const PCB_SHAPE* aShape );
|
2024-03-24 16:25:03 +00:00
|
|
|
void PlotTableBorders( const PCB_TABLE* aTable );
|
2012-09-21 10:20:38 +02:00
|
|
|
|
2012-09-24 08:39:59 +02:00
|
|
|
/**
|
2012-09-25 09:49:29 +02:00
|
|
|
* Plot a pad.
|
2021-06-04 09:04:30 -04:00
|
|
|
*
|
|
|
|
* Unlike other items, a pad had not a specific color and be drawn as a non filled item
|
|
|
|
* although the plot mode is filled color and plot mode are needed by this function.
|
2012-09-25 09:49:29 +02:00
|
|
|
*/
|
2024-10-02 18:07:09 -04:00
|
|
|
void PlotPad( const PAD* aPad, PCB_LAYER_ID aLayer, const COLOR4D& aColor,
|
2025-05-10 14:17:15 +01:00
|
|
|
bool aSketchMode );
|
2012-09-25 09:49:29 +02:00
|
|
|
|
2024-05-27 20:56:16 +01:00
|
|
|
void PlotPadNumber( const PAD* aPad, const COLOR4D& aColor );
|
|
|
|
|
2012-09-25 09:49:29 +02:00
|
|
|
/**
|
2021-06-04 09:04:30 -04:00
|
|
|
* Plot items like text and graphics but not tracks and footprints.
|
2012-09-24 08:39:59 +02:00
|
|
|
*/
|
2023-06-06 12:30:35 +01:00
|
|
|
void PlotBoardGraphicItem( const BOARD_ITEM* item );
|
2012-09-24 08:39:59 +02:00
|
|
|
|
2021-06-04 09:04:30 -04:00
|
|
|
/**
|
2012-09-24 08:39:59 +02:00
|
|
|
* Draw a drill mark for pads and vias.
|
2021-06-04 09:04:30 -04:00
|
|
|
*
|
|
|
|
* Must be called after all drawings, because it redraws the drill mark on a pad or via, as
|
|
|
|
* a negative (i.e. white) shape in FILLED plot mode (for PS and PDF outputs).
|
2012-09-24 08:39:59 +02:00
|
|
|
*/
|
|
|
|
void PlotDrillMarks();
|
|
|
|
|
2012-09-21 10:20:38 +02:00
|
|
|
/**
|
2021-06-04 09:04:30 -04:00
|
|
|
* White color is special because it cannot be seen on a white paper in B&W mode. It is
|
|
|
|
* plotted as white but other colors are plotted in BLACK so the returned color is LIGHTGRAY
|
|
|
|
* when the layer color is WHITE.
|
|
|
|
*
|
|
|
|
* @param aLayer is the layer id.
|
|
|
|
* @return the layer color.
|
2012-09-21 10:20:38 +02:00
|
|
|
*/
|
2021-07-22 00:14:56 +01:00
|
|
|
COLOR4D getColor( int aLayer ) const;
|
2012-09-24 08:39:59 +02:00
|
|
|
|
|
|
|
private:
|
2024-08-18 09:57:55 -06:00
|
|
|
bool hideDNPItems( PCB_LAYER_ID aLayer )
|
|
|
|
{
|
|
|
|
return GetHideDNPFPsOnFabLayers() && ( aLayer == F_Fab || aLayer == B_Fab );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool crossoutDNPItems( PCB_LAYER_ID aLayer )
|
|
|
|
{
|
|
|
|
return GetCrossoutDNPFPsOnFabLayers() && ( aLayer == F_Fab || aLayer == B_Fab );
|
|
|
|
}
|
|
|
|
|
2021-06-04 09:04:30 -04:00
|
|
|
/**
|
|
|
|
* Helper function to plot a single drill mark.
|
|
|
|
*
|
|
|
|
* It compensate and clamp the drill mark size depending on the current plot options.
|
2012-09-24 08:39:59 +02:00
|
|
|
*/
|
2024-04-07 18:01:08 -04:00
|
|
|
void plotOneDrillMark( PAD_DRILL_SHAPE aDrillShape, const VECTOR2I& aDrillPos,
|
2022-01-04 20:42:27 -05:00
|
|
|
const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
|
2022-01-16 01:06:25 +00:00
|
|
|
const EDA_ANGLE& aOrientation, int aSmallDrill );
|
2012-09-24 08:39:59 +02:00
|
|
|
|
2023-06-06 12:30:35 +01:00
|
|
|
PLOTTER* m_plotter;
|
|
|
|
BOARD* m_board;
|
|
|
|
LSET m_layerMask;
|
2012-09-21 10:20:38 +02:00
|
|
|
};
|
2008-10-07 12:10:24 +00:00
|
|
|
|
2022-04-09 15:38:47 +01:00
|
|
|
|
2021-07-22 00:14:56 +01:00
|
|
|
PLOTTER* StartPlotBoard( BOARD* aBoard, const PCB_PLOT_PARAMS* aPlotOpts, int aLayer,
|
2024-05-13 20:03:45 +01:00
|
|
|
const wxString& aLayerName, const wxString& aFullFileName,
|
2024-12-30 23:51:42 -05:00
|
|
|
const wxString& aSheetName, const wxString& aSheetPath,
|
|
|
|
const wxString& aPageName = wxT( "1" ),
|
|
|
|
const wxString& aPageNumber = wxEmptyString,
|
|
|
|
const int aPageCount = 1);
|
|
|
|
|
2025-04-29 07:23:57 -03:00
|
|
|
void setupPlotterNewPDFPage( PLOTTER* aPlotter, BOARD* aBoard, PCB_PLOT_PARAMS* aPlotOpts,
|
2025-03-17 09:48:46 +00:00
|
|
|
const wxString& aLayerName, const wxString& aSheetName,
|
|
|
|
const wxString& aSheetPath, const wxString& aPageNumber,
|
|
|
|
int aPageCount );
|
2024-12-30 23:51:42 -05:00
|
|
|
/**
|
2022-03-29 16:08:02 -04:00
|
|
|
* Plot a sequence of board layer IDs.
|
|
|
|
*
|
|
|
|
* @param aBoard is the board to plot.
|
|
|
|
* @param aPlotter is the plotter to use.
|
|
|
|
* @param aLayerSequence is the sequence of layer IDs to plot.
|
|
|
|
* @param aPlotOptions are the plot options (files, sketch). Has meaning for some formats only.
|
|
|
|
*/
|
|
|
|
void PlotBoardLayers( BOARD* aBoard, PLOTTER* aPlotter, const LSEQ& aLayerSequence,
|
|
|
|
const PCB_PLOT_PARAMS& aPlotOptions );
|
|
|
|
|
2022-09-05 23:28:44 +01:00
|
|
|
/**
|
|
|
|
* Plot interactive items (hypertext links, properties, etc.).
|
|
|
|
*/
|
2023-04-30 18:09:40 +01:00
|
|
|
void PlotInteractiveLayer( BOARD* aBoard, PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpt );
|
2022-09-05 23:28:44 +01:00
|
|
|
|
2012-09-12 13:11:30 +02:00
|
|
|
/**
|
2021-06-04 09:04:30 -04:00
|
|
|
* Plot one copper or technical layer.
|
|
|
|
*
|
|
|
|
* It prepares options and calls the specialized plot function according to the layer type.
|
|
|
|
*
|
|
|
|
* @param aBoard is the board to plot.
|
|
|
|
* @param aPlotter is the plotter to use.
|
|
|
|
* @param aLayer is the layer id to plot.
|
|
|
|
* @param aPlotOpt is the plot options (files, sketch). Has meaning for some formats only.
|
2012-09-12 13:11:30 +02:00
|
|
|
*/
|
2021-03-06 10:27:41 +01:00
|
|
|
void PlotOneBoardLayer( BOARD* aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
|
2025-02-14 14:19:14 +00:00
|
|
|
const PCB_PLOT_PARAMS& aPlotOpt, bool isPrimaryLayer );
|
2012-08-29 18:59:50 +02:00
|
|
|
|
|
|
|
/**
|
2021-06-04 09:04:30 -04:00
|
|
|
* Plot copper or technical layers.
|
|
|
|
*
|
|
|
|
* This is not used for silk screen layers because these layers have specific requirements.
|
|
|
|
* This is mainly for pads.
|
|
|
|
*
|
|
|
|
* @param aBoard is the board to plot.
|
|
|
|
* @param aPlotter is the plotter to use.
|
|
|
|
* @param aLayerMask is the mask to define the layers to plot.
|
|
|
|
* @param aPlotOpt is the plot options (files, sketch). Has meaning for some formats only.
|
2012-09-24 08:39:59 +02:00
|
|
|
*
|
2021-07-22 00:14:56 +01:00
|
|
|
* aPlotOpt has 3 important options which are set depending on the layer type to plot:
|
|
|
|
* SetEnablePlotVia( bool aEnable )
|
|
|
|
* aEnable = true to plot vias, false to skip vias (has meaning only for solder mask layers)
|
|
|
|
* SetSkipPlotNPTH_Pads( bool aSkip )
|
|
|
|
* aSkip = true to skip NPTH Pads, when the pad size and the pad hole have the same size.
|
|
|
|
* Used in GERBER format only.
|
|
|
|
* SetDrillMarksType( DrillMarksType aVal )
|
|
|
|
* aVal = no hole, small hole, actual hole size
|
2012-09-12 13:11:30 +02:00
|
|
|
*/
|
2025-03-23 20:33:22 +00:00
|
|
|
void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, const LSET& aLayerMask,
|
2012-09-24 08:39:59 +02:00
|
|
|
const PCB_PLOT_PARAMS& aPlotOpt );
|
2012-08-29 18:59:50 +02:00
|
|
|
|
2014-05-17 21:29:15 +02:00
|
|
|
/**
|
2021-06-04 09:04:30 -04:00
|
|
|
* Plot copper outline of a copper layer.
|
|
|
|
*
|
|
|
|
* @param aBoard is the board to plot.
|
|
|
|
* @param aPlotter is the plotter to use.
|
|
|
|
* @param aLayerMask is the mask to define the layers to plot.
|
|
|
|
* @param aPlotOpt is the plot options. Has meaning for some formats only.
|
2014-05-17 21:29:15 +02:00
|
|
|
*/
|
2025-03-23 20:33:22 +00:00
|
|
|
void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, const LSET& aLayerMask,
|
2021-07-22 00:14:56 +01:00
|
|
|
const PCB_PLOT_PARAMS& aPlotOpt );
|
2014-05-17 21:29:15 +02:00
|
|
|
|
2012-11-16 15:13:31 +01:00
|
|
|
/**
|
2021-06-04 09:04:30 -04:00
|
|
|
* Complete a plot filename.
|
|
|
|
*
|
|
|
|
* It forces the output directory, adds a suffix to the name, and sets the specified extension.
|
|
|
|
* The suffix is usually the layer name and replaces illegal file name character in the suffix
|
|
|
|
* with an underscore character.
|
|
|
|
*
|
|
|
|
* @param aFilename is the file name to initialize that contains the base filename.
|
|
|
|
* @param aOutputDir is the path.
|
|
|
|
* @param aSuffix is the suffix to add to the base filename.
|
|
|
|
* @param aExtension is the file extension.
|
2012-11-16 15:13:31 +01:00
|
|
|
*/
|
2021-07-22 00:14:56 +01:00
|
|
|
void BuildPlotFileName( wxFileName* aFilename, const wxString& aOutputDir, const wxString& aSuffix,
|
2013-03-20 10:50:12 -04:00
|
|
|
const wxString& aExtension );
|
2012-11-16 15:13:31 +01:00
|
|
|
|
2013-05-10 15:22:29 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the appropriate Gerber file extension for \a aLayer
|
|
|
|
*/
|
2021-07-22 00:14:56 +01:00
|
|
|
const wxString GetGerberProtelExtension( int aLayer );
|
2013-05-10 15:22:29 -04:00
|
|
|
|
2014-06-19 08:26:53 +02:00
|
|
|
/**
|
2021-06-04 09:04:30 -04:00
|
|
|
* Return the "file function" attribute for \a aLayer, as defined in the
|
|
|
|
* Gerber file format specification J1 (chapter 5).
|
|
|
|
*
|
|
|
|
* The returned string includes the "%TF.FileFunction" attribute prefix and the "*%" suffix.
|
|
|
|
*
|
|
|
|
* @param aBoard is the board, needed to get the total count of copper layers.
|
|
|
|
* @param aLayer is the layer number to create the attribute for.
|
2014-06-19 08:26:53 +02:00
|
|
|
* @return The attribute, as a text string
|
|
|
|
*/
|
2021-07-22 00:14:56 +01:00
|
|
|
const wxString GetGerberFileFunctionAttribute( const BOARD* aBoard, int aLayer );
|
2013-05-10 15:22:29 -04:00
|
|
|
|
2017-04-28 12:53:30 +02:00
|
|
|
/**
|
2021-06-04 09:04:30 -04:00
|
|
|
* Calculate some X2 attributes as defined in the Gerber file format specification J4
|
|
|
|
* (chapter 5) and add them the to the gerber file header.
|
|
|
|
*
|
2017-04-28 12:53:30 +02:00
|
|
|
* TF.GenerationSoftware
|
|
|
|
* TF.CreationDate
|
|
|
|
* TF.ProjectId
|
|
|
|
* file format attribute is not added
|
2021-06-04 09:04:30 -04:00
|
|
|
*
|
|
|
|
* @param aPlotter is the current plotter.
|
|
|
|
* @param aBoard is the board, needed to extract some info.
|
|
|
|
* @param aUseX1CompatibilityMode set to false to generate X2 attributes, true to
|
|
|
|
* use X1 compatibility (X2 attributes added as structured comments,
|
|
|
|
* starting by "G04 #@! " followed by the X2 attribute
|
2017-04-28 12:53:30 +02:00
|
|
|
*/
|
2021-06-04 09:04:30 -04:00
|
|
|
void AddGerberX2Header( PLOTTER* aPlotter, const BOARD* aBoard,
|
|
|
|
bool aUseX1CompatibilityMode = false );
|
2017-04-28 12:53:30 +02:00
|
|
|
|
2015-03-25 14:07:05 +01:00
|
|
|
/**
|
2021-06-04 09:04:30 -04:00
|
|
|
* Calculate some X2 attributes as defined in the Gerber file format specification and add them
|
|
|
|
* to the gerber file header.
|
|
|
|
*
|
2017-04-28 12:53:30 +02:00
|
|
|
* TF.GenerationSoftware
|
|
|
|
* TF.CreationDate
|
|
|
|
* TF.ProjectId
|
|
|
|
* TF.FileFunction
|
|
|
|
* TF.FilePolarity
|
|
|
|
*
|
2021-06-04 09:04:30 -04:00
|
|
|
* @param aPlotter is the current plotter.
|
|
|
|
* @param aBoard is the board, needed to extract some info.
|
|
|
|
* @param aLayer is the layer number to create the attribute for.
|
|
|
|
* @param aUseX1CompatibilityMode set to false to generate X2 attributes, true to use X1
|
|
|
|
* compatibility (X2 attributes added as structured comments, starting by "G04 #@! "
|
|
|
|
* followed by the X2 attribute.
|
2015-03-25 14:07:05 +01:00
|
|
|
*/
|
2021-07-22 00:14:56 +01:00
|
|
|
void AddGerberX2Attribute( PLOTTER* aPlotter, const BOARD* aBoard, int aLayer,
|
|
|
|
bool aUseX1CompatibilityMode );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-04-05 13:27:56 -05:00
|
|
|
#endif // PCBPLOT_H_
|