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 
70 public:
71  BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts )
72  : PCB_PLOT_PARAMS( aPlotOpts )
73  {
74  m_plotter = aPlotter;
75  m_board = aBoard;
76  }
77 
84  {
85  if( GetFormat() == PLOT_FORMAT::POST )
86  return GetWidthAdjust();
87  else
88  return 0;
89  }
90 
91  // Basic functions to plot a board item
92  void SetLayerSet( LSET aLayerMask ) { m_layerMask = aLayerMask; }
93  void PlotFootprintGraphicItems( MODULE* aModule );
95  void PlotFootprintTextItem( TEXTE_MODULE* aTextMod, COLOR4D aColor );
96 
97  /*
98  * Reference, Value, and other fields are plotted only if the corresponding option is enabled.
99  * Invisible text fields are plotted only if PlotInvisibleText option is set.
100  */
101  void PlotFootprintTextItems( MODULE* aModule );
102 
103  void PlotDimension( DIMENSION* Dimension );
104  void PlotPcbTarget( PCB_TARGET* PtMire );
105  void PlotFilledAreas( ZONE_CONTAINER* aZone, SHAPE_POLY_SET& aPolysList );
106  void PlotTextePcb( TEXTE_PCB* pt_texte );
107  void PlotDrawSegment( DRAWSEGMENT* PtSegm );
108 
115  void PlotPad( D_PAD* aPad, COLOR4D aColor, EDA_DRAW_MODE_T aPlotMode );
116 
121  void PlotBoardGraphicItems();
122 
129  void PlotDrillMarks();
130 
139  COLOR4D getColor( LAYER_NUM aLayer );
140 
141 private:
145  void plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape,
146  const wxPoint& aDrillPos, wxSize aDrillSize,
147  const wxSize& aPadSize,
148  double aOrientation, int aSmallDrill );
149 
150 };
151 
152 PLOTTER* StartPlotBoard( BOARD* aBoard,
153  PCB_PLOT_PARAMS* aPlotOpts,
154  int aLayer,
155  const wxString& aFullFileName,
156  const wxString& aSheetDesc );
157 
168 void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
169  const PCB_PLOT_PARAMS& aPlotOpt );
170 
192 void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
193  const PCB_PLOT_PARAMS& aPlotOpt );
194 
203 void PlotLayerOutlines( BOARD *aBoard, PLOTTER* aPlotter,
204  LSET aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt );
205 
218 void BuildPlotFileName( wxFileName* aFilename,
219  const wxString& aOutputDir,
220  const wxString& aSuffix,
221  const wxString& aExtension );
222 
223 
230 const wxString GetGerberProtelExtension( LAYER_NUM aLayer );
231 
241 const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard, LAYER_NUM aLayer );
242 
257 void AddGerberX2Header( PLOTTER * aPlotter,
258  const BOARD *aBoard, bool aUseX1CompatibilityMode = false );
259 
276 void AddGerberX2Attribute( PLOTTER * aPlotter, const BOARD *aBoard,
277  LAYER_NUM aLayer, bool aUseX1CompatibilityMode );
278 
279 #endif // PCBPLOT_H_
void PlotFootprintGraphicItems(MODULE *aModule)
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
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: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
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 PlotFootprintTextItems(MODULE *aModule)
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:92
void PlotPcbTarget(PCB_TARGET *PtMire)
SHAPE_POLY_SET.
EDA_DRAW_MODE_T
Definition: eda_text.h:62
void PlotBoardGraphicItems()
plot items like text and graphics, but not tracks and modules
void PlotFootprintGraphicItem(EDGE_MODULE *aEdge)
void PlotStandardLayer(BOARD *aBoard, PLOTTER *aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Function PlotStandardLayer plot copper or technical layers.
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
void PlotFootprintTextItem(TEXTE_MODULE *aTextMod, COLOR4D aColor)
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:181
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:83
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: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