You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

349 lines
14 KiB

  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-2022 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. #include <plotters/plotter.h>
  26. #include <layer_ids.h>
  27. class COLOR_SETTINGS;
  28. class PCB_PLOT_PARAMS_PARSER;
  29. /**
  30. * Parameters and options when plotting/printing a board.
  31. */
  32. class PCB_PLOT_PARAMS
  33. {
  34. public:
  35. enum DrillMarksType {
  36. NO_DRILL_SHAPE = 0,
  37. SMALL_DRILL_SHAPE = 1,
  38. FULL_DRILL_SHAPE = 2
  39. };
  40. PCB_PLOT_PARAMS();
  41. void SetSkipPlotNPTH_Pads( bool aSkip ) { m_skipNPTH_Pads = aSkip; }
  42. bool GetSkipPlotNPTH_Pads() const { return m_skipNPTH_Pads; }
  43. void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl=0 ) const;
  44. void Parse( PCB_PLOT_PARAMS_PARSER* aParser );
  45. /**
  46. * Compare current settings to aPcbPlotParams, including not saved parameters in brd file.
  47. *
  48. * @param aPcbPlotParams is the #PCB_PLOT_PARAMS to compare/
  49. * @param aCompareOnlySavedPrms set to true to compare only saved in file parameters,
  50. * or false to compare the full set of parameters.
  51. * @return true is parameters are same, false if one (or more) parameter does not match.
  52. */
  53. bool IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams ) const;
  54. void SetColorSettings( COLOR_SETTINGS* aSettings ) { m_colors = aSettings; }
  55. COLOR_SETTINGS* ColorSettings() const { return m_colors; }
  56. void SetTextMode( PLOT_TEXT_MODE aVal )
  57. {
  58. m_textMode = aVal;
  59. }
  60. PLOT_TEXT_MODE GetTextMode() const
  61. {
  62. return m_textMode;
  63. }
  64. void SetPlotMode( OUTLINE_MODE aPlotMode ) { m_plotMode = aPlotMode; }
  65. OUTLINE_MODE GetPlotMode() const { return m_plotMode; }
  66. void SetDXFPlotPolygonMode( bool aFlag ) { m_DXFplotPolygonMode = aFlag; }
  67. bool GetDXFPlotPolygonMode() const { return m_DXFplotPolygonMode; }
  68. void SetDXFPlotUnits( DXF_UNITS aUnit ) { m_DXFplotUnits = aUnit; }
  69. DXF_UNITS GetDXFPlotUnits() const { return m_DXFplotUnits; }
  70. void SetDrillMarksType( DrillMarksType aVal ) { m_drillMarks = aVal; }
  71. DrillMarksType GetDrillMarksType() const { return m_drillMarks; }
  72. void SetScale( double aVal ) { m_scale = aVal; }
  73. double GetScale() const { return m_scale; }
  74. void SetFineScaleAdjustX( double aVal ) { m_fineScaleAdjustX = aVal; }
  75. double GetFineScaleAdjustX() const { return m_fineScaleAdjustX; }
  76. void SetFineScaleAdjustY( double aVal ) { m_fineScaleAdjustY = aVal; }
  77. double GetFineScaleAdjustY() const { return m_fineScaleAdjustY; }
  78. void SetWidthAdjust( int aVal ) { m_widthAdjust = aVal; }
  79. int GetWidthAdjust() const { return m_widthAdjust; }
  80. void SetAutoScale( bool aFlag ) { m_autoScale = aFlag; }
  81. bool GetAutoScale() const { return m_autoScale; }
  82. void SetMirror( bool aFlag ) { m_mirror = aFlag; }
  83. bool GetMirror() const { return m_mirror; }
  84. void SetSketchPadsOnFabLayers( bool aFlag ) { m_sketchPadsOnFabLayers = aFlag; }
  85. bool GetSketchPadsOnFabLayers() const { return m_sketchPadsOnFabLayers; }
  86. void SetSketchPadLineWidth( int aWidth ) { m_sketchPadLineWidth = aWidth; }
  87. int GetSketchPadLineWidth() const { return m_sketchPadLineWidth; }
  88. void SetPlotInvisibleText( bool aFlag ) { m_plotInvisibleText = aFlag; }
  89. bool GetPlotInvisibleText() const { return m_plotInvisibleText; }
  90. void SetPlotValue( bool aFlag ) { m_plotValue = aFlag; }
  91. bool GetPlotValue() const { return m_plotValue; }
  92. void SetPlotReference( bool aFlag ) { m_plotReference = aFlag; }
  93. bool GetPlotReference() const { return m_plotReference; }
  94. void SetNegative( bool aFlag ) { m_negative = aFlag; }
  95. bool GetNegative() const { return m_negative; }
  96. void SetPlotViaOnMaskLayer( bool aFlag ) { m_plotViaOnMaskLayer = aFlag; }
  97. bool GetPlotViaOnMaskLayer() const { return m_plotViaOnMaskLayer; }
  98. void SetPlotFrameRef( bool aFlag ) { m_plotFrameRef = aFlag; }
  99. bool GetPlotFrameRef() const { return m_plotFrameRef; }
  100. void SetFormat( PLOT_FORMAT aFormat ) { m_format = aFormat; }
  101. PLOT_FORMAT GetFormat() const { return m_format; }
  102. void SetOutputDirectory( const wxString& aDir ) { m_outputDirectory = aDir; }
  103. wxString GetOutputDirectory() const { return m_outputDirectory; }
  104. void SetDisableGerberMacros( bool aDisable ) { m_gerberDisableApertMacros = aDisable; }
  105. bool GetDisableGerberMacros() const { return m_gerberDisableApertMacros; }
  106. void SetUseGerberX2format( bool aUse ) { m_useGerberX2format = aUse; }
  107. bool GetUseGerberX2format() const { return m_useGerberX2format; }
  108. void SetIncludeGerberNetlistInfo( bool aUse ) { m_includeGerberNetlistInfo = aUse; }
  109. bool GetIncludeGerberNetlistInfo() const { return m_includeGerberNetlistInfo; }
  110. void SetCreateGerberJobFile( bool aCreate ) { m_createGerberJobFile = aCreate; }
  111. bool GetCreateGerberJobFile() const { return m_createGerberJobFile; }
  112. void SetUseGerberProtelExtensions( bool aUse ) { m_useGerberProtelExtensions = aUse; }
  113. bool GetUseGerberProtelExtensions() const { return m_useGerberProtelExtensions; }
  114. void SetGerberPrecision( int aPrecision );
  115. int GetGerberPrecision() const { return m_gerberPrecision; }
  116. void SetSvgPrecision( unsigned aPrecision );
  117. unsigned GetSvgPrecision() const { return m_svgPrecision; }
  118. /**
  119. * Default precision of coordinates in Gerber files.
  120. *
  121. * When units are in mm (7 in inches, but Pcbnew uses mm).
  122. * 6 is the internal resolution of Pcbnew, so the default is 6.
  123. */
  124. static int GetGerberDefaultPrecision() { return 6; }
  125. void SetSubtractMaskFromSilk( bool aSubtract ) { m_subtractMaskFromSilk = aSubtract; }
  126. bool GetSubtractMaskFromSilk() const { return m_subtractMaskFromSilk; }
  127. void SetLayerSelection( LSET aSelection ) { m_layerSelection = aSelection; }
  128. LSET GetLayerSelection() const { return m_layerSelection; }
  129. void SetPlotOnAllLayersSelection( LSET aSelection )
  130. {
  131. m_plotOnAllLayersSelection = aSelection;
  132. }
  133. LSET GetPlotOnAllLayersSelection() const { return m_plotOnAllLayersSelection; }
  134. void SetUseAuxOrigin( bool aAux ) { m_useAuxOrigin = aAux; }
  135. bool GetUseAuxOrigin() const { return m_useAuxOrigin; }
  136. void SetScaleSelection( int aSelection ) { m_scaleSelection = aSelection; }
  137. int GetScaleSelection() const { return m_scaleSelection; }
  138. void SetA4Output( int aForce ) { m_A4Output = aForce; }
  139. bool GetA4Output() const { return m_A4Output; }
  140. // For historical reasons, this parameter is stored in mils
  141. // (but is in mm in hpgl files...)
  142. double GetHPGLPenDiameter() const { return m_HPGLPenDiam; }
  143. bool SetHPGLPenDiameter( double aValue );
  144. // This parameter is always in cm, due to hpgl file format constraint
  145. int GetHPGLPenSpeed() const { return m_HPGLPenSpeed; }
  146. bool SetHPGLPenSpeed( int aValue );
  147. void SetHPGLPenNum( int aVal ) { m_HPGLPenNum = aVal; }
  148. int GetHPGLPenNum() const { return m_HPGLPenNum; }
  149. void SetDashedLineDashRatio( double aVal ) { m_dashedLineDashRatio = aVal; }
  150. double GetDashedLineDashRatio() const { return m_dashedLineDashRatio; }
  151. void SetDashedLineGapRatio( double aVal ) { m_dashedLineGapRatio = aVal; }
  152. double GetDashedLineGapRatio() const { return m_dashedLineGapRatio; }
  153. private:
  154. friend class PCB_PLOT_PARAMS_PARSER;
  155. // If true, do not plot NPTH pads
  156. // (mainly used to disable NPTH pads plotting on copper layers)
  157. bool m_skipNPTH_Pads;
  158. /**
  159. * FILLED or SKETCH selects how to plot filled objects.
  160. *
  161. * FILLED or SKETCH not available with all drivers: some have fixed mode
  162. */
  163. OUTLINE_MODE m_plotMode;
  164. /**
  165. * DXF format: Plot items in outline (polygon) mode.
  166. *
  167. * In polygon mode, each item to plot is converted to a polygon and all polygons are merged.
  168. */
  169. bool m_DXFplotPolygonMode;
  170. /**
  171. * DXF format: Units to use when plotting the DXF
  172. */
  173. DXF_UNITS m_DXFplotUnits;
  174. /// Plot format type (chooses the driver to be used)
  175. PLOT_FORMAT m_format;
  176. /// Holes can be not plotted, have a small mark or plotted in actual size
  177. DrillMarksType m_drillMarks;
  178. /// Choose how represent text with PS, PDF and DXF drivers
  179. PLOT_TEXT_MODE m_textMode;
  180. /// When true set the scale to fit the board in the page
  181. bool m_autoScale;
  182. /// Global scale factor, 1.0 plots a board with its actual size.
  183. double m_scale;
  184. /// Mirror the plot around the X axis
  185. bool m_mirror;
  186. /// Plot in negative color (supported only by some drivers)
  187. bool m_negative;
  188. /// True if vias are drawn on Mask layer (ie untented, *exposed* by mask)
  189. bool m_plotViaOnMaskLayer;
  190. /// True to plot/print frame references
  191. bool m_plotFrameRef;
  192. /// Set of layers to plot
  193. LSET m_layerSelection;
  194. /// Set of layers that get plotted on each of the layers to plot.
  195. LSET m_plotOnAllLayersSelection;
  196. /** When plotting gerber files, use a conventional set of Protel extensions
  197. * instead of .gbr, that is now the official gerber file extension
  198. * this is a deprecated feature
  199. */
  200. bool m_useGerberProtelExtensions;
  201. /// Include attributes from the Gerber X2 format (chapter 5 in revision J2)
  202. bool m_useGerberX2format;
  203. /// Disable aperture macros in Gerber format (only for broken Gerber readers)
  204. /// Ideally, should be never selected.
  205. bool m_gerberDisableApertMacros;
  206. /// Include netlist info (only in Gerber X2 format) (chapter ? in revision ?)
  207. bool m_includeGerberNetlistInfo;
  208. /// generate the auxiliary "job file" in gerber format
  209. bool m_createGerberJobFile;
  210. /// precision of coordinates in Gerber files: accepted 5 or 6
  211. /// when units are in mm (6 or 7 in inches, but Pcbnew uses mm).
  212. /// 6 is the internal resolution of Pcbnew, but not always accepted by board maker
  213. /// 5 is the minimal value for professional boards.
  214. int m_gerberPrecision;
  215. /// precision of coordinates in SVG files: accepted 3 - 6
  216. /// 6 is the internal resolution of Pcbnew
  217. unsigned m_svgPrecision;
  218. /// Plot gerbers using auxiliary (drill) origin instead of absolute coordinates
  219. bool m_useAuxOrigin;
  220. /// On gerbers 'scrape' away the solder mask from silkscreen (trim silks)
  221. bool m_subtractMaskFromSilk;
  222. /// Autoscale the plot to fit an A4 (landscape?) sheet
  223. bool m_A4Output;
  224. /// Scale ratio index (UI only)
  225. int m_scaleSelection;
  226. /// Output directory for plot files (usually relative to the board file)
  227. wxString m_outputDirectory;
  228. /// Enable plotting of part references
  229. bool m_plotReference;
  230. /// Enable plotting of part values
  231. bool m_plotValue;
  232. /// Force plotting of fields marked invisible
  233. bool m_plotInvisibleText;
  234. /// Plots pads outlines on fab layers
  235. bool m_sketchPadsOnFabLayers;
  236. int m_sketchPadLineWidth;
  237. /* These next two scale factors are intended to compensate plotters
  238. * (mainly printers) X and Y scale error. Therefore they are expected very
  239. * near 1.0; only X and Y dimensions are adjusted: circles are plotted as
  240. * circles, even if X and Y fine scale differ; because of this it is mostly
  241. * useful for printers: postscript plots would be best adjusted using
  242. * the prologue (that would change the whole output matrix
  243. */
  244. double m_fineScaleAdjustX; ///< fine scale adjust X axis
  245. double m_fineScaleAdjustY; ///< fine scale adjust Y axis
  246. /**
  247. * This width factor is intended to compensate PS printers/ plotters that do
  248. * not strictly obey line width settings. Only used to plot pads and tracks.
  249. */
  250. int m_widthAdjust;
  251. int m_HPGLPenNum; ///< HPGL only: pen number selection(1 to 9)
  252. int m_HPGLPenSpeed; ///< HPGL only: pen speed, always in cm/s (1 to 99 cm/s)
  253. double m_HPGLPenDiam; ///< HPGL only: pen diameter in MILS, useful to fill areas
  254. ///< However, it is in mm in hpgl files.
  255. double m_dashedLineDashRatio;
  256. double m_dashedLineGapRatio;
  257. /// Pointer to active color settings to be used for plotting
  258. COLOR_SETTINGS* m_colors;
  259. /// Dummy colors object that can be created if there is no Pgm context
  260. std::shared_ptr<COLOR_SETTINGS> m_default_colors;
  261. };
  262. #endif // PCB_PLOT_PARAMS_H_