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.

286 lines
12 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-2015 KiCad Developers, see change_log.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 <plot_common.h>
  28. #include <layers_id_colors_and_visibility.h>
  29. class PCB_PLOT_PARAMS_PARSER;
  30. /**
  31. * Class PCB_PLOT_PARAMS
  32. * handles plot parameters and options when plotting/printing a board.
  33. */
  34. class PCB_PLOT_PARAMS
  35. {
  36. friend class PCB_PLOT_PARAMS_PARSER;
  37. public:
  38. enum DrillMarksType {
  39. NO_DRILL_SHAPE = 0,
  40. SMALL_DRILL_SHAPE = 1,
  41. FULL_DRILL_SHAPE = 2
  42. };
  43. private:
  44. // If true, do not plot NPTH pads
  45. // (mainly used to disable NPTH pads plotting on copper layers)
  46. bool m_skipNPTH_Pads;
  47. /** FILLED or SKETCH selects how to plot filled objects.
  48. * FILLED or SKETCH not available with all drivers: some have fixed mode
  49. */
  50. EDA_DRAW_MODE_T m_plotMode;
  51. /// Plot format type (chooses the driver to be used)
  52. PlotFormat m_format;
  53. /// Holes can be not plotted, have a small mark or plotted in actual size
  54. DrillMarksType m_drillMarks;
  55. /// Choose how represent text with PS, PDF and DXF drivers
  56. PlotTextMode m_textMode;
  57. /// The default line width (used for the frame and in LINE mode)
  58. int m_lineWidth;
  59. /// When true set the scale to fit the board in the page
  60. bool m_autoScale;
  61. /// Global scale factor, 1.0 plots a board with its actual size.
  62. double m_scale;
  63. /// Mirror the plot around the X axis
  64. bool m_mirror;
  65. /// Plot in negative color (supported only by some drivers)
  66. bool m_negative;
  67. /// True if vias are drawn on Mask layer (ie untented, *exposed* by mask)
  68. bool m_plotViaOnMaskLayer;
  69. /// True to plot/print frame references
  70. bool m_plotFrameRef;
  71. /// If false always plot (merge) the pcb edge layer on other layers
  72. bool m_excludeEdgeLayer;
  73. /// Set of layers to plot
  74. LSET m_layerSelection;
  75. /** When plotting gerbers use a conventional set of Protel extensions
  76. * instead of appending a suffix to the board name */
  77. bool m_useGerberProtelExtensions;
  78. /// Include attributes from the Gerber X2 format (chapter 5 in revision J2)
  79. bool m_useGerberAttributes;
  80. /// Include netlist info (only in Gerber X2 format) (chapter ? in revision ?)
  81. bool m_includeGerberNetlistInfo;
  82. /// precision of coordinates in Gerber files: accepted 5 or 6
  83. /// when units are in mm (6 or 7 in inches, but Pcbnew uses mm).
  84. /// 6 is the internal resolution of Pcbnew, but not alwys accepted by board maker
  85. /// 5 is the minimal value for professional boards.
  86. int m_gerberPrecision;
  87. /// Plot gerbers using auxiliary (drill) origin instead of page coordinates
  88. bool m_useAuxOrigin;
  89. /// On gerbers 'scrape' away the solder mask from silkscreen (trim silks)
  90. bool m_subtractMaskFromSilk;
  91. /// Autoscale the plot to fit an A4 (landscape?) sheet
  92. bool m_A4Output;
  93. /// Scale ratio index (UI only)
  94. int m_scaleSelection;
  95. /// Output directory for plot files (usually relative to the board file)
  96. wxString m_outputDirectory;
  97. /// Enable plotting of part references
  98. bool m_plotReference;
  99. /// Enable plotting of part values
  100. bool m_plotValue;
  101. /// Force plotting of fields marked invisible
  102. bool m_plotInvisibleText;
  103. /// Allows pads outlines on silkscreen layer
  104. /// (when pads are also on silk screen)
  105. bool m_plotPadsOnSilkLayer;
  106. /* These next two scale factors are intended to compensate plotters
  107. * (mainly printers) X and Y scale error. Therefore they are expected very
  108. * near 1.0; only X and Y dimensions are adjusted: circles are plotted as
  109. * circles, even if X and Y fine scale differ; because of this it is mostly
  110. * useful for printers: postscript plots would be best adjusted using
  111. * the prologue (that would change the whole output matrix */
  112. double m_fineScaleAdjustX; ///< fine scale adjust X axis
  113. double m_fineScaleAdjustY; ///< fine scale adjust Y axis
  114. /** This width factor is intended to compensate PS printers/ plotters that do
  115. * not strictly obey line width settings. Only used to plot pads and tracks
  116. */
  117. int m_widthAdjust;
  118. int m_HPGLPenNum; ///< HPGL only: pen number selection(1 to 9)
  119. int m_HPGLPenSpeed; ///< HPGL only: pen speed, always in cm/s (1 to 99 cm/s)
  120. int m_HPGLPenDiam; ///< HPGL only: pen diameter in MILS, useful to fill areas
  121. EDA_COLOR_T m_color; ///< Color for plotting the current layer
  122. EDA_COLOR_T m_referenceColor; ///< Color for plotting references
  123. EDA_COLOR_T m_valueColor; ///< Color for plotting values
  124. public:
  125. PCB_PLOT_PARAMS();
  126. void SetSkipPlotNPTH_Pads( bool aSkip ) { m_skipNPTH_Pads = aSkip; }
  127. bool GetSkipPlotNPTH_Pads() const { return m_skipNPTH_Pads; }
  128. void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl=0 )
  129. const throw( IO_ERROR );
  130. void Parse( PCB_PLOT_PARAMS_PARSER* aParser ) throw( PARSE_ERROR, IO_ERROR );
  131. bool operator==( const PCB_PLOT_PARAMS &aPcbPlotParams ) const;
  132. bool operator!=( const PCB_PLOT_PARAMS &aPcbPlotParams ) const;
  133. void SetColor( EDA_COLOR_T aVal ) { m_color = aVal; }
  134. EDA_COLOR_T GetColor() const { return m_color; }
  135. void SetReferenceColor( EDA_COLOR_T aVal ) { m_referenceColor = aVal; }
  136. EDA_COLOR_T GetReferenceColor() const { return m_referenceColor; }
  137. void SetValueColor( EDA_COLOR_T aVal ) { m_valueColor = aVal; }
  138. EDA_COLOR_T GetValueColor() const { return m_valueColor; }
  139. void SetTextMode( PlotTextMode aVal ) { m_textMode = aVal; }
  140. PlotTextMode GetTextMode() const { return m_textMode; }
  141. void SetPlotMode( EDA_DRAW_MODE_T aPlotMode ) { m_plotMode = aPlotMode; }
  142. EDA_DRAW_MODE_T GetPlotMode() const { return m_plotMode; }
  143. void SetDrillMarksType( DrillMarksType aVal ) { m_drillMarks = aVal; }
  144. DrillMarksType GetDrillMarksType() const { return m_drillMarks; }
  145. void SetScale( double aVal ) { m_scale = aVal; }
  146. double GetScale() const { return m_scale; }
  147. void SetFineScaleAdjustX( double aVal ) { m_fineScaleAdjustX = aVal; }
  148. double GetFineScaleAdjustX() const { return m_fineScaleAdjustX; }
  149. void SetFineScaleAdjustY( double aVal ) { m_fineScaleAdjustY = aVal; }
  150. double GetFineScaleAdjustY() const { return m_fineScaleAdjustY; }
  151. void SetWidthAdjust( int aVal ) { m_widthAdjust = aVal; }
  152. int GetWidthAdjust() const { return m_widthAdjust; }
  153. void SetAutoScale( bool aFlag ) { m_autoScale = aFlag; }
  154. bool GetAutoScale() const { return m_autoScale; }
  155. void SetMirror( bool aFlag ) { m_mirror = aFlag; }
  156. bool GetMirror() const { return m_mirror; }
  157. void SetPlotPadsOnSilkLayer( bool aFlag ) { m_plotPadsOnSilkLayer = aFlag; }
  158. bool GetPlotPadsOnSilkLayer() const { return m_plotPadsOnSilkLayer; }
  159. void SetPlotInvisibleText( bool aFlag ) { m_plotInvisibleText = aFlag; }
  160. bool GetPlotInvisibleText() const { return m_plotInvisibleText; }
  161. void SetPlotValue( bool aFlag ) { m_plotValue = aFlag; }
  162. bool GetPlotValue() const { return m_plotValue; }
  163. void SetPlotReference( bool aFlag ) { m_plotReference = aFlag; }
  164. bool GetPlotReference() const { return m_plotReference; }
  165. void SetNegative( bool aFlag ) { m_negative = aFlag; }
  166. bool GetNegative() const { return m_negative; }
  167. void SetPlotViaOnMaskLayer( bool aFlag ) { m_plotViaOnMaskLayer = aFlag; }
  168. bool GetPlotViaOnMaskLayer() const { return m_plotViaOnMaskLayer; }
  169. void SetPlotFrameRef( bool aFlag ) { m_plotFrameRef = aFlag; }
  170. bool GetPlotFrameRef() const { return m_plotFrameRef; }
  171. void SetExcludeEdgeLayer( bool aFlag ) { m_excludeEdgeLayer = aFlag; }
  172. bool GetExcludeEdgeLayer() const { return m_excludeEdgeLayer; }
  173. void SetFormat( PlotFormat aFormat ) { m_format = aFormat; }
  174. PlotFormat GetFormat() const { return m_format; }
  175. void SetOutputDirectory( wxString aDir ) { m_outputDirectory = aDir; }
  176. wxString GetOutputDirectory() const { return m_outputDirectory; }
  177. void SetUseGerberAttributes( bool aUse ) { m_useGerberAttributes = aUse; }
  178. bool GetUseGerberAttributes() const { return m_useGerberAttributes; }
  179. void SetIncludeGerberNetlistInfo( bool aUse ) { m_includeGerberNetlistInfo = aUse; }
  180. bool GetIncludeGerberNetlistInfo() const { return m_includeGerberNetlistInfo; }
  181. void SetUseGerberProtelExtensions( bool aUse ) { m_useGerberProtelExtensions = aUse; }
  182. bool GetUseGerberProtelExtensions() const { return m_useGerberProtelExtensions; }
  183. void SetGerberPrecision( int aPrecision );
  184. int GetGerberPrecision() const { return m_gerberPrecision; }
  185. /** Default precision of coordinates in Gerber files.
  186. * when units are in mm (7 in inches, but Pcbnew uses mm).
  187. * 6 is the internal resolution of Pcbnew, so the default is 6
  188. */
  189. static int GetGerberDefaultPrecision() { return 6; }
  190. void SetSubtractMaskFromSilk( bool aSubtract ) { m_subtractMaskFromSilk = aSubtract; };
  191. bool GetSubtractMaskFromSilk() const { return m_subtractMaskFromSilk; }
  192. void SetLayerSelection( LSET aSelection ) { m_layerSelection = aSelection; };
  193. LSET GetLayerSelection() const { return m_layerSelection; };
  194. void SetUseAuxOrigin( bool aAux ) { m_useAuxOrigin = aAux; };
  195. bool GetUseAuxOrigin() const { return m_useAuxOrigin; };
  196. void SetScaleSelection( int aSelection ) { m_scaleSelection = aSelection; };
  197. int GetScaleSelection() const { return m_scaleSelection; };
  198. void SetA4Output( int aForce ) { m_A4Output = aForce; };
  199. bool GetA4Output() const { return m_A4Output; };
  200. int GetHPGLPenDiameter() const { return m_HPGLPenDiam; };
  201. bool SetHPGLPenDiameter( int aValue );
  202. int GetHPGLPenSpeed() const { return m_HPGLPenSpeed; };
  203. bool SetHPGLPenSpeed( int aValue );
  204. void SetHPGLPenNum( int aVal ) { m_HPGLPenNum = aVal; }
  205. int GetHPGLPenNum() const { return m_HPGLPenNum; }
  206. int GetLineWidth() const { return m_lineWidth; };
  207. bool SetLineWidth( int aValue );
  208. };
  209. /**
  210. * Default line thickness in PCnew units used to draw or plot items having a
  211. * default thickness line value (Frame references) (i.e. = 0 ).
  212. * 0 = single pixel line width.
  213. */
  214. extern int g_DrawDefaultLineThickness;
  215. #endif // PCB_PLOT_PARAMS_H_