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 #include <wx/filename.h>
40 
41 class PLOTTER;
42 class TEXTE_PCB;
43 class D_PAD;
44 class DRAWSEGMENT;
45 class DIMENSION;
46 class MODULE;
47 class EDGE_MODULE;
48 class PCB_TARGET;
49 class TEXTE_MODULE;
50 class ZONE_CONTAINER;
51 class BOARD;
52 class REPORTER;
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 // Small drill marks (small pad holes) diameter value
60 #define SMALL_DRILL KiROUND( 0.35 * IU_PER_MM )
61 
62 
63 // A helper class to plot board items
65 {
69 
72 
73 public:
74  BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts ) :
75  PCB_PLOT_PARAMS( aPlotOpts )
76  {
77  m_plotter = aPlotter;
78  m_board = aBoard;
79 
80  // TODO(JE) do we ever need to plot outside the context of Pgm()?
81  m_colors = Pgm().GetSettingsManager().GetColorSettings();
82  }
83 
90  {
91  if( GetFormat() == PLOT_FORMAT::POST )
92  return GetWidthAdjust();
93  else
94  return 0;
95  }
96 
97  // Basic functions to plot a board item
98  void SetLayerSet( LSET aLayerMask ) { m_layerMask = aLayerMask; }
99  void Plot_Edges_Modules();
100  void Plot_1_EdgeModule( EDGE_MODULE* aEdge );
101  void PlotTextModule( TEXTE_MODULE* aTextMod, COLOR4D aColor );
102 
103  /*
104  * Plot field of a module (footprint)
105  * Reference, Value, and other fields are plotted only if
106  * the corresponding option is enabled
107  * Invisible text fields are plotted only if PlotInvisibleText option is set
108  * usually they are not plotted.
109  */
110  bool PlotAllTextsModule( MODULE* aModule );
111 
112  void PlotDimension( DIMENSION* Dimension );
113  void PlotPcbTarget( PCB_TARGET* PtMire );
114  void PlotFilledAreas( ZONE_CONTAINER* aZone, SHAPE_POLY_SET& aPolysList );
115  void PlotTextePcb( TEXTE_PCB* pt_texte );
116  void PlotDrawSegment( DRAWSEGMENT* PtSegm );
117 
124  void PlotPad( D_PAD* aPad, COLOR4D aColor, EDA_DRAW_MODE_T aPlotMode );
125 
130  void PlotBoardGraphicItems();
131 
138  void PlotDrillMarks();
139 
148  COLOR4D getColor( LAYER_NUM aLayer );
149 
150 private:
154  void plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape,
155  const wxPoint& aDrillPos, wxSize aDrillSize,
156  const wxSize& aPadSize,
157  double aOrientation, int aSmallDrill );
158 
159 };
160 
161 PLOTTER* StartPlotBoard( BOARD* aBoard,
162  PCB_PLOT_PARAMS* aPlotOpts,
163  int aLayer,
164  const wxString& aFullFileName,
165  const wxString& aSheetDesc );
166 
177 void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
178  const PCB_PLOT_PARAMS& aPlotOpt );
179 
201 void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
202  const PCB_PLOT_PARAMS& aPlotOpt );
203 
212 void PlotLayerOutlines( BOARD *aBoard, PLOTTER* aPlotter,
213  LSET aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt );
214 
224 void PlotSilkScreen( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
225  const PCB_PLOT_PARAMS& aPlotOpt );
226 
227 
240 void BuildPlotFileName( wxFileName* aFilename,
241  const wxString& aOutputDir,
242  const wxString& aSuffix,
243  const wxString& aExtension );
244 
245 
252 const wxString GetGerberProtelExtension( LAYER_NUM aLayer );
253 
263 const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard, LAYER_NUM aLayer );
264 
279 void AddGerberX2Header( PLOTTER * aPlotter,
280  const BOARD *aBoard, bool aUseX1CompatibilityMode = false );
281 
298 void AddGerberX2Attribute( PLOTTER * aPlotter, const BOARD *aBoard,
299  LAYER_NUM aLayer, bool aUseX1CompatibilityMode );
300 
301 #endif // PCBPLOT_H_
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
int GetWidthAdjust() const
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
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:282
void PlotPad(D_PAD *aPad, COLOR4D aColor, EDA_DRAW_MODE_T aPlotMode)
Plot a pad.
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 PlotDimension(DIMENSION *Dimension)
PLOTTER * m_plotter
Definition: pcbplot.h:66
void PlotDrillMarks()
Function PlotDrillMarks Draw a drill mark for pads and vias.
const wxString GetGerberProtelExtension(LAYER_NUM aLayer)
Function GetGerberProtelExtension.
Definition: pcbplot.cpp:48
bool PlotAllTextsModule(MODULE *aModule)
REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:62
PAD_DRILL_SHAPE_T
Enum PAD_DRILL_SHAPE_T is the set of pad drill shapes, used with D_PAD::{Set,Get}DrillShape()
Definition: pad_shapes.h:47
void PlotFilledAreas(ZONE_CONTAINER *aZone, SHAPE_POLY_SET &aPolysList)
BOARD * m_board
Definition: pcbplot.h:67
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:373
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:98
void PlotPcbTarget(PCB_TARGET *PtMire)
SHAPE_POLY_SET.
EDA_DRAW_MODE_T
Definition: eda_text.h:59
void PlotBoardGraphicItems()
plot items like text and graphics, but not tracks and modules
void PlotStandardLayer(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Function PlotStandardLayer plot copper or technical layers.
void Plot_1_EdgeModule(EDGE_MODULE *aEdge)
void PlotSilkScreen(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Function PlotSilkScreen plot silkscreen layers which have specific requirements, mainly for pads.
const wxString GetGerberFileFunctionAttribute(const BOARD *aBoard, LAYER_NUM aLayer)
Function GetGerberFileFunctionAttribute Returns the "file function" attribute for aLayer,...
Definition: pcbplot.cpp:89
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:354
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
Base plotter engine class.
Definition: plotter.h:104
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.
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:163
LSET m_layerMask
Definition: pcbplot.h:68
void PlotLayerOutlines(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Function PlotLayerOutlines plot copper outline of a copper layer.
void PlotTextePcb(TEXTE_PCB *pt_texte)
int getFineWidthAdj()
Definition: pcbplot.h:89
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:74
COLOR_SETTINGS * m_colors
Pointer to color settings that should be used for plotting.
Definition: pcbplot.h:71
COLOR4D getColor(LAYER_NUM aLayer)
Function getColor.
DIMENSION.
void PlotDrawSegment(DRAWSEGMENT *PtSegm)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40
void PlotTextModule(TEXTE_MODULE *aTextMod, COLOR4D aColor)