KiCad PCB EDA Suite
pcbplot.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef PCBPLOT_H_
25#define PCBPLOT_H_
26
27#include <pad_shapes.h> // for PAD_DRILL_SHAPE_T
28#include <pcb_plot_params.h>
31#include <board_item.h>
32
33class PLOTTER;
34class PCB_TEXT;
35class PAD;
36class PCB_SHAPE;
38class FOOTPRINT;
39class FP_SHAPE;
40class PCB_TARGET;
41class FP_TEXT;
42class ZONE;
43class BOARD;
44class BOARD_ITEM;
45class REPORTER;
46class wxFileName;
47
48
49// Define min and max reasonable values for plot/print scale
50#define PLOT_MIN_SCALE 0.01
51#define PLOT_MAX_SCALE 100.0
52
53
54
55// A helper class to plot board items
57{
58public:
59 BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts )
60 : PCB_PLOT_PARAMS( aPlotOpts )
61 {
62 m_plotter = aPlotter;
63 m_board = aBoard;
64 }
65
71 int getFineWidthAdj() const
72 {
74 return GetWidthAdjust();
75 else
76 return 0;
77 }
78
79 // Basic functions to plot a board item
80 void SetLayerSet( LSET aLayerMask ) { m_layerMask = aLayerMask; }
81 void PlotFootprintGraphicItems( const FOOTPRINT* aFootprint );
82 void PlotFootprintShape( const FP_SHAPE* aShape );
83 void PlotFootprintTextItem( const FP_TEXT* aText, const COLOR4D& aColor );
84
85 /*
86 * Reference, Value, and other fields are plotted only if the corresponding option is enabled.
87 * Invisible text fields are plotted only if PlotInvisibleText option is set.
88 */
89 void PlotFootprintTextItems( const FOOTPRINT* aFootprint );
90
91 void PlotDimension( const PCB_DIMENSION_BASE* aDim );
92 void PlotPcbTarget( const PCB_TARGET* aMire );
93 void PlotFilledAreas( const ZONE* aZone, PCB_LAYER_ID aLayer,
94 const SHAPE_POLY_SET& aPolysList );
95 void PlotPcbText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout );
96 void PlotPcbShape( const PCB_SHAPE* aShape );
97
104 void PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_MODE aPlotMode );
105
110 void PlotPcbGraphicItem( const BOARD_ITEM* item );
111
118 void PlotDrillMarks();
119
128 COLOR4D getColor( int aLayer ) const;
129
130private:
136 void plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const VECTOR2I& aDrillPos,
137 const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
138 const EDA_ANGLE& aOrientation, int aSmallDrill );
139
143};
144
145
146PLOTTER* StartPlotBoard( BOARD* aBoard, const PCB_PLOT_PARAMS* aPlotOpts, int aLayer,
147 const wxString& aFullFileName, const wxString& aSheetName,
148 const wxString& aSheetPath );
149
158void PlotBoardLayers( BOARD* aBoard, PLOTTER* aPlotter, const LSEQ& aLayerSequence,
159 const PCB_PLOT_PARAMS& aPlotOptions );
160
164void PlotInteractiveLayer( BOARD* aBoard, PLOTTER* aPlotter );
165
176void PlotOneBoardLayer( BOARD* aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
177 const PCB_PLOT_PARAMS& aPlotOpt );
178
199void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
200 const PCB_PLOT_PARAMS& aPlotOpt );
201
210void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
211 const PCB_PLOT_PARAMS& aPlotOpt );
212
225void BuildPlotFileName( wxFileName* aFilename, const wxString& aOutputDir, const wxString& aSuffix,
226 const wxString& aExtension );
227
228
232const wxString GetGerberProtelExtension( int aLayer );
233
244const wxString GetGerberFileFunctionAttribute( const BOARD* aBoard, int aLayer );
245
261void AddGerberX2Header( PLOTTER* aPlotter, const BOARD* aBoard,
262 bool aUseX1CompatibilityMode = false );
263
281void AddGerberX2Attribute( PLOTTER* aPlotter, const BOARD* aBoard, int aLayer,
282 bool aUseX1CompatibilityMode );
283
284#endif // PCBPLOT_H_
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
void PlotDrillMarks()
Draw a drill mark for pads and vias.
LSET m_layerMask
Definition: pcbplot.h:142
void plotOneDrillMark(PAD_DRILL_SHAPE_T aDrillShape, const VECTOR2I &aDrillPos, const VECTOR2I &aDrillSize, const VECTOR2I &aPadSize, const EDA_ANGLE &aOrientation, int aSmallDrill)
Helper function to plot a single drill mark.
void PlotPcbShape(const PCB_SHAPE *aShape)
void SetLayerSet(LSET aLayerMask)
Definition: pcbplot.h:80
void PlotPcbGraphicItem(const BOARD_ITEM *item)
void PlotFilledAreas(const ZONE *aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
void PlotDimension(const PCB_DIMENSION_BASE *aDim)
void PlotPad(const PAD *aPad, const COLOR4D &aColor, OUTLINE_MODE aPlotMode)
Plot a pad.
void PlotFootprintShape(const FP_SHAPE *aShape)
BOARD * m_board
Definition: pcbplot.h:141
PLOTTER * m_plotter
Definition: pcbplot.h:140
COLOR4D getColor(int aLayer) const
White color is special because it cannot be seen on a white paper in B&W mode.
void PlotBoardGraphicItems()
Plot items like text and graphics but not tracks and footprints.
void PlotPcbTarget(const PCB_TARGET *aMire)
void PlotFootprintTextItems(const FOOTPRINT *aFootprint)
int getFineWidthAdj() const
Definition: pcbplot.h:71
BRDITEMS_PLOTTER(PLOTTER *aPlotter, BOARD *aBoard, const PCB_PLOT_PARAMS &aPlotOpts)
Definition: pcbplot.h:59
void PlotPcbText(const EDA_TEXT *aText, PCB_LAYER_ID aLayer, bool aIsKnockout)
void PlotFootprintGraphicItems(const FOOTPRINT *aFootprint)
void PlotFootprintTextItem(const FP_TEXT *aText, const COLOR4D &aColor)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:491
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
Definition: pad.h:59
Abstract dimension API.
Definition: pcb_dimension.h:96
Parameters and options when plotting/printing a board.
PLOT_FORMAT GetFormat() const
int GetWidthAdjust() const
Base plotter engine class.
Definition: plotter.h:110
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
Represent a set of closed polygons.
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
OUTLINE_MODE
Definition: outline_mode.h:25
PAD_DRILL_SHAPE_T
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: pad_shapes.h:69
void PlotStandardLayer(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Plot copper or technical layers.
void PlotInteractiveLayer(BOARD *aBoard, PLOTTER *aPlotter)
Plot interactive items (hypertext links, properties, etc.).
void PlotOneBoardLayer(BOARD *aBoard, PLOTTER *aPlotter, PCB_LAYER_ID aLayer, const PCB_PLOT_PARAMS &aPlotOpt)
Plot one copper or technical layer.
const wxString GetGerberProtelExtension(int aLayer)
Definition: pcbplot.cpp:42
void PlotLayerOutlines(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Plot copper outline of a copper layer.
PLOTTER * StartPlotBoard(BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer, const wxString &aFullFileName, const wxString &aSheetName, const wxString &aSheetPath)
Open a new plotfile using the options (and especially the format) specified in the options and prepar...
void AddGerberX2Header(PLOTTER *aPlotter, const BOARD *aBoard, bool aUseX1CompatibilityMode=false)
Calculate some X2 attributes as defined in the Gerber file format specification J4 (chapter 5) and ad...
Definition: pcbplot.cpp:276
const wxString GetGerberFileFunctionAttribute(const BOARD *aBoard, int aLayer)
Return the "file function" attribute for aLayer, as defined in the Gerber file format specification J...
Definition: pcbplot.cpp:81
void PlotBoardLayers(BOARD *aBoard, PLOTTER *aPlotter, const LSEQ &aLayerSequence, const PCB_PLOT_PARAMS &aPlotOptions)
Plot a sequence of board layer IDs.
void AddGerberX2Attribute(PLOTTER *aPlotter, const BOARD *aBoard, int aLayer, bool aUseX1CompatibilityMode)
Calculate some X2 attributes as defined in the Gerber file format specification and add them to the g...
Definition: pcbplot.cpp:342
void BuildPlotFileName(wxFileName *aFilename, const wxString &aOutputDir, const wxString &aSuffix, const wxString &aExtension)
Complete a plot filename.
Definition: pcbplot.cpp:361