KiCad PCB EDA Suite
DRAWING_SHEET_PARSER Class Reference

DRAWING_SHEET_PARSER holds data and functions pertinent to parsing a S-expression file for a DS_DATA_MODEL. More...

Inheritance diagram for DRAWING_SHEET_PARSER:

Public Member Functions

 DRAWING_SHEET_PARSER (const char *aLine, const wxString &aSource)
 
void Parse (DS_DATA_MODEL *aLayout)
 

Private Member Functions

void parseHeader (T aHeaderType)
 Parse the data specified at the very beginning of the file, like version and the application used to create this file. More...
 
int parseInt ()
 Parse an integer. More...
 
int parseInt (int aMin, int aMax)
 Parse an integer and constrain it between two values. More...
 
double parseDouble ()
 Parse a double. More...
 
void parseSetup (DS_DATA_MODEL *aLayout)
 
void parseGraphic (DS_DATA_ITEM *aItem)
 Parse a graphic item starting by "(line" or "(rect" and read parameters. More...
 
void parseText (DS_DATA_ITEM_TEXT *aItem)
 Parse a text item starting by "(tbtext" and read parameters. More...
 
void parsePolygon (DS_DATA_ITEM_POLYGONS *aItem)
 Parse a polygon item starting by "( polygon" and read parameters. More...
 
void parsePolyOutline (DS_DATA_ITEM_POLYGONS *aItem)
 Parse a list of corners starting by "( pts" and read coordinates. More...
 
void parseBitmap (DS_DATA_ITEM_BITMAP *aItem)
 Parse a bitmap item starting by "( bitmap" and read parameters. More...
 
void parseCoordinate (POINT_COORD &aCoord)
 
void readOption (DS_DATA_ITEM *aItem)
 
void readPngdata (DS_DATA_ITEM_BITMAP *aItem)
 

Private Attributes

int m_requiredVersion
 

Detailed Description

DRAWING_SHEET_PARSER holds data and functions pertinent to parsing a S-expression file for a DS_DATA_MODEL.

Definition at line 44 of file drawing_sheet_parser.cpp.

Constructor & Destructor Documentation

◆ DRAWING_SHEET_PARSER()

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

Definition at line 116 of file drawing_sheet_parser.cpp.

117  :
118  DRAWING_SHEET_LEXER( aLine, aSource ),
119  m_requiredVersion( 0 )
120 {
121 }

Member Function Documentation

◆ Parse()

void DRAWING_SHEET_PARSER::Parse ( DS_DATA_MODEL aLayout)

Definition at line 198 of file drawing_sheet_parser.cpp.

