35 #define PLOT_LINEWIDTH_DEFAULT ( DEFAULT_TEXT_WIDTH * IU_PER_MM ) 37 #define HPGL_PEN_DIAMETER_MIN 0 38 #define HPGL_PEN_DIAMETER_MAX 100.0 // Unit = mil 39 #define HPGL_PEN_SPEED_MIN 1 // this param is always in cm/s 40 #define HPGL_PEN_SPEED_MAX 99 // this param is always in cm/s 41 #define HPGL_PEN_NUMBER_MIN 1 42 #define HPGL_PEN_NUMBER_MAX 16 44 #define SVG_PRECISION_MIN 3U 45 #define SVG_PRECISION_MAX 6U 46 #define SVG_PRECISION_DEFAULT 6 54 using namespace PCBPLOTPARAMS_T;
59 return PCB_PLOT_PARAMS_LEXER::TokenName( aTok );
63 static bool setInt(
int* aTarget,
int aValue,
int aMin,
int aMax )
69 else if( aValue > aMax )
73 return ( temp == aValue );
77 static bool setDouble(
double* aTarget,
double aValue,
double aMin,
double aMax )
83 else if( aValue > aMax )
87 return ( temp == aValue );
93 m_useGerberProtelExtensions =
false;
94 m_gerberDisableApertMacros =
false;
95 m_useGerberX2format =
true;
96 m_includeGerberNetlistInfo =
true;
97 m_createGerberJobFile =
true;
102 m_svgUseInch =
false;
103 m_excludeEdgeLayer =
true;
104 m_plotFrameRef =
false;
105 m_plotViaOnMaskLayer =
false;
107 m_DXFplotPolygonMode =
true;
109 m_useAuxOrigin =
false;
115 m_plotReference =
true;
117 m_plotInvisibleText =
false;
118 m_sketchPadsOnFabLayers =
false;
119 m_subtractMaskFromSilk =
false;
122 m_drillMarks = SMALL_DRILL_SHAPE;
125 m_scaleSelection = 1;
126 m_fineScaleAdjustX = 1.0;
127 m_fineScaleAdjustY = 1.0;
130 m_outputDirectory.clear();
137 m_skipNPTH_Pads =
false;
142 m_default_colors = std::make_shared<COLOR_SETTINGS>();
143 m_colors = m_default_colors.get();
161 m_svgUseInch = aUseInch;
167 int aNestLevel,
int aControl )
const 174 aFormatter->
Print( aNestLevel+1,
"(%s 0x%s)\n",
getTokenName( T_layerselection ),
175 m_layerSelection.FmtHex().c_str() );
177 aFormatter->
Print( aNestLevel+1,
"(%s %s)\n",
getTokenName( T_disableapertmacros ),
178 m_gerberDisableApertMacros ? trueStr : falseStr );
180 aFormatter->
Print( aNestLevel+1,
"(%s %s)\n",
getTokenName( T_usegerberextensions ),
181 m_useGerberProtelExtensions ? trueStr : falseStr );
183 aFormatter->
Print( aNestLevel+1,
"(%s %s)\n",
getTokenName( T_usegerberattributes ),
184 GetUseGerberX2format() ? trueStr : falseStr );
186 aFormatter->
Print( aNestLevel+1,
"(%s %s)\n",
getTokenName( T_usegerberadvancedattributes ),
187 GetIncludeGerberNetlistInfo() ? trueStr : falseStr );
189 aFormatter->
Print( aNestLevel+1,
"(%s %s)\n",
getTokenName( T_creategerberjobfile ),
190 GetCreateGerberJobFile() ? trueStr : falseStr );
195 aFormatter->
Print( aNestLevel+1,
"(%s %d)\n",
200 m_svgUseInch ? trueStr : falseStr );
204 aFormatter->
Print( aNestLevel+1,
"(%s %s)\n",
getTokenName( T_excludeedgelayer ),
205 m_excludeEdgeLayer ? trueStr : falseStr );
207 m_plotFrameRef ? trueStr : falseStr );
209 m_plotViaOnMaskLayer ? trueStr : falseStr );
211 GetPlotMode() ==
SKETCH ? 2 : 1 );
213 m_useAuxOrigin ? trueStr : falseStr );
225 m_DXFplotPolygonMode ? trueStr : falseStr );
226 aFormatter->
Print( aNestLevel+1,
"(%s %s)\n",
getTokenName( T_dxfimperialunits ),
228 aFormatter->
Print( aNestLevel+1,
"(%s %s)\n",
getTokenName( T_dxfusepcbnewfont ),
232 m_negative ? trueStr : falseStr );
234 m_A4Output ? trueStr : falseStr );
236 m_plotReference ? trueStr : falseStr );
238 m_plotValue ? trueStr : falseStr );
239 aFormatter->
Print( aNestLevel+1,
"(%s %s)\n",
getTokenName( T_plotinvisibletext ),
240 m_plotInvisibleText ? trueStr : falseStr );
242 m_sketchPadsOnFabLayers ? trueStr : falseStr );
243 aFormatter->
Print( aNestLevel+1,
"(%s %s)\n",
getTokenName( T_subtractmaskfromsilk ),
244 m_subtractMaskFromSilk ? trueStr : falseStr );
246 static_cast<int>( m_format ) );
248 m_mirror ? trueStr : falseStr );
253 aFormatter->
Print( aNestLevel+1,
"(%s \"%s\")",
getTokenName( T_outputdirectory ),
254 (
const char*) m_outputDirectory.utf8_str() );
255 aFormatter->
Print( 0,
"\n" );
256 aFormatter->
Print( aNestLevel,
")\n" );
262 aParser->
Parse(
this );
346 if( m_format != aPcbPlotParams.
m_format )
349 if( m_mirror != aPcbPlotParams.
m_mirror )
361 if( m_scale != aPcbPlotParams.
m_scale )
396 PCB_PLOT_PARAMS_LEXER( aReader )
402 PCB_PLOT_PARAMS_LEXER( aLine, aSource )
411 while( ( token = NextTok() ) != T_RIGHT )
416 if( token == T_LEFT )
419 if( token == T_pcbplotparams )
422 bool skip_right =
false;
426 case T_layerselection:
428 token = NeedSYMBOLorNUMBER();
430 const std::string& cur = CurStr();
432 if( token == T_NUMBER )
440 else if( cur.find_first_of(
"0x" ) == 0 )
447 Expecting(
"integer or hex layerSelection" );
453 case T_disableapertmacros:
457 case T_usegerberextensions:
461 case T_usegerberattributes:
465 case T_usegerberadvancedattributes:
469 case T_creategerberjobfile:
473 case T_gerberprecision:
490 case T_excludeedgelayer:
510 case T_hpglpennumber:
518 case T_hpglpendiameter:
522 case T_hpglpenoverlay:
527 case T_dxfpolygonmode:
531 case T_dxfimperialunits:
536 case T_dxfusepcbnewfont:
549 case T_plotreference:
557 case T_plotinvisibletext:
561 case T_sketchpadsonfab:
565 case T_subtractmaskfromsilk:
570 aPcbPlotParams->
m_format = static_cast<PLOT_FORMAT>(
580 aPcbPlotParams->
m_drillMarks = static_cast<PCB_PLOT_PARAMS::DrillMarksType>
584 case T_scaleselection:
588 case T_outputdirectory:
589 NeedSYMBOLorNUMBER();
607 T token = NeedSYMBOL();
609 if( token != T_false && token != T_true )
610 Expecting(
"true|false" );
612 return token == T_true;
620 if( token != T_NUMBER )
621 Expecting( T_NUMBER );
623 int val = atoi( CurText() );
627 else if( val > aMax )
638 if( token != T_NUMBER )
639 Expecting( T_NUMBER );
641 double val = strtod( CurText(),
nullptr );
652 while( ( token = NextTok() ) != T_EOF )
654 if( token == T_LEFT )
657 if( token == T_RIGHT )
double m_fineScaleAdjustX
fine scale adjust X axis
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
#define HPGL_PEN_NUMBER_MAX
bool m_plotValue
Enable plotting of part values.
#define HPGL_PEN_SPEED_MAX
static bool setDouble(double *aTarget, double aValue, double aMin, double aMax)
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
double parseDouble()
Function parseDouble parses a double.
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
void SetGerberPrecision(int aPrecision)
wxString m_outputDirectory
Output directory for plot files (usually relative to the board file)
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
bool m_mirror
Mirror the plot around the X axis.
PCB_PLOT_PARAMS_PARSER is the parser class for PCB_PLOT_PARAMS.
bool m_excludeEdgeLayer
If false always plot (merge) the pcb edge layer on other layers.
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControl=0) const
DXF_UNITS m_DXFplotUnits
DXF format: Units to use when plotting the DXF.
static const int gbrDefaultPrecision
bool m_svgUseInch
units for SVG plot false for metric, true for inch/mils
bool m_useGerberX2format
Include attributes from the Gerber X2 format (chapter 5 in revision J2)
double m_scale
Global scale factor, 1.0 plots a board with its actual size.
bool m_plotReference
Enable plotting of part references.
bool m_useGerberProtelExtensions
When plotting gerber files, use a conventional set of Protel extensions instead of ....
bool SetHPGLPenSpeed(int aValue)
OUTLINE_MODE m_plotMode
FILLED or SKETCH selects how to plot filled objects.
int m_scaleSelection
Scale ratio index (UI only)
bool m_negative
Plot in negative color (supported only by some drivers)
bool m_plotFrameRef
True to plot/print frame references.
double m_HPGLPenDiam
HPGL only: pen diameter in MILS, useful to fill areas However, it is in mm in hpgl files.
This file contains miscellaneous commonly used macros and functions.
bool m_includeGerberNetlistInfo
Include netlist info (only in Gerber X2 format) (chapter ? in revision ?)
bool m_plotInvisibleText
Force plotting of fields marked invisible.
bool m_DXFplotPolygonMode
DXF format: Plot items in outline (polygon) mode.
bool m_autoScale
When true set the scale to fit the board in the page.
bool m_A4Output
Autoscale the plot to fit an A4 (landscape?) sheet.
unsigned m_svgPrecision
precision of coordinates in SVG files: accepted 3 - 6 6 is the internal resolution of Pcbnew
LSET is a set of PCB_LAYER_IDs.
PCB_PLOT_PARAMS_PARSER(LINE_READER *aReader)
bool m_sketchPadsOnFabLayers
Plots pads outlines on fab layers.
bool IsSameAs(const PCB_PLOT_PARAMS &aPcbPlotParams) const
Compare current settings to aPcbPlotParams, including not saved parameters in brd file.
bool m_subtractMaskFromSilk
On gerbers 'scrape' away the solder mask from silkscreen (trim silks)
#define HPGL_PEN_DIAMETER_MAX
double m_fineScaleAdjustY
fine scale adjust Y axis
static bool setInt(int *aTarget, int aValue, int aMin, int aMax)
#define HPGL_PEN_DIAMETER_MIN
bool m_plotViaOnMaskLayer
True if vias are drawn on Mask layer (ie untented, exposed by mask)
static const char * getTokenName(T aTok)
Parameters and options when plotting/printing a board.
void SetPlotMode(OUTLINE_MODE aPlotMode)
int m_widthAdjust
This width factor is intended to compensate PS printers/ plotters that do not strictly obey line widt...
bool m_useAuxOrigin
Plot gerbers using auxiliary (drill) origin instead of absolute coordinates.
PLOT_FORMAT m_format
Plot format type (chooses the driver to be used)
void SetSvgPrecision(unsigned aPrecision, bool aUseInch)
#define SVG_PRECISION_MAX
bool m_createGerberJobFile
generate the auxiliary "job file" in gerber format
bool SetHPGLPenDiameter(double aValue)
bool m_gerberDisableApertMacros
Disable aperture macros in Gerber format (only for broken Gerber readers) Ideally,...
int m_HPGLPenNum
HPGL only: pen number selection(1 to 9)
LSET m_layerSelection
Set of layers to plot.
void skipCurrent()
Function skipCurrent Skip the current token level, i.e search for the RIGHT parenthesis which closes ...
#define HPGL_PEN_NUMBER_MIN
#define HPGL_PEN_SPEED_MIN
const T & Clamp(const T &lower, const T &value, const T &upper)
Limit value within the range lower <= value <= upper.
PLOT_TEXT_MODE m_textMode
Choose how represent text with PS, PDF and DXF drivers.
int m_HPGLPenSpeed
HPGL only: pen speed, always in cm/s (1 to 99 cm/s)
int parseInt(int aMin, int aMax)
Function parseInt parses an integer and constrains it between two values.
#define SVG_PRECISION_DEFAULT
void Parse(PCB_PLOT_PARAMS *aPcbPlotParams)
void Parse(PCB_PLOT_PARAMS_PARSER *aParser)
#define SVG_PRECISION_MIN
int ParseHex(const char *aStart, int aCount)
Convert the output of FmtHex() and replaces this set's values with those given in the input string.
static constexpr int Millimeter2iu(double mm)
DrillMarksType m_drillMarks
Holes can be not plotted, have a small mark or plotted in actual size.
int m_gerberPrecision
precision of coordinates in Gerber files: accepted 5 or 6 when units are in mm (6 or 7 in inches,...