1 #ifndef PCB_PLOT_PARAMS_H_ 2 #define PCB_PLOT_PARAMS_H_ 3 /* 4 * This program source code file is part of KiCad, a free EDA CAD application. 5 * 6 * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, you may find one here: 20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 21 * or you may search the http://www.gnu.org website for the version 2 license, 22 * or you may write to the Free Software Foundation, Inc., 23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 24 */ 25 26 #include <plotters/plotter.h> 27 #include <layer_ids.h> 28 29 class COLOR_SETTINGS; 30 class PCB_PLOT_PARAMS_PARSER; 31 32 /** 33 * Parameters and options when plotting/printing a board. 34 */ 35 class PCB_PLOT_PARAMS 36 { 37 public: 38 enum DrillMarksType { 39 NO_DRILL_SHAPE = 0, 40 SMALL_DRILL_SHAPE = 1, 41 FULL_DRILL_SHAPE = 2 42 }; 43 44 PCB_PLOT_PARAMS(); 45 SetSkipPlotNPTH_Pads(bool aSkip)46 void SetSkipPlotNPTH_Pads( bool aSkip ) { m_skipNPTH_Pads = aSkip; } GetSkipPlotNPTH_Pads()47 bool GetSkipPlotNPTH_Pads() const { return m_skipNPTH_Pads; } 48 49 void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl=0 ) const; 50 void Parse( PCB_PLOT_PARAMS_PARSER* aParser ); 51 52 /** 53 * Compare current settings to aPcbPlotParams, including not saved parameters in brd file. 54 * 55 * @param aPcbPlotParams is the #PCB_PLOT_PARAMS to compare/ 56 * @param aCompareOnlySavedPrms set to true to compare only saved in file parameters, 57 * or false to compare the full set of parameters. 58 * @return true is parameters are same, false if one (or more) parameter does not match. 59 */ 60 bool IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams ) const; 61 SetColorSettings(COLOR_SETTINGS * aSettings)62 void SetColorSettings( COLOR_SETTINGS* aSettings ) { m_colors = aSettings; } 63 ColorSettings()64 COLOR_SETTINGS* ColorSettings() const { return m_colors; } 65 SetTextMode(PLOT_TEXT_MODE aVal)66 void SetTextMode( PLOT_TEXT_MODE aVal ) 67 { 68 m_textMode = aVal; 69 } 70 GetTextMode()71 PLOT_TEXT_MODE GetTextMode() const 72 { 73 return m_textMode; 74 } 75 SetPlotMode(OUTLINE_MODE aPlotMode)76 void SetPlotMode( OUTLINE_MODE aPlotMode ) { m_plotMode = aPlotMode; } GetPlotMode()77 OUTLINE_MODE GetPlotMode() const { return m_plotMode; } 78 SetDXFPlotPolygonMode(bool aFlag)79 void SetDXFPlotPolygonMode( bool aFlag ) { m_DXFplotPolygonMode = aFlag; } GetDXFPlotPolygonMode()80 bool GetDXFPlotPolygonMode() const { return m_DXFplotPolygonMode; } 81 SetDXFPlotUnits(DXF_UNITS aUnit)82 void SetDXFPlotUnits( DXF_UNITS aUnit ) 83 { 84 m_DXFplotUnits = aUnit; 85 } 86 GetDXFPlotUnits()87 DXF_UNITS GetDXFPlotUnits() const 88 { 89 return m_DXFplotUnits; 90 } 91 SetDrillMarksType(DrillMarksType aVal)92 void SetDrillMarksType( DrillMarksType aVal ) { m_drillMarks = aVal; } GetDrillMarksType()93 DrillMarksType GetDrillMarksType() const { return m_drillMarks; } 94 SetScale(double aVal)95 void SetScale( double aVal ) { m_scale = aVal; } GetScale()96 double GetScale() const { return m_scale; } 97 SetFineScaleAdjustX(double aVal)98 void SetFineScaleAdjustX( double aVal ) { m_fineScaleAdjustX = aVal; } GetFineScaleAdjustX()99 double GetFineScaleAdjustX() const { return m_fineScaleAdjustX; } SetFineScaleAdjustY(double aVal)100 void SetFineScaleAdjustY( double aVal ) { m_fineScaleAdjustY = aVal; } GetFineScaleAdjustY()101 double GetFineScaleAdjustY() const { return m_fineScaleAdjustY; } SetWidthAdjust(int aVal)102 void SetWidthAdjust( int aVal ) { m_widthAdjust = aVal; } GetWidthAdjust()103 int GetWidthAdjust() const { return m_widthAdjust; } 104 SetAutoScale(bool aFlag)105 void SetAutoScale( bool aFlag ) { m_autoScale = aFlag; } GetAutoScale()106 bool GetAutoScale() const { return m_autoScale; } 107 SetMirror(bool aFlag)108 void SetMirror( bool aFlag ) { m_mirror = aFlag; } GetMirror()109 bool GetMirror() const { return m_mirror; } 110 SetSketchPadsOnFabLayers(bool aFlag)111 void SetSketchPadsOnFabLayers( bool aFlag ) { m_sketchPadsOnFabLayers = aFlag; } GetSketchPadsOnFabLayers()112 bool GetSketchPadsOnFabLayers() const { return m_sketchPadsOnFabLayers; } SetSketchPadLineWidth(int aWidth)113 void SetSketchPadLineWidth( int aWidth ) { m_sketchPadLineWidth = aWidth; } GetSketchPadLineWidth()114 int GetSketchPadLineWidth() const { return m_sketchPadLineWidth; } 115 SetPlotInvisibleText(bool aFlag)116 void SetPlotInvisibleText( bool aFlag ) { m_plotInvisibleText = aFlag; } GetPlotInvisibleText()117 bool GetPlotInvisibleText() const { return m_plotInvisibleText; } SetPlotValue(bool aFlag)118 void SetPlotValue( bool aFlag ) { m_plotValue = aFlag; } GetPlotValue()119 bool GetPlotValue() const { return m_plotValue; } SetPlotReference(bool aFlag)120 void SetPlotReference( bool aFlag ) { m_plotReference = aFlag; } GetPlotReference()121 bool GetPlotReference() const { return m_plotReference; } 122 SetNegative(bool aFlag)123 void SetNegative( bool aFlag ) { m_negative = aFlag; } GetNegative()124 bool GetNegative() const { return m_negative; } 125 SetPlotViaOnMaskLayer(bool aFlag)126 void SetPlotViaOnMaskLayer( bool aFlag ) { m_plotViaOnMaskLayer = aFlag; } GetPlotViaOnMaskLayer()127 bool GetPlotViaOnMaskLayer() const { return m_plotViaOnMaskLayer; } 128 SetPlotFrameRef(bool aFlag)129 void SetPlotFrameRef( bool aFlag ) { m_plotFrameRef = aFlag; } GetPlotFrameRef()130 bool GetPlotFrameRef() const { return m_plotFrameRef; } 131 SetExcludeEdgeLayer(bool aFlag)132 void SetExcludeEdgeLayer( bool aFlag ) { m_excludeEdgeLayer = aFlag; } GetExcludeEdgeLayer()133 bool GetExcludeEdgeLayer() const { return m_excludeEdgeLayer; } 134 SetFormat(PLOT_FORMAT aFormat)135 void SetFormat( PLOT_FORMAT aFormat ) { m_format = aFormat; } GetFormat()136 PLOT_FORMAT GetFormat() const { return m_format; } 137 SetOutputDirectory(const wxString & aDir)138 void SetOutputDirectory( const wxString& aDir ) { m_outputDirectory = aDir; } GetOutputDirectory()139 wxString GetOutputDirectory() const { return m_outputDirectory; } 140 SetDisableGerberMacros(bool aDisable)141 void SetDisableGerberMacros( bool aDisable ) { m_gerberDisableApertMacros = aDisable; } GetDisableGerberMacros()142 bool GetDisableGerberMacros() const { return m_gerberDisableApertMacros; } 143 SetUseGerberX2format(bool aUse)144 void SetUseGerberX2format( bool aUse ) { m_useGerberX2format = aUse; } GetUseGerberX2format()145 bool GetUseGerberX2format() const { return m_useGerberX2format; } 146 SetIncludeGerberNetlistInfo(bool aUse)147 void SetIncludeGerberNetlistInfo( bool aUse ) { m_includeGerberNetlistInfo = aUse; } GetIncludeGerberNetlistInfo()148 bool GetIncludeGerberNetlistInfo() const { return m_includeGerberNetlistInfo; } 149 SetCreateGerberJobFile(bool aCreate)150 void SetCreateGerberJobFile( bool aCreate ) { m_createGerberJobFile = aCreate; } GetCreateGerberJobFile()151 bool GetCreateGerberJobFile() const { return m_createGerberJobFile; } 152 SetUseGerberProtelExtensions(bool aUse)153 void SetUseGerberProtelExtensions( bool aUse ) { m_useGerberProtelExtensions = aUse; } GetUseGerberProtelExtensions()154 bool GetUseGerberProtelExtensions() const { return m_useGerberProtelExtensions; } 155 156 void SetGerberPrecision( int aPrecision ); GetGerberPrecision()157 int GetGerberPrecision() const { return m_gerberPrecision; } 158 159 void SetSvgPrecision( unsigned aPrecision, bool aUseInch ); GetSvgPrecision()160 unsigned GetSvgPrecision() const { return m_svgPrecision; } GetSvgUseInch()161 bool GetSvgUseInch() const { return m_svgUseInch; } 162 163 /** 164 * Default precision of coordinates in Gerber files. 165 * 166 * When units are in mm (7 in inches, but Pcbnew uses mm). 167 * 6 is the internal resolution of Pcbnew, so the default is 6. 168 */ GetGerberDefaultPrecision()169 static int GetGerberDefaultPrecision() { return 6; } 170 SetSubtractMaskFromSilk(bool aSubtract)171 void SetSubtractMaskFromSilk( bool aSubtract ) { m_subtractMaskFromSilk = aSubtract; }; GetSubtractMaskFromSilk()172 bool GetSubtractMaskFromSilk() const { return m_subtractMaskFromSilk; } 173 SetLayerSelection(LSET aSelection)174 void SetLayerSelection( LSET aSelection ) { m_layerSelection = aSelection; }; GetLayerSelection()175 LSET GetLayerSelection() const { return m_layerSelection; }; 176 SetUseAuxOrigin(bool aAux)177 void SetUseAuxOrigin( bool aAux ) { m_useAuxOrigin = aAux; }; GetUseAuxOrigin()178 bool GetUseAuxOrigin() const { return m_useAuxOrigin; }; 179 SetScaleSelection(int aSelection)180 void SetScaleSelection( int aSelection ) { m_scaleSelection = aSelection; }; GetScaleSelection()181 int GetScaleSelection() const { return m_scaleSelection; }; 182 SetA4Output(int aForce)183 void SetA4Output( int aForce ) { m_A4Output = aForce; }; GetA4Output()184 bool GetA4Output() const { return m_A4Output; }; 185 186 // For historical reasons, this parameter is stored in mils 187 // (but is in mm in hpgl files...) GetHPGLPenDiameter()188 double GetHPGLPenDiameter() const { return m_HPGLPenDiam; }; 189 bool SetHPGLPenDiameter( double aValue ); 190 191 // This parameter is always in cm, due to hpgl file format constraint GetHPGLPenSpeed()192 int GetHPGLPenSpeed() const { return m_HPGLPenSpeed; }; 193 bool SetHPGLPenSpeed( int aValue ); 194 SetHPGLPenNum(int aVal)195 void SetHPGLPenNum( int aVal ) { m_HPGLPenNum = aVal; } GetHPGLPenNum()196 int GetHPGLPenNum() const { return m_HPGLPenNum; } 197 198 private: 199 friend class PCB_PLOT_PARAMS_PARSER; 200 201 // If true, do not plot NPTH pads 202 // (mainly used to disable NPTH pads plotting on copper layers) 203 bool m_skipNPTH_Pads; 204 205 /** 206 * FILLED or SKETCH selects how to plot filled objects. 207 * 208 * FILLED or SKETCH not available with all drivers: some have fixed mode 209 */ 210 OUTLINE_MODE m_plotMode; 211 212 /** 213 * DXF format: Plot items in outline (polygon) mode. 214 * 215 * In polygon mode, each item to plot is converted to a polygon and all polygons are merged. 216 */ 217 bool m_DXFplotPolygonMode; 218 219 /** 220 * DXF format: Units to use when plotting the DXF 221 */ 222 DXF_UNITS m_DXFplotUnits; 223 224 /// Plot format type (chooses the driver to be used) 225 PLOT_FORMAT m_format; 226 227 /// Holes can be not plotted, have a small mark or plotted in actual size 228 DrillMarksType m_drillMarks; 229 230 /// Choose how represent text with PS, PDF and DXF drivers 231 PLOT_TEXT_MODE m_textMode; 232 233 /// When true set the scale to fit the board in the page 234 bool m_autoScale; 235 236 /// Global scale factor, 1.0 plots a board with its actual size. 237 double m_scale; 238 239 /// Mirror the plot around the X axis 240 bool m_mirror; 241 242 /// Plot in negative color (supported only by some drivers) 243 bool m_negative; 244 245 /// True if vias are drawn on Mask layer (ie untented, *exposed* by mask) 246 bool m_plotViaOnMaskLayer; 247 248 /// True to plot/print frame references 249 bool m_plotFrameRef; 250 251 /// If false always plot (merge) the pcb edge layer on other layers 252 bool m_excludeEdgeLayer; 253 254 /// Set of layers to plot 255 LSET m_layerSelection; 256 257 /** When plotting gerber files, use a conventional set of Protel extensions 258 * instead of .gbr, that is now the official gerber file extension 259 * this is a deprecated feature 260 */ 261 bool m_useGerberProtelExtensions; 262 263 /// Include attributes from the Gerber X2 format (chapter 5 in revision J2) 264 bool m_useGerberX2format; 265 266 /// Disable aperture macros in Gerber format (only for broken Gerber readers) 267 /// Ideally, should be never selected. 268 bool m_gerberDisableApertMacros; 269 270 /// Include netlist info (only in Gerber X2 format) (chapter ? in revision ?) 271 bool m_includeGerberNetlistInfo; 272 273 /// generate the auxiliary "job file" in gerber format 274 bool m_createGerberJobFile; 275 276 /// precision of coordinates in Gerber files: accepted 5 or 6 277 /// when units are in mm (6 or 7 in inches, but Pcbnew uses mm). 278 /// 6 is the internal resolution of Pcbnew, but not always accepted by board maker 279 /// 5 is the minimal value for professional boards. 280 int m_gerberPrecision; 281 282 /// precision of coordinates in SVG files: accepted 3 - 6 283 /// 6 is the internal resolution of Pcbnew 284 unsigned m_svgPrecision; 285 286 /// units for SVG plot 287 /// false for metric, true for inch/mils 288 bool m_svgUseInch; 289 290 /// Plot gerbers using auxiliary (drill) origin instead of absolute coordinates 291 bool m_useAuxOrigin; 292 293 /// On gerbers 'scrape' away the solder mask from silkscreen (trim silks) 294 bool m_subtractMaskFromSilk; 295 296 /// Autoscale the plot to fit an A4 (landscape?) sheet 297 bool m_A4Output; 298 299 /// Scale ratio index (UI only) 300 int m_scaleSelection; 301 302 /// Output directory for plot files (usually relative to the board file) 303 wxString m_outputDirectory; 304 305 /// Enable plotting of part references 306 bool m_plotReference; 307 308 /// Enable plotting of part values 309 bool m_plotValue; 310 311 /// Force plotting of fields marked invisible 312 bool m_plotInvisibleText; 313 314 /// Plots pads outlines on fab layers 315 bool m_sketchPadsOnFabLayers; 316 int m_sketchPadLineWidth; 317 318 /* These next two scale factors are intended to compensate plotters 319 * (mainly printers) X and Y scale error. Therefore they are expected very 320 * near 1.0; only X and Y dimensions are adjusted: circles are plotted as 321 * circles, even if X and Y fine scale differ; because of this it is mostly 322 * useful for printers: postscript plots would be best adjusted using 323 * the prologue (that would change the whole output matrix 324 */ 325 326 double m_fineScaleAdjustX; ///< fine scale adjust X axis 327 double m_fineScaleAdjustY; ///< fine scale adjust Y axis 328 329 /** 330 * This width factor is intended to compensate PS printers/ plotters that do 331 * not strictly obey line width settings. Only used to plot pads and tracks. 332 */ 333 int m_widthAdjust; 334 335 int m_HPGLPenNum; ///< HPGL only: pen number selection(1 to 9) 336 int m_HPGLPenSpeed; ///< HPGL only: pen speed, always in cm/s (1 to 99 cm/s) 337 double m_HPGLPenDiam; ///< HPGL only: pen diameter in MILS, useful to fill areas 338 ///< However, it is in mm in hpgl files. 339 340 /// Pointer to active color settings to be used for plotting 341 COLOR_SETTINGS* m_colors; 342 343 /// Dummy colors object that can be created if there is no Pgm context 344 std::shared_ptr<COLOR_SETTINGS> m_default_colors; 345 }; 346 347 348 #endif // PCB_PLOT_PARAMS_H_ 349