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 (C) 1992-2023 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 <lset.h>
28#include <padstack.h> // for PAD_DRILL_SHAPE
29#include <pcb_plot_params.h>
32#include <board.h>
34#include <board_item.h>
35
36class EDA_TEXT;
37class PLOTTER;
38class PCB_TEXT;
39class PAD;
40class PCB_SHAPE;
41class PCB_TABLE;
43class FOOTPRINT;
44class PCB_TARGET;
45class ZONE;
46class REPORTER;
47class wxFileName;
48
49namespace KIFONT
50{
51class FONT;
52class METRICS;
53}
54
55
56// Define min and max reasonable values for plot/print scale
57#define PLOT_MIN_SCALE 0.01
58#define PLOT_MAX_SCALE 100.0
59
60
61
62// A helper class to plot board items
64{
65public:
66 BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts ) :
67 PCB_PLOT_PARAMS( aPlotOpts ),
68 m_plotter( aPlotter ),
69 m_board( aBoard )
70 { }
71
77 int getFineWidthAdj() const
78 {
79 if( GetFormat() == PLOT_FORMAT::POST )
80 return GetWidthAdjust();
81 else
82 return 0;
83 }
84
85 // Basic functions to plot a board item
86 void SetLayerSet( LSET aLayerMask ) { m_layerMask = aLayerMask; }
87 void PlotFootprintGraphicItems( const FOOTPRINT* aFootprint );
88 void PlotFootprintTextItems( const FOOTPRINT* aFootprint );
89
90 void PlotDimension( const PCB_DIMENSION_BASE* aDim );
91 void PlotPcbTarget( const PCB_TARGET* aMire );
92 void PlotZone( const ZONE* aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList );
93 void PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout,
94 const KIFONT::METRICS& aFontMetrics, bool aStrikeout = false );
95 void PlotShape( const PCB_SHAPE* aShape );
96 void PlotTableBorders( const PCB_TABLE* aTable );
97
104 void PlotPad( const PAD* aPad, PCB_LAYER_ID aLayer, const COLOR4D& aColor,
105 OUTLINE_MODE aPlotMode );
106
107 void PlotPadNumber( const PAD* aPad, const COLOR4D& aColor );
108
112 void PlotBoardGraphicItem( const BOARD_ITEM* item );
113
120 void PlotDrillMarks();
121
130 COLOR4D getColor( int aLayer ) const;
131
132private:
134 {
135 return GetHideDNPFPsOnFabLayers() && ( aLayer == F_Fab || aLayer == B_Fab );
136 }
137
139 {
140 return GetCrossoutDNPFPsOnFabLayers() && ( aLayer == F_Fab || aLayer == B_Fab );
141 }
142
148 void plotOneDrillMark( PAD_DRILL_SHAPE aDrillShape, const VECTOR2I& aDrillPos,
149 const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
150 const EDA_ANGLE& aOrientation, int aSmallDrill );
151
155};
156
157
158PLOTTER* StartPlotBoard( BOARD* aBoard, const PCB_PLOT_PARAMS* aPlotOpts, int aLayer,
159 const wxString& aLayerName, const wxString& aFullFileName,
160 const wxString& aSheetName, const wxString& aSheetPath );
161
170void PlotBoardLayers( BOARD* aBoard, PLOTTER* aPlotter, const LSEQ& aLayerSequence,
171 const PCB_PLOT_PARAMS& aPlotOptions );
172
176void PlotInteractiveLayer( BOARD* aBoard, PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpt );
177
188void PlotOneBoardLayer( BOARD* aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
189 const PCB_PLOT_PARAMS& aPlotOpt );
190
211void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
212 const PCB_PLOT_PARAMS& aPlotOpt );
213
222void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
223 const PCB_PLOT_PARAMS& aPlotOpt );
224
237void BuildPlotFileName( wxFileName* aFilename, const wxString& aOutputDir, const wxString& aSuffix,
238 const wxString& aExtension );
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:79
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
void PlotDrillMarks()
Draw a drill mark for pads and vias.
void PlotZone(const ZONE *aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
LSET m_layerMask
Definition: pcbplot.h:154
void PlotPadNumber(const PAD *aPad, const COLOR4D &aColor)
void PlotBoardGraphicItem(const BOARD_ITEM *item)
Plot items like text and graphics but not tracks and footprints.
void SetLayerSet(LSET aLayerMask)
Definition: pcbplot.h:86
void PlotDimension(const PCB_DIMENSION_BASE *aDim)
void PlotText(const EDA_TEXT *aText, PCB_LAYER_ID aLayer, bool aIsKnockout, const KIFONT::METRICS &aFontMetrics, bool aStrikeout=false)
void PlotPad(const PAD *aPad, PCB_LAYER_ID aLayer, const COLOR4D &aColor, OUTLINE_MODE aPlotMode)
Plot a pad.
BOARD * m_board
Definition: pcbplot.h:153
void PlotShape(const PCB_SHAPE *aShape)
PLOTTER * m_plotter
Definition: pcbplot.h:152
bool crossoutDNPItems(PCB_LAYER_ID aLayer)
Definition: pcbplot.h:138
COLOR4D getColor(int aLayer) const
White color is special because it cannot be seen on a white paper in B&W mode.
void PlotPcbTarget(const PCB_TARGET *aMire)
void PlotTableBorders(const PCB_TABLE *aTable)
void PlotFootprintTextItems(const FOOTPRINT *aFootprint)
int getFineWidthAdj() const
Definition: pcbplot.h:77
void plotOneDrillMark(PAD_DRILL_SHAPE aDrillShape, const VECTOR2I &aDrillPos, const VECTOR2I &aDrillSize, const VECTOR2I &aPadSize, const EDA_ANGLE &aOrientation, int aSmallDrill)
Helper function to plot a single drill mark.
bool hideDNPItems(PCB_LAYER_ID aLayer)
Definition: pcbplot.h:133
BRDITEMS_PLOTTER(PLOTTER *aPlotter, BOARD *aBoard, const PCB_PLOT_PARAMS &aPlotOpts)
Definition: pcbplot.h:66
void PlotFootprintGraphicItems(const FOOTPRINT *aFootprint)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:79
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: lseq.h:47
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:36
Definition: pad.h:54
Abstract dimension API.
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:105
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:72
Represent a set of closed polygons.
Handle a list of polygons defining a copper zone.
Definition: zone.h:73
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ F_Fab
Definition: layer_ids.h:119
@ B_Fab
Definition: layer_ids.h:118
OUTLINE_MODE
Definition: outline_mode.h:25
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: padstack.h:69
void PlotStandardLayer(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Plot copper or technical layers.
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:43
void PlotLayerOutlines(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Plot copper outline of a copper layer.
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:294
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:82
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.).
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:360
void BuildPlotFileName(wxFileName *aFilename, const wxString &aOutputDir, const wxString &aSuffix, const wxString &aExtension)
Complete a plot filename.
Definition: pcbplot.cpp:379
PLOTTER * StartPlotBoard(BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer, const wxString &aLayerName, 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...