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.

348 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-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. #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 )
  69. {
  70. m_DXFplotUnits = aUnit;
  71. }
  72. DXF_UNITS GetDXFPlotUnits() const
  73. {
  74. return m_DXFplotUnits;
  75. }
  76. void SetDrillMarksType( DrillMarksType aVal ) { m_drillMarks = aVal; }
  77. DrillMarksType GetDrillMarksType() const { return m_drillMarks; }
  78. void SetScale( double aVal ) { m_scale = aVal; }
  79. double GetScale() const { return m_scale; }
  80. void SetFineScaleAdjustX( double aVal ) { m_fineScaleAdjustX = aVal; }
  81. double GetFineScaleAdjustX() const { return m_fineScaleAdjustX; }
  82. void SetFineScaleAdjustY( double aVal ) { m_fineScaleAdjustY = aVal; }
  83. double GetFineScaleAdjustY() const { return m_fineScaleAdjustY; }
  84. void SetWidthAdjust( int aVal ) { m_widthAdjust = aVal; }
  85. int GetWidthAdjust() const { return m_widthAdjust; }
  86. void SetAutoScale( bool aFlag ) { m_autoScale = aFlag; }
  87. bool GetAutoScale() const { return m_autoScale; }
  88. void SetMirror( bool aFlag ) { m_mirror = aFlag; }
  89. bool GetMirror() const { return m_mirror; }
  90. void SetSketchPadsOnFabLayers( bool aFlag ) { m_sketchPadsOnFabLayers = aFlag; }
  91. bool GetSketchPadsOnFabLayers() const { return m_sketchPadsOnFabLayers; }
  92. void SetSketchPadLineWidth( int aWidth ) { m_sketchPadLineWidth = aWidth; }
  93. int GetSketchPadLineWidth() const { return m_sketchPadLineWidth; }
  94. void SetPlotInvisibleText( bool aFlag ) { m_plotInvisibleText = aFlag; }
  95. bool GetPlotInvisibleText() const { return m_plotInvisibleText; }
  96. void SetPlotValue( bool aFlag ) { m_plotValue = aFlag; }
  97. bool GetPlotValue() const { return m_plotValue; }
  98. void SetPlotReference( bool aFlag ) { m_plotReference = aFlag; }
  99. bool GetPlotReference() const { return m_plotReference; }
  100. void SetNegative( bool aFlag ) { m_negative = aFlag; }
  101. bool GetNegative() const { return m_negative; }
  102. void SetPlotViaOnMaskLayer( bool aFlag ) { m_plotViaOnMaskLayer = aFlag; }
  103. bool GetPlotViaOnMaskLayer() const { return m_plotViaOnMaskLayer; }
  104. void SetPlotFrameRef( bool aFlag ) { m_plotFrameRef = aFlag; }
  105. bool GetPlotFrameRef() const { return m_plotFrameRef; }
  106. void SetExcludeEdgeLayer( bool aFlag ) { m_excludeEdgeLayer = aFlag; }
  107. bool GetExcludeEdgeLayer() const { return m_excludeEdgeLayer; }
  108. void SetFormat( PLOT_FORMAT aFormat ) { m_format = aFormat; }
  109. PLOT_FORMAT GetFormat() const { return m_format; }
  110. void SetOutputDirectory( const wxString& aDir ) { m_outputDirectory = aDir; }
  111. wxString GetOutputDirectory() const { return m_outputDirectory; }
  112. void SetDisableGerberMacros( bool aDisable ) { m_gerberDisableApertMacros = aDisable; }
  113. bool GetDisableGerberMacros() const { return m_gerberDisableApertMacros; }
  114. void SetUseGerberX2format( bool aUse ) { m_useGerberX2format = aUse; }
  115. bool GetUseGerberX2format() const { return m_useGerberX2format; }
  116. void SetIncludeGerberNetlistInfo( bool aUse ) { m_includeGerberNetlistInfo = aUse; }
  117. bool GetIncludeGerberNetlistInfo() const { return m_includeGerberNetlistInfo; }
  118. void SetCreateGerberJobFile( bool aCreate ) { m_createGerberJobFile = aCreate; }
  119. bool GetCreateGerberJobFile() const { return m_createGerberJobFile; }
  120. void SetUseGerberProtelExtensions( bool aUse ) { m_useGerberProtelExtensions = aUse; }
  121. bool GetUseGerberProtelExtensions() const { return m_useGerberProtelExtensions; }
  122. void SetGerberPrecision( int aPrecision );
  123. int GetGerberPrecision() const { return m_gerberPrecision; }
  124. void SetSvgPrecision( unsigned aPrecision, bool aUseInch );
  125. unsigned GetSvgPrecision() const { return m_svgPrecision; }
  126. bool GetSvgUseInch() const { return m_svgUseInch; }
  127. /**
  128. * Default precision of coordinates in Gerber files.
  129. *
  130. * When units are in mm (7 in inches, but Pcbnew uses mm).
  131. * 6 is the internal resolution of Pcbnew, so the default is 6.
  132. */
  133. static int GetGerberDefaultPrecision() { return 6; }
  134. void SetSubtractMaskFromSilk( bool aSubtract ) { m_subtractMaskFromSilk = aSubtract; };
  135. bool GetSubtractMaskFromSilk() const { return m_subtractMaskFromSilk; }
  136. void SetLayerSelection( LSET aSelection ) { m_layerSelection = aSelection; };
  137. LSET GetLayerSelection() const { return m_layerSelection; };
  138. void SetUseAuxOrigin( bool aAux ) { m_useAuxOrigin = aAux; };
  139. bool GetUseAuxOrigin() const { return m_useAuxOrigin; };
  140. void SetScaleSelection( int aSelection ) { m_scaleSelection = aSelection; };
  141. int GetScaleSelection() const { return m_scaleSelection; };
  142. void SetA4Output( int aForce ) { m_A4Output = aForce; };
  143. bool GetA4Output() const { return m_A4Output; };
  144. // For historical reasons, this parameter is stored in mils
  145. // (but is in mm in hpgl files...)
  146. double GetHPGLPenDiameter() const { return m_HPGLPenDiam; };
  147. bool SetHPGLPenDiameter( double aValue );
  148. // This parameter is always in cm, due to hpgl file format constraint
  149. int GetHPGLPenSpeed() const { return m_HPGLPenSpeed; };
  150. bool SetHPGLPenSpeed( int aValue );
  151. void SetHPGLPenNum( int aVal ) { m_HPGLPenNum = aVal; }
  152. int GetHPGLPenNum() const { return m_HPGLPenNum; }
  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. /// If false always plot (merge) the pcb edge layer on other layers
  193. bool m_excludeEdgeLayer;
  194. /// Set of layers to plot
  195. LSET m_layerSelection;
  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. /// units for SVG plot
  219. /// false for metric, true for inch/mils
  220. bool m_svgUseInch;
  221. /// Plot gerbers using auxiliary (drill) origin instead of absolute coordinates
  222. bool m_useAuxOrigin;
  223. /// On gerbers 'scrape' away the solder mask from silkscreen (trim silks)
  224. bool m_subtractMaskFromSilk;
  225. /// Autoscale the plot to fit an A4 (landscape?) sheet
  226. bool m_A4Output;
  227. /// Scale ratio index (UI only)
  228. int m_scaleSelection;
  229. /// Output directory for plot files (usually relative to the board file)
  230. wxString m_outputDirectory;
  231. /// Enable plotting of part references
  232. bool m_plotReference;
  233. /// Enable plotting of part values
  234. bool m_plotValue;
  235. /// Force plotting of fields marked invisible
  236. bool m_plotInvisibleText;
  237. /// Plots pads outlines on fab layers
  238. bool m_sketchPadsOnFabLayers;
  239. int m_sketchPadLineWidth;
  240. /* These next two scale factors are intended to compensate plotters
  241. * (mainly printers) X and Y scale error. Therefore they are expected very
  242. * near 1.0; only X and Y dimensions are adjusted: circles are plotted as
  243. * circles, even if X and Y fine scale differ; because of this it is mostly
  244. * useful for printers: postscript plots would be best adjusted using
  245. * the prologue (that would change the whole output matrix
  246. */
  247. double m_fineScaleAdjustX; ///< fine scale adjust X axis
  248. double m_fineScaleAdjustY; ///< fine scale adjust Y axis
  249. /**
  250. * This width factor is intended to compensate PS printers/ plotters that do
  251. * not strictly obey line width settings. Only used to plot pads and tracks.
  252. */
  253. int m_widthAdjust;
  254. int m_HPGLPenNum; ///< HPGL only: pen number selection(1 to 9)
  255. int m_HPGLPenSpeed; ///< HPGL only: pen speed, always in cm/s (1 to 99 cm/s)
  256. double m_HPGLPenDiam; ///< HPGL only: pen diameter in MILS, useful to fill areas
  257. ///< However, it is in mm in hpgl files.
  258. /// Pointer to active color settings to be used for plotting
  259. COLOR_SETTINGS* m_colors;
  260. /// Dummy colors object that can be created if there is no Pgm context
  261. std::shared_ptr<COLOR_SETTINGS> m_default_colors;
  262. };
  263. #endif // PCB_PLOT_PARAMS_H_