199 {
200  DS_DATA_ITEM* item;
201  LOCALE_IO toggle;
202 
203  NeedLEFT();
204  T token = NextTok();
205 
206  parseHeader( token );
208 
209  for( token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
210  {
211  if( token == T_LEFT )
212  token = NextTok();
213 
214  switch( token )
215  {
216  case T_setup: // Defines default values for graphic items
217  parseSetup( aLayout );
218  break;
219 
220  case T_line:
222  parseGraphic( item );
223  aLayout->Append( item );
224  break;
225 
226  case T_rect:
227  item = new DS_DATA_ITEM( DS_DATA_ITEM::DS_RECT );
228  parseGraphic( item );
229  aLayout->Append( item );
230  break;
231 
232  case T_polygon:
233  item = new DS_DATA_ITEM_POLYGONS();
235  aLayout->Append( item );
236  break;
237 
238  case T_bitmap:
239  item = new DS_DATA_ITEM_BITMAP( NULL );
240  parseBitmap( (DS_DATA_ITEM_BITMAP*) item );
241  aLayout->Append( item );
242  break;
243 
244  case T_tbtext:
245  NeedSYMBOLorNUMBER();
246  item = new DS_DATA_ITEM_TEXT( convertLegacyVariableRefs( FromUTF8() ) );
247  parseText( (DS_DATA_ITEM_TEXT*) item );
248  aLayout->Append( item );
249  break;
250 
251  default:
252  Unexpected( CurText() );
253  break;
254  }
255  }
256 }
void parseGraphic(DS_DATA_ITEM *aItem)
Parse a graphic item starting by "(line" or "(rect" and read parameters.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
void parseHeader(T aHeaderType)
Parse the data specified at the very beginning of the file, like version and the application used to ...
void parseText(DS_DATA_ITEM_TEXT *aItem)
Parse a text item starting by "(tbtext" and read parameters.
wxString convertLegacyVariableRefs(const wxString &aTextbase)
void parseBitmap(DS_DATA_ITEM_BITMAP *aItem)
Parse a bitmap item starting by "( bitmap" and read parameters.
void parseSetup(DS_DATA_MODEL *aLayout)
void SetFileFormatVersionAtLoad(int aVersion)
Definition: ds_data_model.h:61
Drawing sheet structure type definitions.
Definition: ds_data_item.h:95
void parsePolygon(DS_DATA_ITEM_POLYGONS *aItem)
Parse a polygon item starting by "( polygon" and read parameters.
void Append(DS_DATA_ITEM *aItem)

References DS_DATA_MODEL::Append(), convertLegacyVariableRefs(), DS_DATA_ITEM::DS_RECT, DS_DATA_ITEM::DS_SEGMENT, m_requiredVersion, parseBitmap(), parseGraphic(), parseHeader(), parsePolygon(), parseSetup(), parseText(), and DS_DATA_MODEL::SetFileFormatVersionAtLoad().

Referenced by DS_DATA_MODEL::LoadDrawingSheet(), and DS_DATA_MODEL::SetPageLayout().

◆ parseBitmap()

void DRAWING_SHEET_PARSER::parseBitmap ( DS_DATA_ITEM_BITMAP aItem)
private

Parse a bitmap item starting by "( bitmap" and read parameters.

Definition at line 450 of file drawing_sheet_parser.cpp.

451 {
453  aItem->m_ImageBitmap = image;
454 
455  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
456  {
457  if( token == T_LEFT )
458  token = NextTok();
459 
460  switch( token )
461  {
462  case T_name:
463  NeedSYMBOLorNUMBER();
464  aItem->m_Name = FromUTF8();
465  NeedRIGHT();
466  break;
467 
468  case T_pos:
469  parseCoordinate( aItem->m_Pos );
470  break;
471 
472  case T_repeat:
473  aItem->m_RepeatCount = parseInt( -1, 100 );
474  NeedRIGHT();
475  break;
476 
477  case T_incrx:
478  aItem->m_IncrementVector.x = parseDouble();
479  NeedRIGHT();
480  break;
481 
482  case T_incry:
483  aItem->m_IncrementVector.y = parseDouble();
484  NeedRIGHT();
485  break;
486 
487  case T_linewidth:
488  aItem->m_LineWidth = parseDouble();
489  NeedRIGHT();
490  break;
491 
492  case T_scale:
493  aItem->m_ImageBitmap->SetScale( parseDouble() );
494  NeedRIGHT();
495  break;
496 
497  case T_pngdata:
498  readPngdata( aItem );
499  break;
500 
501  case T_option:
502  readOption( aItem );
503  break;
504 
505  default:
506  Unexpected( CurText() );
507  break;
508  }
509  }
510 }
void SetScale(double aScale)
Definition: bitmap_base.h:80
void readOption(DS_DATA_ITEM *aItem)
int parseInt()
Parse an integer.
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:51
DPOINT m_IncrementVector
Definition: ds_data_item.h:204
double m_LineWidth
Definition: ds_data_item.h:202
BITMAP_BASE * m_ImageBitmap
Definition: ds_data_item.h:368
void parseCoordinate(POINT_COORD &aCoord)
void readPngdata(DS_DATA_ITEM_BITMAP *aItem)
POINT_COORD m_Pos
Definition: ds_data_item.h:200
double parseDouble()
Parse a double.
wxString m_Name
Definition: ds_data_item.h:198

References image, DS_DATA_ITEM_BITMAP::m_ImageBitmap, DS_DATA_ITEM::m_IncrementVector, DS_DATA_ITEM::m_LineWidth, DS_DATA_ITEM::m_Name, DS_DATA_ITEM::m_Pos, DS_DATA_ITEM::m_RepeatCount, parseCoordinate(), parseDouble(), parseInt(), readOption(), readPngdata(), BITMAP_BASE::SetScale(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Parse().

◆ parseCoordinate()

void DRAWING_SHEET_PARSER::parseCoordinate ( POINT_COORD aCoord)
private

Definition at line 772 of file drawing_sheet_parser.cpp.

773 {
774  aCoord.m_Pos.x = parseDouble();
775  aCoord.m_Pos.y = parseDouble();
776 
777  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
778  {
779  switch( token )
780  {
781  case T_ltcorner: aCoord.m_Anchor = LT_CORNER; break;
782  case T_lbcorner: aCoord.m_Anchor = LB_CORNER; break;
783  case T_rbcorner: aCoord.m_Anchor = RB_CORNER; break;
784  case T_rtcorner: aCoord.m_Anchor = RT_CORNER; break;
785  default: Unexpected( CurText() ); break;
786  }
787  }
788 }
DPOINT m_Pos
Definition: ds_data_item.h:80
double parseDouble()
Parse a double.

References LB_CORNER, LT_CORNER, POINT_COORD::m_Anchor, POINT_COORD::m_Pos, parseDouble(), RB_CORNER, RT_CORNER, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by parseBitmap(), parseGraphic(), parsePolygon(), and parseText().

◆ parseDouble()

double DRAWING_SHEET_PARSER::parseDouble ( )
private

Parse a double.

Returns
double - the parsed double.

Definition at line 813 of file drawing_sheet_parser.cpp.

814 {
815  T token = NextTok();
816 
817  if( token != T_NUMBER )
818  Expecting( T_NUMBER );
819 
820  double val = strtod( CurText(), NULL );
821 
822  return val;
823 }

Referenced by parseBitmap(), parseCoordinate(), parseGraphic(), parsePolygon(), parsePolyOutline(), parseSetup(), and parseText().

◆ parseGraphic()

void DRAWING_SHEET_PARSER::parseGraphic ( DS_DATA_ITEM aItem)
private

Parse a graphic item starting by "(line" or "(rect" and read parameters.

Definition at line 560 of file drawing_sheet_parser.cpp.

561 {
562  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
563  {
564  if( token == T_LEFT )
565  token = NextTok();
566  else
567  {
568  // If another token than T_LEFT is read here, this is an error
569  // however, due to a old bug in kicad, the token T_end can be found
570  // without T_LEFT in a very few .wks files (perhaps only one in a demo).
571  // So this ugly hack disables the error detection.
572  if( token != T_end )
573  Unexpected( CurText() );
574  }
575 
576  switch( token )
577  {
578  case T_comment:
579  NeedSYMBOLorNUMBER();
580  aItem->m_Info = FromUTF8();
581  NeedRIGHT();
582  break;
583 
584  case T_option:
585  readOption( aItem );
586  break;
587 
588  case T_name:
589  NeedSYMBOLorNUMBER();
590  aItem->m_Name = FromUTF8();
591  NeedRIGHT();
592  break;
593 
594  case T_start:
595  parseCoordinate( aItem->m_Pos );
596  break;
597 
598  case T_end:
599  parseCoordinate( aItem->m_End );
600  break;
601 
602  case T_repeat:
603  aItem->m_RepeatCount = parseInt( -1, 100 );
604  NeedRIGHT();
605  break;
606 
607  case T_incrx:
608  aItem->m_IncrementVector.x = parseDouble();
609  NeedRIGHT();
610  break;
611 
612  case T_incry:
613  aItem->m_IncrementVector.y = parseDouble();
614  NeedRIGHT();
615  break;
616 
617  case T_linewidth:
618  aItem->m_LineWidth = parseDouble();
619  NeedRIGHT();
620  break;
621 
622  default:
623  Unexpected( CurText() );
624  break;
625  }
626  }
627 }
wxString m_Info
Definition: ds_data_item.h:199
void readOption(DS_DATA_ITEM *aItem)
int parseInt()
Parse an integer.
POINT_COORD m_End
Definition: ds_data_item.h:201
DPOINT m_IncrementVector
Definition: ds_data_item.h:204
double m_LineWidth
Definition: ds_data_item.h:202
void parseCoordinate(POINT_COORD &aCoord)
POINT_COORD m_Pos
Definition: ds_data_item.h:200
double parseDouble()
Parse a double.
wxString m_Name
Definition: ds_data_item.h:198

References DS_DATA_ITEM::m_End, DS_DATA_ITEM::m_IncrementVector, DS_DATA_ITEM::m_Info, DS_DATA_ITEM::m_LineWidth, DS_DATA_ITEM::m_Name, DS_DATA_ITEM::m_Pos, DS_DATA_ITEM::m_RepeatCount, parseCoordinate(), parseDouble(), parseInt(), readOption(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Parse().

◆ parseHeader()

void DRAWING_SHEET_PARSER::parseHeader ( aHeaderType)
private

Parse the data specified at the very beginning of the file, like version and the application used to create this file.

Definition at line 258 of file drawing_sheet_parser.cpp.

259 {
260  // The older files had no versioning and their first token after the initial left parenthesis
261  // was a `page_layout` or `drawing_sheet` token. The newer files have versions and have a
262  // `kicad_wks` token instead.
263 
264  if( aHeaderType == T_kicad_wks || aHeaderType == T_drawing_sheet )
265  {
266  NeedLEFT();
267 
268  T tok = NextTok();
269 
270  if( tok == T_version )
271  {
273 
275  throw FUTURE_FORMAT_ERROR( FromUTF8() );
276 
277  NeedRIGHT();
278  }
279  else
280  {
281  Expecting( T_version );
282  }
283 
284  // Ignore generator info.
285  NeedLEFT();
286  NeedSYMBOL();
287  NeedSYMBOL();
288  NeedRIGHT();
289  }
290  else
291  {
292  // We assign version 0 to files that were created before there was any versioning of
293  // worksheets. The below line is not strictly necessary, as `m_requiredVersion` is already
294  // initialized to 0 in the constructor.
295  m_requiredVersion = 0;
296  }
297 }
int parseInt()
Parse an integer.
#define SEXPR_WORKSHEET_FILE_VERSION
This file contains the file format version information for the s-expression drawing sheet file format...
Variant of PARSE_ERROR indicating that a syntax or related error was likely caused by a file generate...
Definition: ki_exception.h:174

References m_requiredVersion, parseInt(), and SEXPR_WORKSHEET_FILE_VERSION.

Referenced by Parse().

◆ parseInt() [1/2]

int DRAWING_SHEET_PARSER::parseInt ( )
private

Parse an integer.

Definition at line 790 of file drawing_sheet_parser.cpp.

791 {
792  T token = NextTok();
793 
794  if( token != T_NUMBER )
795  Expecting( T_NUMBER );
796 
797  return atoi( CurText() );
798 }

Referenced by parseBitmap(), parseGraphic(), parseHeader(), parseInt(), parsePolygon(), and parseText().

◆ parseInt() [2/2]

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

Parse an integer and constrain it between two values.

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

Definition at line 800 of file drawing_sheet_parser.cpp.

801 {
802  int val = parseInt();
803 
804  if( val < aMin )
805  val = aMin;
806  else if( val > aMax )
807  val = aMax;
808 
809  return val;
810 }
int parseInt()
Parse an integer.

References parseInt().

◆ parsePolygon()

void DRAWING_SHEET_PARSER::parsePolygon ( DS_DATA_ITEM_POLYGONS aItem)
private

Parse a polygon item starting by "( polygon" and read parameters.

the list of corners included in this description is read by parsePolyOutline.

Definition at line 356 of file drawing_sheet_parser.cpp.

357 {
358  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
359  {
360  if( token == T_LEFT )
361  token = NextTok();
362 
363  switch( token )
364  {
365  case T_comment:
366  NeedSYMBOLorNUMBER();
367  aItem->m_Info = FromUTF8();
368  NeedRIGHT();
369  break;
370 
371  case T_pos:
372  parseCoordinate( aItem->m_Pos );
373  break;
374 
375  case T_name:
376  NeedSYMBOLorNUMBER();
377  aItem->m_Name = FromUTF8();
378  NeedRIGHT();
379  break;
380 
381  case T_option:
382  readOption( aItem );
383  break;
384 
385  case T_pts:
386  parsePolyOutline( aItem );
387  aItem->CloseContour();
388  break;
389 
390  case T_rotate:
391  aItem->m_Orient = parseDouble();
392  NeedRIGHT();
393  break;
394 
395  case T_repeat:
396  aItem->m_RepeatCount = parseInt( -1, 100 );
397  NeedRIGHT();
398  break;
399 
400  case T_incrx:
401  aItem->m_IncrementVector.x = parseDouble();
402  NeedRIGHT();
403  break;
404 
405  case T_incry:
406  aItem->m_IncrementVector.y = parseDouble();
407  NeedRIGHT();
408  break;
409 
410  case T_linewidth:
411  aItem->m_LineWidth = parseDouble();
412  NeedRIGHT();
413  break;
414 
415  default:
416  Unexpected( CurText() );
417  break;
418  }
419  }
420 
421  aItem->SetBoundingBox();
422 }
wxString m_Info
Definition: ds_data_item.h:199
void SetBoundingBox()
Calculate the bounding box of the set polygons.
void readOption(DS_DATA_ITEM *aItem)
int parseInt()
Parse an integer.
DPOINT m_IncrementVector
Definition: ds_data_item.h:204
double m_LineWidth
Definition: ds_data_item.h:202
void CloseContour()
Close the current contour, by storing the index of the last corner of the current polygon in m_polyIn...
Definition: ds_data_item.h:238
void parseCoordinate(POINT_COORD &aCoord)
void parsePolyOutline(DS_DATA_ITEM_POLYGONS *aItem)
Parse a list of corners starting by "( pts" and read coordinates.
POINT_COORD m_Pos
Definition: ds_data_item.h:200
double parseDouble()
Parse a double.
wxString m_Name
Definition: ds_data_item.h:198

References DS_DATA_ITEM_POLYGONS::CloseContour(), DS_DATA_ITEM::m_IncrementVector, DS_DATA_ITEM::m_Info, DS_DATA_ITEM::m_LineWidth, DS_DATA_ITEM::m_Name, DS_DATA_ITEM_POLYGONS::m_Orient, DS_DATA_ITEM::m_Pos, DS_DATA_ITEM::m_RepeatCount, parseCoordinate(), parseDouble(), parseInt(), parsePolyOutline(), readOption(), DS_DATA_ITEM_POLYGONS::SetBoundingBox(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Parse().

◆ parsePolyOutline()

void DRAWING_SHEET_PARSER::parsePolyOutline ( DS_DATA_ITEM_POLYGONS aItem)
private

Parse a list of corners starting by "( pts" and read coordinates.

Definition at line 424 of file drawing_sheet_parser.cpp.

425 {
426  DPOINT corner;
427 
428  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
429  {
430  if( token == T_LEFT )
431  token = NextTok();
432 
433  switch( token )
434  {
435  case T_xy:
436  corner.x = parseDouble();
437  corner.y = parseDouble();
438  aItem->AppendCorner( corner );
439  NeedRIGHT();
440  break;
441 
442  default:
443  Unexpected( CurText() );
444  break;
445  }
446  }
447 }
double parseDouble()
Parse a double.
void AppendCorner(const DPOINT &aCorner)
Add a corner in corner list.
Definition: ds_data_item.h:229

References DS_DATA_ITEM_POLYGONS::AppendCorner(), parseDouble(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by parsePolygon().

◆ parseSetup()

void DRAWING_SHEET_PARSER::parseSetup ( DS_DATA_MODEL aLayout)
private

Definition at line 299 of file drawing_sheet_parser.cpp.

300 {
301  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
302  {
303  switch( token )
304  {
305  case T_LEFT:
306  break;
307 
308  case T_linewidth:
309  aLayout->m_DefaultLineWidth = parseDouble();
310  NeedRIGHT();
311  break;
312 
313  case T_textsize:
314  aLayout->m_DefaultTextSize.x = parseDouble();
315  aLayout->m_DefaultTextSize.y = parseDouble();
316  NeedRIGHT();
317  break;
318 
319  case T_textlinewidth:
320  aLayout->m_DefaultTextThickness = parseDouble();
321  NeedRIGHT();
322  break;
323 
324  case T_left_margin:
325  aLayout->SetLeftMargin( parseDouble() );
326  NeedRIGHT();
327  break;
328 
329  case T_right_margin:
330  aLayout->SetRightMargin( parseDouble() );
331  NeedRIGHT();
332  break;
333 
334  case T_top_margin:
335  aLayout->SetTopMargin( parseDouble() );
336  NeedRIGHT();
337  break;
338 
339  case T_bottom_margin:
340  aLayout->SetBottomMargin( parseDouble() );
341  NeedRIGHT();
342  break;
343 
344  default:
345  Unexpected( CurText() );
346  break;
347  }
348  }
349 
350  // The file is well-formed. If it has no further items, then that's the way the
351  // user wants it.
352  aLayout->AllowVoidList( true );
353 }
void SetBottomMargin(double aMargin)
Definition: ds_data_model.h:73
double m_DefaultLineWidth
void SetLeftMargin(double aMargin)
Definition: ds_data_model.h:64
void SetRightMargin(double aMargin)
Definition: ds_data_model.h:67
double m_DefaultTextThickness
DSIZE m_DefaultTextSize
void AllowVoidList(bool Allow)
In KiCad applications, a drawing sheet is needed So if the list is empty, a default drawing sheet is ...
Definition: ds_data_model.h:83
void SetTopMargin(double aMargin)
Definition: ds_data_model.h:70
double parseDouble()
Parse a double.

References DS_DATA_MODEL::AllowVoidList(), DS_DATA_MODEL::m_DefaultLineWidth, DS_DATA_MODEL::m_DefaultTextSize, DS_DATA_MODEL::m_DefaultTextThickness, parseDouble(), DS_DATA_MODEL::SetBottomMargin(), DS_DATA_MODEL::SetLeftMargin(), DS_DATA_MODEL::SetRightMargin(), DS_DATA_MODEL::SetTopMargin(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Parse().

◆ parseText()

void DRAWING_SHEET_PARSER::parseText ( DS_DATA_ITEM_TEXT aItem)
private

Parse a text item starting by "(tbtext" and read parameters.

Definition at line 630 of file drawing_sheet_parser.cpp.

631 {
632  if( m_requiredVersion < 20210606 )
634 
635  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
636  {
637  if( token == T_LEFT )
638  token = NextTok();
639 
640  switch( token )
641  {
642  case T_comment:
643  NeedSYMBOLorNUMBER();
644  aItem->m_Info = FromUTF8();
645  NeedRIGHT();
646  break;
647 
648  case T_option:
649  readOption( aItem );
650  break;
651 
652  case T_name:
653  NeedSYMBOLorNUMBER();
654  aItem->m_Name = FromUTF8();
655  NeedRIGHT();
656  break;
657 
658  case T_pos:
659  parseCoordinate( aItem->m_Pos );
660  break;
661 
662  case T_repeat:
663  aItem->m_RepeatCount = parseInt( -1, 100 );
664  NeedRIGHT();
665  break;
666 
667  case T_incrx:
668  aItem->m_IncrementVector.x = parseDouble();
669  NeedRIGHT();
670  break;
671 
672  case T_incry:
673  aItem->m_IncrementVector.y = parseDouble();
674  NeedRIGHT();
675  break;
676 
677  case T_incrlabel:
678  aItem->m_IncrementLabel = parseInt(INT_MIN, INT_MAX);
679  NeedRIGHT();
680  break;
681 
682  case T_maxlen:
683  aItem->m_BoundingBoxSize.x = parseDouble();
684  NeedRIGHT();
685  break;
686 
687  case T_maxheight:
688  aItem->m_BoundingBoxSize.y = parseDouble();
689  NeedRIGHT();
690  break;
691 
692  case T_font:
693  for( token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
694  {
695  switch( token )
696  {
697  case T_LEFT:
698  break;
699 
700  case T_bold:
701  aItem->m_Bold = true;
702  break;
703 
704  case T_italic:
705  aItem->m_Italic = true;
706  break;
707 
708  case T_size:
709  aItem->m_TextSize.x = parseDouble();
710  aItem->m_TextSize.y = parseDouble();
711  NeedRIGHT();
712  break;
713 
714  case T_linewidth:
715  aItem->m_LineWidth = parseDouble();
716  NeedRIGHT();
717  break;
718 
719  default:
720  Unexpected( CurText() );
721  break;
722  }
723  }
724  break;
725 
726  case T_justify:
727  for( token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
728  {
729  switch( token )
730  {
731  case T_center:
734  break;
735 
736  case T_left:
738  break;
739 
740  case T_right:
742  break;
743 
744  case T_top:
746  break;
747 
748  case T_bottom:
750  break;
751 
752  default:
753  Unexpected( CurText() );
754  break;
755  }
756  }
757  break;
758 
759  case T_rotate:
760  aItem->m_Orient = parseDouble();
761  NeedRIGHT();
762  break;
763 
764  default:
765  Unexpected( CurText() );
766  break;
767  }
768  }
769 }
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.
wxString m_Info
Definition: ds_data_item.h:199
EDA_TEXT_VJUSTIFY_T m_Vjustify
Definition: ds_data_item.h:339
void readOption(DS_DATA_ITEM *aItem)
int parseInt()
Parse an integer.
EDA_TEXT_HJUSTIFY_T m_Hjustify
Definition: ds_data_item.h:338
DPOINT m_IncrementVector
Definition: ds_data_item.h:204
double m_LineWidth
Definition: ds_data_item.h:202
int m_IncrementLabel
Definition: ds_data_item.h:205
void parseCoordinate(POINT_COORD &aCoord)
POINT_COORD m_Pos
Definition: ds_data_item.h:200
double parseDouble()
Parse a double.
wxString m_Name
Definition: ds_data_item.h:198

References ConvertToNewOverbarNotation(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, DS_DATA_ITEM_TEXT::m_Bold, DS_DATA_ITEM_TEXT::m_BoundingBoxSize, DS_DATA_ITEM_TEXT::m_Hjustify, DS_DATA_ITEM::m_IncrementLabel, DS_DATA_ITEM::m_IncrementVector, DS_DATA_ITEM::m_Info, DS_DATA_ITEM_TEXT::m_Italic, DS_DATA_ITEM::m_LineWidth, DS_DATA_ITEM::m_Name, DS_DATA_ITEM_TEXT::m_Orient, DS_DATA_ITEM::m_Pos, DS_DATA_ITEM::m_RepeatCount, m_requiredVersion, DS_DATA_ITEM_TEXT::m_TextBase, DS_DATA_ITEM_TEXT::m_TextSize, DS_DATA_ITEM_TEXT::m_Vjustify, parseCoordinate(), parseDouble(), parseInt(), readOption(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Parse().

◆ readOption()

void DRAWING_SHEET_PARSER::readOption ( DS_DATA_ITEM aItem)
private

Definition at line 546 of file drawing_sheet_parser.cpp.

547 {
548  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
549  {
550  switch( token )
551  {
552  case T_page1only: aItem->SetPage1Option( FIRST_PAGE_ONLY ); break;
553  case T_notonpage1: aItem->SetPage1Option( SUBSEQUENT_PAGES ); break;
554  default: Unexpected( CurText() ); break;
555  }
556  }
557 }
void SetPage1Option(PAGE_OPTION aChoice)
Definition: ds_data_item.h:134

References FIRST_PAGE_ONLY, DS_DATA_ITEM::SetPage1Option(), and SUBSEQUENT_PAGES.

Referenced by parseBitmap(), parseGraphic(), parsePolygon(), and parseText().

◆ readPngdata()

void DRAWING_SHEET_PARSER::readPngdata ( DS_DATA_ITEM_BITMAP aItem)
private

Definition at line 512 of file drawing_sheet_parser.cpp.

513 {
514  std::string tmp;
515 
516  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
517  {
518  if( token == T_LEFT )
519  token = NextTok();
520 
521  switch( token )
522  {
523  case T_data:
524  NeedSYMBOLorNUMBER();
525  tmp += CurStr();
526  tmp += "\n";
527  NeedRIGHT();
528  break;
529 
530  default:
531  Unexpected( CurText() );
532  break;
533  }
534  }
535 
536  tmp += "EndData";
537 
538  wxString msg;
539  STRING_LINE_READER str_reader( tmp, wxT("Png kicad_wks data") );
540 
541  if( ! aItem->m_ImageBitmap->LoadData( str_reader, msg ) )
542  wxLogMessage(msg);
543 }
BITMAP_BASE * m_ImageBitmap
Definition: ds_data_item.h:368
bool LoadData(LINE_READER &aLine, wxString &aErrorMsg)
Load an image data saved by SaveData.
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:240

References BITMAP_BASE::LoadData(), and DS_DATA_ITEM_BITMAP::m_ImageBitmap.

Referenced by parseBitmap().

Member Data Documentation

◆ m_requiredVersion

int DRAWING_SHEET_PARSER::m_requiredVersion
private

Definition at line 51 of file drawing_sheet_parser.cpp.

Referenced by Parse(), parseHeader(), and parseText().


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