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 46 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 118 of file drawing_sheet_parser.cpp.

119 :
120 DRAWING_SHEET_LEXER( aLine, aSource ),
122{
123}

Member Function Documentation

◆ Parse()

void DRAWING_SHEET_PARSER::Parse ( DS_DATA_MODEL aLayout)

Definition at line 200 of file drawing_sheet_parser.cpp.

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

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 452 of file drawing_sheet_parser.cpp.

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

References image, DS_DATA_ITEM_BITMAP::m_ImageBitmap, 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(), 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 804 of file drawing_sheet_parser.cpp.

805{
806 aCoord.m_Pos.x = parseDouble();
807 aCoord.m_Pos.y = parseDouble();
808
809 for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
810 {
811 switch( token )
812 {
813 case T_ltcorner: aCoord.m_Anchor = LT_CORNER; break;
814 case T_lbcorner: aCoord.m_Anchor = LB_CORNER; break;
815 case T_rbcorner: aCoord.m_Anchor = RB_CORNER; break;
816 case T_rtcorner: aCoord.m_Anchor = RT_CORNER; break;
817 default: Unexpected( CurText() ); break;
818 }
819 }
820}
VECTOR2D m_Pos
Definition: ds_data_item.h:80
@ RB_CORNER
Definition: ds_data_item.h:49
@ RT_CORNER
Definition: ds_data_item.h:50
@ LT_CORNER
Definition: ds_data_item.h:52
@ LB_CORNER
Definition: ds_data_item.h:51

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 845 of file drawing_sheet_parser.cpp.

846{
847 T token = NextTok();
848
849 if( token != T_NUMBER )
850 Expecting( T_NUMBER );
851
852
853 return DSNLEXER::parseDouble();
854}
double parseDouble()
Parse the current token as an ASCII numeric string with possible leading whitespace into a double pre...
Definition: dsnlexer.cpp:825

References DSNLEXER::parseDouble().

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 568 of file drawing_sheet_parser.cpp.

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

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 260 of file drawing_sheet_parser.cpp.

261{
262 // The older files had no versioning and their first token after the initial left parenthesis
263 // was a `page_layout` or `drawing_sheet` token. The newer files have versions and have a
264 // `kicad_wks` token instead.
265
266 if( aHeaderType == T_kicad_wks || aHeaderType == T_drawing_sheet )
267 {
268 NeedLEFT();
269
270 T tok = NextTok();
271
272 if( tok == T_version )
273 {
275
277 throw FUTURE_FORMAT_ERROR( FromUTF8() );
278
279 NeedRIGHT();
280 }
281 else
282 {
283 Expecting( T_version );
284 }
285
286 // Ignore generator info.
287 NeedLEFT();
288 NeedSYMBOL();
289 NeedSYMBOL();
290 NeedRIGHT();
291 }
292 else
293 {
294 // We assign version 0 to files that were created before there was any versioning of
295 // worksheets. The below line is not strictly necessary, as `m_requiredVersion` is already
296 // initialized to 0 in the constructor.
298 }
299}
#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:175

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 822 of file drawing_sheet_parser.cpp.

823{
824 T token = NextTok();
825
826 if( token != T_NUMBER )
827 Expecting( T_NUMBER );
828
829 return atoi( CurText() );
830}

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 832 of file drawing_sheet_parser.cpp.

833{
834 int val = parseInt();
835
836 if( val < aMin )
837 val = aMin;
838 else if( val > aMax )
839 val = aMax;
840
841 return val;
842}

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 358 of file drawing_sheet_parser.cpp.

