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 
32 #include <wx/filename.h>
33 #include <pad_shapes.h>
34 #include <pcb_plot_params.h>
36 
37 class PLOTTER;
38 class TEXTE_PCB;
39 class DRAWSEGMENT;
40 class DIMENSION;
41 class MODULE;
42 class EDGE_MODULE;
43 class PCB_TARGET;
44 class TEXTE_MODULE;
45 class ZONE_CONTAINER;
46 class BOARD;
47 class REPORTER;
48 
51 
52 #define OPTKEY_LAYERBASE wxT( "PlotLayer_%d" )
53 #define OPTKEY_PRINT_X_FINESCALE_ADJ wxT( "PrintXFineScaleAdj" )
54 #define OPTKEY_PRINT_Y_FINESCALE_ADJ wxT( "PrintYFineScaleAdj" )
55 #define OPTKEY_PRINT_SCALE wxT( "PrintScale" )
56 #define OPTKEY_PRINT_MODULE_SCALE wxT( "PrintModuleScale" )
57 #define OPTKEY_PRINT_PAGE_FRAME wxT( "PrintPageFrame" )
58 #define OPTKEY_PRINT_MONOCHROME_MODE wxT( "PrintMonochrome" )
59 #define OPTKEY_PRINT_PAGE_PER_LAYER wxT( "PrintSinglePage" )
60 #define OPTKEY_PRINT_PADS_DRILL wxT( "PrintPadsDrillOpt" )
61 #define OPTKEY_PLOT_X_FINESCALE_ADJ wxT( "PlotXFineScaleAdj" )
62 #define OPTKEY_PLOT_Y_FINESCALE_ADJ wxT( "PlotYFineScaleAdj" )
63 #define CONFIG_PS_FINEWIDTH_ADJ wxT( "PSPlotFineWidthAdj" )
64 
66 
67 // Define min and max reasonable values for plot/print scale
68 #define PLOT_MIN_SCALE 0.01
69 #define PLOT_MAX_SCALE 100.0
70 
71 // Small drill marks (small pad holes) diameter value
72 #define SMALL_DRILL KiROUND( 0.35 * IU_PER_MM )
73 
74 
75 // A helper class to plot board items
77 {
81 
82 public:
83  BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts ) :
84  PCB_PLOT_PARAMS( aPlotOpts )
85  {
86  m_plotter = aPlotter;
87  m_board = aBoard;
88  }
89 
96  {
97  if( GetFormat() == PLOT_FORMAT_POST )
98  return GetWidthAdjust();
99  else
100  return 0;
101  }
102 
103  // Basic functions to plot a board item
104  void SetLayerSet( LSET aLayerMask ) { m_layerMask = aLayerMask; }
105  void Plot_Edges_Modules();
106  void Plot_1_EdgeModule( EDGE_MODULE* aEdge );
107  void PlotTextModule( TEXTE_MODULE* aTextMod, COLOR4D aColor );
108 
109  /*
110  * Plot field of a module (footprint)
111  * Reference, Value, and other fields are plotted only if
112  * the corresponding option is enabled
113  * Invisible text fields are plotted only if PlotInvisibleText option is set
114  * usually they are not plotted.
115  */
116  bool PlotAllTextsModule( MODULE* aModule );
117 
118  void PlotDimension( DIMENSION* Dimension );
119  void PlotPcbTarget( PCB_TARGET* PtMire );
120  void PlotFilledAreas( ZONE_CONTAINER* aZone );
121  void PlotTextePcb( TEXTE_PCB* pt_texte );
122  void PlotDrawSegment( DRAWSEGMENT* PtSegm );
123 
130  void PlotPad( D_PAD* aPad, COLOR4D aColor, EDA_DRAW_MODE_T aPlotMode );
131 
136  void PlotBoardGraphicItems();
137 
144  void PlotDrillMarks();
145 
154  COLOR4D getColor( LAYER_NUM aLayer );
155 
156 private:
160  void plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape,
161  const wxPoint& aDrillPos, wxSize aDrillSize,
162  const wxSize& aPadSize,
163  double aOrientation, int aSmallDrill );
164 
165 };
166 
167 PLOTTER* StartPlotBoard( BOARD* aBoard,
168  PCB_PLOT_PARAMS* aPlotOpts,
169  int aLayer,
170  const wxString& aFullFileName,
171  const wxString& aSheetDesc );
172 
183 void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
184  const PCB_PLOT_PARAMS& aPlotOpt );
185 
207 void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
208  const PCB_PLOT_PARAMS& aPlotOpt );
209 
218 void PlotLayerOutlines( BOARD *aBoard, PLOTTER* aPlotter,
219  LSET aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt );
220 
230 void PlotSilkScreen( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
231  const PCB_PLOT_PARAMS& aPlotOpt );
232 
233 
246 void BuildPlotFileName( wxFileName* aFilename,
247  const wxString& aOutputDir,
248  const wxString& aSuffix,
249  const wxString& aExtension );
250 
251 
258 const wxString GetGerberProtelExtension( LAYER_NUM aLayer );
259 
269 const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard, LAYER_NUM aLayer );
270 
285 void AddGerberX2Header( PLOTTER * aPlotter,
286  const BOARD *aBoard, bool aUseX1CompatibilityMode = false );
287 
304 void AddGerberX2Attribute( PLOTTER * aPlotter, const BOARD *aBoard,
305  LAYER_NUM aLayer, bool aUseX1CompatibilityMode );
306 
307 #endif // PCBPLOT_H_
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
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:368
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:78
void PlotDrillMarks()
Function PlotDrillMarks Draw a drill mark for pads and vias.
const wxString GetGerberProtelExtension(LAYER_NUM aLayer)
Function GetGerberProtelExtension.
Definition: pcbplot.cpp:47
bool PlotAllTextsModule(MODULE *aModule)
Class REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:61
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:46
BOARD * m_board
Definition: pcbplot.h:79
void PlotFilledAreas(ZONE_CONTAINER *aZone)
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:484
PCB_LAYER_ID
A quick note on layer IDs:
Class LSET is a set of PCB_LAYER_IDs.
void SetLayerSet(LSET aLayerMask)
Definition: pcbplot.h:104
void PlotPcbTarget(PCB_TARGET *PtMire)
EDA_DRAW_MODE_T
Definition: eda_text.h:62
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:88
PlotFormat GetFormat() const
Class 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:465
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
Base plotter engine class.
Definition: class_plotter.h:96
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.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
LSET m_layerMask
Definition: pcbplot.h:80
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:95
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:83
COLOR4D getColor(LAYER_NUM aLayer)
Function getColor.
Class DIMENSION.
int GetWidthAdjust() const
void PlotDrawSegment(DRAWSEGMENT *PtSegm)
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void PlotTextModule(TEXTE_MODULE *aTextMod, COLOR4D aColor)