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

356  :
357  PCB_PLOT_PARAMS_LEXER( aReader )
358 {
359 }

◆ PCB_PLOT_PARAMS_PARSER() [2/2]

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

Definition at line 362 of file pcb_plot_params.cpp.

362  :
363  PCB_PLOT_PARAMS_LEXER( aLine, aSource )
364 {
365 }

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

369 {
370  T token;
371 
372  while( ( token = NextTok() ) != T_RIGHT )
373  {
374  if( token == T_EOF)
375  Unexpected( T_EOF );
376 
377  if( token == T_LEFT )
378  token = NextTok();
379 
380  if( token == T_pcbplotparams )
381  continue;
382 
383  bool skip_right = false;
384 
385  switch( token )
386  {
387  case T_layerselection:
388  {
389  token = NeedSYMBOLorNUMBER();
390 
391  const std::string& cur = CurStr();
392 
393  if( token == T_NUMBER ) // pretty 3 format had legacy Cu stack.
394  {
395  // It's not possible to convert a legacy Cu layer number to a new Cu layer
396  // number without knowing the number or total Cu layers in the legacy board.
397  // We do not have that information here, so simply set all layers ON. User
398  // can turn them off in the UI.
399  aPcbPlotParams->m_layerSelection = LSET( 2, F_SilkS, B_SilkS)
400  | LSET::AllCuMask();
401  }
402  else if( cur.find_first_of( "0x" ) == 0 ) // pretty ver. 4.
403  {
404  // skip the leading 2 0x bytes.
405  aPcbPlotParams->m_layerSelection.ParseHex( cur.c_str()+2, cur.size()-2 );
406  }
407  else
408  Expecting( "integer or hex layerSelection" );
409  }
410  break;
411 
412  case T_disableapertmacros:
413  aPcbPlotParams->m_gerberDisableApertMacros = parseBool();
414  break;
415 
416  case T_usegerberextensions:
417  aPcbPlotParams->m_useGerberProtelExtensions = parseBool();
418  break;
419 
420  case T_usegerberattributes:
421  aPcbPlotParams->m_useGerberX2format = parseBool();
422  break;
423 
424  case T_usegerberadvancedattributes:
425  aPcbPlotParams->m_includeGerberNetlistInfo = parseBool();
426  break;
427 
428  case T_creategerberjobfile:
429  aPcbPlotParams->m_createGerberJobFile = parseBool();
430  break;
431 
432  case T_gerberprecision:
433  aPcbPlotParams->m_gerberPrecision = parseInt( gbrDefaultPrecision-1,
435  break;
436 
437  case T_svgprecision:
439  break;
440 
441  case T_svguseinch:
442  aPcbPlotParams->m_svgUseInch = parseBool();
443  break;
444 
445  case T_psa4output:
446  aPcbPlotParams->m_A4Output = parseBool();
447  break;
448 
449  case T_excludeedgelayer:
450  aPcbPlotParams->m_excludeEdgeLayer = parseBool();
451  break;
452 
453  case T_plotframeref:
454  aPcbPlotParams->m_plotFrameRef = parseBool();
455  break;
456 
457  case T_viasonmask:
458  aPcbPlotParams->m_plotViaOnMaskLayer = parseBool();
459  break;
460 
461  case T_mode:
462  aPcbPlotParams->SetPlotMode( parseInt( 0, 2 ) > 1 ? SKETCH : FILLED );
463  break;
464 
465  case T_useauxorigin:
466  aPcbPlotParams->m_useAuxOrigin = parseBool();
467  break;
468 
469  case T_hpglpennumber:
470  aPcbPlotParams->m_HPGLPenNum = parseInt( HPGL_PEN_NUMBER_MIN,
472  break;
473 
474  case T_hpglpenspeed:
475  aPcbPlotParams->m_HPGLPenSpeed = parseInt( HPGL_PEN_SPEED_MIN,
477  break;
478 
479  case T_hpglpendiameter:
480  aPcbPlotParams->m_HPGLPenDiam = parseDouble();
481  break;
482 
483  case T_hpglpenoverlay:
484  // No more used. juste here for compatibility with old versions
486  break;
487 
488  case T_dxfpolygonmode:
489  aPcbPlotParams->m_DXFplotPolygonMode = parseBool();
490  break;
491 
492  case T_dxfimperialunits:
493  aPcbPlotParams->m_DXFplotUnits = parseBool() ? DXF_UNITS::INCHES
495  break;
496 
497  case T_dxfusepcbnewfont:
498  aPcbPlotParams->m_textMode = parseBool() ? PLOT_TEXT_MODE::DEFAULT
500  break;
501 
502  case T_pscolor:
503  NeedSYMBOL(); // This actually was never used...
504  break;
505 
506  case T_psnegative:
507  aPcbPlotParams->m_negative = parseBool();
508  break;
509 
510  case T_plotreference:
511  aPcbPlotParams->m_plotReference = parseBool();
512  break;
513 
514  case T_plotvalue:
515  aPcbPlotParams->m_plotValue = parseBool();
516  break;
517 
518  case T_plotinvisibletext:
519  aPcbPlotParams->m_plotInvisibleText = parseBool();
520  break;
521 
522  case T_sketchpadsonfab:
523  aPcbPlotParams->m_sketchPadsOnFabLayers= parseBool();
524  break;
525 
526  case T_subtractmaskfromsilk:
527  aPcbPlotParams->m_subtractMaskFromSilk = parseBool();
528  break;
529 
530  case T_outputformat:
531  aPcbPlotParams->m_format = static_cast<PLOT_FORMAT>(
532  parseInt( static_cast<int>( PLOT_FORMAT::FIRST_FORMAT ),
533  static_cast<int>( PLOT_FORMAT::LAST_FORMAT ) ) );
534  break;
535 
536  case T_mirror:
537  aPcbPlotParams->m_mirror = parseBool();
538  break;
539 
540  case T_drillshape:
541  aPcbPlotParams->m_drillMarks = static_cast<PCB_PLOT_PARAMS::DrillMarksType>
542  ( parseInt( 0, 2 ) );
543  break;
544 
545  case T_scaleselection:
546  aPcbPlotParams->m_scaleSelection = parseInt( 0, 4 );
547  break;
548 
549  case T_outputdirectory:
550  NeedSYMBOLorNUMBER(); // a dir name can be like a number
551  aPcbPlotParams->m_outputDirectory = FROM_UTF8( CurText() );
552  break;
553 
554  default:
555  skipCurrent(); // skip unknown or outdated plot parameter
556  skip_right = true; // the closing right token is already read.
557  break;
558  }
559 
560  if( ! skip_right )
561  NeedRIGHT();
562  }
563 }
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 In polygon mode, each item to plot is converted to a...
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)
void SetPlotMode(OUTLINE_MODE aPlotMode)
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
bool m_gerberDisableApertMacros
Disable aperure macros in Gerber format (only for broken Gerber readers) Ideally, should be never sel...
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 566 of file pcb_plot_params.cpp.

567 {
568  T token = NeedSYMBOL();
569 
570  if( token != T_false && token != T_true )
571  Expecting( "true|false" );
572 
573  return token == T_true;
574 }

Referenced by Parse().

◆ parseDouble()

double PCB_PLOT_PARAMS_PARSER::parseDouble ( )
private

Function parseDouble parses a double.

Returns
double - the parsed double.

Definition at line 595 of file pcb_plot_params.cpp.

596 {
597  T token = NextTok();
598 
599  if( token != T_NUMBER )
600  Expecting( T_NUMBER );
601 
602  double val = strtod( CurText(), NULL );
603 
604  return val;
605 }
#define NULL

References NULL.

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

578 {
579  T token = NextTok();
580 
581  if( token != T_NUMBER )
582  Expecting( T_NUMBER );
583 
584  int val = atoi( CurText() );
585 
586  if( val < aMin )
587  val = aMin;
588  else if( val > aMax )
589  val = aMax;
590 
591  return val;
592 }

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

609 {
610  int curr_level = 0;
611  T token;
612 
613  while( ( token = NextTok() ) != T_EOF )
614  {
615  if( token == T_LEFT )
616  curr_level--;
617 
618  if( token == T_RIGHT )
619  {
620  curr_level++;
621 
622  if( curr_level > 0 )
623  return;
624  }
625  }
626 }

Referenced by Parse().


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