359{
360 for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
361 {
362 if( token == T_LEFT )
363 token = NextTok();
364
365 switch( token )
366 {
367 case T_comment:
368 NeedSYMBOLorNUMBER();
369 aItem->m_Info = FromUTF8();
370 NeedRIGHT();
371 break;
372
373 case T_pos:
374 parseCoordinate( aItem->m_Pos );
375 break;
376
377 case T_name:
378 NeedSYMBOLorNUMBER();
379 aItem->m_Name = FromUTF8();
380 NeedRIGHT();
381 break;
382
383 case T_option:
384 readOption( aItem );
385 break;
386
387 case T_pts:
388 parsePolyOutline( aItem );
389 aItem->CloseContour();
390 break;
391
392 case T_rotate:
394 NeedRIGHT();
395 break;
396
397 case T_repeat:
398 aItem->m_RepeatCount = parseInt( -1, 100 );
399 NeedRIGHT();
400 break;
401
402 case T_incrx:
404 NeedRIGHT();
405 break;
406
407 case T_incry:
409 NeedRIGHT();
410 break;
411
412 case T_linewidth:
413 aItem->m_LineWidth = parseDouble();
414 NeedRIGHT();
415 break;
416
417 default:
418 Unexpected( CurText() );
419 break;
420 }
421 }
422
423 aItem->SetBoundingBox();
424}
void parsePolyOutline(DS_DATA_ITEM_POLYGONS *aItem)
Parse a list of corners starting by "( pts" and read coordinates.
void SetBoundingBox()
Calculate the bounding box of the set polygons.
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
@ DEGREES_T
Definition: eda_angle.h:31

References DS_DATA_ITEM_POLYGONS::CloseContour(), DEGREES_T, 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 426 of file drawing_sheet_parser.cpp.

