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.

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