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-2021 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 
29 #ifndef PCBPLOT_H_
30 #define PCBPLOT_H_
31 
32 #include <layer_ids.h>
33 #include <pad_shapes.h>
34 #include <pcb_plot_params.h>
37 
38 class PLOTTER;
39 class PCB_TEXT;
40 class PAD;
41 class PCB_SHAPE;
42 class PCB_DIMENSION_BASE;
43 class FOOTPRINT;
44 class FP_SHAPE;
45 class PCB_TARGET;
46 class FP_TEXT;
47 class ZONE;
48 class BOARD;
49 class REPORTER;
50 class wxFileName;
51 
52 
53 // Define min and max reasonable values for plot/print scale
54 #define PLOT_MIN_SCALE 0.01
55 #define PLOT_MAX_SCALE 100.0
56 
57 
58 
59 // A helper class to plot board items
61 {
62 public:
63  BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts )
64  : PCB_PLOT_PARAMS( aPlotOpts )
65  {
66  m_plotter = aPlotter;
67  m_board = aBoard;
68  }
69 
75  int getFineWidthAdj() const
76  {
77  if( GetFormat() == PLOT_FORMAT::POST )
78  return GetWidthAdjust();
79  else
80  return 0;
81  }
82 
83  // Basic functions to plot a board item
84  void SetLayerSet( LSET aLayerMask ) { m_layerMask = aLayerMask; }
85  void PlotFootprintGraphicItems( const FOOTPRINT* aFootprint );
86  void PlotFootprintGraphicItem( const FP_SHAPE* aShape );
87  void PlotFootprintTextItem( const FP_TEXT* aText, const COLOR4D& aColor );
88 
89  /*
90  * Reference, Value, and other fields are plotted only if the corresponding option is enabled.
91  * Invisible text fields are plotted only if PlotInvisibleText option is set.
92  */
93  void PlotFootprintTextItems( const FOOTPRINT* aFootprint );
94 
95  void PlotDimension( const PCB_DIMENSION_BASE* aDim );
96  void PlotPcbTarget( const PCB_TARGET* aMire );
97  void PlotFilledAreas( const ZONE* aZone, const SHAPE_POLY_SET& aPolysList );
98  void PlotPcbText( const PCB_TEXT* aText );
99  void PlotPcbShape( const PCB_SHAPE* aShape );
100 
107  void PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_MODE aPlotMode );
108 
112  void PlotBoardGraphicItems();
113 
120  void PlotDrillMarks();
121 
130  COLOR4D getColor( LAYER_NUM aLayer ) const;
131 
132 private:
138  void plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const wxPoint& aDrillPos,
139  const wxSize& aDrillSize, const wxSize& aPadSize,
140  double aOrientation, int aSmallDrill );
141 
145 };
146 
147 PLOTTER* StartPlotBoard( BOARD* aBoard,
148  const PCB_PLOT_PARAMS* aPlotOpts,
149  int aLayer,
150  const wxString& aFullFileName,
151  const wxString& aSheetDesc );
152 
163 void PlotOneBoardLayer( BOARD* aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
164  const PCB_PLOT_PARAMS& aPlotOpt );
165 
188 void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
189  const PCB_PLOT_PARAMS& aPlotOpt );
190 
199 void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter,
200  LSET aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt );
201 
214 void BuildPlotFileName( wxFileName* aFilename,
215  const wxString& aOutputDir,
216  const wxString& aSuffix,
217  const wxString& aExtension );
218 
219 
223 const wxString GetGerberProtelExtension( LAYER_NUM aLayer );
224 
235 const wxString GetGerberFileFunctionAttribute( const BOARD* aBoard, LAYER_NUM aLayer );
236 
252 void AddGerberX2Header( PLOTTER* aPlotter, const BOARD* aBoard,
253  bool aUseX1CompatibilityMode = false );
254 
272 void AddGerberX2Attribute( PLOTTER* aPlotter, const BOARD* aBoard,
273  LAYER_NUM aLayer, bool aUseX1CompatibilityMode );
274 
275 #endif // PCBPLOT_H_
void PlotPcbTarget(const PCB_TARGET *aMire)
COLOR4D getColor(LAYER_NUM aLayer) const
White color is special because it cannot be seen on a white paper in B&W mode.
void plotOneDrillMark(PAD_DRILL_SHAPE_T aDrillShape, const wxPoint &aDrillPos, const wxSize &aDrillSize, const wxSize &aPadSize, double aOrientation, int aSmallDrill)
Helper function to plot a single drill mark.
OUTLINE_MODE
Definition: outline_mode.h:24
int GetWidthAdjust() const
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:282
void PlotFootprintGraphicItems(const FOOTPRINT *aFootprint)
void PlotOneBoardLayer(BOARD *aBoard, PLOTTER *aPlotter, PCB_LAYER_ID aLayer, const PCB_PLOT_PARAMS &aPlotOpt)
Plot one copper or technical layer.
PLOTTER * StartPlotBoard(BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer, const wxString &aFullFileName, const wxString &aSheetDesc)
Open a new plotfile using the options (and especially the format) specified in the options and prepar...
PLOTTER * m_plotter
Definition: pcbplot.h:142
void PlotDrillMarks()
Draw a drill mark for pads and vias.
void PlotPcbText(const PCB_TEXT *aText)
const wxString GetGerberProtelExtension(LAYER_NUM aLayer)
Definition: pcbplot.cpp:46
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:40
Abstract dimension API.
Definition: pcb_dimension.h:95
void PlotFootprintGraphicItem(const FP_SHAPE *aShape)
void PlotPad(const PAD *aPad, const COLOR4D &aColor, OUTLINE_MODE aPlotMode)
Plot a pad.
void PlotFootprintTextItems(const FOOTPRINT *aFootprint)
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:70
PAD_DRILL_SHAPE_T
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: pad_shapes.h:67
BOARD * m_board
Definition: pcbplot.h:143
void BuildPlotFileName(wxFileName *aFilename, const wxString &aOutputDir, const wxString &aSuffix, const wxString &aExtension)
Complete a plot filename.
Definition: pcbplot.cpp:372
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:502
PLOT_FORMAT GetFormat() const
void SetLayerSet(LSET aLayerMask)
Definition: pcbplot.h:84
Represent a set of closed polygons.
void PlotBoardGraphicItems()
Plot items like text and graphics but not tracks and footprints.
void PlotStandardLayer(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Plot copper or technical layers.
int getFineWidthAdj() const
Definition: pcbplot.h:75
const wxString GetGerberFileFunctionAttribute(const BOARD *aBoard, LAYER_NUM aLayer)
Return the "file function" attribute for aLayer, as defined in the Gerber file format specification J...
Definition: pcbplot.cpp:87
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
Parameters and options when plotting/printing a board.
void AddGerberX2Attribute(PLOTTER *aPlotter, const BOARD *aBoard, LAYER_NUM aLayer, bool aUseX1CompatibilityMode)
Calculate some X2 attributes as defined in the Gerber file format specification and add them to the g...
Definition: pcbplot.cpp:353
void PlotFilledAreas(const ZONE *aZone, const SHAPE_POLY_SET &aPolysList)
Base plotter engine class.
Definition: plotter.h:121
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void PlotPcbShape(const PCB_SHAPE *aShape)
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:64
LSET m_layerMask
Definition: pcbplot.h:144
void PlotLayerOutlines(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Plot copper outline of a copper layer.
BRDITEMS_PLOTTER(PLOTTER *aPlotter, BOARD *aBoard, const PCB_PLOT_PARAMS &aPlotOpts)
Definition: pcbplot.h:63
Definition: pad.h:57
void PlotDimension(const PCB_DIMENSION_BASE *aDim)
void PlotFootprintTextItem(const FP_TEXT *aText, const COLOR4D &aColor)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103