KiCad PCB EDA Suite
PAGE_LAYOUT_READER_PARSER Class Reference

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

Inheritance diagram for PAGE_LAYOUT_READER_PARSER:

Public Member Functions

 PAGE_LAYOUT_READER_PARSER (const char *aLine, const wxString &aSource)
 
void Parse (WORKSHEET_LAYOUT *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 (WORKSHEET_LAYOUT *aLayout)
 
void parseGraphic (WORKSHEET_DATAITEM *aItem)
 parse a graphic item starting by "(line" or "(rect" and read parameters. More...
 
void parseText (WORKSHEET_DATAITEM_TEXT *aItem)
 parse a text item starting by "(tbtext" and read parameters. More...
 
void parsePolygon (WORKSHEET_DATAITEM_POLYPOLYGON *aItem)
 parse a polygon item starting by "( polygon" and read parameters. More...
 
void parsePolyOutline (WORKSHEET_DATAITEM_POLYPOLYGON *aItem)
 parse a list of corners starting by "( pts" and read coordinates. More...
 
void parseBitmap (WORKSHEET_DATAITEM_BITMAP *aItem)
 parse a bitmap item starting by "( bitmap" and read parameters. More...
 
void parseCoordinate (POINT_COORD &aCoord)
 
void readOption (WORKSHEET_DATAITEM *aItem)
 
void readPngdata (WORKSHEET_DATAITEM_BITMAP *aItem)
 

Detailed Description

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

Definition at line 50 of file page_layout_reader.cpp.

Constructor & Destructor Documentation

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

void PAGE_LAYOUT_READER_PARSER::Parse ( WORKSHEET_LAYOUT aLayout)

Definition at line 116 of file page_layout_reader.cpp.

References WORKSHEET_LAYOUT::Append(), parseBitmap(), parseGraphic(), parsePolygon(), parseSetup(), parseText(), WORKSHEET_DATAITEM::WS_RECT, and WORKSHEET_DATAITEM::WS_SEGMENT.

Referenced by WORKSHEET_LAYOUT::SetPageLayout().

117 {
118  T token;
119  WORKSHEET_DATAITEM * item;
120 
121  LOCALE_IO toggle;
122 
123  while( ( token = NextTok() ) != T_RIGHT )
124  {
125  if( token == T_EOF)
126  break;
127 
128  if( token == T_LEFT )
129  token = NextTok();
130 
131  if( token == T_page_layout )
132  continue;
133 
134  switch( token )
135  {
136  case T_setup: // Defines default values for graphic items
137  parseSetup( aLayout );
138  break;
139 
140  case T_line:
142  parseGraphic( item );
143  aLayout->Append( item );
144  break;
145 
146  case T_rect:
148  parseGraphic( item );
149  aLayout->Append( item );
150  break;
151 
152  case T_polygon:
153  item = new WORKSHEET_DATAITEM_POLYPOLYGON();
155  aLayout->Append( item );
156  break;
157 
158  case T_bitmap:
159  item = new WORKSHEET_DATAITEM_BITMAP( NULL );
161  aLayout->Append( item );
162  break;
163 
164  case T_tbtext:
165  NeedSYMBOLorNUMBER();
166  item = new WORKSHEET_DATAITEM_TEXT( FromUTF8() );
168  aLayout->Append( item );
169  break;
170 
171  default:
172  Unexpected( CurText() );
173  break;
174  }
175  }
176 }
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
void parseText(WORKSHEET_DATAITEM_TEXT *aItem)
parse a text item starting by "(tbtext" and read parameters.
void Append(WORKSHEET_DATAITEM *aItem)
Add an item to the list of items.
void parseBitmap(WORKSHEET_DATAITEM_BITMAP *aItem)
parse a bitmap item starting by "( bitmap" and read parameters.
void parseGraphic(WORKSHEET_DATAITEM *aItem)
parse a graphic item starting by "(line" or "(rect" and read parameters.
void parsePolygon(WORKSHEET_DATAITEM_POLYPOLYGON *aItem)
parse a polygon item starting by "( polygon" and read parameters.
void parseSetup(WORKSHEET_LAYOUT *aLayout)
void PAGE_LAYOUT_READER_PARSER::parseBitmap ( WORKSHEET_DATAITEM_BITMAP aItem)
private

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

Definition at line 337 of file page_layout_reader.cpp.

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

Referenced by Parse().

338 {
339  T token;
340  BITMAP_BASE* image = new BITMAP_BASE;
341  aItem->m_ImageBitmap = image;
342 
343  while( ( token = NextTok() ) != T_RIGHT )
344  {
345  if( token == T_EOF)
346  break;
347 
348  if( token == T_LEFT )
349  token = NextTok();
350 
351  switch( token )
352  {
353  case T_name:
354  NeedSYMBOLorNUMBER();
355  aItem->m_Name = FromUTF8();
356  NeedRIGHT();
357  break;
358 
359  case T_pos:
360  parseCoordinate( aItem->m_Pos );
361  break;
362 
363  case T_repeat:
364  aItem->m_RepeatCount = parseInt( -1, 100 );
365  NeedRIGHT();
366  break;
367 
368  case T_incrx:
369  aItem->m_IncrementVector.x = parseDouble();
370  NeedRIGHT();
371  break;
372 
373  case T_incry:
374  aItem->m_IncrementVector.y = parseDouble();
375  NeedRIGHT();
376  break;
377 
378  case T_linewidth:
379  aItem->m_LineWidth = parseDouble();
380  NeedRIGHT();
381  break;
382 
383  case T_scale:
384  aItem->m_ImageBitmap->SetScale( parseDouble() );
385  NeedRIGHT();
386  break;
387 
388  case T_pngdata:
389  readPngdata( aItem );
390  break;
391 
392  case T_option:
393  readOption( aItem );
394  break;
395 
396  default:
397  Unexpected( CurText() );
398  break;
399  }
400  }
401 }
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:83
void readPngdata(WORKSHEET_DATAITEM_BITMAP *aItem)
double parseDouble()
Function parseDouble parses a double.
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:44
void readOption(WORKSHEET_DATAITEM *aItem)
void PAGE_LAYOUT_READER_PARSER::parseCoordinate ( POINT_COORD aCoord)
private

Definition at line 695 of file page_layout_reader.cpp.

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().

696 {
697  T token;
698 
699  aCoord.m_Pos.x = parseDouble();
700  aCoord.m_Pos.y = parseDouble();
701 
702  while( ( token = NextTok() ) != T_RIGHT )
703  {
704  switch( token )
705  {
706  case T_ltcorner:
707  aCoord.m_Anchor = LT_CORNER; // left top corner
708  break;
709 
710  case T_lbcorner:
711  aCoord.m_Anchor = LB_CORNER; // left bottom corner
712  break;
713 
714  case T_rbcorner:
715  aCoord.m_Anchor = RB_CORNER; // right bottom corner
716  break;
717 
718  case T_rtcorner:
719  aCoord.m_Anchor = RT_CORNER; // right top corner
720  break;
721 
722  default:
723  Unexpected( CurText() );
724  break;
725  }
726  }
727 }
double parseDouble()
Function parseDouble parses a double.
double PAGE_LAYOUT_READER_PARSER::parseDouble ( )
private

Function parseDouble parses a double.

Returns
double - the parsed double.

Definition at line 747 of file page_layout_reader.cpp.

References defaultPageLayout.

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

748 {
749  T token = NextTok();
750 
751  if( token != T_NUMBER )
752  Expecting( T_NUMBER );
753 
754  double val = strtod( CurText(), NULL );
755 
756  return val;
757 }
void PAGE_LAYOUT_READER_PARSER::parseGraphic ( WORKSHEET_DATAITEM aItem)
private

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

Definition at line 470 of file page_layout_reader.cpp.

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

Referenced by Parse().

471 {
472  T token;
473 
474  while( ( token = NextTok() ) != T_RIGHT )
475  {
476  if( token == T_EOF)
477  break;
478 
479  if( token == T_LEFT )
480  token = NextTok();
481  else
482  {
483  // If another token than T_LEFT is read here, this is an error
484  // however, due to a old bug in kicad, the token T_end can be found
485  // without T_LEFT in a very few .wks files (perhaps only one in a demo).
486  // So this ugly hack disables the error detection.
487  if( token != T_end )
488  Unexpected( CurText() );
489  }
490 
491  switch( token )
492  {
493  case T_comment:
494  NeedSYMBOLorNUMBER();
495  aItem->m_Info = FromUTF8();
496  NeedRIGHT();
497  break;
498 
499  case T_option:
500  readOption( aItem );
501  break;
502 
503  case T_name:
504  NeedSYMBOLorNUMBER();
505  aItem->m_Name = FromUTF8();
506  NeedRIGHT();
507  break;
508 
509  case T_start:
510  parseCoordinate( aItem->m_Pos );
511  break;
512 
513  case T_end:
514  parseCoordinate( aItem->m_End );
515  break;
516 
517  case T_repeat:
518  aItem->m_RepeatCount = parseInt( -1, 100 );
519  NeedRIGHT();
520  break;
521 
522  case T_incrx:
523  aItem->m_IncrementVector.x = parseDouble();
524  NeedRIGHT();
525  break;
526 
527  case T_incry:
528  aItem->m_IncrementVector.y = parseDouble();
529  NeedRIGHT();
530  break;
531 
532  case T_linewidth:
533  aItem->m_LineWidth = parseDouble();
534  NeedRIGHT();
535  break;
536 
537  default:
538  Unexpected( CurText() );
539  break;
540  }
541  }
542 }
void parseCoordinate(POINT_COORD &aCoord)
int parseInt(int aMin, int aMax)
Function parseInt parses an integer and constrains it between two values.
double parseDouble()
Function parseDouble parses a double.
void readOption(WORKSHEET_DATAITEM *aItem)
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 729 of file page_layout_reader.cpp.

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

730 {
731  T token = NextTok();
732 
733  if( token != T_NUMBER )
734  Expecting( T_NUMBER );
735 
736  int val = atoi( CurText() );
737 
738  if( val < aMin )
739  val = aMin;
740  else if( val > aMax )
741  val = aMax;
742 
743  return val;
744 }
void PAGE_LAYOUT_READER_PARSER::parsePolygon ( WORKSHEET_DATAITEM_POLYPOLYGON 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 234 of file page_layout_reader.cpp.

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

Referenced by Parse().

235 {
236  T token;
237 
238  while( ( token = NextTok() ) != T_RIGHT )
239  {
240  if( token == T_EOF)
241  break;
242 
243  if( token == T_LEFT )
244  token = NextTok();
245 
246  switch( token )
247  {
248  case T_comment:
249  NeedSYMBOLorNUMBER();
250  aItem->m_Info = FromUTF8();
251  NeedRIGHT();
252  break;
253 
254  case T_pos:
255  parseCoordinate( aItem->m_Pos );
256  break;
257 
258  case T_name:
259  NeedSYMBOLorNUMBER();
260  aItem->m_Name = FromUTF8();
261  NeedRIGHT();
262  break;
263 
264  case T_option:
265  readOption( aItem );
266  break;
267 
268  case T_pts:
269  parsePolyOutline( aItem );
270  aItem->CloseContour();
271  break;
272 
273  case T_rotate:
274  aItem->m_Orient = parseDouble();
275  NeedRIGHT();
276  break;
277 
278  case T_repeat:
279  aItem->m_RepeatCount = parseInt( -1, 100 );
280  NeedRIGHT();
281  break;
282 
283  case T_incrx:
284  aItem->m_IncrementVector.x = parseDouble();
285  NeedRIGHT();
286  break;
287 
288  case T_incry:
289  aItem->m_IncrementVector.y = parseDouble();
290  NeedRIGHT();
291  break;
292 
293  case T_linewidth:
294  aItem->m_LineWidth = parseDouble();
295  NeedRIGHT();
296  break;
297 
298  default:
299  Unexpected( CurText() );
300  break;
301  }
302  }
303 
304  aItem->SetBoundingBox();
305 }
void parseCoordinate(POINT_COORD &aCoord)
int parseInt(int aMin, int aMax)
Function parseInt parses an integer and constrains it between two values.
void SetBoundingBox()
calculate the bounding box of the set polygons
double parseDouble()
Function parseDouble parses a double.
void parsePolyOutline(WORKSHEET_DATAITEM_POLYPOLYGON *aItem)
parse a list of corners starting by "( pts" and read coordinates.
void CloseContour()
Closes the current contour, by storing the index of the last corner of the current polygon in m_polyI...
void readOption(WORKSHEET_DATAITEM *aItem)
void PAGE_LAYOUT_READER_PARSER::parsePolyOutline ( WORKSHEET_DATAITEM_POLYPOLYGON aItem)
private

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

Definition at line 307 of file page_layout_reader.cpp.

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

Referenced by parsePolygon().

308 {
309  DPOINT corner;
310  T token;
311 
312  while( ( token = NextTok() ) != T_RIGHT )
313  {
314  if( token == T_EOF)
315  break;
316 
317  if( token == T_LEFT )
318  token = NextTok();
319 
320  switch( token )
321  {
322  case T_xy:
323  corner.x = parseDouble();
324  corner.y = parseDouble();
325  aItem->AppendCorner( corner );
326  NeedRIGHT();
327  break;
328 
329  default:
330  Unexpected( CurText() );
331  break;
332  }
333  }
334 }
void AppendCorner(const DPOINT &aCorner)
add a corner in corner list
double parseDouble()
Function parseDouble parses a double.
void PAGE_LAYOUT_READER_PARSER::parseSetup ( WORKSHEET_LAYOUT aLayout)
private

Definition at line 178 of file page_layout_reader.cpp.

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

Referenced by Parse().

179 {
180  T token;
181  while( ( token = NextTok() ) != T_RIGHT )
182  {
183  if( token == T_EOF)
184  break;
185 
186  switch( token )
187  {
188  case T_LEFT:
189  break;
190 
191  case T_linewidth:
193  NeedRIGHT();
194  break;
195 
196  case T_textsize:
199  NeedRIGHT();
200  break;
201 
202  case T_textlinewidth:
204  NeedRIGHT();
205  break;
206 
207  case T_left_margin:
208  aLayout->SetLeftMargin( parseDouble() );
209  NeedRIGHT();
210  break;
211 
212  case T_right_margin:
213  aLayout->SetRightMargin( parseDouble() );
214  NeedRIGHT();
215  break;
216 
217  case T_top_margin:
218  aLayout->SetTopMargin( parseDouble() );
219  NeedRIGHT();
220  break;
221 
222  case T_bottom_margin:
223  aLayout->SetBottomMargin( parseDouble() );
224  NeedRIGHT();
225  break;
226 
227  default:
228  Unexpected( CurText() );
229  break;
230  }
231  }
232 }
static DSIZE m_DefaultTextSize
double parseDouble()
Function parseDouble parses a double.
void SetLeftMargin(double aMargin)
void SetTopMargin(double aMargin)
void SetBottomMargin(double aMargin)
static double m_DefaultTextThickness
static double m_DefaultLineWidth
void SetRightMargin(double aMargin)
void PAGE_LAYOUT_READER_PARSER::parseText ( WORKSHEET_DATAITEM_TEXT aItem)
private

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

Definition at line 545 of file page_layout_reader.cpp.

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, WORKSHEET_DATAITEM_TEXT::m_BoundingBoxSize, WORKSHEET_DATAITEM_TEXT::m_Hjustify, WORKSHEET_DATAITEM::m_IncrementLabel, WORKSHEET_DATAITEM::m_IncrementVector, WORKSHEET_DATAITEM::m_Info, WORKSHEET_DATAITEM::m_LineWidth, WORKSHEET_DATAITEM::m_Name, WORKSHEET_DATAITEM_TEXT::m_Orient, WORKSHEET_DATAITEM::m_Pos, WORKSHEET_DATAITEM::m_RepeatCount, WORKSHEET_DATAITEM_TEXT::m_TextSize, WORKSHEET_DATAITEM_TEXT::m_Vjustify, parseCoordinate(), parseDouble(), parseInt(), readOption(), WORKSHEET_DATAITEM_TEXT::SetBold(), WORKSHEET_DATAITEM_TEXT::SetItalic(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Parse().

546 {
547  T token;
548 
549  while( ( token = NextTok() ) != T_RIGHT )
550  {
551  if( token == T_EOF)
552  break;
553 
554  if( token == T_LEFT )
555  token = NextTok();
556 
557  switch( token )
558  {
559  case T_comment:
560  NeedSYMBOLorNUMBER();
561  aItem->m_Info = FromUTF8();
562  NeedRIGHT();
563  break;
564 
565  case T_option:
566  readOption( aItem );
567  break;
568 
569  case T_name:
570  NeedSYMBOLorNUMBER();
571  aItem->m_Name = FromUTF8();
572  NeedRIGHT();
573  break;
574 
575  case T_pos:
576  parseCoordinate( aItem->m_Pos );
577  break;
578 
579  case T_repeat:
580  aItem->m_RepeatCount = parseInt( -1, 100 );
581  NeedRIGHT();
582  break;
583 
584  case T_incrx:
585  aItem->m_IncrementVector.x = parseDouble();
586  NeedRIGHT();
587  break;
588 
589  case T_incry:
590  aItem->m_IncrementVector.y = parseDouble();
591  NeedRIGHT();
592  break;
593 
594  case T_incrlabel:
595  aItem->m_IncrementLabel = parseInt(INT_MIN, INT_MAX);
596  NeedRIGHT();
597  break;
598 
599  case T_maxlen:
600  aItem->m_BoundingBoxSize.x = parseDouble();
601  NeedRIGHT();
602  break;
603 
604  case T_maxheight:
605  aItem->m_BoundingBoxSize.y = parseDouble();
606  NeedRIGHT();
607  break;
608 
609  case T_font:
610  while( ( token = NextTok() ) != T_RIGHT )
611  {
612  if( token == T_EOF)
613  break;
614 
615  switch( token )
616  {
617  case T_LEFT:
618  break;
619 
620  case T_bold:
621  aItem->SetBold( true );
622  break;
623 
624  case T_italic:
625  aItem->SetItalic( true );
626  break;
627 
628  case T_size:
629  aItem->m_TextSize.x = parseDouble();
630  aItem->m_TextSize.y = parseDouble();
631  NeedRIGHT();
632  break;
633 
634  case T_linewidth:
635  aItem->m_LineWidth = parseDouble();
636  NeedRIGHT();
637  break;
638 
639  default:
640  Unexpected( CurText() );
641  break;
642  }
643  }
644  break;
645 
646  case T_justify:
647  while( ( token = NextTok() ) != T_RIGHT )
648  {
649  if( token == T_EOF)
650  break;
651 
652  switch( token )
653  {
654  case T_center:
657  break;
658 
659  case T_left:
661  break;
662 
663  case T_right:
665  break;
666 
667  case T_top:
669  break;
670 
671  case T_bottom:
673  break;
674 
675  default:
676  Unexpected( CurText() );
677  break;
678  }
679  }
680  break;
681 
682  case T_rotate:
683  aItem->m_Orient = parseDouble();
684  NeedRIGHT();
685  break;
686 
687  default:
688  Unexpected( CurText() );
689  break;
690  }
691  }
692 }
EDA_TEXT_HJUSTIFY_T m_Hjustify
void parseCoordinate(POINT_COORD &aCoord)
int parseInt(int aMin, int aMax)
Function parseInt parses an integer and constrains it between two values.
EDA_TEXT_VJUSTIFY_T m_Vjustify
double parseDouble()
Function parseDouble parses a double.
void SetItalic(bool aState)
Function SetItalic Toggles on/off the italic option flag.
void SetBold(bool aState)
Function SetBold Toggles on/off the bold option flag.
void readOption(WORKSHEET_DATAITEM *aItem)
void PAGE_LAYOUT_READER_PARSER::readOption ( WORKSHEET_DATAITEM aItem)
private

Definition at line 443 of file page_layout_reader.cpp.

References WORKSHEET_DATAITEM::SetPage1Option().

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

444 {
445  T token;
446 
447  while( ( token = NextTok() ) != T_RIGHT )
448  {
449  if( token == T_EOF)
450  break;
451 
452  switch( token )
453  {
454  case T_page1only:
455  aItem->SetPage1Option( 1 );
456  break;
457 
458  case T_notonpage1:
459  aItem->SetPage1Option( -1 );
460  break;
461 
462  default:
463  Unexpected( CurText() );
464  break;
465  }
466  }
467 }
void SetPage1Option(int aChoice)
Set the option for page 1.
void PAGE_LAYOUT_READER_PARSER::readPngdata ( WORKSHEET_DATAITEM_BITMAP aItem)
private

Definition at line 403 of file page_layout_reader.cpp.

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

Referenced by parseBitmap().

404 {
405  std::string tmp;
406  T token;
407 
408  while( ( token = NextTok() ) != T_RIGHT )
409  {
410  if( token == T_EOF)
411  break;
412 
413  if( token == T_LEFT )
414  token = NextTok();
415 
416  switch( token )
417  {
418  case T_data:
419  NeedSYMBOLorNUMBER();
420  tmp += CurStr();
421  tmp += "\n";
422  NeedRIGHT();
423  break;
424 
425  default:
426  Unexpected( CurText() );
427  break;
428  }
429  }
430 
431  tmp += "EndData";
432 
433  wxString msg;
434  STRING_LINE_READER str_reader( tmp, wxT("Png kicad_wks data") );
435 
436  if( ! aItem->m_ImageBitmap->LoadData( str_reader, msg ) )
437  {
438  wxLogMessage(msg);
439  }
440 }
bool LoadData(LINE_READER &aLine, wxString &aErrorMsg)
Load an image data saved by SaveData (png, in Hexadecimal form)
Class STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254

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