KiCad PCB EDA Suite
PAGE_LAYOUT_READER_PARSER Class Reference

PAGE_LAYOUT_READER_PARSER holds data and functions pertinent to parsing a S-expression file for a WS_DATA_MODEL. More...

Inheritance diagram for PAGE_LAYOUT_READER_PARSER:

Public Member Functions

 PAGE_LAYOUT_READER_PARSER (const char *aLine, const wxString &aSource)
 
void Parse (WS_DATA_MODEL *aLayout)
 

Private Member Functions

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 parseSetup (WS_DATA_MODEL *aLayout)
 
void parseGraphic (WS_DATA_ITEM *aItem)
 parse a graphic item starting by "(line" or "(rect" and read parameters. More...
 
void parseText (WS_DATA_ITEM_TEXT *aItem)
 parse a text item starting by "(tbtext" and read parameters. More...
 
void parsePolygon (WS_DATA_ITEM_POLYGONS *aItem)
 parse a polygon item starting by "( polygon" and read parameters. More...
 
void parsePolyOutline (WS_DATA_ITEM_POLYGONS *aItem)
 parse a list of corners starting by "( pts" and read coordinates. More...
 
void parseBitmap (WS_DATA_ITEM_BITMAP *aItem)
 parse a bitmap item starting by "( bitmap" and read parameters. More...
 
void parseCoordinate (POINT_COORD &aCoord)
 
void readOption (WS_DATA_ITEM *aItem)
 
void readPngdata (WS_DATA_ITEM_BITMAP *aItem)
 

Detailed Description

PAGE_LAYOUT_READER_PARSER holds data and functions pertinent to parsing a S-expression file for a WS_DATA_MODEL.

Definition at line 50 of file page_layout_reader.cpp.

Constructor & Destructor Documentation

◆ PAGE_LAYOUT_READER_PARSER()

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

Definition at line 110 of file page_layout_reader.cpp.

110  :
111  PAGE_LAYOUT_READER_LEXER( aLine, aSource )
112 {
113 }

Member Function Documentation

◆ Parse()

void PAGE_LAYOUT_READER_PARSER::Parse ( WS_DATA_MODEL aLayout)

Definition at line 191 of file page_layout_reader.cpp.

192 {
193  WS_DATA_ITEM* item;
194  LOCALE_IO toggle;
195 
196  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
197  {
198  if( token == T_LEFT )
199  token = NextTok();
200 
201  if( token == T_page_layout )
202  continue;
203 
204  switch( token )
205  {
206  case T_setup: // Defines default values for graphic items
207  parseSetup( aLayout );
208  break;
209 
210  case T_line:
212  parseGraphic( item );
213  aLayout->Append( item );
214  break;
215 
216  case T_rect:
217  item = new WS_DATA_ITEM( WS_DATA_ITEM::WS_RECT );
218  parseGraphic( item );
219  aLayout->Append( item );
220  break;
221 
222  case T_polygon:
223  item = new WS_DATA_ITEM_POLYGONS();
225  aLayout->Append( item );
226  break;
227 
228  case T_bitmap:
229  item = new WS_DATA_ITEM_BITMAP( NULL );
230  parseBitmap( (WS_DATA_ITEM_BITMAP*) item );
231  aLayout->Append( item );
232  break;
233 
234  case T_tbtext:
235  NeedSYMBOLorNUMBER();
236  item = new WS_DATA_ITEM_TEXT( convertLegacyVariableRefs( FromUTF8() ) );
237  parseText( (WS_DATA_ITEM_TEXT*) item );
238  aLayout->Append( item );
239  break;
240 
241  default:
242  Unexpected( CurText() );
243  break;
244  }
245  }
246 }
void parseText(WS_DATA_ITEM_TEXT *aItem)
parse a text item starting by "(tbtext" and read parameters.
Work sheet structure type definitions.
Definition: ws_data_item.h:93
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:216
T
enum T contains all this lexer's tokens.
#define NULL
wxString convertLegacyVariableRefs(const wxString &aTextbase)
void parseBitmap(WS_DATA_ITEM_BITMAP *aItem)
parse a bitmap item starting by "( bitmap" and read parameters.
void Append(WS_DATA_ITEM *aItem)
void parseGraphic(WS_DATA_ITEM *aItem)
parse a graphic item starting by "(line" or "(rect" and read parameters.
void parsePolygon(WS_DATA_ITEM_POLYGONS *aItem)
parse a polygon item starting by "( polygon" and read parameters.
void parseSetup(WS_DATA_MODEL *aLayout)

