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.

312 lines
15 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. #include <plotprint_opts.h>
  28. class COLOR_SETTINGS;
  29. class PCB_PLOT_PARAMS_PARSER;
  30. /**
  31. * Parameters and options when plotting/printing a board.
  32. */
  33. class PCB_PLOT_PARAMS
  34. {
  35. public:
  36. PCB_PLOT_PARAMS();
  37. void SetSkipPlotNPTH_Pads( bool aSkip ) { m_skipNPTH_Pads = aSkip; }
  38. bool GetSkipPlotNPTH_Pads() const { return m_skipNPTH_Pads; }
  39. void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl=0 ) const;
  40. void Parse( PCB_PLOT_PARAMS_PARSER* aParser );
  41. /**
  42. * Compare current settings to aPcbPlotParams, including not saved parameters in brd file.
  43. *
  44. * @param aPcbPlotParams is the #PCB_PLOT_PARAMS to compare/
  45. * @param aCompareOnlySavedPrms set to true to compare only saved in file parameters,
  46. * or false to compare the full set of parameters.
  47. * @return true is parameters are same, false if one (or more) parameter does not match.
  48. */
  49. bool IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams ) const;
  50. void SetColorSettings( COLOR_SETTINGS* aSettings ) { m_colors = aSettings; }
  51. COLOR_SETTINGS* ColorSettings() const { return m_colors; }
  52. void SetTextMode( PLOT_TEXT_MODE aVal )
  53. {
  54. m_textMode = aVal;
  55. }
  56. PLOT_TEXT_MODE GetTextMode() const
  57. {
  58. return m_textMode;
  59. }
  60. void SetPlotMode( OUTLINE_MODE aPlotMode ) { m_plotMode = aPlotMode; }
  61. OUTLINE_MODE GetPlotMode() const { return m_plotMode; }
  62. void SetPlotPadNumbers( bool aFlag ) { m_plotPadNumbers = aFlag; }
  63. bool GetPlotPadNumbers() const { return m_plotPadNumbers; }
  64. void SetDXFPlotPolygonMode( bool aFlag ) { m_DXFPolygonMode = aFlag; }
  65. bool GetDXFPlotPolygonMode() const { return m_DXFPolygonMode; }
  66. void SetDXFPlotUnits( DXF_UNITS aUnit ) { m_DXFUnits = aUnit; }
  67. DXF_UNITS GetDXFPlotUnits() const { return m_DXFUnits; }
  68. void SetDrillMarksType( DRILL_MARKS aVal ) { m_drillMarks = aVal; }
  69. DRILL_MARKS GetDrillMarksType() const { return m_drillMarks; }
  70. void SetScale( double aVal ) { m_scale = aVal; }
  71. double GetScale() const { return m_scale; }
  72. void SetFineScaleAdjustX( double aVal ) { m_fineScaleAdjustX = aVal; }
  73. double GetFineScaleAdjustX() const { return m_fineScaleAdjustX; }
  74. void SetFineScaleAdjustY( double aVal ) { m_fineScaleAdjustY = aVal; }
  75. double GetFineScaleAdjustY() const { return m_fineScaleAdjustY; }
  76. void SetWidthAdjust( int aVal ) { m_widthAdjust = aVal; }
  77. int GetWidthAdjust() const { return m_widthAdjust; }
  78. void SetAutoScale( bool aFlag ) { m_autoScale = aFlag; }
  79. bool GetAutoScale() const { return m_autoScale; }
  80. void SetMirror( bool aFlag ) { m_mirror = aFlag; }
  81. bool GetMirror() const { return m_mirror; }
  82. void SetSketchPadsOnFabLayers( bool aFlag ) { m_sketchPadsOnFabLayers = aFlag; }
  83. bool GetSketchPadsOnFabLayers() const { return m_sketchPadsOnFabLayers; }
  84. void SetSketchPadLineWidth( int aWidth ) { m_sketchPadLineWidth = aWidth; }
  85. int GetSketchPadLineWidth() const { return m_sketchPadLineWidth; }
  86. void SetHideDNPFPsOnFabLayers( bool aFlag ) { m_hideDNPFPsOnFabLayers = aFlag; }
  87. bool GetHideDNPFPsOnFabLayers() const { return m_hideDNPFPsOnFabLayers; }
  88. void SetSketchDNPFPsOnFabLayers( bool aFlag ) { m_sketchDNPFPsOnFabLayers = aFlag; }
  89. bool GetSketchDNPFPsOnFabLayers() const { return m_sketchDNPFPsOnFabLayers; }
  90. void SetCrossoutDNPFPsOnFabLayers( bool aFlag ) { m_crossoutDNPFPsOnFabLayers = aFlag; }
  91. bool GetCrossoutDNPFPsOnFabLayers() const { return m_crossoutDNPFPsOnFabLayers; }
  92. void SetPlotInvisibleText( bool aFlag ) { m_plotInvisibleText = aFlag; }
  93. bool GetPlotInvisibleText() const { return m_plotInvisibleText; }
  94. void SetPlotValue( bool aFlag ) { m_plotValue = aFlag; }
  95. bool GetPlotValue() const { return m_plotValue; }
  96. void SetPlotReference( bool aFlag ) { m_plotReference = aFlag; }
  97. bool GetPlotReference() const { return m_plotReference; }
  98. void SetPlotFPText( bool aFlag ) { m_plotFPText = aFlag; }
  99. bool GetPlotFPText() const { return m_plotFPText; }
  100. void SetNegative( bool aFlag ) { m_negative = aFlag; }
  101. bool GetNegative() const { return m_negative; }
  102. std::optional<bool> GetLegacyPlotViaOnMaskLayer() const { return m_plotViaOnMaskLayer; }
  103. void SetPlotFrameRef( bool aFlag ) { m_plotDrawingSheet = aFlag; }
  104. bool GetPlotFrameRef() const { return m_plotDrawingSheet; }
  105. void SetFormat( PLOT_FORMAT aFormat ) { m_format = aFormat; }
  106. PLOT_FORMAT GetFormat() const { return m_format; }
  107. void SetOutputDirectory( const wxString& aDir ) { m_outputDirectory = aDir; }
  108. wxString GetOutputDirectory() const { return m_outputDirectory; }
  109. void SetDisableGerberMacros( bool aDisable ) { m_gerberDisableApertMacros = aDisable; }
  110. bool GetDisableGerberMacros() const { return m_gerberDisableApertMacros; }
  111. void SetUseGerberX2format( bool aUse ) { m_useGerberX2format = aUse; }
  112. bool GetUseGerberX2format() const { return m_useGerberX2format; }
  113. void SetIncludeGerberNetlistInfo( bool aUse ) { m_includeGerberNetlistInfo = aUse; }
  114. bool GetIncludeGerberNetlistInfo() const { return m_includeGerberNetlistInfo; }
  115. void SetCreateGerberJobFile( bool aCreate ) { m_createGerberJobFile = aCreate; }
  116. bool GetCreateGerberJobFile() const { return m_createGerberJobFile; }
  117. void SetUseGerberProtelExtensions( bool aUse ) { m_useGerberProtelExtensions = aUse; }
  118. bool GetUseGerberProtelExtensions() const { return m_useGerberProtelExtensions; }
  119. void SetGerberPrecision( int aPrecision );
  120. int GetGerberPrecision() const { return m_gerberPrecision; }
  121. void SetSvgPrecision( unsigned aPrecision );
  122. unsigned GetSvgPrecision() const { return m_svgPrecision; }
  123. void SetBlackAndWhite( bool blackAndWhite ) { m_blackAndWhite = blackAndWhite; }
  124. unsigned GetBlackAndWhite() const { return m_blackAndWhite; }
  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. public:
  154. bool m_PDFFrontFPPropertyPopups; ///< Generate PDF property popup menus for footprints
  155. bool m_PDFBackFPPropertyPopups; ///< on front and/or back of board
  156. bool m_PDFMetadata; ///< Generate PDF metadata for SUBJECT and AUTHOR
  157. private:
  158. friend class PCB_PLOT_PARAMS_PARSER;
  159. PLOT_FORMAT m_format; /// Plot format type (chooses the driver to be used)
  160. LSET m_layerSelection;
  161. LSET m_plotOnAllLayersSelection;
  162. bool m_skipNPTH_Pads; /// Used to disable NPTH pads plotting on copper layers
  163. OUTLINE_MODE m_plotMode; /// FILLED or SKETCH for filled objects.
  164. bool m_plotPadNumbers; /// Plot pad numbers when sketching pads on fab layers
  165. DRILL_MARKS m_drillMarks; /// Holes can be not plotted, have a small mark, or be
  166. /// plotted in actual size
  167. PLOT_TEXT_MODE m_textMode;
  168. DXF_UNITS m_DXFUnits;
  169. bool m_DXFPolygonMode; /// In polygon mode, each item to plot is converted to a
  170. /// polygon and all polygons are merged.
  171. bool m_A4Output; /// Autoscale the plot to fit an A4 (landscape?) sheet
  172. bool m_autoScale; /// When true set the scale to fit the board in the page
  173. double m_scale; /// Global scale factor, 1.0 plots a board at actual size
  174. bool m_mirror; /// Mirror the plot around the X axis
  175. bool m_negative; /// Plot in negative color (supported only by some drivers)
  176. bool m_blackAndWhite; /// Plot in black and white only
  177. bool m_plotDrawingSheet;
  178. std::optional<bool> m_plotViaOnMaskLayer; /// Deprecated; only used for reading legacy files
  179. bool m_subtractMaskFromSilk; /// On gerbers 'scrape' away the solder mask from
  180. /// silkscreen (trim silks)
  181. /// When plotting gerber files, use a conventional set of Protel extensions instead of .gbr,
  182. /// that is now the official gerber file extension (this is a deprecated feature)
  183. bool m_useGerberProtelExtensions;
  184. /// Include attributes from the Gerber X2 format (chapter 5 in revision J2)
  185. bool m_useGerberX2format;
  186. /// Disable aperture macros in Gerber format (only for broken Gerber readers). Ideally,
  187. /// should be never selected.
  188. bool m_gerberDisableApertMacros;
  189. /// Include netlist info (only in Gerber X2 format) (chapter ? in revision ?)
  190. bool m_includeGerberNetlistInfo;
  191. /// generate the auxiliary "job file" in gerber format
  192. bool m_createGerberJobFile;
  193. /// Precision of coordinates in Gerber: accepted 5 or 6 when units are in mm, 6 or 7 in inches
  194. /// (but Pcbnew uses mm).
  195. /// 6 is the internal resolution of Pcbnew, but not always accepted by board maker
  196. /// 5 is the minimal value for professional boards
  197. int m_gerberPrecision;
  198. /// Precision of coordinates in SVG: accepted 3 - 6; 6 is the internal resolution of Pcbnew
  199. unsigned m_svgPrecision;
  200. bool m_useAuxOrigin; ///< Plot gerbers using auxiliary (drill) origin instead
  201. ///< of absolute coordinates
  202. wxString m_outputDirectory; ///< Output directory for plot files (usually relative to
  203. ///< the board file)
  204. int m_scaleSelection; ///< Scale ratio index (UI only)
  205. bool m_plotReference; ///< Enable plotting of part references
  206. bool m_plotValue; ///< Enable plotting of part values
  207. bool m_plotFPText;
  208. bool m_plotInvisibleText; ///< Force plotting of fields marked invisible
  209. bool m_sketchPadsOnFabLayers; ///< Plots pads outlines on fab layers
  210. int m_sketchPadLineWidth;
  211. bool m_hideDNPFPsOnFabLayers;
  212. bool m_sketchDNPFPsOnFabLayers;
  213. bool m_crossoutDNPFPsOnFabLayers;
  214. double m_fineScaleAdjustX; ///< Compensation for printer scale errors (and therefore
  215. double m_fineScaleAdjustY; ///< expected to be very near 1.0). Only X and Y
  216. ///< dimensions are adjusted: circles are plotted as
  217. ///< circles, even if X and Y fine scale differ.
  218. ///< Because of this it is mostly useful for printers:
  219. ///< postscript plots should use the prologue, which will
  220. ///< change the whole output matrix.
  221. int m_widthAdjust; ///< Compensation for PS printers/plotters that do not
  222. ///< strictly obey line width settings. Only used to plot
  223. ///< pads and tracks.
  224. int m_HPGLPenNum; ///< HPGL only: pen number selection(1 to 9)
  225. int m_HPGLPenSpeed; ///< HPGL only: pen speed, always in cm/s (1 to 99 cm/s)
  226. double m_HPGLPenDiam; ///< HPGL only: pen diameter in MILS, useful to fill areas
  227. ///< However, it is in mm in hpgl files.
  228. double m_dashedLineDashRatio;
  229. double m_dashedLineGapRatio;
  230. COLOR_SETTINGS* m_colors; /// Pointer to color settings to be used for plotting
  231. /// Dummy colors object that can be created if there is no Pgm context
  232. std::shared_ptr<COLOR_SETTINGS> m_default_colors;
  233. };
  234. #endif // PCB_PLOT_PARAMS_H_