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 367 of file pcb_plot_params.cpp.

367  :
368  PCB_PLOT_PARAMS_LEXER( aReader )
369 {
370 }

◆ PCB_PLOT_PARAMS_PARSER() [2/2]

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

Definition at line 373 of file pcb_plot_params.cpp.

373  :
374  PCB_PLOT_PARAMS_LEXER( aLine, aSource )
375 {
376 }

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 379 of file pcb_plot_params.cpp.

380 {
381  T token;
382 
383  while( ( token = NextTok() ) != T_RIGHT )
384  {
385  if( token == T_EOF)
386  Unexpected( T_EOF );
387 
388  if( token == T_LEFT )
389  token = NextTok();
390 
391  if( token == T_pcbplotparams )
392  continue;
393 
394  bool skip_right = false;
395 
396  switch( token )
397  {
398  case T_layerselection:
399  {
400  token = NeedSYMBOLorNUMBER();
401 
402  const std::string& cur = CurStr();
403 
404  if( token == T_NUMBER ) // pretty 3 format had legacy Cu stack.
405  {
406  // unsigned legacy_mask = atol( cur.c_str() );
407 
408  /* It's not possible to convert a legacy Cu layer number to a new
409  Cu layer number without knowing the number or total Cu layers
410  in the legacy board. We do not have that information here.
411  So simply set all layers ON. User can turn them off in the UI.
412  This is one of the superiorities of the new Cu sequence.
413  aPcbPlotParams->m_layerSelection = LEGACY_PLUGIN::leg_mask2new( cu_count, legacy_mask );
414  */
415 
416  // sorry, use the UI once to fix:
417  aPcbPlotParams->m_layerSelection = LSET( 2, F_SilkS, B_SilkS) | LSET::AllCuMask();
418  }
419  else if( cur.find_first_of( "0x" ) == 0 ) // pretty ver. 4.
420  {
421  // skip the leading 2 0x bytes.
422  aPcbPlotParams->m_layerSelection.ParseHex( cur.c_str()+2, cur.size()-2 );
423  }
424  else
425  Expecting( "integer or hex layerSelection" );
426  }
427  break;
428 
429  case T_usegerberextensions:
430  aPcbPlotParams->m_useGerberProtelExtensions = parseBool();
431  break;
432 
433  case T_usegerberattributes:
434  aPcbPlotParams->m_useGerberX2format = parseBool();
435  break;
436 
437  case T_usegerberadvancedattributes:
438  aPcbPlotParams->m_includeGerberNetlistInfo = parseBool();
439  break;
440 
441  case T_creategerberjobfile:
442  aPcbPlotParams->m_createGerberJobFile = parseBool();
443  break;
444 
445  case T_gerberprecision:
446  aPcbPlotParams->m_gerberPrecision =
448  break;
449 
450  case T_svgprecision:
452  break;
453 
454  case T_svguseinch:
455  aPcbPlotParams->m_svgUseInch = parseBool();
456  break;
457 
458  case T_psa4output:
459  aPcbPlotParams->m_A4Output = parseBool();
460  break;
461 
462  case T_excludeedgelayer:
463  aPcbPlotParams->m_excludeEdgeLayer = parseBool();
464  break;
465 
466  case T_plotframeref:
467  aPcbPlotParams->m_plotFrameRef = parseBool();
468  break;
469 
470  case T_viasonmask:
471  aPcbPlotParams->m_plotViaOnMaskLayer = parseBool();
472  break;
473 
474  case T_mode:
475  aPcbPlotParams->SetPlotMode( parseInt( 0, 2 ) > 1 ? SKETCH : FILLED );
476  break;
477 
478  case T_useauxorigin:
479  aPcbPlotParams->m_useAuxOrigin = parseBool();
480  break;
481 
482  case T_hpglpennumber:
483  aPcbPlotParams->m_HPGLPenNum = parseInt( HPGL_PEN_NUMBER_MIN,
485  break;
486 
487  case T_hpglpenspeed:
488  aPcbPlotParams->m_HPGLPenSpeed = parseInt( HPGL_PEN_SPEED_MIN,
490  break;
491 
492  case T_hpglpendiameter:
493  aPcbPlotParams->m_HPGLPenDiam = parseDouble();
494  break;
495 
496  case T_hpglpenoverlay:
497  // No more used. juste here for compatibility with old versions
499  break;
500 
501  case T_pscolor:
502  NeedSYMBOL(); // This actually was never used...
503  break;
504 
505  case T_psnegative:
506  aPcbPlotParams->m_negative = parseBool();
507  break;
508 
509  case T_plotreference:
510  aPcbPlotParams->m_plotReference = parseBool();
511  break;
512 
513  case T_plotvalue:
514  aPcbPlotParams->m_plotValue = parseBool();
515  break;
516 
517  case T_plotinvisibletext:
518  aPcbPlotParams->m_plotInvisibleText = parseBool();
519  break;
520 
521  case T_sketchpadsonfab:
522  aPcbPlotParams->m_sketchPadsOnFabLayers= parseBool();
523  break;
524 
525  case T_subtractmaskfromsilk:
526  aPcbPlotParams->m_subtractMaskFromSilk = parseBool();
527  break;
528 
529  case T_outputformat:
530  aPcbPlotParams->m_format = static_cast<PLOT_FORMAT>(
531  parseInt( static_cast<int>( PLOT_FORMAT::FIRST_FORMAT ),
532  static_cast<int>( PLOT_FORMAT::LAST_FORMAT ) ) );
533  break;
534 
535  case T_mirror:
536  aPcbPlotParams->m_mirror = parseBool();
537  break;
538 
539  case T_drillshape:
540  aPcbPlotParams->m_drillMarks = static_cast<PCB_PLOT_PARAMS::DrillMarksType>
541  ( parseInt( 0, 2 ) );
542  break;
543 
544  case T_scaleselection:
545  aPcbPlotParams->m_scaleSelection = parseInt( 0, 4 );
546  break;
547 
548  case T_outputdirectory:
549  NeedSYMBOLorNUMBER(); // a dir name can be like a number
550  aPcbPlotParams->m_outputDirectory = FROM_UTF8( CurText() );
551  break;
552 
553  default:
554  skipCurrent(); // skip unknown or outdated plot parameter
555  skip_right = true; // the closing right token is already read.
556  break;
557  }
558 
559  if( ! skip_right )
560  NeedRIGHT();
561  }
562 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:712
#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)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:114
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.
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 ....
T
enum T contains all this lexer's tokens.
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_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.
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)
bool m_useAuxOrigin
Plot gerbers using auxiliary (drill) origin instead of absolue 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
void SetPlotMode(EDA_DRAW_MODE_T aPlotMode)
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
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)
Function ParseHex understands the output of FmtHex() and replaces this set's values with those given ...
Definition: lset.cpp:325
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, 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, LAST_FORMAT, PCB_PLOT_PARAMS::m_A4Output, PCB_PLOT_PARAMS::m_createGerberJobFile, PCB_PLOT_PARAMS::m_drillMarks, PCB_PLOT_PARAMS::m_excludeEdgeLayer, PCB_PLOT_PARAMS::m_format, 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_useAuxOrigin, PCB_PLOT_PARAMS::m_useGerberProtelExtensions, PCB_PLOT_PARAMS::m_useGerberX2format, parseBool(), parseDouble(), LSET::ParseHex(), parseInt(), PCB_PLOT_PARAMS::SetPlotMode(), SKETCH, skipCurrent(), SVG_PRECISION_MAX, SVG_PRECISION_MIN, DRCRULE_T::T_EOF, DRCRULE_T::T_LEFT, DRCRULE_T::T_NUMBER, and DRCRULE_T::T_RIGHT.

Referenced by PCB_PLOT_PARAMS::Parse().

◆ parseBool()

bool PCB_PLOT_PARAMS_PARSER::parseBool ( )
private

Definition at line 565 of file pcb_plot_params.cpp.

566 {
567  T token = NeedSYMBOL();
568 
569  if( token != T_false && token != T_true )
570  Expecting( "true|false" );
571 
572  return token == T_true;
573 }
T
enum T contains all this lexer's tokens.

Referenced by Parse().

◆ parseDouble()

double PCB_PLOT_PARAMS_PARSER::parseDouble ( )
private

Function parseDouble parses a double.

Returns
double - the parsed double.

Definition at line 594 of file pcb_plot_params.cpp.

595 {
596  T token = NextTok();
597 
598  if( token != T_NUMBER )
599  Expecting( T_NUMBER );
600 
601  double val = strtod( CurText(), NULL );
602 
603  return val;
604 }
T
enum T contains all this lexer's tokens.
#define NULL

References NULL, and DRCRULE_T::T_NUMBER.

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 576 of file pcb_plot_params.cpp.

577 {
578  T token = NextTok();
579 
580  if( token != T_NUMBER )
581  Expecting( T_NUMBER );
582 
583  int val = atoi( CurText() );
584 
585  if( val < aMin )
586  val = aMin;
587  else if( val > aMax )
588  val = aMax;
589 
590  return val;
591 }
T
enum T contains all this lexer's tokens.

References DRCRULE_T::T_NUMBER.

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 607 of file pcb_plot_params.cpp.

608 {
609  int curr_level = 0;
610  T token;
611 
612  while( ( token = NextTok() ) != T_EOF )
613  {
614  if( token == T_LEFT )
615  curr_level--;
616 
617  if( token == T_RIGHT )
618  {
619  curr_level++;
620 
621  if( curr_level > 0 )
622  return;
623  }
624  }
625 }
T
enum T contains all this lexer's tokens.

References DRCRULE_T::T_EOF, DRCRULE_T::T_LEFT, and DRCRULE_T::T_RIGHT.

Referenced by Parse().


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