KiCad PCB EDA Suite
PCB_PLOT_PARAMS_PARSER Class Reference

PCB_PLOT_PARAMS_PARSER is the parser class for PCB_PLOT_PARAMS. More...

#include <pcb_plot_params_parser.h>

Inheritance diagram for PCB_PLOT_PARAMS_PARSER:

Public Member Functions

 PCB_PLOT_PARAMS_PARSER (LINE_READER *aReader)
 
 PCB_PLOT_PARAMS_PARSER (char *aLine, const wxString &aSource)
 
LINE_READERGetReader ()
 
void Parse (PCB_PLOT_PARAMS *aPcbPlotParams)
 

Private Member Functions

bool parseBool ()
 
int parseInt (int aMin, int aMax)
 Function parseInt parses an integer and constrains it between two values. More...
 
double parseDouble ()
 Function parseDouble parses a double. More...
 
void skipCurrent ()
 Function skipCurrent Skip the current token level, i.e search for the RIGHT parenthesis which closes the current description. More...
 

Detailed Description

PCB_PLOT_PARAMS_PARSER is the parser class for PCB_PLOT_PARAMS.

Definition at line 36 of file pcb_plot_params_parser.h.

Constructor & Destructor Documentation

◆ PCB_PLOT_PARAMS_PARSER() [1/2]

PCB_PLOT_PARAMS_PARSER::PCB_PLOT_PARAMS_PARSER ( LINE_READER aReader)

Definition at line 395 of file pcb_plot_params.cpp.

395  :
396  PCB_PLOT_PARAMS_LEXER( aReader )
397 {
398 }

◆ PCB_PLOT_PARAMS_PARSER() [2/2]

PCB_PLOT_PARAMS_PARSER::PCB_PLOT_PARAMS_PARSER ( char *  aLine,
const wxString &  aSource 
)

Definition at line 401 of file pcb_plot_params.cpp.

401  :
402  PCB_PLOT_PARAMS_LEXER( aLine, aSource )
403 {
404 }

Member Function Documentation

◆ GetReader()

LINE_READER* PCB_PLOT_PARAMS_PARSER::GetReader ( )
inline

Definition at line 42 of file pcb_plot_params_parser.h.

42 { return reader; };

◆ Parse()

void PCB_PLOT_PARAMS_PARSER::Parse ( PCB_PLOT_PARAMS aPcbPlotParams)

Definition at line 407 of file pcb_plot_params.cpp.

