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 #define OPTKEY_PLOT_CHECK_ZONES wxT( "CheckZonesBeforePlotting" )
65 
67 
68 // Define min and max reasonable values for plot/print scale
69 #define PLOT_MIN_SCALE 0.01
70 #define PLOT_MAX_SCALE 100.0
71 
72 // Small drill marks (small pad holes) diameter value
73 #define SMALL_DRILL KiROUND( 0.35 * IU_PER_MM )
74 
75 
76 // A helper class to plot board items
78 {
82 
83 public:
84  BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts ) :
85  PCB_PLOT_PARAMS( aPlotOpts )
86  {
87  m_plotter = aPlotter;
88  m_board = aBoard;
89  }
90 
97  {
98  if( GetFormat() == PLOT_FORMAT_POST )
99  return GetWidthAdjust();
100  else
101  return 0;
102  }
103 
104  // Basic functions to plot a board item
105  void SetLayerSet( LSET aLayerMask ) { m_layerMask = aLayerMask; }
106  void Plot_Edges_Modules();
107  void Plot_1_EdgeModule( EDGE_MODULE* aEdge );
108  void PlotTextModule( TEXTE_MODULE* aTextMod, COLOR4D aColor );
109 
110  /*
111  * Plot field of a module (footprint)
112  * Reference, Value, and other fields are plotted only if
113  * the corresponding option is enabled
114  * Invisible text fields are plotted only if PlotInvisibleText option is set
115  * usually they are not plotted.
116  */
117  bool PlotAllTextsModule( MODULE* aModule );
118 
119  void PlotDimension( DIMENSION* Dimension );
120  void PlotPcbTarget( PCB_TARGET* PtMire );
121  void PlotFilledAreas( ZONE_CONTAINER* aZone );
122  void PlotTextePcb( TEXTE_PCB* pt_texte );
123  void PlotDrawSegment( DRAWSEGMENT* PtSegm );
124 
131  void PlotPad( D_PAD* aPad, COLOR4D aColor, EDA_DRAW_MODE_T aPlotMode );
132 
137  void PlotBoardGraphicItems();
138 
145  void PlotDrillMarks();
146 
155  COLOR4D getColor( LAYER_NUM aLayer );
156 
157 private:
161  void plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape,
162  const wxPoint& aDrillPos, wxSize aDrillSize,
163  const wxSize& aPadSize,
164  double aOrientation, int aSmallDrill );
165 
166 };
167 
168 PLOTTER* StartPlotBoard( BOARD* aBoard,
169  PCB_PLOT_PARAMS* aPlotOpts,
170  int aLayer,
171  const wxString& aFullFileName,
172  const wxString& aSheetDesc );
173 
184 void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, PCB_LAYER_ID aLayer,
185  const PCB_PLOT_PARAMS& aPlotOpt );
186 
208 void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
209  const PCB_PLOT_PARAMS& aPlotOpt );
210 
219 void PlotLayerOutlines( BOARD *aBoard, PLOTTER* aPlotter,
220  LSET aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt );
221 
231 void PlotSilkScreen( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
232  const PCB_PLOT_PARAMS& aPlotOpt );
233 
234 
247 void BuildPlotFileName( wxFileName* aFilename,
248  const wxString& aOutputDir,
249  const wxString& aSuffix,
250  const wxString& aExtension );
251 
252 
259 const wxString GetGerberProtelExtension( LAYER_NUM aLayer );
260 
270 const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard, LAYER_NUM aLayer );
271 
286 void AddGerberX2Header( PLOTTER * aPlotter,
287  const BOARD *aBoard, bool aUseX1CompatibilityMode = false );
288 
305 void AddGerberX2Attribute( PLOTTER * aPlotter, const BOARD *aBoard,
306  LAYER_NUM aLayer, bool aUseX1CompatibilityMode );
307 
308 #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:79
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:80
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:105
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: 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:81
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:96
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:84
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)