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.

298 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. #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 SetDXFPlotPolygonMode( bool aFlag ) { m_DXFPolygonMode = aFlag; }
  63. bool GetDXFPlotPolygonMode() const { return m_DXFPolygonMode; }
  64. void SetDXFPlotUnits( DXF_UNITS aUnit ) { m_DXFUnits = aUnit; }
  65. DXF_UNITS GetDXFPlotUnits() const { return m_DXFUnits; }
  66. void SetDrillMarksType( DRILL_MARKS aVal ) { m_drillMarks = aVal; }
  67. DRILL_MARKS GetDrillMarksType() const { return m_drillMarks; }
  68. void SetScale( double aVal ) { m_scale = aVal; }
  69. double GetScale() const { return m_scale; }
  70. void SetFineScaleAdjustX( double aVal ) { m_fineScaleAdjustX = aVal; }
  71. double GetFineScaleAdjustX() const { return m_fineScaleAdjustX; }
  72. void SetFineScaleAdjustY( double aVal ) { m_fineScaleAdjustY = aVal; }
  73. double GetFineScaleAdjustY() const { return m_fineScaleAdjustY; }
  74. void SetWidthAdjust( int aVal ) { m_widthAdjust = aVal; }
  75. int GetWidthAdjust() const { return m_widthAdjust; }
  76. void SetAutoScale( bool aFlag ) { m_autoScale = aFlag; }
  77. bool GetAutoScale() const { return m_autoScale; }
  78. void SetMirror( bool aFlag ) { m_mirror = aFlag; }
  79. bool GetMirror() const { return m_mirror; }
  80. void SetSketchPadsOnFabLayers( bool aFlag ) { m_sketchPadsOnFabLayers = aFlag; }
  81. bool GetSketchPadsOnFabLayers() const { return m_sketchPadsOnFabLayers; }
  82. void SetSketchPadLineWidth( int aWidth ) { m_sketchPadLineWidth = aWidth; }
  83. int GetSketchPadLineWidth() const { return m_sketchPadLineWidth; }
  84. void SetPlotInvisibleText( bool aFlag ) { m_plotInvisibleText = aFlag; }
  85. bool GetPlotInvisibleText() const { return m_plotInvisibleText; }
  86. void SetPlotValue( bool aFlag ) { m_plotValue = aFlag; }
  87. bool GetPlotValue() const { return m_plotValue; }
  88. void SetPlotReference( bool aFlag ) { m_plotReference = aFlag; }
  89. bool GetPlotReference() const { return m_plotReference; }
  90. void SetPlotFPText( bool aFlag ) { m_plotFPText = aFlag; }
  91. bool GetPlotFPText() const { return m_plotFPText; }
  92. void SetNegative( bool aFlag ) { m_negative = aFlag; }
  93. bool GetNegative() const { return m_negative; }
  94. void SetPlotViaOnMaskLayer( bool aFlag ) { m_plotViaOnMaskLayer = aFlag; }
  95. bool GetPlotViaOnMaskLayer() const { return m_plotViaOnMaskLayer; }
  96. void SetPlotFrameRef( bool aFlag ) { m_plotDrawingSheet = aFlag; }
  97. bool GetPlotFrameRef() const { return m_plotDrawingSheet; }
  98. void SetFormat( PLOT_FORMAT aFormat ) { m_format = aFormat; }
  99. PLOT_FORMAT GetFormat() const { return m_format; }
  100. void SetOutputDirectory( const wxString& aDir ) { m_outputDirectory = aDir; }
  101. wxString GetOutputDirectory() const { return m_outputDirectory; }
  102. void SetDisableGerberMacros( bool aDisable ) { m_gerberDisableApertMacros = aDisable; }
  103. bool GetDisableGerberMacros() const { return m_gerberDisableApertMacros; }
  104. void SetUseGerberX2format( bool aUse ) { m_useGerberX2format = aUse; }
  105. bool GetUseGerberX2format() const { return m_useGerberX2format; }
  106. void SetIncludeGerberNetlistInfo( bool aUse ) { m_includeGerberNetlistInfo = aUse; }
  107. bool GetIncludeGerberNetlistInfo() const { return m_includeGerberNetlistInfo; }
  108. void SetCreateGerberJobFile( bool aCreate ) { m_createGerberJobFile = aCreate; }
  109. bool GetCreateGerberJobFile() const { return m_createGerberJobFile; }
  110. void SetUseGerberProtelExtensions( bool aUse ) { m_useGerberProtelExtensions = aUse; }
  111. bool GetUseGerberProtelExtensions() const { return m_useGerberProtelExtensions; }
  112. void SetGerberPrecision( int aPrecision );
  113. int GetGerberPrecision() const { return m_gerberPrecision; }
  114. void SetSvgPrecision( unsigned aPrecision );
  115. unsigned GetSvgPrecision() const { return m_svgPrecision; }
  116. void SetBlackAndWhite( bool blackAndWhite ) { m_blackAndWhite = blackAndWhite; }
  117. unsigned GetBlackAndWhite() const { return m_blackAndWhite; }
  118. void SetSubtractMaskFromSilk( bool aSubtract ) { m_subtractMaskFromSilk = aSubtract; }
  119. bool GetSubtractMaskFromSilk() const { return m_subtractMaskFromSilk; }
  120. void SetLayerSelection( LSET aSelection ) { m_layerSelection = aSelection; }
  121. LSET GetLayerSelection() const { return m_layerSelection; }
  122. void SetPlotOnAllLayersSelection( LSET aSelection )
  123. {
  124. m_plotOnAllLayersSelection = aSelection;
  125. }
  126. LSET GetPlotOnAllLayersSelection() const { return m_plotOnAllLayersSelection; }
  127. void SetUseAuxOrigin( bool aAux ) { m_useAuxOrigin = aAux; }
  128. bool GetUseAuxOrigin() const { return m_useAuxOrigin; }
  129. void SetScaleSelection( int aSelection ) { m_scaleSelection = aSelection; }
  130. int GetScaleSelection() const { return m_scaleSelection; }
  131. void SetA4Output( int aForce ) { m_A4Output = aForce; }
  132. bool GetA4Output() const { return m_A4Output; }
  133. // For historical reasons, this parameter is stored in mils
  134. // (but is in mm in hpgl files...)
  135. double GetHPGLPenDiameter() const { return m_HPGLPenDiam; }
  136. bool SetHPGLPenDiameter( double aValue );
  137. // This parameter is always in cm, due to hpgl file format constraint
  138. int GetHPGLPenSpeed() const { return m_HPGLPenSpeed; }
  139. bool SetHPGLPenSpeed( int aValue );
  140. void SetHPGLPenNum( int aVal ) { m_HPGLPenNum = aVal; }
  141. int GetHPGLPenNum() const { return m_HPGLPenNum; }
  142. void SetDashedLineDashRatio( double aVal ) { m_dashedLineDashRatio = aVal; }
  143. double GetDashedLineDashRatio() const { return m_dashedLineDashRatio; }
  144. void SetDashedLineGapRatio( double aVal ) { m_dashedLineGapRatio = aVal; }
  145. double GetDashedLineGapRatio() const { return m_dashedLineGapRatio; }
  146. public:
  147. bool m_PDFFrontFPPropertyPopups; ///< Generate PDF property popup menus for footprints
  148. bool m_PDFBackFPPropertyPopups; ///< on front and/or back of board
  149. private:
  150. friend class PCB_PLOT_PARAMS_PARSER;
  151. PLOT_FORMAT m_format; /// Plot format type (chooses the driver to be used)
  152. LSET m_layerSelection;
  153. LSET m_plotOnAllLayersSelection;
  154. bool m_skipNPTH_Pads; /// Used to disable NPTH pads plotting on copper layers
  155. OUTLINE_MODE m_plotMode; /// FILLED or SKETCH for filled objects.
  156. DRILL_MARKS m_drillMarks; /// Holes can be not plotted, have a small mark, or be
  157. /// plotted in actual size
  158. PLOT_TEXT_MODE m_textMode;
  159. DXF_UNITS m_DXFUnits;
  160. bool m_DXFPolygonMode; /// In polygon mode, each item to plot is converted to a
  161. /// polygon and all polygons are merged.
  162. bool m_A4Output; /// Autoscale the plot to fit an A4 (landscape?) sheet
  163. bool m_autoScale; /// When true set the scale to fit the board in the page
  164. double m_scale; /// Global scale factor, 1.0 plots a board at actual size
  165. bool m_mirror; /// Mirror the plot around the X axis
  166. bool m_negative; /// Plot in negative color (supported only by some drivers)
  167. bool m_blackAndWhite; /// Plot in black and white only
  168. bool m_plotDrawingSheet;
  169. bool m_plotViaOnMaskLayer; /// True if vias are drawn on Mask layer (ie untented,
  170. /// *exposed* by mask)
  171. bool m_subtractMaskFromSilk; /// On gerbers 'scrape' away the solder mask from
  172. /// silkscreen (trim silks)
  173. /// When plotting gerber files, use a conventional set of Protel extensions instead of .gbr,
  174. /// that is now the official gerber file extension (this is a deprecated feature)
  175. bool m_useGerberProtelExtensions;
  176. /// Include attributes from the Gerber X2 format (chapter 5 in revision J2)
  177. bool m_useGerberX2format;
  178. /// Disable aperture macros in Gerber format (only for broken Gerber readers). Ideally,
  179. /// should be never selected.
  180. bool m_gerberDisableApertMacros;
  181. /// Include netlist info (only in Gerber X2 format) (chapter ? in revision ?)
  182. bool m_includeGerberNetlistInfo;
  183. /// generate the auxiliary "job file" in gerber format
  184. bool m_createGerberJobFile;
  185. /// Precision of coordinates in Gerber: accepted 5 or 6 when units are in mm, 6 or 7 in inches
  186. /// (but Pcbnew uses mm).
  187. /// 6 is the internal resolution of Pcbnew, but not always accepted by board maker
  188. /// 5 is the minimal value for professional boards
  189. int m_gerberPrecision;
  190. /// Precision of coordinates in SVG: accepted 3 - 6; 6 is the internal resolution of Pcbnew
  191. unsigned m_svgPrecision;
  192. bool m_useAuxOrigin; ///< Plot gerbers using auxiliary (drill) origin instead
  193. ///< of absolute coordinates
  194. wxString m_outputDirectory; ///< Output directory for plot files (usually relative to
  195. ///< the board file)
  196. int m_scaleSelection; ///< Scale ratio index (UI only)
  197. bool m_plotReference; ///< Enable plotting of part references
  198. bool m_plotValue; ///< Enable plotting of part values
  199. bool m_plotFPText;
  200. bool m_plotInvisibleText; ///< Force plotting of fields marked invisible
  201. bool m_sketchPadsOnFabLayers; ///< Plots pads outlines on fab layers
  202. int m_sketchPadLineWidth;
  203. double m_fineScaleAdjustX; ///< Compensation for printer scale errors (and therefore
  204. double m_fineScaleAdjustY; ///< expected to be very near 1.0). Only X and Y
  205. ///< dimensions are adjusted: circles are plotted as
  206. ///< circles, even if X and Y fine scale differ.
  207. ///< Because of this it is mostly useful for printers:
  208. ///< postscript plots should use the prologue, which will
  209. ///< change the whole output matrix.
  210. int m_widthAdjust; ///< Compensation for PS printers/plotters that do not
  211. ///< strictly obey line width settings. Only used to plot
  212. ///< pads and tracks.
  213. int m_HPGLPenNum; ///< HPGL only: pen number selection(1 to 9)
  214. int m_HPGLPenSpeed; ///< HPGL only: pen speed, always in cm/s (1 to 99 cm/s)
  215. double m_HPGLPenDiam; ///< HPGL only: pen diameter in MILS, useful to fill areas
  216. ///< However, it is in mm in hpgl files.
  217. double m_dashedLineDashRatio;
  218. double m_dashedLineGapRatio;
  219. COLOR_SETTINGS* m_colors; /// Pointer to color settings to be used for plotting
  220. /// Dummy colors object that can be created if there is no Pgm context
  221. std::shared_ptr<COLOR_SETTINGS> m_default_colors;
  222. };
  223. #endif // PCB_PLOT_PARAMS_H_