References WS_DATA_MODEL::Append(), convertLegacyVariableRefs(), NULL, parseBitmap(), parseGraphic(), parsePolygon(), parseSetup(), parseText(), DRCRULE_T::T_LEFT, DRCRULE_T::T_RIGHT, WS_DATA_ITEM::WS_RECT, and WS_DATA_ITEM::WS_SEGMENT.

Referenced by WS_DATA_MODEL::SetPageLayout().

◆ parseBitmap()

void PAGE_LAYOUT_READER_PARSER::parseBitmap ( WS_DATA_ITEM_BITMAP aItem)
private

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

Definition at line 400 of file page_layout_reader.cpp.

401 {
402  BITMAP_BASE* image = new BITMAP_BASE;
403  aItem->m_ImageBitmap = image;
404 
405  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
406  {
407  if( token == T_LEFT )
408  token = NextTok();
409 
410  switch( token )
411  {
412  case T_name:
413  NeedSYMBOLorNUMBER();
414  aItem->m_Name = FromUTF8();
415  NeedRIGHT();
416  break;
417 
418  case T_pos:
419  parseCoordinate( aItem->m_Pos );
420  break;
421 
422  case T_repeat:
423  aItem->m_RepeatCount = parseInt( -1, 100 );
424  NeedRIGHT();
425  break;
426 
427  case T_incrx:
428  aItem->m_IncrementVector.x = parseDouble();
429  NeedRIGHT();
430  break;
431 
432  case T_incry:
433  aItem->m_IncrementVector.y = parseDouble();
434  NeedRIGHT();
435  break;
436 
437  case T_linewidth:
438  aItem->m_LineWidth = parseDouble();
439  NeedRIGHT();
440  break;
441 
442  case T_scale:
443  aItem->m_ImageBitmap->SetScale( parseDouble() );
444  NeedRIGHT();
445  break;
446 
447  case T_pngdata:
448  readPngdata( aItem );
449  break;
450 
451  case T_option:
452  readOption( aItem );
453  break;
454 
455  default:
456  Unexpected( CurText() );
457  break;
458  }
459  }
460 }
wxString m_Name
Definition: ws_data_item.h:111
void parseCoordinate(POINT_COORD &aCoord)
int parseInt(int aMin, int aMax)
Function parseInt parses an integer and constrains it between two values.
void SetScale(double aScale)
Definition: bitmap_base.h:93
BITMAP_BASE * m_ImageBitmap
Definition: ws_data_item.h:366
T
enum T contains all this lexer's tokens.
double parseDouble()
Function parseDouble parses a double.
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:51
void readPngdata(WS_DATA_ITEM_BITMAP *aItem)
DPOINT m_IncrementVector
Definition: ws_data_item.h:119
double m_LineWidth
Definition: ws_data_item.h:117
void readOption(WS_DATA_ITEM *aItem)
POINT_COORD m_Pos
Definition: ws_data_item.h:115

References WS_DATA_ITEM_BITMAP::m_ImageBitmap, WS_DATA_ITEM::m_IncrementVector, WS_DATA_ITEM::m_LineWidth, WS_DATA_ITEM::m_Name, WS_DATA_ITEM::m_Pos, WS_DATA_ITEM::m_RepeatCount, parseCoordinate(), parseDouble(), parseInt(), readOption(), readPngdata(), BITMAP_BASE::SetScale(), DRCRULE_T::T_LEFT, DRCRULE_T::T_name, DRCRULE_T::T_RIGHT, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Parse().

◆ parseCoordinate()

void PAGE_LAYOUT_READER_PARSER::parseCoordinate ( POINT_COORD aCoord)
private

Definition at line 719 of file page_layout_reader.cpp.

720 {
721  aCoord.m_Pos.x = parseDouble();
722  aCoord.m_Pos.y = parseDouble();
723 
724  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
725  {
726  switch( token )
727  {
728  case T_ltcorner: aCoord.m_Anchor = LT_CORNER; break;
729  case T_lbcorner: aCoord.m_Anchor = LB_CORNER; break;
730  case T_rbcorner: aCoord.m_Anchor = RB_CORNER; break;
731  case T_rtcorner: aCoord.m_Anchor = RT_CORNER; break;
732  default: Unexpected( CurText() ); break;
733  }
734  }
735 }
T
enum T contains all this lexer's tokens.
double parseDouble()
Function parseDouble parses a double.
DPOINT m_Pos
Definition: ws_data_item.h:71

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

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