427{
428 VECTOR2D corner;
429
430 for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
431 {
432 if( token == T_LEFT )
433 token = NextTok();
434
435 switch( token )
436 {
437 case T_xy:
438 corner.x = parseDouble();
439 corner.y = parseDouble();
440 aItem->AppendCorner( corner );
441 NeedRIGHT();
442 break;
443
444 default:
445 Unexpected( CurText() );
446 break;
447 }
448 }
449}
void AppendCorner(const VECTOR2D &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 301 of file drawing_sheet_parser.cpp.

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

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 638 of file drawing_sheet_parser.cpp.

639{
640 if( m_requiredVersion < 20210606 )
642
643 for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
644 {
645 if( token == T_LEFT )
646 token = NextTok();
647
648 switch( token )
649 {
650 case T_comment:
651 NeedSYMBOLorNUMBER();
652 aItem->m_Info = FromUTF8();
653 NeedRIGHT();
654 break;
655
656 case T_option:
657 readOption( aItem );
658 break;
659
660 case T_name:
661 NeedSYMBOLorNUMBER();
662 aItem->m_Name = FromUTF8();
663 NeedRIGHT();
664 break;
665
666 case T_pos:
667 parseCoordinate( aItem->m_Pos );
668 break;
669
670 case T_repeat:
671 aItem->m_RepeatCount = parseInt( -1, 100 );
672 NeedRIGHT();
673 break;
674
675 case T_incrx:
677 NeedRIGHT();
678 break;
679
680 case T_incry:
682 NeedRIGHT();
683 break;
684
685 case T_incrlabel:
686 aItem->m_IncrementLabel = parseInt(INT_MIN, INT_MAX);
687 NeedRIGHT();
688 break;
689
690 case T_maxlen:
692 NeedRIGHT();
693 break;
694
695 case T_maxheight:
697 NeedRIGHT();
698 break;
699
700 case T_font:
701 {
702 wxString faceName;
703
704 aItem->m_TextColor = COLOR4D::UNSPECIFIED;
705
706 for( token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
707 {
708 switch( token )
709 {
710 case T_LEFT:
711 break;
712
713 case T_face:
714 NeedSYMBOL();
715 faceName = FromUTF8();
716 NeedRIGHT();
717 break;
718
719 case T_bold:
720 aItem->m_Bold = true;
721 break;
722
723 case T_italic:
724 aItem->m_Italic = true;
725 break;
726
727 case T_size:
728 aItem->m_TextSize.x = parseDouble();
729 aItem->m_TextSize.y = parseDouble();
730 NeedRIGHT();
731 break;
732
733 case T_color:
734 aItem->m_TextColor.r = parseInt( 0, 255 ) / 255.0;
735 aItem->m_TextColor.g = parseInt( 0, 255 ) / 255.0;
736 aItem->m_TextColor.b = parseInt( 0, 255 ) / 255.0;
737 aItem->m_TextColor.a = Clamp( parseDouble(), 0.0, 1.0 );
738 NeedRIGHT();
739 break;
740
741 case T_linewidth:
742 aItem->m_LineWidth = parseDouble();
743 NeedRIGHT();
744 break;
745
746 default:
747 Unexpected( CurText() );
748 break;
749 }
750 }
751
752 if( !faceName.IsEmpty() )
753 aItem->m_Font = KIFONT::FONT::GetFont( faceName, aItem->m_Bold, aItem->m_Italic );
754
755 break;
756 }
757
758 case T_justify:
759 for( token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
760 {
761 switch( token )
762 {
763 case T_center:
766 break;
767
768 case T_left:
770 break;
771
772 case T_right:
774 break;
775
776 case T_top:
778 break;
779
780 case T_bottom:
782 break;
783
784 default:
785 Unexpected( CurText() );
786 break;
787 }
788 }
789 break;
790
791 case T_rotate:
792 aItem->m_Orient = parseDouble();
793 NeedRIGHT();
794 break;
795
796 default:
797 Unexpected( CurText() );
798 break;
799 }
800 }
801}
KIFONT::FONT * m_Font
Definition: ds_data_item.h:342
GR_TEXT_H_ALIGN_T m_Hjustify
Definition: ds_data_item.h:338
KIGFX::COLOR4D m_TextColor
Definition: ds_data_item.h:344
VECTOR2D m_BoundingBoxSize
Definition: ds_data_item.h:345
GR_TEXT_V_ALIGN_T m_Vjustify
Definition: ds_data_item.h:339
int m_IncrementLabel
Definition: ds_data_item.h:205
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:65
double r
Red component.
Definition: color4d.h:390
double g
Green component.
Definition: color4d.h:391
double a
Alpha component.
Definition: color4d.h:393
double b
Blue component.
Definition: color4d.h:392
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
constexpr T Clamp(const T &lower, const T &value, const T &upper)
Limit value within the range lower <= value <= upper.
Definition: util.h:64

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, Clamp(), ConvertToNewOverbarNotation(), KIGFX::COLOR4D::g, KIFONT::FONT::GetFont(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, DS_DATA_ITEM_TEXT::m_Bold, DS_DATA_ITEM_TEXT::m_BoundingBoxSize, DS_DATA_ITEM_TEXT::m_Font, 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_TextColor, DS_DATA_ITEM_TEXT::m_TextSize, DS_DATA_ITEM_TEXT::m_Vjustify, parseCoordinate(), parseDouble(), parseInt(), KIGFX::COLOR4D::r, 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 554 of file drawing_sheet_parser.cpp.

555{
556 for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
557 {
558 switch( token )
559 {
560 case T_page1only: aItem->SetPage1Option( FIRST_PAGE_ONLY ); break;
561 case T_notonpage1: aItem->SetPage1Option( SUBSEQUENT_PAGES ); break;
562 default: Unexpected( CurText() ); break;
563 }
564 }
565}
void SetPage1Option(PAGE_OPTION aChoice)
Definition: ds_data_item.h:134
@ FIRST_PAGE_ONLY
Definition: ds_data_item.h:58
@ SUBSEQUENT_PAGES
Definition: ds_data_item.h:59

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 520 of file drawing_sheet_parser.cpp.

521{
522 std::string tmp;
523
524 for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
525 {
526 if( token == T_LEFT )
527 token = NextTok();
528
529 switch( token )
530 {
531 case T_data:
532 NeedSYMBOLorNUMBER();
533 tmp += CurStr();
534 tmp += "\n";
535 NeedRIGHT();
536 break;
537
538 default:
539 Unexpected( CurText() );
540 break;
541 }
542 }
543
544 tmp += "EndData";
545
546 wxString msg;
547 STRING_LINE_READER str_reader( tmp, wxT("Png kicad_wks data") );
548
549 if( ! aItem->m_ImageBitmap->LoadData( str_reader, msg ) )
550 wxLogMessage(msg);
551}
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:241

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 53 of file drawing_sheet_parser.cpp.

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


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