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-2016 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 
33 #include <math/util.h> // for KiROUND
34 #include <pad_shapes.h>
35 #include <pcb_plot_params.h>
36 #include <pgm_base.h>
39 
40 class PLOTTER;
41 class PCB_TEXT;
42 class PAD;
43 class PCB_SHAPE;
44 class DIMENSION_BASE;
45 class FOOTPRINT;
46 class FP_SHAPE;
47 class PCB_TARGET;
48 class FP_TEXT;
49 class ZONE;
50 class BOARD;
51 class REPORTER;
52 class wxFileName;
53 
54 
55 // Define min and max reasonable values for plot/print scale
56 #define PLOT_MIN_SCALE 0.01
57 #define PLOT_MAX_SCALE 100.0
58 
59 
60 
61 // A helper class to plot board items
63 {
67 
68 public:
69  BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts )
70  : PCB_PLOT_PARAMS( aPlotOpts )
71  {
72  m_plotter = aPlotter;
73  m_board = aBoard;
74  }
75 
82  {
83  if( GetFormat() == PLOT_FORMAT::POST )
84  return GetWidthAdjust();
85  else
86  return 0;
87  }
88 
89  // Basic functions to plot a board item
90  void SetLayerSet( LSET aLayerMask ) { m_layerMask = aLayerMask; }
91  void PlotFootprintGraphicItems( FOOTPRINT* aFootprint );
92  void PlotFootprintGraphicItem( FP_SHAPE* aShape );
93  void PlotFootprintTextItem( FP_TEXT* aText, COLOR4D aColor );
94 
95  /*
96  * Reference, Value, and other fields are plotted only if the corresponding option is enabled.
97  * Invisible text fields are plotted only if PlotInvisibleText option is set.
98  */
99  void PlotFootprintTextItems( FOOTPRINT* aFootprint );
100 
101  void PlotDimension( DIMENSION_BASE* Dimension );
102  void PlotPcbTarget( PCB_TARGET* PtMire );
103  void PlotFilledAreas( ZONE* aZone, SHAPE_POLY_SET& aPolysList );
104  void PlotPcbText( PCB_TEXT* aText );
105  void PlotPcbShape( PCB_SHAPE* aShape );
106 
113  void PlotPad( PAD* aPad, COLOR4D aColor, OUTLINE_MODE aPlotMode );
114 
119  void PlotBoardGraphicItems();
120 
127  void PlotDrillMarks();
128 
137  COLOR4D getColor( LAYER_NUM aLayer );
138 
139 private:
143  void plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape,
144  const wxPoint& aDrillPos, wxSize aDrillSize,
145  const wxSize& aPadSize,
146  double aOrientation, int aSmallDrill );
147 
148 };
149 
150 PLOTTER* StartPlotBoard( BOARD* aBoard,
151  PCB_PLOT_PARAMS* aPlotOpts,
152  int aLayer,
153  const wxString& aFullFileName,
154  const wxString& aSheetDesc );
155 
166 void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
167  const PCB_PLOT_PARAMS& aPlotOpt );
168 
190 void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
191  const PCB_PLOT_PARAMS& aPlotOpt );
192 
201 void PlotLayerOutlines( BOARD *aBoard, PLOTTER* aPlotter,
202  LSET aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt );
203 
216 void BuildPlotFileName( wxFileName* aFilename,
217  const wxString& aOutputDir,
218  const wxString& aSuffix,
219  const wxString& aExtension );
220 
221 
228 const wxString GetGerberProtelExtension( LAYER_NUM aLayer );
229 
239 const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard, LAYER_NUM aLayer );
240 
255 void AddGerberX2Header( PLOTTER * aPlotter,
256  const BOARD *aBoard, bool aUseX1CompatibilityMode = false );
257 
274 void AddGerberX2Attribute( PLOTTER * aPlotter, const BOARD *aBoard,
275  LAYER_NUM aLayer, bool aUseX1CompatibilityMode );
276 
277 #endif // PCBPLOT_H_
OUTLINE_MODE
Definition: outline_mode.h:24
int GetWidthAdjust() const
void AddGerberX2Header(PLOTTER *aPlotter, const BOARD *aBoard, bool aUseX1CompatibilityMode=false)
Calculates some X2 attributes, as defined in the Gerber file format specification J4 (chapter 5) and ...
Definition: pcbplot.cpp:279
void PlotOneBoardLayer(BOARD *aBoard, PLOTTER *aPlotter, PCB_LAYER_ID aLayer, const PCB_PLOT_PARAMS &aPlotOpt)
Function PlotOneBoardLayer main function to plot one copper or technical layer.
void PlotPcbText(PCB_TEXT *aText)
PLOTTER * m_plotter
Definition: pcbplot.h:64
void PlotDrillMarks()
Function PlotDrillMarks Draw a drill mark for pads and vias.
void PlotFootprintTextItems(FOOTPRINT *aFootprint)
const wxString GetGerberProtelExtension(LAYER_NUM aLayer)
Function GetGerberProtelExtension.
Definition: pcbplot.cpp:45
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
PAD_DRILL_SHAPE_T
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: pad_shapes.h:66
BOARD * m_board
Definition: pcbplot.h:65
void BuildPlotFileName(wxFileName *aFilename, const wxString &aOutputDir, const wxString &aSuffix, const wxString &aExtension)
Function BuildPlotFileName (helper function) Complete a plot filename: forces the output directory,...
Definition: pcbplot.cpp:369
PCB_LAYER_ID
A quick note on layer IDs:
LSET is a set of PCB_LAYER_IDs.
PLOT_FORMAT GetFormat() const
void SetLayerSet(LSET aLayerMask)
Definition: pcbplot.h:90
void PlotPcbTarget(PCB_TARGET *PtMire)
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)
Function PlotStandardLayer plot copper or technical layers.
void PlotFootprintTextItem(FP_TEXT *aText, COLOR4D aColor)
const wxString GetGerberFileFunctionAttribute(const BOARD *aBoard, LAYER_NUM aLayer)
Function GetGerberFileFunctionAttribute Returns the "file function" attribute for aLayer,...
Definition: pcbplot.cpp:86
void PlotFootprintGraphicItems(FOOTPRINT *aFootprint)
ZONE handles a list of polygons defining a copper zone.
Definition: zone.h:57
PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board.
void AddGerberX2Attribute(PLOTTER *aPlotter, const BOARD *aBoard, LAYER_NUM aLayer, bool aUseX1CompatibilityMode)
Calculates some X2 attributes, as defined in the Gerber file format specification and add them to the...
Definition: pcbplot.cpp:350
int LAYER_NUM
This can be replaced with int and removed.
void PlotFilledAreas(ZONE *aZone, SHAPE_POLY_SET &aPolysList)
void PlotPad(PAD *aPad, COLOR4D aColor, OUTLINE_MODE aPlotMode)
Plot a pad.
Base plotter engine class.
Definition: plotter.h:121
see class PGM_BASE
Board layer functions and definitions.
void plotOneDrillMark(PAD_DRILL_SHAPE_T aDrillShape, const wxPoint &aDrillPos, wxSize aDrillSize, const wxSize &aPadSize, double aOrientation, int aSmallDrill)
Helper function to plot a single drill mark.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void PlotPcbShape(PCB_SHAPE *aShape)
LSET m_layerMask
Definition: pcbplot.h:66
void PlotFootprintGraphicItem(FP_SHAPE *aShape)
void PlotLayerOutlines(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Function PlotLayerOutlines plot copper outline of a copper layer.
int getFineWidthAdj()
Definition: pcbplot.h:81
PLOTTER * StartPlotBoard(BOARD *aBoard, 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...
BRDITEMS_PLOTTER(PLOTTER *aPlotter, BOARD *aBoard, const PCB_PLOT_PARAMS &aPlotOpts)
Definition: pcbplot.h:69
Definition: pad.h:60
Abstract dimension API.
Definition: dimension.h:95
void PlotDimension(DIMENSION_BASE *Dimension)
COLOR4D getColor(LAYER_NUM aLayer)
Function getColor.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98