408 {
409  T token;
410 
411  while( ( token = NextTok() ) != T_RIGHT )
412  {
413  if( token == T_EOF)
414  Unexpected( T_EOF );
415 
416  if( token == T_LEFT )
417  token = NextTok();
418 
419  if( token == T_pcbplotparams )
420  continue;
421 
422  bool skip_right = false;
423 
424  switch( token )
425  {
426  case T_layerselection:
427  {
428  token = NeedSYMBOLorNUMBER();
429 
430  const std::string& cur = CurStr();
431 
432  if( token == T_NUMBER ) // pretty 3 format had legacy Cu stack.
433  {
434  // It's not possible to convert a legacy Cu layer number to a new Cu layer
435  // number without knowing the number or total Cu layers in the legacy board.
436  // We do not have that information here, so simply set all layers ON. User
437  // can turn them off in the UI.
438  aPcbPlotParams->m_layerSelection = LSET( 2, F_SilkS, B_SilkS ) | LSET::AllCuMask();
439  }
440  else if( cur.find_first_of( "0x" ) == 0 ) // pretty ver. 4.
441  {
442  // skip the leading 2 0x bytes.
443  aPcbPlotParams->m_layerSelection.ParseHex( cur.c_str() + 2, cur.size() - 2 );
444  }
445  else
446  {
447  Expecting( "integer or hex layerSelection" );
448  }
449 
450  break;
451  }
452 
453  case T_disableapertmacros:
454  aPcbPlotParams->m_gerberDisableApertMacros = parseBool();
455  break;
456 
457  case T_usegerberextensions:
458  aPcbPlotParams->m_useGerberProtelExtensions = parseBool();
459  break;
460 
461  case T_usegerberattributes:
462  aPcbPlotParams->m_useGerberX2format = parseBool();
463  break;
464 
465  case T_usegerberadvancedattributes:
466  aPcbPlotParams->m_includeGerberNetlistInfo = parseBool();
467  break;
468 
469  case T_creategerberjobfile:
470  aPcbPlotParams->m_createGerberJobFile = parseBool();
471  break;
472 
473  case T_gerberprecision:
474  aPcbPlotParams->m_gerberPrecision = parseInt( gbrDefaultPrecision - 1,
476  break;
477 
478  case T_svgprecision:
480  break;
481 
482  case T_svguseinch:
483  aPcbPlotParams->m_svgUseInch = parseBool();
484  break;
485 
486  case T_psa4output:
487  aPcbPlotParams->m_A4Output = parseBool();
488  break;
489 
490  case T_excludeedgelayer:
491  aPcbPlotParams->m_excludeEdgeLayer = parseBool();
492  break;
493 
494  case T_plotframeref:
495  aPcbPlotParams->m_plotFrameRef = parseBool();
496  break;
497 
498  case T_viasonmask:
499  aPcbPlotParams->m_plotViaOnMaskLayer = parseBool();
500  break;
501 
502  case T_mode:
503  aPcbPlotParams->SetPlotMode( parseInt( 0, 2 ) > 1 ? SKETCH : FILLED );
504  break;
505 
506  case T_useauxorigin:
507  aPcbPlotParams->m_useAuxOrigin = parseBool();
508  break;
509 
510  case T_hpglpennumber:
512  break;
513 
514  case T_hpglpenspeed:
516  break;
517 
518  case T_hpglpendiameter:
519  aPcbPlotParams->m_HPGLPenDiam = parseDouble();
520  break;
521 
522  case T_hpglpenoverlay:
523  // No more used. just here for compatibility with old versions
525  break;
526 
527  case T_dxfpolygonmode:
528  aPcbPlotParams->m_DXFplotPolygonMode = parseBool();
529  break;
530 
531  case T_dxfimperialunits:
532  aPcbPlotParams->m_DXFplotUnits = parseBool() ? DXF_UNITS::INCHES
534  break;
535 
536  case T_dxfusepcbnewfont:
537  aPcbPlotParams->m_textMode = parseBool() ? PLOT_TEXT_MODE::DEFAULT
539  break;
540 
541  case T_pscolor:
542  NeedSYMBOL(); // This actually was never used...
543  break;
544 
545  case T_psnegative:
546  aPcbPlotParams->m_negative = parseBool();
547  break;
548 
549  case T_plotreference:
550  aPcbPlotParams->m_plotReference = parseBool();
551  break;
552 
553  case T_plotvalue:
554  aPcbPlotParams->m_plotValue = parseBool();
555  break;
556 
557  case T_plotinvisibletext:
558  aPcbPlotParams->m_plotInvisibleText = parseBool();
559  break;
560 
561  case T_sketchpadsonfab:
562  aPcbPlotParams->m_sketchPadsOnFabLayers= parseBool();
563  break;
564 
565  case T_subtractmaskfromsilk:
566  aPcbPlotParams->m_subtractMaskFromSilk = parseBool();
567  break;
568 
569  case T_outputformat:
570  aPcbPlotParams->m_format = static_cast<PLOT_FORMAT>(
571  parseInt( static_cast<int>( PLOT_FORMAT::FIRST_FORMAT ),
572  static_cast<int>( PLOT_FORMAT::LAST_FORMAT ) ) );
573  break;
574 
575  case T_mirror:
576  aPcbPlotParams->m_mirror = parseBool();
577  break;
578 
579  case T_drillshape:
580  aPcbPlotParams->m_drillMarks = static_cast<PCB_PLOT_PARAMS::DrillMarksType>
581  ( parseInt( 0, 2 ) );
582  break;
583 
584  case T_scaleselection:
585  aPcbPlotParams->m_scaleSelection = parseInt( 0, 4 );
586  break;
587 
588  case T_outputdirectory:
589  NeedSYMBOLorNUMBER(); // a dir name can be like a number
590  aPcbPlotParams->m_outputDirectory = FROM_UTF8( CurText() );
591  break;
592 
593  default:
594  skipCurrent(); // skip unknown or outdated plot parameter
595  skip_right = true; // the closing right token is already read.
596  break;
597  }
598 
599  if( ! skip_right )
600  NeedRIGHT();
601  }
602 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:750
#define HPGL_PEN_NUMBER_MAX
bool m_plotValue
Enable plotting of part values.
#define HPGL_PEN_SPEED_MAX
double parseDouble()
Function parseDouble parses a double.
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.
Definition: macros.h:110
bool m_mirror
Mirror the plot around the X axis.
bool m_excludeEdgeLayer
If false always plot (merge) the pcb edge layer on other layers.
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)
bool m_plotReference
Enable plotting of part references.
bool m_useGerberProtelExtensions
When plotting gerber files, use a conventional set of Protel extensions instead of ....
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.
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_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.
Definition: layer_ids.h:504
bool m_sketchPadsOnFabLayers
Plots pads outlines on fab layers.
bool m_subtractMaskFromSilk
On gerbers 'scrape' away the solder mask from silkscreen (trim silks)
#define HPGL_PEN_DIAMETER_MAX
bool m_plotViaOnMaskLayer
True if vias are drawn on Mask layer (ie untented, exposed by mask)
void SetPlotMode(OUTLINE_MODE aPlotMode)
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)
#define SVG_PRECISION_MAX
bool m_createGerberJobFile
generate the auxiliary "job file" in gerber format
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
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_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.
Definition: lset.cpp:359
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,...

