2013-03-20 14:50:12 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-11-30 16:48:31 +00:00
|
|
|
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-03-20 14:50:12 +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
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file pcbnew/pcbplot.h
|
2013-03-20 14:50:12 +00:00
|
|
|
* @brief Board plot function definition file.
|
2011-09-23 13:57:12 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
#ifndef PCBPLOT_H_
|
|
|
|
#define PCBPLOT_H_
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <layers_id_colors_and_visibility.h>
|
|
|
|
#include <math/util.h> // for KiROUND
|
2012-09-24 06:39:59 +00:00
|
|
|
#include <pad_shapes.h>
|
2012-04-05 18:27:56 +00:00
|
|
|
#include <pcb_plot_params.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <settings/color_settings.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
class PLOTTER;
|
2020-10-04 23:34:59 +00:00
|
|
|
class PCB_TEXT;
|
2020-11-12 22:30:02 +00:00
|
|
|
class PAD;
|
2020-10-04 23:34:59 +00:00
|
|
|
class PCB_SHAPE;
|
2020-11-11 23:05:59 +00:00
|
|
|
class DIMENSION_BASE;
|
2020-11-13 15:15:52 +00:00
|
|
|
class FOOTPRINT;
|
2020-10-04 23:34:59 +00:00
|
|
|
class FP_SHAPE;
|
2011-09-23 13:57:12 +00:00
|
|
|
class PCB_TARGET;
|
2020-10-04 23:34:59 +00:00
|
|
|
class FP_TEXT;
|
2020-11-11 23:05:59 +00:00
|
|
|
class ZONE;
|
2012-09-21 08:20:38 +00:00
|
|
|
class BOARD;
|
2013-05-10 19:22:29 +00:00
|
|
|
class REPORTER;
|
2020-10-15 00:46:32 +00:00
|
|
|
class wxFileName;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2016-05-12 19:45:47 +00:00
|
|
|
|
2012-09-15 12:13:03 +00: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 16:03:03 +00:00
|
|
|
// Small drill marks (small pad holes) diameter value
|
2013-05-04 11:57:09 +00:00
|
|
|
#define SMALL_DRILL KiROUND( 0.35 * IU_PER_MM )
|
2012-09-24 16:03:03 +00:00
|
|
|
|
|
|
|
|
2012-09-21 08:20:38 +00:00
|
|
|
// A helper class to plot board items
|
2014-06-24 16:17:18 +00:00
|
|
|
class BRDITEMS_PLOTTER : public PCB_PLOT_PARAMS
|
2012-09-21 08:20:38 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
PLOTTER* m_plotter;
|
|
|
|
BOARD* m_board;
|
|
|
|
LSET m_layerMask;
|
2012-09-24 06:39:59 +00:00
|
|
|
|
2012-09-21 08:20:38 +00:00
|
|
|
public:
|
2020-03-25 01:45:58 +00:00
|
|
|
BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts )
|
2020-03-30 01:43:18 +00:00
|
|
|
: PCB_PLOT_PARAMS( aPlotOpts )
|
2012-09-21 08:20:38 +00:00
|
|
|
{
|
|
|
|
m_plotter = aPlotter;
|
|
|
|
m_board = aBoard;
|
|
|
|
}
|
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
/**
|
|
|
|
* @return a 'width adjustment' for the postscript engine
|
|
|
|
* (useful for controlling toner bleeding during direct transfer)
|
2013-03-20 14:50:12 +00:00
|
|
|
* added to track width and via/pads size
|
2012-09-24 06:39:59 +00:00
|
|
|
*/
|
|
|
|
int getFineWidthAdj()
|
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
if( GetFormat() == PLOT_FORMAT::POST )
|
2012-09-24 06:39:59 +00:00
|
|
|
return GetWidthAdjust();
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2012-09-21 08:20:38 +00:00
|
|
|
// Basic functions to plot a board item
|
2014-06-24 16:17:18 +00:00
|
|
|
void SetLayerSet( LSET aLayerMask ) { m_layerMask = aLayerMask; }
|
2020-11-13 15:15:52 +00:00
|
|
|
void PlotFootprintGraphicItems( FOOTPRINT* aFootprint );
|
2020-10-04 23:34:59 +00:00
|
|
|
void PlotFootprintGraphicItem( FP_SHAPE* aShape );
|
|
|
|
void PlotFootprintTextItem( FP_TEXT* aText, COLOR4D aColor );
|
2013-03-20 14:50:12 +00:00
|
|
|
|
|
|
|
/*
|
2020-05-01 16:24:01 +00:00
|
|
|
* Reference, Value, and other fields are plotted only if the corresponding option is enabled.
|
|
|
|
* Invisible text fields are plotted only if PlotInvisibleText option is set.
|
2013-03-20 14:50:12 +00:00
|
|
|
*/
|
2020-11-13 15:15:52 +00:00
|
|
|
void PlotFootprintTextItems( FOOTPRINT* aFootprint );
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void PlotDimension( DIMENSION_BASE* Dimension );
|
2012-09-21 08:20:38 +00:00
|
|
|
void PlotPcbTarget( PCB_TARGET* PtMire );
|
2020-11-11 23:05:59 +00:00
|
|
|
void PlotFilledAreas( ZONE* aZone, SHAPE_POLY_SET& aPolysList );
|
2020-10-04 23:34:59 +00:00
|
|
|
void PlotPcbText( PCB_TEXT* aText );
|
|
|
|
void PlotPcbShape( PCB_SHAPE* aShape );
|
2012-09-21 08:20:38 +00:00
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
/**
|
2012-09-25 07:49:29 +00:00
|
|
|
* Plot a pad.
|
|
|
|
* 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
|
|
|
|
*/
|
2020-11-12 22:30:02 +00:00
|
|
|
void PlotPad( PAD* aPad, COLOR4D aColor, OUTLINE_MODE aPlotMode );
|
2012-09-25 07:49:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* plot items like text and graphics,
|
2020-10-21 03:48:06 +00:00
|
|
|
* but not tracks and footprints
|
2012-09-24 06:39:59 +00:00
|
|
|
*/
|
|
|
|
void PlotBoardGraphicItems();
|
|
|
|
|
|
|
|
/** Function PlotDrillMarks
|
|
|
|
* Draw a drill mark for pads and vias.
|
|
|
|
* Must be called after all drawings, because it
|
|
|
|
* redraw the drill mark on a pad or via, as a negative (i.e. white) shape in
|
|
|
|
* FILLED plot mode (for PS and PDF outputs)
|
|
|
|
*/
|
|
|
|
void PlotDrillMarks();
|
|
|
|
|
2012-09-21 08:20:38 +00:00
|
|
|
/**
|
|
|
|
* Function getColor
|
|
|
|
* @return the layer color
|
|
|
|
* @param aLayer = the layer id
|
|
|
|
* White color is special: cannot be seen on a white paper
|
|
|
|
* and in B&W mode, is plotted as white but other colors are plotted in BLACK
|
|
|
|
* so the returned color is LIGHTGRAY when the layer color is WHITE
|
|
|
|
*/
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D getColor( LAYER_NUM aLayer );
|
2012-09-24 06:39:59 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/** Helper function to plot a single drill mark. It compensate and clamp
|
|
|
|
* the drill mark size depending on the current plot options
|
|
|
|
*/
|
2014-01-26 14:20:58 +00:00
|
|
|
void plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape,
|
2012-11-19 16:19:38 +00:00
|
|
|
const wxPoint& aDrillPos, wxSize aDrillSize,
|
|
|
|
const wxSize& aPadSize,
|
2012-09-24 06:39:59 +00:00
|
|
|
double aOrientation, int aSmallDrill );
|
|
|
|
|
2012-09-21 08:20:38 +00:00
|
|
|
};
|
2008-10-07 12:10:24 +00:00
|
|
|
|
2012-11-19 16:19:38 +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 );
|
|
|
|
|
2012-09-12 11:11:30 +00:00
|
|
|
/**
|
2012-09-24 06:39:59 +00:00
|
|
|
* Function PlotOneBoardLayer
|
|
|
|
* main function to plot one copper or technical layer.
|
2013-03-20 14:50:12 +00:00
|
|
|
* It prepare options and calls the specialized plot function,
|
2012-09-24 06:39:59 +00:00
|
|
|
* according to the layer type
|
2012-09-12 11:11:30 +00:00
|
|
|
* @param aBoard = the board to plot
|
|
|
|
* @param aPlotter = the plotter to use
|
|
|
|
* @param aLayer = the layer id to plot
|
|
|
|
* @param aPlotOpt = the plot options (files, sketch). Has meaning for some formats only
|
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
|
2012-09-24 06:39:59 +00:00
|
|
|
const PCB_PLOT_PARAMS& aPlotOpt );
|
2012-08-29 16:59:50 +00:00
|
|
|
|
|
|
|
/**
|
2012-09-24 06:39:59 +00:00
|
|
|
* Function PlotStandardLayer
|
2012-09-12 11:11:30 +00:00
|
|
|
* plot copper or technical layers.
|
|
|
|
* not used for silk screen layers, because these layers have specific
|
|
|
|
* requirements, mainly for pads
|
|
|
|
* @param aBoard = the board to plot
|
|
|
|
* @param aPlotter = the plotter to use
|
|
|
|
* @param aLayerMask = the mask to define the layers to plot
|
|
|
|
* @param aPlotOpt = the plot options (files, sketch). Has meaning for some formats only
|
2012-09-24 06:39:59 +00:00
|
|
|
*
|
2013-03-20 14:50:12 +00:00
|
|
|
* aPlotOpt has 3 important options to control this plot,
|
|
|
|
* which are set, depending on the layer type to plot
|
2012-09-24 06:39:59 +00:00
|
|
|
* 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 ) controle the actual hole:
|
|
|
|
* no hole, small hole, actual hole
|
2012-09-12 11:11:30 +00:00
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
|
2012-09-24 06:39:59 +00:00
|
|
|
const PCB_PLOT_PARAMS& aPlotOpt );
|
2012-08-29 16:59:50 +00:00
|
|
|
|
2014-05-17 19:29:15 +00:00
|
|
|
/**
|
|
|
|
* Function PlotLayerOutlines
|
|
|
|
* plot copper outline of a copper layer.
|
|
|
|
* @param aBoard = the board to plot
|
|
|
|
* @param aPlotter = the plotter to use
|
|
|
|
* @param aLayerMask = the mask to define the layers to plot
|
|
|
|
* @param aPlotOpt = the plot options. Has meaning for some formats only
|
|
|
|
*/
|
|
|
|
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
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
/**
|
|
|
|
* Function BuildPlotFileName (helper function)
|
|
|
|
* Complete a plot filename: forces the output directory,
|
|
|
|
* add a suffix to the name and sets the specified extension
|
|
|
|
* the suffix is usually the layer name
|
|
|
|
* replaces not allowed chars in suffix by '_'
|
|
|
|
* @param aFilename = the wxFileName to initialize
|
2013-05-10 19:22:29 +00:00
|
|
|
* Contains the base filename
|
2012-11-16 14:13:31 +00:00
|
|
|
* @param aOutputDir = the path
|
|
|
|
* @param aSuffix = the suffix to add to the base filename
|
|
|
|
* @param aExtension = the file extension
|
|
|
|
*/
|
2013-05-10 19:22:29 +00:00
|
|
|
void BuildPlotFileName( wxFileName* aFilename,
|
2013-03-20 14:50:12 +00:00
|
|
|
const wxString& aOutputDir,
|
|
|
|
const wxString& aSuffix,
|
|
|
|
const wxString& aExtension );
|
2012-11-16 14:13:31 +00:00
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
|
|
|
|
/**
|
2015-10-20 18:03:07 +00:00
|
|
|
* Function GetGerberProtelExtension
|
2013-05-10 19:22:29 +00:00
|
|
|
* @return the appropriate Gerber file extension for \a aLayer
|
2015-10-20 18:03:07 +00:00
|
|
|
* used by Protel, and still sometimes in use (although the
|
|
|
|
* official Gerber Ext is now .gbr)
|
2013-05-10 19:22:29 +00:00
|
|
|
*/
|
2015-10-20 18:03:07 +00:00
|
|
|
const wxString GetGerberProtelExtension( LAYER_NUM aLayer );
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2014-06-19 06:26:53 +00:00
|
|
|
/**
|
2015-03-25 13:07:05 +00:00
|
|
|
* Function GetGerberFileFunctionAttribute
|
2014-06-19 06:26:53 +00:00
|
|
|
* Returns the "file function" attribute for \a aLayer, as defined in the
|
2015-03-25 13:07:05 +00:00
|
|
|
* Gerber file format specification J1 (chapter 5). The returned string includes
|
2014-06-19 06:26:53 +00:00
|
|
|
* the "%TF.FileFunction" attribute prefix and the "*%" suffix.
|
|
|
|
* @param aBoard = the board, needed to get the total count of copper layers
|
|
|
|
* @param aLayer = the layer number to create the attribute for
|
|
|
|
* @return The attribute, as a text string
|
|
|
|
*/
|
2016-11-30 16:48:31 +00:00
|
|
|
const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard, LAYER_NUM aLayer );
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2017-04-28 10:53:30 +00:00
|
|
|
/**
|
|
|
|
* Calculates some X2 attributes, as defined in the
|
|
|
|
* Gerber file format specification J4 (chapter 5) and add them
|
|
|
|
* the to the gerber file header:
|
|
|
|
* TF.GenerationSoftware
|
|
|
|
* TF.CreationDate
|
|
|
|
* TF.ProjectId
|
|
|
|
* file format attribute is not added
|
2017-06-17 08:40:38 +00:00
|
|
|
* @param aPlotter = the current plotter.
|
2017-04-28 10:53:30 +00:00
|
|
|
* @param aBoard = the board, needed to extract some info
|
|
|
|
* @param aUseX1CompatibilityMode = false to generate X2 attributes, true to
|
|
|
|
* use X1 compatibility (X2 attributes added as structured comments,
|
|
|
|
* starting by "G04 #@! " followed by the X2 attribute
|
|
|
|
*/
|
|
|
|
void AddGerberX2Header( PLOTTER * aPlotter,
|
|
|
|
const BOARD *aBoard, bool aUseX1CompatibilityMode = false );
|
|
|
|
|
2015-03-25 13:07:05 +00:00
|
|
|
/**
|
2017-06-17 08:40:38 +00:00
|
|
|
* Calculates some X2 attributes, as defined in the Gerber file format
|
|
|
|
* specification and add them to the gerber file header:
|
2017-04-28 10:53:30 +00:00
|
|
|
* TF.GenerationSoftware
|
|
|
|
* TF.CreationDate
|
|
|
|
* TF.ProjectId
|
|
|
|
* TF.FileFunction
|
|
|
|
* TF.FilePolarity
|
|
|
|
*
|
2017-06-17 08:40:38 +00:00
|
|
|
* @param aPlotter = the current plotter.
|
2015-03-25 13:07:05 +00:00
|
|
|
* @param aBoard = the board, needed to extract some info
|
|
|
|
* @param aLayer = the layer number to create the attribute for
|
2016-11-30 16:48:31 +00:00
|
|
|
* @param aUseX1CompatibilityMode = 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 13:07:05 +00:00
|
|
|
*/
|
2017-04-28 10:53:30 +00:00
|
|
|
void AddGerberX2Attribute( PLOTTER * aPlotter, const BOARD *aBoard,
|
|
|
|
LAYER_NUM aLayer, bool aUseX1CompatibilityMode );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
#endif // PCBPLOT_H_
|