◆ parseDouble()

double PAGE_LAYOUT_READER_PARSER::parseDouble ( )
private

Function parseDouble parses a double.

Returns
double - the parsed double.

Definition at line 755 of file page_layout_reader.cpp.

756 {
757  T token = NextTok();
758 
759  if( token != T_NUMBER )
760  Expecting( T_NUMBER );
761 
762  double val = strtod( CurText(), NULL );
763 
764  return val;
765 }
T
enum T contains all this lexer's tokens.
#define NULL

References NULL, and DRCRULE_T::T_NUMBER.

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

◆ parseGraphic()

void PAGE_LAYOUT_READER_PARSER::parseGraphic ( WS_DATA_ITEM aItem)
private

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

Definition at line 510 of file page_layout_reader.cpp.

511 {
512  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
513  {
514  if( token == T_LEFT )
515  token = NextTok();
516  else
517  {
518  // If another token than T_LEFT is read here, this is an error
519  // however, due to a old bug in kicad, the token T_end can be found
520  // without T_LEFT in a very few .wks files (perhaps only one in a demo).
521  // So this ugly hack disables the error detection.
522  if( token != T_end )
523  Unexpected( CurText() );
524  }
525 
526  switch( token )
527  {
528  case T_comment:
529  NeedSYMBOLorNUMBER();
530  aItem->m_Info = FromUTF8();
531  NeedRIGHT();
532  break;
533 
534  case T_option:
535  readOption( aItem );
536  break;
537 
538  case T_name:
539  NeedSYMBOLorNUMBER();
540  aItem->m_Name = FromUTF8();
541  NeedRIGHT();
542  break;
543 
544  case T_start:
545  parseCoordinate( aItem->m_Pos );
546  break;
547 
548  case T_end:
549  parseCoordinate( aItem->m_End );
550  break;
551 
552  case T_repeat:
553  aItem->m_RepeatCount = parseInt( -1, 100 );
554  NeedRIGHT();
555  break;
556 
557  case T_incrx:
558  aItem->m_IncrementVector.x = parseDouble();
559  NeedRIGHT();
560  break;
561 
562  case T_incry:
563  aItem->m_IncrementVector.y = parseDouble();
564  NeedRIGHT();
565  break;
566 
567  case T_linewidth:
568  aItem->m_LineWidth = parseDouble();
569  NeedRIGHT();
570  break;
571 
572  default:
573  Unexpected( CurText() );
574  break;
575  }
576  }
577 }
wxString m_Name
Definition: ws_data_item.h:111
void parseCoordinate(POINT_COORD &aCoord)
int parseInt(int aMin, int aMax)
Function parseInt parses an integer and constrains it between two values.
POINT_COORD m_End
Definition: ws_data_item.h:116
T
enum T contains all this lexer's tokens.
double parseDouble()
Function parseDouble parses a double.
wxString m_Info
Definition: ws_data_item.h:113
DPOINT m_IncrementVector
Definition: ws_data_item.h:119
double m_LineWidth
Definition: ws_data_item.h:117
void readOption(WS_DATA_ITEM *aItem)
POINT_COORD m_Pos
Definition: ws_data_item.h:115

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

Referenced by Parse().

◆ parseInt()

int PAGE_LAYOUT_READER_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 737 of file page_layout_reader.cpp.

738 {
739  T token = NextTok();
740 
741  if( token != T_NUMBER )
742  Expecting( T_NUMBER );
743 
744  int val = atoi( CurText() );
745 
746  if( val < aMin )
747  val = aMin;
748  else if( val > aMax )
749  val = aMax;
750 
751  return val;
752 }
T
enum T contains all this lexer's tokens.

References DRCRULE_T::T_NUMBER.

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

◆ parsePolygon()