References LSET::AllCuMask(), B_SilkS, DEFAULT, F_SilkS, FILLED, FIRST_FORMAT, FROM_UTF8(), gbrDefaultPrecision, HPGL_PEN_DIAMETER_MAX, HPGL_PEN_NUMBER_MAX, HPGL_PEN_NUMBER_MIN, HPGL_PEN_SPEED_MAX, HPGL_PEN_SPEED_MIN, INCHES, LAST_FORMAT, PCB_PLOT_PARAMS::m_A4Output, PCB_PLOT_PARAMS::m_createGerberJobFile, PCB_PLOT_PARAMS::m_drillMarks, PCB_PLOT_PARAMS::m_DXFplotPolygonMode, PCB_PLOT_PARAMS::m_DXFplotUnits, PCB_PLOT_PARAMS::m_excludeEdgeLayer, PCB_PLOT_PARAMS::m_format, PCB_PLOT_PARAMS::m_gerberDisableApertMacros, PCB_PLOT_PARAMS::m_gerberPrecision, PCB_PLOT_PARAMS::m_HPGLPenDiam, PCB_PLOT_PARAMS::m_HPGLPenNum, PCB_PLOT_PARAMS::m_HPGLPenSpeed, PCB_PLOT_PARAMS::m_includeGerberNetlistInfo, PCB_PLOT_PARAMS::m_layerSelection, PCB_PLOT_PARAMS::m_mirror, PCB_PLOT_PARAMS::m_negative, PCB_PLOT_PARAMS::m_outputDirectory, PCB_PLOT_PARAMS::m_plotFrameRef, PCB_PLOT_PARAMS::m_plotInvisibleText, PCB_PLOT_PARAMS::m_plotReference, PCB_PLOT_PARAMS::m_plotValue, PCB_PLOT_PARAMS::m_plotViaOnMaskLayer, PCB_PLOT_PARAMS::m_scaleSelection, PCB_PLOT_PARAMS::m_sketchPadsOnFabLayers, PCB_PLOT_PARAMS::m_subtractMaskFromSilk, PCB_PLOT_PARAMS::m_svgPrecision, PCB_PLOT_PARAMS::m_svgUseInch, PCB_PLOT_PARAMS::m_textMode, PCB_PLOT_PARAMS::m_useAuxOrigin, PCB_PLOT_PARAMS::m_useGerberProtelExtensions, PCB_PLOT_PARAMS::m_useGerberX2format, MILLIMETERS, NATIVE, parseBool(), parseDouble(), LSET::ParseHex(), parseInt(), PCB_PLOT_PARAMS::SetPlotMode(), SKETCH, skipCurrent(), SVG_PRECISION_MAX, and SVG_PRECISION_MIN.

Referenced by PCB_PLOT_PARAMS::Parse().

◆ parseBool()

bool PCB_PLOT_PARAMS_PARSER::parseBool ( )
private

Definition at line 605 of file pcb_plot_params.cpp.

606 {
607  T token = NeedSYMBOL();
608 
609  if( token != T_false && token != T_true )
610  Expecting( "true|false" );
611 
612  return token == T_true;
613 }

Referenced by Parse().

◆ parseDouble()

double PCB_PLOT_PARAMS_PARSER::parseDouble ( )
private

Function parseDouble parses a double.

Returns
double - the parsed double.

Definition at line 634 of file pcb_plot_params.cpp.

635 {
636  T token = NextTok();
637 
638  if( token != T_NUMBER )
639  Expecting( T_NUMBER );
640 
641  double val = strtod( CurText(), nullptr );
642 
643  return val;
644 }

Referenced by Parse().

◆ parseInt()

int PCB_PLOT_PARAMS_PARSER::parseInt ( int  aMin,
int  aMax 
)
private

Function parseInt parses an integer and constrains it between two values.

Parameters
aMinis the smallest return value.
aMaxis the largest return value.
Returns
int - the parsed integer.

Definition at line 616 of file pcb_plot_params.cpp.

617 {
618  T token = NextTok();
619 
620  if( token != T_NUMBER )
621  Expecting( T_NUMBER );
622 
623  int val = atoi( CurText() );
624 
625  if( val < aMin )
626  val = aMin;
627  else if( val > aMax )
628  val = aMax;
629 
630  return val;
631 }

Referenced by Parse().

◆ skipCurrent()

void PCB_PLOT_PARAMS_PARSER::skipCurrent ( )
private

Function skipCurrent Skip the current token level, i.e search for the RIGHT parenthesis which closes the current description.

Definition at line 647 of file pcb_plot_params.cpp.

648 {
649  int curr_level = 0;
650  T token;
651 
652  while( ( token = NextTok() ) != T_EOF )
653  {
654  if( token == T_LEFT )
655  curr_level--;
656 
657  if( token == T_RIGHT )
658  {
659  curr_level++;
660 
661  if( curr_level > 0 )
662  return;
663  }
664  }
665 }

Referenced by Parse().


The documentation for this class was generated from the following files: