KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef PCBPLOT_H_
21#define PCBPLOT_H_
22
23#include <lset.h>
24#include <padstack.h> // for PAD_DRILL_SHAPE
25#include <pcb_plot_params.h>
28#include <board.h>
30#include <board_item.h>
31
32class EDA_TEXT;
33class PLOTTER;
34class PCB_TEXT;
35class PCB_BARCODE;
36class PAD;
37class PCB_SHAPE;
38class PCB_DRILL_CHART;
39class PCB_TABLE;
41class FOOTPRINT;
42class PCB_TARGET;
43class ZONE;
44class REPORTER;
45class wxFileName;
46
47namespace KIFONT
48{
49class FONT;
50class METRICS;
51}
52
53
54// Define min and max reasonable values for plot/print scale
55#define PLOT_MIN_SCALE 0.01
56#define PLOT_MAX_SCALE 100.0
57
58
59
60// A helper class to plot board items
62{
63public:
64 BRDITEMS_PLOTTER( PLOTTER* aPlotter, const BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts ) :
65 PCB_PLOT_PARAMS( aPlotOpts ),
66 m_plotter( aPlotter ),
67 m_board( aBoard )
68 { }
69
75 int getFineWidthAdj() const
76 {
78 return GetWidthAdjust();
79 else
80 return 0;
81 }
82
83 // Basic functions to plot a board item
84 void SetLayerSet( const LSET& aLayerMask ) { m_layerMask = aLayerMask; }
85 void PlotFootprintGraphicItems( const FOOTPRINT* aFootprint ) const;
86 void PlotFootprintTextItems( const FOOTPRINT* aFootprint ) const;
87
88 void PlotDimension( const PCB_DIMENSION_BASE* aDim ) const;
89 void PlotPcbTarget( const PCB_TARGET* aMire ) const;
90 void PlotZone( const ZONE* aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList ) const;
91 void PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout, const KIFONT::METRICS& aFontMetrics,
92 bool aStrikeout = false ) const;
93 void PlotShape( const PCB_SHAPE* aShape ) const;
94 void PlotTableBorders( const PCB_TABLE* aTable ) const;
95 void PlotBarCode( const PCB_BARCODE* aBarCode ) const;
96
103 void PlotPad( const PAD* aPad, PCB_LAYER_ID aLayer, const COLOR4D& aColor, bool aSketchMode ) const;
104
105 void PlotPadNumber( const PAD* aPad, const COLOR4D& aColor ) const;
106
110 void PlotBoardGraphicItem( const BOARD_ITEM* item ) const;
111
118 void PlotDrillMarks() const;
119
123 void PlotDrillSymbols( PCB_LAYER_ID aLayer ) const;
124
128 void PlotChartSymbols( const PCB_DRILL_CHART* aChart ) const;
129
138 COLOR4D getColor( int aLayer ) const;
139
140private:
141 bool hideDNPItems( PCB_LAYER_ID aLayer ) const
142 {
143 return GetHideDNPFPsOnFabLayers() && ( aLayer == F_Fab || aLayer == B_Fab );
144 }
145
146 bool crossoutDNPItems( PCB_LAYER_ID aLayer ) const
147 {
148 return GetCrossoutDNPFPsOnFabLayers() && ( aLayer == F_Fab || aLayer == B_Fab );
149 }
150
156 void plotOneDrillMark( PAD_DRILL_SHAPE aDrillShape, const VECTOR2I& aDrillPos, const VECTOR2I& aDrillSize,
157 const VECTOR2I& aPadSize, const EDA_ANGLE& aOrientation, int aSmallDrill ) const;
158
162};
163
164
165PLOTTER* StartPlotBoard( BOARD* aBoard, const PCB_PLOT_PARAMS* aPlotOpts, int aLayer,
166 const wxString& aLayerName, const wxString& aFullFileName,
167 const wxString& aSheetName, const wxString& aSheetPath,
168 const wxString& aPageName = wxT( "1" ),
169 const wxString& aPageNumber = wxEmptyString,
170 const int aPageCount = 1);
171
172void setupPlotterNewPDFPage( PLOTTER* aPlotter, BOARD* aBoard, PCB_PLOT_PARAMS* aPlotOpts,
173 const wxString& aLayerName, const wxString& aSheetName,
174 const wxString& aSheetPath, const wxString& aPageNumber,
175 int aPageCount );
184void PlotBoardLayers( BOARD* aBoard, PLOTTER* aPlotter, const LSEQ& aLayerSequence,
185 const PCB_PLOT_PARAMS& aPlotOptions );
186
190void PlotInteractiveLayer( BOARD* aBoard, PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpt );
191
203void PlotOneBoardLayer( BOARD* aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
204 const PCB_PLOT_PARAMS& aPlotOpt, bool isPrimaryLayer );
205
226void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, const LSET& aLayerMask,
227 const PCB_PLOT_PARAMS& aPlotOpt );
228
237void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, const LSET& aLayerMask,
238 const PCB_PLOT_PARAMS& aPlotOpt );
239
240
244const wxString GetGerberProtelExtension( int aLayer );
245
256const wxString GetGerberFileFunctionAttribute( const BOARD* aBoard, int aLayer );
257
273void AddGerberX2Header( PLOTTER* aPlotter, const BOARD* aBoard,
274 bool aUseX1CompatibilityMode = false );
275
293void AddGerberX2Attribute( PLOTTER* aPlotter, const BOARD* aBoard, int aLayer,
294 bool aUseX1CompatibilityMode );
295
296#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:85
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
void SetLayerSet(const LSET &aLayerMask)
Definition pcbplot.h:84
void PlotFootprintGraphicItems(const FOOTPRINT *aFootprint) const
void PlotBoardGraphicItem(const BOARD_ITEM *item) const
Plot items like text and graphics but not tracks and footprints.
void PlotText(const EDA_TEXT *aText, PCB_LAYER_ID aLayer, bool aIsKnockout, const KIFONT::METRICS &aFontMetrics, bool aStrikeout=false) const
void PlotPadNumber(const PAD *aPad, const COLOR4D &aColor) const
void PlotDimension(const PCB_DIMENSION_BASE *aDim) const
void PlotDrillSymbols(PCB_LAYER_ID aLayer) const
Draw each hole's chart symbol on aLayer, from the board's shared symbol profile.
void PlotZone(const ZONE *aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList) const
void plotOneDrillMark(PAD_DRILL_SHAPE aDrillShape, const VECTOR2I &aDrillPos, const VECTOR2I &aDrillSize, const VECTOR2I &aPadSize, const EDA_ANGLE &aOrientation, int aSmallDrill) const
Helper function to plot a single drill mark.
bool crossoutDNPItems(PCB_LAYER_ID aLayer) const
Definition pcbplot.h:146
void PlotTableBorders(const PCB_TABLE *aTable) const
bool hideDNPItems(PCB_LAYER_ID aLayer) const
Definition pcbplot.h:141
void PlotFootprintTextItems(const FOOTPRINT *aFootprint) const
PLOTTER * m_plotter
Definition pcbplot.h:159
void PlotPcbTarget(const PCB_TARGET *aMire) const
const BOARD * m_board
Definition pcbplot.h:160
COLOR4D getColor(int aLayer) const
White color is special because it cannot be seen on a white paper in B&W mode.
void PlotDrillMarks() const
Draw a drill mark for pads and vias.
void PlotShape(const PCB_SHAPE *aShape) const
int getFineWidthAdj() const
Definition pcbplot.h:75
BRDITEMS_PLOTTER(PLOTTER *aPlotter, const BOARD *aBoard, const PCB_PLOT_PARAMS &aPlotOpts)
Definition pcbplot.h:64
void PlotBarCode(const PCB_BARCODE *aBarCode) const
void PlotChartSymbols(const PCB_DRILL_CHART *aChart) const
Shape marks in a chart's symbol column, which carry no cell text of their own.
void PlotPad(const PAD *aPad, PCB_LAYER_ID aLayer, const COLOR4D &aColor, bool aSketchMode) const
Plot a pad.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:94
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:94
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition lseq.h:47
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
Definition pad.h:61
Abstract dimension API.
A drill chart placed on the board, kept in step with the holes.
Parameters and options when plotting/printing a board.
PLOT_FORMAT GetFormat() const
bool GetHideDNPFPsOnFabLayers() const
int GetWidthAdjust() const
bool GetCrossoutDNPFPsOnFabLayers() const
Base plotter engine class.
Definition plotter.h:138
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
Represent a set of closed polygons.
Handle a list of polygons defining a copper zone.
Definition zone.h:70
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ F_Fab
Definition layer_ids.h:115
@ B_Fab
Definition layer_ids.h:114
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition padstack.h:68
void PlotStandardLayer(BOARD *aBoard, PLOTTER *aPlotter, const LSET &aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Plot copper or technical layers.
const wxString GetGerberProtelExtension(int aLayer)
Definition pcbplot.cpp:39
PLOTTER * StartPlotBoard(BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer, const wxString &aLayerName, const wxString &aFullFileName, const wxString &aSheetName, const wxString &aSheetPath, const wxString &aPageName=wxT("1"), const wxString &aPageNumber=wxEmptyString, const int aPageCount=1)
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:290
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:78
void setupPlotterNewPDFPage(PLOTTER *aPlotter, BOARD *aBoard, PCB_PLOT_PARAMS *aPlotOpts, const wxString &aLayerName, const wxString &aSheetName, const wxString &aSheetPath, const wxString &aPageNumber, int aPageCount)
void PlotBoardLayers(BOARD *aBoard, PLOTTER *aPlotter, const LSEQ &aLayerSequence, const PCB_PLOT_PARAMS &aPlotOptions)
Plot a sequence of board layer IDs.
void PlotInteractiveLayer(BOARD *aBoard, PLOTTER *aPlotter, const PCB_PLOT_PARAMS &aPlotOpt)
Plot interactive items (hypertext links, properties, etc.) for the footprints the page drew.
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:356
void PlotOneBoardLayer(BOARD *aBoard, PLOTTER *aPlotter, PCB_LAYER_ID aLayer, const PCB_PLOT_PARAMS &aPlotOpt, bool isPrimaryLayer)
Plot one copper or technical layer.
void PlotLayerOutlines(BOARD *aBoard, PLOTTER *aPlotter, const LSET &aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Plot copper outline of a copper layer.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708