void PAGE_LAYOUT_READER_PARSER::parsePolygon ( WS_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 306 of file page_layout_reader.cpp.

307 {
308  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
309  {
310  if( token == T_LEFT )
311  token = NextTok();
312 
313  switch( token )
314  {
315  case T_comment:
316  NeedSYMBOLorNUMBER();
317  aItem->m_Info = FromUTF8();
318  NeedRIGHT();
319  break;
320 
321  case T_pos:
322  parseCoordinate( aItem->m_Pos );
323  break;
324 
325  case T_name:
326  NeedSYMBOLorNUMBER();
327  aItem->m_Name = FromUTF8();
328  NeedRIGHT();
329  break;
330 
331  case T_option:
332  readOption( aItem );
333  break;
334 
335  case T_pts:
336  parsePolyOutline( aItem );
337  aItem->CloseContour();
338  break;
339 
340  case T_rotate:
341  aItem->m_Orient = parseDouble();
342  NeedRIGHT();
343  break;
344 
345  case T_repeat:
346  aItem->m_RepeatCount = parseInt( -1, 100 );
347  NeedRIGHT();
348  break;
349 
350  case T_incrx:
351  aItem->m_IncrementVector.x = parseDouble();
352  NeedRIGHT();
353  break;
354 
355  case T_incry:
356  aItem->m_IncrementVector.y = parseDouble();
357  NeedRIGHT();
358  break;
359 
360  case T_linewidth:
361  aItem->m_LineWidth = parseDouble();
362  NeedRIGHT();
363  break;
364 
365  default:
366  Unexpected( CurText() );
367  break;
368  }
369  }
370 
371  aItem->SetBoundingBox();
372 }
wxString m_Name
Definition: ws_data_item.h:111
void parseCoordinate(POINT_COORD &aCoord)
int parseInt(int aMin, int aMax)
Function parseInt parses an integer and constrains it between two values.
T
enum T contains all this lexer's tokens.
double parseDouble()
Function parseDouble parses a double.
wxString m_Info
Definition: ws_data_item.h:113
void CloseContour()
Closes the current contour, by storing the index of the last corner of the current polygon in m_polyI...
Definition: ws_data_item.h:246
void parsePolyOutline(WS_DATA_ITEM_POLYGONS *aItem)
parse a list of corners starting by "( pts" and read coordinates.
DPOINT m_IncrementVector
Definition: ws_data_item.h:119
double m_LineWidth
Definition: ws_data_item.h:117
void readOption(WS_DATA_ITEM *aItem)
void SetBoundingBox()
calculate the bounding box of the set polygons
POINT_COORD m_Pos
Definition: ws_data_item.h:115

References WS_DATA_ITEM_POLYGONS::CloseContour(), WS_DATA_ITEM::m_IncrementVector, WS_DATA_ITEM::m_Info, WS_DATA_ITEM::m_LineWidth, WS_DATA_ITEM::m_Name, WS_DATA_ITEM_POLYGONS::m_Orient, WS_DATA_ITEM::m_Pos, WS_DATA_ITEM::m_RepeatCount, parseCoordinate(), parseDouble(), parseInt(), parsePolyOutline(), readOption(), WS_DATA_ITEM_POLYGONS::SetBoundingBox(), DRCRULE_T::T_LEFT, DRCRULE_T::T_name, DRCRULE_T::T_RIGHT, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Parse().

◆ parsePolyOutline()

void PAGE_LAYOUT_READER_PARSER::parsePolyOutline ( WS_DATA_ITEM_POLYGONS aItem)
private

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

Definition at line 374 of file page_layout_reader.cpp.

375 {
376  DPOINT corner;
377 
378  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
379  {
380  if( token == T_LEFT )
381  token = NextTok();
382 
383  switch( token )
384  {
385  case T_xy:
386  corner.x = parseDouble();
387  corner.y = parseDouble();
388  aItem->AppendCorner( corner );
389  NeedRIGHT();
390  break;
391 
392  default:
393  Unexpected( CurText() );
394  break;
395  }
396  }
397 }
void AppendCorner(const DPOINT &aCorner)
add a corner in corner list
Definition: ws_data_item.h:237
T
enum T contains all this lexer's tokens.
double parseDouble()
Function parseDouble parses a double.

References WS_DATA_ITEM_POLYGONS::AppendCorner(), parseDouble(), DRCRULE_T::T_LEFT, DRCRULE_T::T_RIGHT, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by parsePolygon().

◆ parseSetup()

void PAGE_LAYOUT_READER_PARSER::parseSetup ( WS_DATA_MODEL aLayout)
private

Definition at line 249 of file page_layout_reader.cpp.

250 {
251  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
252  {
253  switch( token )
254  {
255  case T_LEFT:
256  break;
257 
258  case T_linewidth:
259  aLayout->m_DefaultLineWidth = parseDouble();
260  NeedRIGHT();
261  break;
262 
263  case T_textsize:
264  aLayout->m_DefaultTextSize.x = parseDouble();
265  aLayout->m_DefaultTextSize.y = parseDouble();
266  NeedRIGHT();
267  break;
268 
269  case T_textlinewidth:
270  aLayout->m_DefaultTextThickness = parseDouble();
271  NeedRIGHT();
272  break;
273 
274  case T_left_margin:
275  aLayout->SetLeftMargin( parseDouble() );
276  NeedRIGHT();
277  break;
278 
279  case T_right_margin:
280  aLayout->SetRightMargin( parseDouble() );
281  NeedRIGHT();
282  break;
283 
284  case T_top_margin:
285  aLayout->SetTopMargin( parseDouble() );
286  NeedRIGHT();
287  break;
288 
289  case T_bottom_margin:
290  aLayout->SetBottomMargin( parseDouble() );
291  NeedRIGHT();
292  break;
293 
294  default:
295  Unexpected( CurText() );
296  break;
297  }
298  }
299 
300  // The file is well-formed. If it has no further items, then that's the way the
301  // user wants it.
302  aLayout->AllowVoidList( true );
303 }
T
enum T contains all this lexer's tokens.
double parseDouble()
Function parseDouble parses a double.
DSIZE m_DefaultTextSize
Definition: ws_data_model.h:56
void AllowVoidList(bool Allow)
In Kicad applications, a page layout description is needed So if the list is empty,...
void SetLeftMargin(double aMargin)
Definition: ws_data_model.h:85
void SetTopMargin(double aMargin)
Definition: ws_data_model.h:91
void SetBottomMargin(double aMargin)
Definition: ws_data_model.h:94
double m_DefaultLineWidth
Definition: ws_data_model.h:55
double m_DefaultTextThickness
Definition: ws_data_model.h:57
void SetRightMargin(double aMargin)
Definition: ws_data_model.h:88

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

Referenced by Parse().

◆ parseText()

void PAGE_LAYOUT_READER_PARSER::parseText ( WS_DATA_ITEM_TEXT aItem)
private

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

Definition at line 580 of file page_layout_reader.cpp.

581 {
582  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
583  {
584  if( token == T_LEFT )
585  token = NextTok();
586 
587  switch( token )
588  {
589  case T_comment:
590  NeedSYMBOLorNUMBER();
591  aItem->m_Info = FromUTF8();
592  NeedRIGHT();
593  break;
594 
595  case T_option:
596  readOption( aItem );
597  break;
598 
599  case T_name:
600  NeedSYMBOLorNUMBER();
601  aItem->m_Name = FromUTF8();
602  NeedRIGHT();
603  break;
604 
605  case T_pos:
606  parseCoordinate( aItem->m_Pos );
607  break;
608 
609  case T_repeat:
610  aItem->m_RepeatCount = parseInt( -1, 100 );
611  NeedRIGHT();
612  break;
613 
614  case T_incrx:
615  aItem->m_IncrementVector.x = parseDouble();
616  NeedRIGHT();
617  break;
618 
619  case T_incry:
620  aItem->m_IncrementVector.y = parseDouble();
621  NeedRIGHT();
622  break;
623 
624  case T_incrlabel:
625  aItem->m_IncrementLabel = parseInt(INT_MIN, INT_MAX);
626  NeedRIGHT();
627  break;
628 
629  case T_maxlen:
630  aItem->m_BoundingBoxSize.x = parseDouble();
631  NeedRIGHT();
632  break;
633 
634  case T_maxheight:
635  aItem->m_BoundingBoxSize.y = parseDouble();
636  NeedRIGHT();
637  break;
638 
639  case T_font:
640  for( token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
641  {
642  switch( token )
643  {
644  case T_LEFT:
645  break;
646 
647  case T_bold:
648  aItem->m_Bold = true;
649  break;
650 
651  case T_italic:
652  aItem->m_Italic = true;
653  break;
654 
655  case T_size:
656  aItem->m_TextSize.x = parseDouble();
657  aItem->m_TextSize.y = parseDouble();
658  NeedRIGHT();
659  break;
660 
661  case T_linewidth:
662  aItem->m_LineWidth = parseDouble();
663  NeedRIGHT();
664  break;
665 
666  default:
667  Unexpected( CurText() );
668  break;
669  }
670  }
671  break;
672 
673  case T_justify:
674  for( token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
675  {
676  switch( token )
677  {
678  case T_center:
681  break;
682 
683  case T_left:
685  break;
686 
687  case T_right:
689  break;
690 
691  case T_top:
693  break;
694 
695  case T_bottom:
697  break;
698 
699  default:
700  Unexpected( CurText() );
701  break;
702  }
703  }
704  break;
705 
706  case T_rotate:
707  aItem->m_Orient = parseDouble();
708  NeedRIGHT();
709  break;
710 
711  default:
712  Unexpected( CurText() );
713  break;
714  }
715  }
716 }
wxString m_Name
Definition: ws_data_item.h:111
void parseCoordinate(POINT_COORD &aCoord)
int parseInt(int aMin, int aMax)
Function parseInt parses an integer and constrains it between two values.
T
enum T contains all this lexer's tokens.
double parseDouble()
Function parseDouble parses a double.
wxString m_Info
Definition: ws_data_item.h:113
EDA_TEXT_HJUSTIFY_T m_Hjustify
Definition: ws_data_item.h:304
EDA_TEXT_VJUSTIFY_T m_Vjustify
Definition: ws_data_item.h:305
DPOINT m_IncrementVector
Definition: ws_data_item.h:119
double m_LineWidth
Definition: ws_data_item.h:117
void readOption(WS_DATA_ITEM *aItem)
int m_IncrementLabel
Definition: ws_data_item.h:121
POINT_COORD m_Pos
Definition: ws_data_item.h:115

References GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, WS_DATA_ITEM_TEXT::m_Bold, WS_DATA_ITEM_TEXT::m_BoundingBoxSize, WS_DATA_ITEM_TEXT::m_Hjustify, WS_DATA_ITEM::m_IncrementLabel, WS_DATA_ITEM::m_IncrementVector, WS_DATA_ITEM::m_Info, WS_DATA_ITEM_TEXT::m_Italic, WS_DATA_ITEM::m_LineWidth, WS_DATA_ITEM::m_Name, WS_DATA_ITEM_TEXT::m_Orient, WS_DATA_ITEM::m_Pos, WS_DATA_ITEM::m_RepeatCount, WS_DATA_ITEM_TEXT::m_TextSize, WS_DATA_ITEM_TEXT::m_Vjustify, parseCoordinate(), parseDouble(), parseInt(), readOption(), DRCRULE_T::T_LEFT, DRCRULE_T::T_name, DRCRULE_T::T_RIGHT, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Parse().

◆ readOption()

void PAGE_LAYOUT_READER_PARSER::readOption ( WS_DATA_ITEM aItem)
private

Definition at line 496 of file page_layout_reader.cpp.

497 {
498  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
499  {
500  switch( token )
501  {
502  case T_page1only: aItem->SetPage1Option( FIRST_PAGE_ONLY ); break;
503  case T_notonpage1: aItem->SetPage1Option( SUBSEQUENT_PAGES ); break;
504  default: Unexpected( CurText() ); break;
505  }
506  }
507 }
void SetPage1Option(PAGE_OPTION aChoice)
Definition: ws_data_item.h:154
T
enum T contains all this lexer's tokens.

References FIRST_PAGE_ONLY, WS_DATA_ITEM::SetPage1Option(), SUBSEQUENT_PAGES, and DRCRULE_T::T_RIGHT.

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

◆ readPngdata()

void PAGE_LAYOUT_READER_PARSER::readPngdata ( WS_DATA_ITEM_BITMAP aItem)
private

Definition at line 462 of file page_layout_reader.cpp.

463 {
464  std::string tmp;
465 
466  for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
467  {
468  if( token == T_LEFT )
469  token = NextTok();
470 
471  switch( token )
472  {
473  case T_data:
474  NeedSYMBOLorNUMBER();
475  tmp += CurStr();
476  tmp += "\n";
477  NeedRIGHT();
478  break;
479 
480  default:
481  Unexpected( CurText() );
482  break;
483  }
484  }
485 
486  tmp += "EndData";
487 
488  wxString msg;
489  STRING_LINE_READER str_reader( tmp, wxT("Png kicad_wks data") );
490 
491  if( ! aItem->m_ImageBitmap->LoadData( str_reader, msg ) )
492  wxLogMessage(msg);
493 }
BITMAP_BASE * m_ImageBitmap
Definition: ws_data_item.h:366
T
enum T contains all this lexer's tokens.
bool LoadData(LINE_READER &aLine, wxString &aErrorMsg)
Load an image data saved by SaveData (png, in Hexadecimal form)
STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254

References BITMAP_BASE::LoadData(), WS_DATA_ITEM_BITMAP::m_ImageBitmap, DRCRULE_T::T_LEFT, and DRCRULE_T::T_RIGHT.

Referenced by parseBitmap().


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