31#include <fmt/format.h>
35#include <wx/mstream.h>
36#include <wx/tokenzr.h>
74using namespace TSCHEMATIC_T;
79 unsigned aLineCount,
SCH_SHEET* aRootSheet,
81 SCHEMATIC_LEXER( aLineReader ),
100 unsigned progressDelta = std::max( 50u,
m_lineCount / 10 );
119 KIID id( FromUTF8() );
136 else if( token == T_no )
139 Expecting(
"yes or no" );
150 bool ret = aDefaultValue;
152 if( PrevTok() == T_LEFT )
157 if(
static_cast<int>( token ) ==
DSN_RIGHT )
158 return aDefaultValue;
162 else if( token == T_no )
165 Expecting(
"yes or no" );
172 return aDefaultValue;
190 bool versionChecked =
false;
201 versionChecked =
true;
204 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
206 if( token != T_LEFT )
232 case T_generator_version:
255 aSymbolLibMap[symbol->
GetName()] = symbol;
260 wxString warning = wxString::Format(
261 _(
"Error parsing symbol at line %d: %s\nSkipping symbol and continuing." ),
262 CurLineNumber(), e.
What() );
274 Expecting(
"symbol, generator, or generator_version" );
288 if( CurTok() == T_LEFT )
292 if( CurTok() == T_symbol )
297 const std::vector<wxString>* embeddedFonts =
304 textItem->ResolveFont( embeddedFonts );
310 wxString msg = wxString::Format(
_(
"Cannot parse %s as a symbol" ),
311 GetTokenString( CurTok() ) );
322 wxCHECK_MSG( CurTok() == T_symbol,
nullptr,
323 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a symbol." ) );
330 std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>( wxEmptyString );
332 symbol->SetUnitCount( 1,
true );
336 if( !IsSymbol( token ) )
337 THROW_PARSE_ERROR(
_(
"Invalid symbol name" ), CurSource(), CurLine(), CurLineNumber(), CurOffset() );
344 name.Replace( wxS(
"{slash}" ), wxT(
"/" ) );
351 if(
static_cast<int>(
name.size() ) > bad_pos )
353 wxString msg = wxString::Format(
_(
"Symbol %s contains invalid character '%c'" ),
362 CurLineNumber(), CurOffset() );
367 symbol->SetLibId(
id );
369 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
371 if( token != T_LEFT )
379 symbol->SetGlobalPower();
382 if( token == T_RIGHT )
385 if( token == T_local )
386 symbol->SetLocalPower();
387 else if( token != T_global )
388 Expecting(
"global or local" );
405 case T_exclude_from_sim:
406 symbol->SetExcludedFromSim(
parseBool() );
411 symbol->SetExcludedFromBOM( !
parseBool() );
416 symbol->SetExcludedFromBoard( !
parseBool() );
421 symbol->SetExcludedFromPosFiles( !
parseBool() );
425 case T_duplicate_pin_numbers_are_jumpers:
426 symbol->SetDuplicatePinNumbersAreJumpers(
parseBool() );
430 case T_jumper_pin_groups:
432 std::vector<std::set<wxString>>& groups = symbol->JumperPinGroups();
433 std::set<wxString>* currentGroup =
nullptr;
435 for( token = NextTok(); currentGroup || token != T_RIGHT; token = NextTok() )
437 switch(
static_cast<int>( token ) )
440 currentGroup = &groups.emplace_back();
444 currentGroup->insert( FromUTF8() );
448 currentGroup =
nullptr;
452 Expecting(
"list of pin names" );
467 if( !IsSymbol( token ) )
470 CurLineNumber(), CurOffset() );
478 name.Replace( wxS(
"{slash}" ), wxT(
"/" ) );
480 symbol->SetParentName(
name );
489 if( !IsSymbol( token ) )
492 CurLineNumber(), CurOffset() );
500 name.Replace( wxS(
"{slash}" ), wxT(
"/" ) );
504 error.Printf(
_(
"Invalid symbol unit name prefix %s" ),
name.c_str() );
505 THROW_PARSE_ERROR( error, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
510 wxStringTokenizer tokenizer(
name,
"_" );
512 if( tokenizer.CountTokens() != 2 )
514 error.Printf(
_(
"Invalid symbol unit name suffix %s" ),
name.c_str() );
515 THROW_PARSE_ERROR( error, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
518 if( !tokenizer.GetNextToken().ToLong( &tmp ) )
520 error.Printf(
_(
"Invalid symbol unit number %s" ),
name.c_str() );
521 THROW_PARSE_ERROR( error, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
524 m_unit =
static_cast<int>( tmp );
526 if( !tokenizer.GetNextToken().ToLong( &tmp ) )
528 error.Printf(
_(
"Invalid symbol body style number %s" ),
name.c_str() );
529 THROW_PARSE_ERROR( error, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
535 symbol->SetBodyStyleCount(
m_bodyStyle,
false,
false );
537 if(
m_unit > symbol->GetUnitCount() )
538 symbol->SetUnitCount(
m_unit,
false );
540 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
542 if( token != T_LEFT )
552 if( IsSymbol( token ) )
553 symbol->GetUnitDisplayNames()[
m_unit] = FromUTF8();
570 wxCHECK_MSG( item,
nullptr,
"Invalid draw item pointer." );
573 symbol->AddDrawItem( item,
false );
577 Expecting(
"arc, bezier, circle, ellipse, ellipse_arc, pin, polyline, "
578 "rectangle, or text" );
599 wxCHECK_MSG( item,
nullptr,
"Invalid draw item pointer." );
602 symbol->AddDrawItem( item,
false );
605 case T_embedded_fonts:
607 symbol->SetAreFontsEmbedded(
parseBool() );
612 case T_embedded_files:
615 embeddedFilesParser.SyncLineReaderWith( *
this );
619 embeddedFilesParser.
ParseEmbedded( symbol->GetEmbeddedFiles() );
627 for(
int tok = embeddedFilesParser.NextTok();
629 tok = embeddedFilesParser.NextTok() )
633 else if( tok ==
DSN_RIGHT && --depth < 0 )
638 SyncLineReaderWith( embeddedFilesParser );
643 Expecting(
"pin_names, pin_numbers, arc, bezier, circle, ellipse, ellipse_arc, "
644 "pin, polyline, rectangle, or text" );
648 symbol->GetDrawItems().sort();
651 const std::vector<wxString>* embeddedFonts = symbol->GetEmbeddedFiles()->UpdateFontFiles();
653 symbol->RunOnChildren(
657 textItem->ResolveFont( embeddedFonts );
664 symbol->SetHasDeMorganBodyStyles( symbol->HasLegacyAlternateBodyStyle() );
666 symbol->RefreshLibraryTreeCaches();
668 return symbol.release();
687 Expecting(
"arc, bezier, circle, ellipse, ellipse_arc, pin, "
688 "polyline, rectangle, or text" );
702 constexpr double int_limit = std::numeric_limits<int>::max() * 0.7071;
704 return KiROUND( std::clamp( retval, -int_limit, int_limit ) );
712 constexpr double int_limit = std::numeric_limits<int>::max() * 0.7071;
714 return KiROUND( std::clamp( retval, -int_limit, int_limit ) );
721 strokeParser.SyncLineReaderWith( *
this );
724 SyncLineReaderWith( strokeParser );
730 wxCHECK_RET( CurTok() == T_fill,
"Cannot parse " + GetTokenString( CurTok() ) +
" as a fill." );
737 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
739 if( token != T_LEFT )
759 default: Expecting(
"none, outline, hatch, reverse_hatch, "
760 "cross_hatch, color or background" );
774 color.
a = std::clamp(
parseDouble(
"alpha" ), 0.0, 1.0 );
781 Expecting(
"type or color" );
788 bool aEnforceMinTextSize )
790 wxCHECK_RET( aText && ( CurTok() == T_effects || CurTok() == T_href ),
791 "Cannot parse " + GetTokenString( CurTok() ) +
" as an EDA_TEXT." );
808 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
810 if( token == T_LEFT )
816 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
818 if( token == T_LEFT )
858 color.
a = std::clamp(
parseDouble(
"alpha" ), 0.0, 1.0 );
869 Expecting(
"face, size, thickness, line_spacing, bold, or italic" );
876 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
885 case T_mirror:
break;
886 default: Expecting(
"left, right, top, bottom, or mirror" );
895 wxString hyperlink = FromUTF8();
900 CurSource(), CurLine(), CurLineNumber(), CurOffset() );
919 Expecting(
"font, justify, hide or href" );
927 if( CurTok() != aHeaderType )
930 GetTokenString( CurTok() ) ),
931 CurSource(), CurLine(), CurLineNumber(), CurOffset() );
938 if( tok == T_version )
952 wxCHECK_RET( CurTok() == T_body_styles,
953 "Cannot parse " + GetTokenString( CurTok() ) +
" as a body_styles token." );
955 std::vector<wxString> names;
957 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
959 if( token == T_demorgan )
961 aSymbol->SetHasDeMorganBodyStyles(
true );
964 else if( !IsSymbol( token ) )
966 THROW_PARSE_ERROR(
_(
"Invalid property value" ), CurSource(), CurLine(), CurLineNumber(),
970 names.push_back( FromUTF8() );
974 aSymbol->SetBodyStyleNames( names );
980 wxCHECK_RET( CurTok() == T_pin_names,
981 "Cannot parse " + GetTokenString( CurTok() ) +
" as a pin_name token." );
991 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
994 if( token == T_hide )
996 aSymbol->SetShowPinNames(
false );
1000 if( token != T_LEFT )
1002 Expecting( T_LEFT );
1015 aSymbol->SetShowPinNames( !
parseBool() );
1020 Expecting(
"offset or hide" );
1028 wxCHECK_RET( CurTok() == T_pin_numbers,
1029 "Cannot parse " + GetTokenString( CurTok() ) +
" as a pin_number token." );
1038 for(
T token = NextTok(); token != T_RIGHT; token = NextTok() )
1041 if( token == T_hide )
1043 aSymbol->SetShowPinNumbers(
false );
1047 if( token != T_LEFT )
1049 Expecting( T_LEFT );
1057 aSymbol->SetShowPinNumbers( !
parseBool() );
1062 Expecting(
"hide" );
1071 wxCHECK_MSG( CurTok() == T_property,
nullptr,
1072 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a property." ) );
1073 wxCHECK( aSymbol,
nullptr );
1078 bool isPrivate =
false;
1079 bool isVisible =
true;
1081 T token = NextTok();
1083 if( token == T_private )
1089 if( !IsSymbol( token ) )
1091 THROW_PARSE_ERROR(
_(
"Invalid property name" ), CurSource(), CurLine(), CurLineNumber(),
1097 if(
name.IsEmpty() )
1099 THROW_PARSE_ERROR(
_(
"Empty property name" ), CurSource(), CurLine(), CurLineNumber(),
1113 auto field = std::make_unique<SCH_FIELD>( aSymbol.get(), fieldId,
name );
1114 field->SetPrivate( isPrivate );
1115 field->SetVisible( isVisible );
1119 if( !IsSymbol( token ) )
1121 THROW_PARSE_ERROR(
_(
"Invalid property value" ), CurSource(), CurLine(), CurLineNumber(),
1128 value = wxEmptyString;
1132 field->SetText( value );
1134 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
1136 if( token != T_LEFT )
1137 Expecting( T_LEFT );
1149 field->SetPosition(
parseXY(
true ) );
1167 field->SetNameShown( show );
1171 case T_do_not_autoplace:
1174 field->SetCanAutoplace( !doNotAutoplace );
1179 Expecting(
"id, at, hide, show_name, do_not_autoplace, or effects" );
1185 if( field->IsMandatory() )
1187 existingField = aSymbol->GetField( field->GetId() );
1189 *existingField = *field;
1190 return existingField;
1192 else if(
name ==
"ki_keywords" )
1195 aSymbol->SetKeyWords( value );
1199 else if(
name ==
"ki_description" )
1201 aSymbol->SetDescription( value );
1204 else if(
name ==
"ki_fp_filters" )
1207 wxArrayString filters;
1208 wxStringTokenizer tokenizer( value,
" \t\r\n", wxTOKEN_STRTOK );
1210 while( tokenizer.HasMoreTokens() )
1212 wxString curr_token =
UnescapeString( tokenizer.GetNextToken() );
1213 filters.Add( curr_token );
1216 aSymbol->SetFPFilters( filters );
1219 else if(
name ==
"ki_locked" )
1223 aSymbol->LockUnits(
true );
1229 existingField = aSymbol->GetField( field->GetCanonicalName() );
1237 wxString base_name = field->GetCanonicalName();
1240 for(
int ii = 1; ii < 10 && existingField; ii++ )
1242 wxString newname = base_name;
1243 newname <<
'_' << ii;
1245 existingField = aSymbol->GetField( newname );
1247 if( !existingField )
1248 field->SetName( newname );
1252 if( !existingField )
1254 aSymbol->AddDrawItem( field.get(),
false );
1255 return field.release();
1268 wxCHECK_MSG( CurTok() == T_arc,
nullptr,
1269 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as an arc." ) );
1275 bool hasMidPoint =
false;
1283 bool hasAngles =
false;
1292 if( token == T_private )
1294 arc->SetPrivate(
true );
1298 for( ; token != T_RIGHT; token = NextTok() )
1300 if( token != T_LEFT )
1301 Expecting( T_LEFT );
1324 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
1326 if( token != T_LEFT )
1327 Expecting( T_LEFT );
1355 Expecting(
"at, length, or angles" );
1363 arc->SetStroke( stroke );
1369 arc->SetFillColor( fill.
m_Color );
1373 Expecting(
"start, mid, end, radius, stroke, or fill" );
1379 arc->SetArcGeometry( startPoint, midPoint, endPoint );
1390 EDA_ANGLE arc_start, arc_end, arc_angle;
1391 arc->CalcArcAngles( arc_start, arc_end );
1392 arc_angle = arc_end - arc_start;
1397 arc->SetStart( endPoint );
1398 arc->SetEnd( startPoint );
1401 arc->SetCenter( new_center );
1407 arc->SetCenter( new_center );
1411 else if( hasAngles )
1413 arc->SetCenter(
center );
1419 arc->SetStart( endPoint );
1420 arc->SetEnd( startPoint );
1424 EDA_ANGLE arc_start, arc_end, arc_angle;
1425 arc->CalcArcAngles( arc_start, arc_end );
1426 arc_angle = arc_end - arc_start;
1432 arc->SetStart( startPoint );
1433 arc->SetEnd( endPoint );
1441 arc->SetStart( startPoint );
1442 arc->SetEnd( endPoint );
1446 arc->SetCenter( new_center );
1452 wxFAIL_MSG(
"Setting arc without either midpoint or angles not implemented." );
1455 return arc.release();
1461 wxCHECK_MSG( CurTok() == T_bezier,
nullptr,
1462 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a bezier." ) );
1470 bezier->SetUnit(
m_unit );
1475 if( token == T_private )
1477 bezier->SetPrivate(
true );
1481 for( ; token != T_RIGHT; token = NextTok() )
1483 if( token != T_LEFT )
1484 Expecting( T_LEFT );
1494 for( token = NextTok(); token != T_RIGHT; token = NextTok(), ++ii )
1496 if( token != T_LEFT )
1497 Expecting( T_LEFT );
1506 case 0: bezier->SetStart(
parseXY(
true ) );
break;
1507 case 1: bezier->SetBezierC1(
parseXY(
true ) );
break;
1508 case 2: bezier->SetBezierC2(
parseXY(
true ) );
break;
1509 case 3: bezier->SetEnd(
parseXY(
true ) );
break;
1510 default: Unexpected(
"control point" );
break;
1520 bezier->SetStroke( stroke );
1526 bezier->SetFillColor( fill.
m_Color );
1530 Expecting(
"pts, stroke, or fill" );
1534 bezier->RebuildBezierToSegmentsPointsList(
m_maxError );
1536 return bezier.release();
1542 wxCHECK_MSG( CurTok() == T_circle,
nullptr,
1543 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a circle." ) );
1558 if( token == T_private )
1560 circle->SetPrivate(
true );
1564 for( ; token != T_RIGHT; token = NextTok() )
1566 if( token != T_LEFT )
1567 Expecting( T_LEFT );
1585 circle->SetStroke( stroke );
1595 Expecting(
"center, radius, stroke, or fill" );
1608 wxCHECK_MSG( CurTok() == T_ellipse,
nullptr,
1609 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as an ellipse." ) );
1612 ellipse->SetUnit(
m_unit );
1615 T token = NextTok();
1617 if( token == T_private )
1619 ellipse->SetPrivate(
true );
1624 return ellipse.release();
1630 wxCHECK_MSG( CurTok() == T_ellipse_arc,
nullptr,
1631 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as an elliptical arc." ) );
1637 T token = NextTok();
1639 if( token == T_private )
1641 arc->SetPrivate(
true );
1646 return arc.release();
1672 Expecting(
"input, output, bidirectional, tri_state, passive, unspecified, "
1673 "power_in, power_out, open_collector, open_emitter, free or "
1695 Expecting(
"line, inverted, clock, inverted_clock, input_low, clock_low, "
1696 "output_low, edge_clock_high, non_logic" );
1701 wxCHECK_MSG( CurTok() == T_pin,
nullptr,
1702 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a pin token." ) );
1705 std::unique_ptr<SCH_PIN>
pin = std::make_unique<SCH_PIN>(
nullptr );
1712 pin->SetType( parseType( token ) );
1716 pin->SetShape( parseShape( token ) );
1718 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
1721 if( token == T_hide )
1723 pin->SetVisible(
false );
1727 if( token != T_LEFT )
1728 Expecting( T_LEFT );
1737 switch(
parseInt(
"pin orientation" ) )
1743 default: Expecting(
"0, 90, 180, or 270" );
1762 if( !IsSymbol( token ) )
1769 pin->SetName( wxEmptyString );
1773 pin->SetName( FromUTF8() );
1777 if( token != T_RIGHT )
1781 if( token == T_effects )
1788 pin->SetNameTextSize(
text.GetTextHeight() );
1793 Expecting(
"effects" );
1802 if( !IsSymbol( token ) )
1805 CurLineNumber(), CurOffset() );
1809 pin->SetNumber( wxEmptyString );
1813 pin->SetNumber( FromUTF8() );
1817 if( token != T_RIGHT )
1821 if( token == T_effects )
1828 pin->SetNumberTextSize(
text.GetTextHeight() );
1833 Expecting(
"effects" );
1845 if( !IsSymbol( token ) )
1848 CurLineNumber(), CurOffset() );
1854 alt.
m_Type = parseType( token );
1857 alt.
m_Shape = parseShape( token );
1859 pin->GetAlternates()[ alt.
m_Name ] = alt;
1866 Expecting(
"at, name, number, hide, length, or alternate" );
1870 return pin.release();
1876 wxCHECK_MSG( CurTok() == T_polyline,
nullptr,
1877 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a poly." ) );
1889 if( token == T_private )
1891 poly->SetPrivate(
true );
1895 for( ; token != T_RIGHT; token = NextTok() )
1897 if( token != T_LEFT )
1898 Expecting( T_LEFT );
1905 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
1907 if( token != T_LEFT )
1908 Expecting( T_LEFT );
1915 poly->AddPoint(
parseXY(
true ) );
1924 poly->SetStroke( stroke );
1930 poly->SetFillColor( fill.
m_Color );
1934 Expecting(
"pts, stroke, or fill" );
1938 return poly.release();
1944 wxCHECK_MSG( CurTok() == T_rectangle,
nullptr,
1945 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a rectangle." ) );
1952 rectangle->SetUnit(
m_unit );
1957 if( token == T_private )
1959 rectangle->SetPrivate(
true );
1963 for( ; token != T_RIGHT; token = NextTok() )
1965 if( token != T_LEFT )
1966 Expecting( T_LEFT );
1973 rectangle->SetPosition(
parseXY(
true ) );
1978 rectangle->SetEnd(
parseXY(
true ) );
1989 rectangle->SetStroke( stroke );
1995 rectangle->SetFillColor( fill.
m_Color );
1999 Expecting(
"start, end, stroke, or fill" );
2003 return rectangle.release();
2009 wxCHECK_MSG( CurTok() == T_text,
nullptr,
2010 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a text token." ) );
2013 std::unique_ptr<SCH_TEXT>
text = std::make_unique<SCH_TEXT>();
2020 if( token == T_private )
2022 text->SetPrivate(
true );
2026 if( !IsSymbol( token ) )
2028 THROW_PARSE_ERROR(
_(
"Invalid text string" ), CurSource(), CurLine(), CurLineNumber(),
2032 text->SetText( FromUTF8() );
2034 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2036 if( token != T_LEFT )
2037 Expecting( T_LEFT );
2055 Expecting(
"at or effects" );
2060 if( !
text->IsVisible() )
2063 return text.release();
2069 wxCHECK_MSG( CurTok() == T_text_box,
nullptr,
2070 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a text box." ) );
2082 bool foundEnd =
false;
2083 bool foundSize =
false;
2084 bool foundMargins =
false;
2086 std::unique_ptr<SCH_TEXTBOX> textBox = std::make_unique<SCH_TEXTBOX>(
LAYER_DEVICE );
2088 textBox->SetUnit(
m_unit );
2092 if( token == T_private )
2094 textBox->SetPrivate(
true );
2098 if( !IsSymbol( token ) )
2100 THROW_PARSE_ERROR(
_(
"Invalid text string" ), CurSource(), CurLine(), CurLineNumber(),
2104 textBox->SetText( FromUTF8() );
2106 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2108 if( token != T_LEFT )
2109 Expecting( T_LEFT );
2140 textBox->SetStroke( stroke );
2146 textBox->SetFillColor( fill.
m_Color );
2151 textBox->SetMarginLeft(
left );
2152 textBox->SetMarginTop(
top );
2153 textBox->SetMarginRight(
right );
2154 textBox->SetMarginBottom( bottom );
2155 foundMargins =
true;
2164 Expecting(
"at, size, stroke, fill or effects" );
2168 textBox->SetPosition( pos );
2171 textBox->SetEnd(
end );
2172 else if( foundSize )
2173 textBox->SetEnd( pos + size );
2175 Expecting(
"size" );
2179 int margin = textBox->GetLegacyTextMargin();
2180 textBox->SetMarginLeft( margin );
2181 textBox->SetMarginTop( margin );
2182 textBox->SetMarginRight( margin );
2183 textBox->SetMarginBottom( margin );
2186 return textBox.release();
2192 wxCHECK_RET( ( CurTok() == T_page &&
m_requiredVersion <= 20200506 ) || CurTok() == T_paper,
2193 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a PAGE_INFO." ) );
2199 wxString pageType = FromUTF8();
2201 if( !aPageInfo.
SetType( pageType ) )
2203 THROW_PARSE_ERROR(
_(
"Invalid page type" ), CurSource(), CurLine(), CurLineNumber(),
2230 if( token == T_portrait )
2235 else if( token != T_RIGHT )
2237 Expecting(
"portrait" );
2244 wxCHECK_RET( CurTok() == T_title_block,
2245 "Cannot parse " + GetTokenString( CurTok() ) +
" as a TITLE_BLOCK." );
2249 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2251 if( token != T_LEFT )
2252 Expecting( T_LEFT );
2260 aTitleBlock.
SetTitle( FromUTF8() );
2265 aTitleBlock.
SetDate( FromUTF8() );
2280 int commentNumber =
parseInt(
"comment" );
2282 switch( commentNumber )
2331 CurLine(), CurLineNumber(), CurOffset() );
2338 Expecting(
"title, date, rev, company, or comment" );
2348 wxCHECK_MSG( CurTok() == T_property,
nullptr,
2349 "Cannot parse " + GetTokenString( CurTok() ) +
" as a property token." );
2351 bool is_private =
false;
2353 T token = NextTok();
2355 if( token == T_private )
2361 if( !IsSymbol( token ) )
2363 THROW_PARSE_ERROR(
_(
"Invalid property name" ), CurSource(), CurLine(), CurLineNumber(),
2367 wxString
name = FromUTF8();
2369 if(
name.IsEmpty() )
2371 THROW_PARSE_ERROR(
_(
"Empty property name" ), CurSource(), CurLine(), CurLineNumber(),
2380 name = wxT(
"Netclass" );
2384 if( !IsSymbol( token ) )
2386 THROW_PARSE_ERROR(
_(
"Invalid property value" ), CurSource(), CurLine(), CurLineNumber(),
2394 value = wxEmptyString;
2426 if(
name.CmpNoCase( wxT(
"Sheet name" ) ) == 0 )
2428 else if(
name.CmpNoCase( wxT(
"Sheet file" ) ) == 0 )
2443 if(
name.CmpNoCase( wxT(
"Intersheet References" ) ) == 0 )
2447 std::unique_ptr<SCH_FIELD> field = std::make_unique<SCH_FIELD>( aParent, fieldId,
name );
2448 field->SetText( value );
2451 field->SetPrivate( is_private );
2453 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2455 if( token != T_LEFT )
2456 Expecting( T_LEFT );
2468 field->SetPosition(
parseXY() );
2486 field->SetNameShown( show );
2490 case T_do_not_autoplace:
2493 field->SetCanAutoplace( !doNotAutoplace );
2498 Expecting(
"id, at, hide, show_name, do_not_autoplace or effects" );
2502 return field.release();
2508 wxCHECK_MSG( aSheet !=
nullptr,
nullptr,
"" );
2509 wxCHECK_MSG( CurTok() == T_pin,
nullptr,
2510 "Cannot parse " + GetTokenString( CurTok() ) +
" as a sheet pin token." );
2512 T token = NextTok();
2514 if( !IsSymbol( token ) )
2516 THROW_PARSE_ERROR(
_(
"Invalid sheet pin name" ), CurSource(), CurLine(), CurLineNumber(),
2520 wxString
name = FromUTF8();
2522 if(
name.IsEmpty() )
2524 THROW_PARSE_ERROR(
_(
"Empty sheet pin name" ), CurSource(), CurLine(), CurLineNumber(),
2528 auto sheetPin = std::make_unique<SCH_SHEET_PIN>( aSheet,
VECTOR2I( 0, 0 ),
name );
2540 Expecting(
"input, output, bidirectional, tri_state, or passive" );
2543 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2545 if( token != T_LEFT )
2546 Expecting( T_LEFT );
2554 sheetPin->SetPosition(
parseXY() );
2556 double angle =
parseDouble(
"sheet pin angle (side)" );
2560 else if( angle == 90.0 )
2562 else if( angle == 180.0 )
2564 else if( angle == 270.0 )
2567 Expecting(
"0, 90, 180, or 270" );
2584 Expecting(
"at, uuid or effects" );
2588 return sheetPin.release();
2594 wxCHECK_RET( CurTok() == T_sheet_instances,
2595 "Cannot parse " + GetTokenString( CurTok() ) +
" as an instances token." );
2596 wxCHECK( aScreen, );
2600 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2602 if( token != T_LEFT )
2603 Expecting( T_LEFT );
2621 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2623 if( token != T_LEFT )
2624 Expecting( T_LEFT );
2628 std::vector<wxString> whitespaces = { wxT(
"\r" ), wxT(
"\n" ), wxT(
"\t" ),
2631 size_t numReplacements = 0;
2649 for(
const wxString& ch : whitespaces )
2650 numReplacements += instance.
m_PageNumber.Replace( ch, wxEmptyString );
2655 if( numReplacements > 0 )
2662 Expecting(
"path or page" );
2667 && ( instance.
m_Path.empty() ) )
2683 Expecting(
"path" );
2691 wxCHECK_RET( CurTok() == T_symbol_instances,
2692 "Cannot parse " + GetTokenString( CurTok() ) +
" as an instances token." );
2693 wxCHECK( aScreen, );
2698 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2700 if( token != T_LEFT )
2701 Expecting( T_LEFT );
2718 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2720 if( token != T_LEFT )
2721 Expecting( T_LEFT );
2742 instance.
m_Value = wxEmptyString;
2744 instance.
m_Value = FromUTF8();
2761 Expecting(
"path, unit, value or footprint" );
2770 Expecting(
"path" );
2779 wxCHECK( aSheet !=
nullptr, );
2783 wxCHECK( screen !=
nullptr, );
2786 m_maxError = schematic->Settings().m_MaxError;
2788 if( aIsCopyableOnly )
2791 bool fileHasUuid =
false;
2805 if( !aIsCopyableOnly )
2810 if( CurTok() != T_kicad_sch )
2811 Expecting(
"kicad_sch" );
2830 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2832 if( aIsCopyableOnly && token == T_EOF )
2835 if( token != T_LEFT )
2836 Expecting( T_LEFT );
2870 case T_generator_version:
2896 if( aIsCopyableOnly )
2897 Unexpected( T_paper );
2907 if( aIsCopyableOnly )
2908 Unexpected( T_page );
2912 NeedSYMBOLorNUMBER();
2913 NeedSYMBOLorNUMBER();
2920 if( aIsCopyableOnly )
2921 Unexpected( T_title_block );
2935 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2937 if( token != T_LEFT )
2938 Expecting( T_LEFT );
2950 Expecting(
"symbol" );
3007 THROW_PARSE_ERROR(
_(
"Schematic polyline has too few points" ), CurSource(), CurLine(),
3008 CurLineNumber(), CurOffset() );
3062 case T_netclass_flag:
3067 case T_global_label:
3068 case T_hierarchical_label:
3069 case T_directive_label:
3085 case T_sheet_instances:
3089 case T_symbol_instances:
3094 if( aIsCopyableOnly )
3095 Unexpected( T_bus_alias );
3100 case T_embedded_fonts:
3106 CurLineNumber(), CurOffset() );
3108 schematic->GetEmbeddedFiles()->SetAreFontsEmbedded(
parseBool() );
3113 case T_embedded_files:
3119 CurLineNumber(), CurOffset() );
3122 embeddedFilesParser.SyncLineReaderWith( *
this );
3126 embeddedFilesParser.
ParseEmbedded( schematic->GetEmbeddedFiles() );
3134 for(
int tok = embeddedFilesParser.NextTok();
3136 tok = embeddedFilesParser.NextTok() )
3140 else if( tok ==
DSN_RIGHT && --depth < 0 )
3145 SyncLineReaderWith( embeddedFilesParser );
3151 Expecting(
"arc, bezier, bitmap, bus, bus_alias, bus_entry, circle, class_label, "
3152 "directive_label, ellipse, ellipse_arc, embedded_fonts, embedded_files, "
3153 "global_label, hierarchical_label, image, junction, lib_symbols, "
3154 "netclass_flag, no_connect, polyline, rectangle, rule_area, sheet, "
3155 "sheet_instances, signal, symbol, symbol_instances, table, text, "
3156 "text_box, title_block, uuid, wire" );
3177 CurLineNumber(), CurOffset() );
3181 std::vector<std::string> fontNames;
3182 Fontconfig()->ListFonts( fontNames, std::string(
Pgm().GetLanguageTag().utf8_str() ),
3183 schematic->GetEmbeddedFiles()->GetFontFiles(),
true );
3192 wxCHECK_MSG( CurTok() == T_symbol,
nullptr,
3193 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a symbol." ) );
3198 std::unique_ptr<SCH_SYMBOL> symbol = std::make_unique<SCH_SYMBOL>();
3200 std::set<int> fieldIDsRead;
3205 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3207 if( token != T_LEFT )
3208 Expecting( T_LEFT );
3220 if( !IsSymbol( token ) )
3223 CurLineNumber(), CurOffset() );
3226 libName = FromUTF8();
3230 libName.Replace(
"{slash}",
"/" );
3240 if( !IsSymbol( token ) && token != T_NUMBER )
3241 Expecting(
"symbol|number" );
3244 wxString
name = FromUTF8();
3248 name.Replace(
"{slash}",
"/" );
3254 if(
static_cast<int>(
name.size() ) > bad_pos )
3256 wxString msg = wxString::Format(
_(
"Symbol %s contains invalid character '%c'" ),
3264 CurLineNumber(), CurOffset() );
3267 symbol->SetLibId( libId );
3273 symbol->SetPosition(
parseXY() );
3275 switch(
static_cast<int>(
parseDouble(
"symbol orientation" ) ) )
3278 case 90: transform =
TRANSFORM( 0, 1, -1, 0 );
break;
3279 case 180: transform =
TRANSFORM( -1, 0, 0, -1 );
break;
3280 case 270: transform =
TRANSFORM( 0, -1, 1, 0 );
break;
3281 default: Expecting(
"0, 90, 180, or 270" );
3284 symbol->SetTransform( transform );
3293 else if( token == T_y )
3296 Expecting(
"x or y" );
3302 symbol->SetUnit(
parseInt(
"symbol unit" ) );
3308 symbol->SetBodyStyle(
parseInt(
"symbol body style" ) );
3312 case T_exclude_from_sim:
3313 symbol->SetExcludedFromSim(
parseBool() );
3318 symbol->SetExcludedFromBOM( !
parseBool() );
3323 symbol->SetExcludedFromBoard( !
parseBool() );
3327 case T_in_pos_files:
3328 symbol->SetExcludedFromPosFiles( !
parseBool() );
3348 if( !IsSymbol( t ) )
3349 Expecting(
"default, block or force" );
3351 wxString mode = FromUTF8();
3353 if( mode.IsSameAs( wxT(
"default"),
false ) )
3355 else if( mode.IsSameAs( wxT(
"block"),
false ) )
3357 else if( mode.IsSameAs( wxT(
"force"),
false ) )
3360 Expecting(
"default, block or force" );
3366 case T_fields_autoplaced:
3378 case T_default_instance:
3382 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3384 if( token != T_LEFT )
3385 Expecting( T_LEFT );
3406 symbol->SetValueFieldText( wxEmptyString );
3408 symbol->SetValueFieldText( FromUTF8() );
3417 symbol->SetFootprintFieldText( wxEmptyString );
3419 symbol->SetFootprintFieldText( FromUTF8() );
3425 Expecting(
"reference, unit, value or footprint" );
3434 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3436 if( token != T_LEFT )
3437 Expecting( T_LEFT );
3441 if( token != T_project )
3442 Expecting(
"project" );
3446 wxString projectName = FromUTF8();
3448 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3450 if( token != T_LEFT )
3451 Expecting( T_LEFT );
3455 if( token != T_path )
3456 Expecting(
"path" );
3465 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3467 if( token != T_LEFT )
3468 Expecting( T_LEFT );
3489 symbol->SetValueFieldText( wxEmptyString );
3491 symbol->SetValueFieldText( FromUTF8() );
3500 symbol->SetFootprintFieldText( wxEmptyString );
3502 symbol->SetFootprintFieldText( FromUTF8() );
3513 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3515 if( token != T_LEFT )
3516 Expecting( T_LEFT );
3524 variant.
m_Name = FromUTF8();
3533 case T_exclude_from_sim:
3555 case T_in_pos_files:
3563 wxString fieldValue;
3565 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3567 if( token != T_LEFT )
3568 Expecting( T_LEFT );
3576 fieldName = FromUTF8();
3582 fieldValue = FromUTF8();
3587 Expecting(
"name or value" );
3591 variant.
m_Fields[fieldName] = fieldValue;
3596 Expecting(
"dnp, exclude_from_sim, field, in_bom, in_pos_files, name, or on_board" );
3606 Expecting(
"reference, unit, value, footprint, or variant" );
3610 symbol->AddHierarchicalReference( instance );
3626 symbol->SetExcludedFromSim( field->
GetText() == wxS(
"0" ) );
3634 symbol->SetExcludedFromSim( field->
GetText() == wxS(
"N" ) );
3642 existing = symbol->GetField( field->
GetId() );
3644 existing = symbol->GetField( field->
GetName() );
3649 symbol->AddField( *field );
3652 symbol->UpdatePrefix();
3665 number = FromUTF8();
3667 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3669 if( token != T_LEFT )
3670 Expecting( T_LEFT );
3694 Expecting(
"alternate or uuid" );
3698 symbol->GetRawPins().emplace_back( std::make_unique<SCH_PIN>( symbol.get(), number,
3704 Expecting(
"lib_id, lib_name, at, mirror, uuid, exclude_from_sim, on_board, in_bom, dnp, passthrough, "
3705 "default_instance, property, pin, or instances" );
3709 if( !libName.IsEmpty() && ( symbol->GetLibId().Format().wx_str() != libName ) )
3710 symbol->SetSchSymbolLibraryName( libName );
3713 symbol->ClearFlags();
3715 return symbol.release();
3721 wxCHECK_MSG( CurTok() == T_image,
nullptr,
3722 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as an image." ) );
3725 std::unique_ptr<SCH_BITMAP> bitmap = std::make_unique<SCH_BITMAP>();
3728 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3730 if( token != T_LEFT )
3731 Expecting( T_LEFT );
3738 bitmap->SetPosition(
parseXY() );
3764 data.reserve( 1 << 17 );
3766 while( token != T_RIGHT )
3768 if( !IsSymbol( token ) )
3769 Expecting(
"base64 image data" );
3775 wxMemoryBuffer buffer = wxBase64Decode( data );
3789 Expecting(
"at, scale, uuid, data or locked" );
3807 int legacyPPI =
image.GetLegacyPPI();
3809 if( legacyPPI > 0 &&
image.GetPPI() != legacyPPI )
3813 return bitmap.release();
3819 wxCHECK_MSG( CurTok() == T_sheet,
nullptr,
3820 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a sheet." ) );
3826 std::vector<SCH_FIELD> fields;
3827 std::unique_ptr<SCH_SHEET> sheet = std::make_unique<SCH_SHEET>();
3828 std::set<int> fieldIDsRead;
3833 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3835 if( token != T_LEFT )
3836 Expecting( T_LEFT );
3843 sheet->SetPosition(
parseXY() );
3852 sheet->SetSize( size );
3857 case T_exclude_from_sim:
3858 sheet->SetExcludedFromSim(
parseBool() );
3863 sheet->SetExcludedFromBOM( !
parseBool() );
3868 sheet->SetExcludedFromBoard( !
parseBool() );
3882 case T_fields_autoplaced:
3890 sheet->SetBorderWidth( stroke.
GetWidth() );
3891 sheet->SetBorderColor( stroke.
GetColor() );
3896 sheet->SetBackgroundColor( fill.
m_Color );
3913 if( fields.empty() )
3919 fields.emplace_back( *field );
3930 std::vector<SCH_SHEET_INSTANCE> instances;
3932 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3934 if( token != T_LEFT )
3935 Expecting( T_LEFT );
3939 if( token != T_project )
3940 Expecting(
"project" );
3944 wxString projectName = FromUTF8();
3946 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3948 if( token != T_LEFT )
3949 Expecting( T_LEFT );
3953 if( token != T_path )
3954 Expecting(
"path" );
3963 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3965 if( token != T_LEFT )
3966 Expecting( T_LEFT );
3986 static std::vector<wxString> whitespaces =
3992 for( wxString ch : whitespaces )
4005 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4007 if( token != T_LEFT )
4008 Expecting( T_LEFT );
4016 variant.
m_Name = FromUTF8();
4025 case T_exclude_from_sim:
4047 case T_in_pos_files:
4055 wxString fieldValue;
4057 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4059 if( token != T_LEFT )
4060 Expecting( T_LEFT );
4068 fieldName = FromUTF8();
4074 fieldValue = FromUTF8();
4079 Expecting(
"name or value" );
4083 variant.
m_Fields[fieldName] = fieldValue;
4088 Expecting(
"dnp, exclude_from_sim, field, in_bom, in_pos_files, name, or on_board" );
4098 Expecting(
"page or variant" );
4102 instances.emplace_back( instance );
4106 sheet->setInstances( instances );
4111 Expecting(
"at, size, stroke, background, instances, uuid, property, or pin" );
4115 sheet->SetFields( fields );
4120 CurLineNumber(), CurOffset() );
4126 CurLineNumber(), CurOffset() );
4129 return sheet.release();
4135 wxCHECK_MSG( CurTok() == T_junction,
nullptr,
4136 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a junction." ) );
4139 std::unique_ptr<SCH_JUNCTION> junction = std::make_unique<SCH_JUNCTION>();
4141 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4143 if( token != T_LEFT )
4144 Expecting( T_LEFT );
4151 junction->SetPosition(
parseXY() );
4167 color.
a = std::clamp(
parseDouble(
"alpha" ), 0.0, 1.0 );
4169 junction->SetColor( color );
4186 Expecting(
"at, diameter, color, uuid or locked" );
4190 return junction.release();
4196 wxCHECK_MSG( CurTok() == T_no_connect,
nullptr,
4197 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a no connect." ) );
4200 std::unique_ptr<SCH_NO_CONNECT> no_connect = std::make_unique<SCH_NO_CONNECT>();
4202 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4204 if( token != T_LEFT )
4205 Expecting( T_LEFT );
4212 no_connect->SetPosition(
parseXY() );
4228 Expecting(
"at, uuid or locked" );
4232 return no_connect.release();
4238 wxCHECK_MSG( CurTok() == T_bus_entry,
nullptr,
4239 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a bus entry." ) );
4243 std::unique_ptr<SCH_BUS_WIRE_ENTRY> busEntry = std::make_unique<SCH_BUS_WIRE_ENTRY>();
4245 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4247 if( token != T_LEFT )
4248 Expecting( T_LEFT );
4255 busEntry->SetPosition(
parseXY() );
4265 busEntry->SetSize( size );
4272 busEntry->SetStroke( stroke );
4287 Expecting(
"at, size, uuid, stroke or locked" );
4291 return busEntry.release();
4313 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4315 if( token != T_LEFT )
4316 Expecting( T_LEFT );
4323 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4325 if( token != T_LEFT )
4326 Expecting( T_LEFT );
4333 polyline->AddPoint(
parseXY() );
4346 polyline->SetStroke( stroke );
4352 polyline->SetFillColor( fill.
m_Color );
4368 Expecting(
"pts, uuid, stroke, fill or locked" );
4372 return polyline.release();
4391 wxCHECK_MSG(
false,
nullptr,
"Cannot parse " + GetTokenString( CurTok() ) +
" as a line." );
4394 std::unique_ptr<SCH_LINE> line = std::make_unique<SCH_LINE>(
VECTOR2I(), layer );
4396 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4398 if( token != T_LEFT )
4399 Expecting( T_LEFT );
4412 line->SetStartPoint(
parseXY() );
4420 line->SetEndPoint(
parseXY() );
4427 line->SetStroke( stroke );
4442 Expecting(
"pts, uuid, stroke or locked" );
4446 return line.release();
4452 wxCHECK_MSG( CurTok() == T_arc,
nullptr,
4453 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as an arc." ) );
4461 std::unique_ptr<SCH_SHAPE> arc = std::make_unique<SCH_SHAPE>(
SHAPE_T::ARC );
4463 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4465 if( token != T_LEFT )
4466 Expecting( T_LEFT );
4489 arc->SetStroke( stroke );
4495 arc->SetFillColor( fill.
m_Color );
4511 Expecting(
"start, mid, end, stroke, fill, uuid or locked" );
4515 arc->SetArcGeometry( startPoint, midPoint, endPoint );
4517 return arc.release();
4523 wxCHECK_MSG( CurTok() == T_circle,
nullptr,
4524 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a circle." ) );
4533 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4535 if( token != T_LEFT )
4536 Expecting( T_LEFT );
4554 circle->SetStroke( stroke );
4576 Expecting(
"center, radius, stroke, fill, uuid or locked" );
4589 wxCHECK_MSG( CurTok() == T_rectangle,
nullptr,
4590 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a rectangle." ) );
4595 std::unique_ptr<SCH_SHAPE> rectangle = std::make_unique<SCH_SHAPE>(
SHAPE_T::RECTANGLE );
4597 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4599 if( token != T_LEFT )
4600 Expecting( T_LEFT );
4607 rectangle->SetPosition(
parseXY() );
4612 rectangle->SetEnd(
parseXY() );
4623 rectangle->SetStroke( stroke );
4629 rectangle->SetFillColor( fill.
m_Color );
4645 Expecting(
"start, end, stroke, fill, uuid or locked" );
4649 return rectangle.release();
4655 wxCHECK_MSG( CurTok() == T_rule_area,
nullptr,
4656 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a rule area." ) );
4661 std::unique_ptr<SCH_RULE_AREA> ruleArea = std::make_unique<SCH_RULE_AREA>();
4663 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4665 if( token != T_LEFT )
4666 Expecting( T_LEFT );
4680 ruleArea->SetPolyShape( sch_rule_poly );
4682 ruleArea->SetStroke( poly->GetStroke() );
4683 ruleArea->SetFillMode( poly->GetFillMode() );
4684 ruleArea->SetFillColor( poly->GetFillColor() );
4687 const_cast<KIID&
>( ruleArea->m_Uuid ) = poly->m_Uuid;
4691 case T_exclude_from_sim:
4692 ruleArea->SetExcludedFromSim(
parseBool() );
4697 ruleArea->SetExcludedFromBOM( !
parseBool() );
4702 ruleArea->SetExcludedFromBoard( !
parseBool() );
4717 Expecting(
"exclude_from_sim, on_board, in_bom, dnp, locked, or polyline" );
4721 return ruleArea.release();
4727 wxCHECK_MSG( CurTok() == T_bezier,
nullptr,
4728 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a bezier." ) );
4733 std::unique_ptr<SCH_SHAPE> bezier = std::make_unique<SCH_SHAPE>(
SHAPE_T::BEZIER );
4735 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4737 if( token != T_LEFT )
4738 Expecting( T_LEFT );
4748 for( token = NextTok(); token != T_RIGHT; token = NextTok(), ++ii )
4750 if( token != T_LEFT )
4751 Expecting( T_LEFT );
4760 case 0: bezier->SetStart(
parseXY() );
break;
4761 case 1: bezier->SetBezierC1(
parseXY() );
break;
4762 case 2: bezier->SetBezierC2(
parseXY() );
break;
4763 case 3: bezier->SetEnd(
parseXY() );
break;
4764 default: Unexpected(
"control point" );
break;
4774 bezier->SetStroke( stroke );
4780 bezier->SetFillColor( fill.
m_Color );
4796 Expecting(
"pts, stroke, fill, uuid or locked" );
4800 bezier->RebuildBezierToSegmentsPointsList(
m_maxError );
4802 return bezier.release();
4807 TSCHEMATIC_T::T aFirstTok )
4813 int majorRadius = 1;
4814 int minorRadius = 1;
4821 for(
T token = aFirstTok; token != T_RIGHT; token = NextTok() )
4823 if( token != T_LEFT )
4824 Expecting( T_LEFT );
4836 case T_major_radius:
4841 case T_minor_radius:
4846 case T_rotation_angle:
4853 Expecting(
"start_angle only valid inside ellipse_arc" );
4860 Expecting(
"end_angle only valid inside ellipse_arc" );
4880 Expecting(
"uuid only valid in schematic context" );
4888 Expecting(
"locked only valid in schematic context" );
4894 Expecting(
"center, major_radius, minor_radius, rotation_angle, "
4895 "start_angle, end_angle, stroke, fill, uuid, or locked" );
4914 wxCHECK_MSG( CurTok() == T_ellipse,
nullptr,
4915 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as an ellipse." ) );
4919 return ellipse.release();
4925 wxCHECK_MSG( CurTok() == T_ellipse_arc,
nullptr,
4926 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as an elliptical arc." ) );
4930 return arc.release();
4937 std::unique_ptr<SCH_TEXT>
text;
4941 case T_text:
text = std::make_unique<SCH_TEXT>();
break;
4942 case T_label:
text = std::make_unique<SCH_LABEL>();
break;
4943 case T_global_label:
text = std::make_unique<SCH_GLOBALLABEL>();
break;
4944 case T_hierarchical_label:
text = std::make_unique<SCH_HIERLABEL>();
break;
4945 case T_netclass_flag:
text = std::make_unique<SCH_DIRECTIVE_LABEL>();
break;
4946 case T_directive_label:
text = std::make_unique<SCH_DIRECTIVE_LABEL>();
break;
4948 wxCHECK_MSG(
false,
nullptr,
"Cannot parse " + GetTokenString( CurTok() ) +
" as text." );
4956 text->SetText( FromUTF8() );
4958 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
4960 if( token != T_LEFT )
4961 Expecting( T_LEFT );
4967 case T_exclude_from_sim:
4978 switch(
static_cast<int>( label->GetTextAngle().AsDegrees() ) )
4994 Unexpected( T_shape );
5012 Expecting(
"input, output, bidirectional, tri_state, passive, dot, round, diamond"
5023 Unexpected( T_length );
5032 case T_fields_autoplaced:
5042 text->SetVisible(
true );
5067 Unexpected( T_property );
5092 Expecting(
"at, shape, iref, uuid, effects or locked" );
5098 if( label && label->
GetFields().empty() )
5101 return text.release();
5107 wxCHECK_MSG( CurTok() == T_text_box,
nullptr,
5108 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a text box." ) );
5110 std::unique_ptr<SCH_TEXTBOX> textBox = std::make_unique<SCH_TEXTBOX>();
5114 return textBox.release();
5120 wxCHECK_MSG( CurTok() == T_table_cell,
nullptr,
5121 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a table cell." ) );
5123 std::unique_ptr<SCH_TABLECELL> cell = std::make_unique<SCH_TABLECELL>();
5127 return cell.release();
5143 bool foundEnd =
false;
5144 bool foundSize =
false;
5145 bool foundMargins =
false;
5149 aTextBox->
SetText( FromUTF8() );
5151 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
5153 if( token != T_LEFT )
5154 Expecting( T_LEFT );
5160 case T_exclude_from_sim:
5191 cell->SetColSpan(
parseInt(
"column span" ) );
5192 cell->SetRowSpan(
parseInt(
"row span" ) );
5196 Expecting(
"at, size, stroke, fill, effects or uuid" );
5220 foundMargins =
true;
5241 Expecting(
"at, size, stroke, fill, effects, span, uuid or locked" );
5243 Expecting(
"at, size, stroke, fill, effects, uuid or locked" );
5251 else if( foundSize )
5252 aTextBox->
SetEnd( pos + size );
5254 Expecting(
"size" );
5269 wxCHECK_MSG( CurTok() == T_table,
nullptr,
5270 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a table." ) );
5276 std::unique_ptr<SCH_TABLE>
table = std::make_unique<SCH_TABLE>( defaultLineWidth );
5278 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
5280 if( token != T_LEFT )
5281 Expecting( T_LEFT );
5287 case T_column_count:
5292 case T_column_widths:
5296 while( ( token = NextTok() ) != T_RIGHT )
5306 while( ( token = NextTok() ) != T_RIGHT )
5313 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
5315 if( token != T_LEFT )
5316 Expecting( T_LEFT );
5320 if( token != T_table_cell )
5321 Expecting(
"table_cell" );
5329 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
5331 if( token != T_LEFT )
5332 Expecting( T_LEFT );
5350 table->SetBorderStroke( borderStroke );
5354 Expecting(
"external, header or stroke" );
5362 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
5364 if( token != T_LEFT )
5365 Expecting( T_LEFT );
5383 table->SetSeparatorsStroke( separatorsStroke );
5387 Expecting(
"rows, cols, or stroke" );
5406 Expecting(
"columns, col_widths, row_heights, border, separators, uuid, locked, header or cells" );
5410 if( !
table->GetCell( 0, 0 ) )
5412 THROW_PARSE_ERROR(
_(
"Invalid table: no cells defined" ), CurSource(), CurLine(), CurLineNumber(),
5416 return table.release();
5422 wxCHECK_RET( CurTok() == T_bus_alias,
5423 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a bus alias." ) );
5424 wxCHECK( aScreen, );
5427 std::shared_ptr<BUS_ALIAS> busAlias = std::make_shared<BUS_ALIAS>();
5438 busAlias->SetName( alias );
5443 if( token != T_members )
5444 Expecting(
"members" );
5448 while( token != T_RIGHT )
5450 if( !IsSymbol( token ) )
5451 Expecting(
"quoted string" );
5453 member = FromUTF8();
5458 busAlias->AddMember( member );
5474 wxString
name = FromUTF8();
5478 wxString fromRef, fromPin, toRef, toPin;
5479 std::set<wxString> memberNets;
5481 for(
T tok = NextTok(); tok != T_RIGHT; tok = NextTok() )
5488 NeedSYMBOLorNUMBER();
5490 NeedSYMBOLorNUMBER();
5494 else if( tok == T_to )
5496 NeedSYMBOLorNUMBER();
5498 NeedSYMBOLorNUMBER();
5502 else if( tok == T_net_class )
5504 NeedSYMBOLorNUMBER();
5505 netClass = FromUTF8();
5508 else if( tok == T_color )
5514 color =
COLOR4D( r / 255.0, g / 255.0, b / 255.0, al );
5517 else if( tok == T_nets )
5519 for(
T inner = NextTok(); inner != T_RIGHT; inner = NextTok() )
5521 if( !IsSymbol( inner ) && inner != T_NUMBER )
5522 Expecting(
"net name" );
5524 memberNets.insert( FromUTF8() );
5534 T inner = NextTok();
5536 if( inner == T_EOF )
5539 if( inner == T_LEFT )
5541 else if( inner == T_RIGHT )
5547 if( !fromRef.IsEmpty() && !toRef.IsEmpty() )
5552 if( !netClass.IsEmpty() )
5558 if( !memberNets.empty() )
5567 while( ( token = NextTok() ) != T_RIGHT )
5572 KIID uuid( CurStr() );
5580 wxCHECK_RET( CurTok() == T_group,
5581 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as PCB_GROUP." ) );
5588 while( ( token = NextTok() ) != T_LEFT )
5590 if( token == T_STRING )
5591 groupInfo.
name = FromUTF8();
5593 Expecting(
"group name or locked" );
5596 for( ; token != T_RIGHT; token = NextTok() )
5598 if( token != T_LEFT )
5599 Expecting( T_LEFT );
5615 if( !IsSymbol( token ) && token != T_NUMBER )
5616 Expecting(
"symbol|number" );
5619 wxString
name = FromUTF8();
5623 name.Replace(
"{slash}",
"/" );
5629 if(
static_cast<int>(
name.size() ) > bad_pos )
5631 wxString msg = wxString::Format(
_(
"Group library link %s contains invalid character '%c'" ),
name,
5637 THROW_PARSE_ERROR(
_(
"Invalid library ID" ), CurSource(), CurLine(), CurLineNumber(), CurOffset() );
5656 Expecting(
"uuid, lib_id, members, locked" );
5668 [&](
const KIID& aId )
5674 if( item->m_Uuid == aId )
5693 group->SetName( groupInfo.name );
5695 const_cast<KIID&
>(
group->m_Uuid ) = groupInfo.uuid;
5697 if( groupInfo.libId.IsValid() )
5698 group->SetDesignBlockLibId( groupInfo.libId );
5700 group->SetLocked( groupInfo.locked );
5711 for(
const KIID& aUuid : groupInfo.memberUuids )
5713 if(
SCH_ITEM* gItem = getItem( aUuid ) )
5714 group->AddItem( gItem );
5729 T token = NextTok();
5731 if( token == T_EOF )
5733 else if( token == T_LEFT )
5735 else if( token == T_RIGHT )
constexpr EDA_IU_SCALE schIUScale
constexpr double ARC_LOW_DEF_MM
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
void SetContentModified(bool aModified=true)
This class handle bitmap images in KiCad.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
KICAD_T Type() const
Returns the type of object.
EDA_ITEM * GetParent() const
virtual void SetParent(EDA_ITEM *aParent)
virtual void SetEnd(const VECTOR2I &aEnd)
FILL_T GetFillMode() const
SHAPE_POLY_SET & GetPolyShape()
virtual void SetEllipseEndAngle(const EDA_ANGLE &aA)
virtual void SetEllipseRotation(const EDA_ANGLE &aA)
void SetFillColor(const COLOR4D &aColor)
int GetPointCount() const
virtual void SetEllipseCenter(const VECTOR2I &aPt)
virtual void SetEllipseMinorRadius(int aR)
virtual void SetEllipseMajorRadius(int aR)
virtual void SetEllipseStartAngle(const EDA_ANGLE &aA)
void SetFillMode(FILL_T aFill)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
void SetTextColor(const COLOR4D &aColor)
virtual void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
void SetUnresolvedFontName(const wxString &aFontName)
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual void SetTextPos(const VECTOR2I &aPoint)
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
void SetBoldFlag(bool aBold)
Set only the bold flag, without changing the font.
virtual void SetVisible(bool aVisible)
void SetLineSpacing(double aLineSpacing)
virtual void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
static bool ValidateHyperlink(const wxString &aURL)
Check if aURL is a valid hyperlink.
void SetItalicFlag(bool aItalic)
Set only the italic flag, without changing the font.
void SetHyperlink(wxString aLink)
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
void ParseEmbedded(EMBEDDED_FILES *aFiles)
const std::vector< wxString > * UpdateFontFiles()
Helper function to get a list of fonts for fontconfig to add to the library.
Simple container to manage fill parameters.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
A color representation with 4 components: red, green, blue, alpha.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Define a library symbol object.
wxString GetName() const override
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
EMBEDDED_FILES * GetEmbeddedFiles() override
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Describe the page size and margins of a paper page on which to eventually print or plot.
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
bool SetType(PAGE_SIZE_TYPE aPageSize, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
void SetWidthMM(double aWidthInMM)
void SetHeightMM(double aHeightInMM)
const PAGE_SIZE_TYPE & GetType() const
A progress reporter interface for use in multi-threaded environments.
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
bool ReadImageFile(const wxString &aFullFilename)
Read and store an image file.
const BITMAP_BASE & GetImage() const
Get the underlying image.
double GetImageScale() const
void SetImageScale(double aScale)
Set the image "zoom" value.
Holds all the data relating to one schematic.
Object to handle a bitmap image that can be inserted in a schematic.
Class for a wire to bus entry.
void SetPinLength(int aLength)
virtual const wxString & GetText() const override
Return the string associated with the text object.
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
static bool IsNetclassLabelFieldName(const wxString &aName)
Test whether aName is one of the known translations of the directive-label net class field name (used...
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this label.
A set of SCH_ITEMs (i.e., without duplicates).
SCH_ITEM * ParseSymbolDrawItem()
SCH_SHAPE * parseSymbolPolyLine()
SCH_TABLE * parseSchTable()
bool m_appending
Appending load status.
unsigned m_lastProgressLine
SCH_FIELD * parseSchField(SCH_ITEM *aParent)
SCH_SHAPE * parseSchCircle()
SCH_TEXT * parseSchText()
SCH_TABLECELL * parseSchTableCell()
void parseSchSymbolInstances(SCH_SCREEN *aScreen)
void parsePinNumbers(std::unique_ptr< LIB_SYMBOL > &aSymbol)
LIB_SYMBOL * parseLibSymbol(LIB_SYMBOL_MAP &aSymbolLibMap)
void parseEllipseBody(SCH_SHAPE *aShape, bool aIsArc, bool aIsSchematic, TSCHEMATIC_T::T aFirstTok)
SCH_RULE_AREA * parseSchRuleArea()
SCH_SHAPE * parseSymbolEllipseArc()
SCH_ITEM * parseSymbolText()
PROGRESS_REPORTER * m_progressReporter
void parseFill(FILL_PARAMS &aFill)
SCH_TEXTBOX * parseSymbolTextBox()
void parseBusAlias(SCH_SCREEN *aScreen)
void parseTITLE_BLOCK(TITLE_BLOCK &aTitleBlock)
void parseGroupMembers(GROUP_INFO &aGroupInfo)
void parseStroke(STROKE_PARAMS &aStroke)
Parse stroke definition aStroke.
int m_unit
The current unit being parsed.
std::map< wxString, std::set< wxString > > m_netChainMemberNets
SCH_SHAPE * parseSymbolBezier()
void parseEDA_TEXT(EDA_TEXT *aText, bool aConvertOverbarSyntax, bool aEnforceMinTextSize=true)
SCH_TEXTBOX * parseSchTextBox()
void resolveGroups(SCH_SCREEN *aParent)
std::map< wxString, wxString > m_netChainNetClasses
SCH_SHEET * m_rootSheet
The rootsheet for full project loads or null for importing a schematic.
SCH_SHAPE * parseSchArc()
SCH_SHAPE * parseSchPolyLine()
SCH_BITMAP * parseImage()
SCH_SHAPE * parseSymbolCircle()
wxString m_generatorVersion
void ParseLib(LIB_SYMBOL_MAP &aSymbolLibMap)
SCH_PIN * parseSymbolPin()
std::vector< GROUP_INFO > m_groupInfos
void parseHeader(TSCHEMATIC_T::T aHeaderType, int aFileVersion)
void parseBodyStyles(std::unique_ptr< LIB_SYMBOL > &aSymbol)
SCH_SHAPE * parseSchEllipse()
void parseMargins(int &aLeft, int &aTop, int &aRight, int &aBottom)
wxString m_symbolName
The current symbol name.
std::map< wxString, CHAIN_TERMINALS > m_netChainTerminalRefs
VECTOR2I parseXY(bool aInvertY=false)
SCH_SHAPE * parseSymbolRectangle()
void parsePinNames(std::unique_ptr< LIB_SYMBOL > &aSymbol)
SCH_SHAPE * parseSchBezier()
std::vector< wxString > m_parseWarnings
Non-fatal warnings collected during parsing.
SCH_JUNCTION * parseJunction()
void ParseSchematic(SCH_SHEET *aSheet, bool aIsCopyablyOnly=false, int aFileVersion=SEXPR_SCHEMATIC_FILE_VERSION)
Parse the internal LINE_READER object into aSheet.
SCH_SHEET_PIN * parseSchSheetPin(SCH_SHEET *aSheet)
int m_bodyStyle
The current body style being parsed.
SCH_NO_CONNECT * parseNoConnect()
SCH_SHAPE * parseSymbolArc()
SCH_BUS_WIRE_ENTRY * parseBusEntry()
SCH_SHAPE * parseSymbolEllipse()
std::map< wxString, COLOR4D > m_netChainColors
SCH_SHAPE * parseSchRectangle()
SCH_FIELD * parseProperty(std::unique_ptr< LIB_SYMBOL > &aSymbol)
SCH_SYMBOL * parseSchematicSymbol()
void parseSchTextBoxContent(SCH_TEXTBOX *aTextBox)
bool parseMaybeAbsentBool(bool aDefaultValue)
Parses a boolean flag inside a list that existed before boolean normalization.
void parsePAGE_INFO(PAGE_INFO &aPageInfo)
int m_requiredVersion
Set to the symbol library file version required.
int m_maxError
Max deviation allowed when approximating bezier curves.
const LINE_READER * m_lineReader
LIB_SYMBOL * ParseSymbol(LIB_SYMBOL_MAP &aSymbolLibMap, int aFileVersion=SEXPR_SYMBOL_LIB_FILE_VERSION)
Parse internal LINE_READER object into symbols and return all found.
void skipToBlockEnd(int aDepth=1)
Skip tokens until we reach the end of the current S-expression block.
void parseSchSheetInstances(SCH_SHEET *aRootSheet, SCH_SCREEN *aScreen)
SCH_SHAPE * parseSchEllipseArc()
SCH_IO_KICAD_SEXPR_PARSER(LINE_READER *aLineReader=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr, unsigned aLineCount=0, SCH_SHEET *aRootSheet=nullptr, bool aIsAppending=false)
Base class for any item which can be embedded within the SCHEMATIC container class,...
void SetLocked(bool aLocked) override
bool IsLocked() const override
void SetFieldsAutoplaced(AUTOPLACE_ALGO aAlgo)
void SetShape(LABEL_FLAG_SHAPE aShape)
std::vector< SCH_FIELD > & GetFields()
Segment description base class to describe items which have 2 end points (track, wire,...
void SetStartPoint(const VECTOR2I &aPosition)
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
void SetEndPoint(const VECTOR2I &aPosition)
void SetFileFormatVersionAtLoad(int aVersion)
std::vector< SCH_SHEET_INSTANCE > m_sheetInstances
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
void AddLibSymbol(LIB_SYMBOL *aLibSymbol)
Add aLibSymbol to the library symbol map.
void AddBusAlias(std::shared_ptr< BUS_ALIAS > aAlias)
Add a bus alias definition.
void SetPageSettings(const PAGE_INFO &aPageSettings)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
const KIID & GetUuid() const
void UpdateLocalLibSymbolLinks()
Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in this schematic with the local projec...
void SetLegacySymbolInstanceData()
Update the symbol value and footprint instance data for legacy designs.
SCHEMATIC * Schematic() const
void FixupEmbeddedData()
After loading a file from disk, the library symbols do not yet contain the full data for their embedd...
int GetFileFormatVersionAtLoad() const
wxString GroupsSanityCheck(bool repair=false)
Consistency check of internal m_groups structure.
KIID m_uuid
A unique identifier for each schematic file.
std::vector< SCH_SYMBOL_INSTANCE > m_symbolInstances
The list of symbol instances loaded from the schematic file.
void SetPosition(const VECTOR2I &aPos) override
void SetStroke(const STROKE_PARAMS &aStroke) override
STROKE_PARAMS GetStroke() const override
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Variant information for a schematic sheet.
void InitializeAttributes(const SCH_SHEET &aSheet)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
SCH_SCREEN * GetScreen() const
Variant information for a schematic symbol.
void InitializeAttributes(const SCH_SYMBOL &aSymbol)
void SetMarginBottom(int aBottom)
int GetLegacyTextMargin() const
void SetMarginLeft(int aLeft)
void SetMarginRight(int aRight)
void SetExcludedFromSim(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
void SetMarginTop(int aTop)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
void ParseStroke(STROKE_PARAMS &aStroke)
Simple container to manage line stroke parameters.
void SetLineStyle(LINE_STYLE aLineStyle)
LINE_STYLE GetLineStyle() const
KIGFX::COLOR4D GetColor() const
Hold the information shown in the lower right corner of a plot, printout, or editing view.
void SetRevision(const wxString &aRevision)
void SetComment(int aIdx, const wxString &aComment)
void SetTitle(const wxString &aTitle)
void SetCompany(const wxString &aCompany)
void SetDate(const wxString &aDate)
Set the date field, and defaults to the current time and date.
std::map< wxString, wxString > m_Fields
bool m_ExcludedFromPosFiles
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_360
static constexpr EDA_ANGLE ANGLE_180
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
@ FILLED_WITH_BG_BODYCOLOR
@ FILLED_SHAPE
Fill with object color.
FONTCONFIG * Fontconfig()
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
#define MAX_PAGE_SIZE_EESCHEMA_MM
#define MIN_PAGE_SIZE_MM
Min and max page sizes for clamping, in mm.
PGM_BASE & Pgm()
The global program "get" accessor.
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
@ PT_INPUT
usual pin input: must be connected
@ PT_NC
not connected (must be left open)
@ PT_TRISTATE
tri state bus pin
@ PT_NIC
not internally connected (may be connected to anything)
@ PT_BIDI
input or output (like port for a microprocessor)
@ PT_OPENEMITTER
pin type open emitter
@ PT_POWER_OUT
output of a regulator: intended to be connected to power input pins
@ PT_OPENCOLLECTOR
pin type open collector
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
@ PIN_UP
The pin extends upwards from the connection point: Probably on the bottom side of the symbol.
@ PIN_RIGHT
The pin extends rightwards from the connection point.
@ PIN_LEFT
The pin extends leftwards from the connection point: Probably on the right side of the symbol.
@ PIN_DOWN
The pin extends downwards from the connection: Probably on the top side of the symbol.
const SCH_FIELD * FindField(const std::vector< SCH_FIELD > &aFields, FIELD_T aFieldId)
#define SEXPR_SYMBOL_LIB_FILE_VERSION
This file contains the file format version information for the s-expression schematic and symbol libr...
#define SEXPR_SCHEMATIC_FILE_VERSION
Schematic file version.
Class to handle a set of SCH_ITEMs.
double parseDouble(LINE_READER &aReader, const char *aLine, const char **aOutput)
Parses an ASCII point string with possible leading whitespace into a double precision floating point ...
void fixupSchFillMode(SCH_SHAPE *aShape)
#define SIM_LEGACY_ENABLE_FIELD
#define SIM_LEGACY_ENABLE_FIELD_V7
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.
wxString UnescapeString(const wxString &aSource)
wxString From_UTF8(const char *cstring)
A filename or source description, a problem input line, a line number, a byte offset,...
std::vector< KIID > memberUuids
ELECTRICAL_PINTYPE m_Type
A simple container for sheet instance information.
std::map< wxString, SCH_SHEET_VARIANT > m_Variants
A list of sheet variants.
A simple container for schematic symbol instance information.
std::map< wxString, SCH_SYMBOL_VARIANT > m_Variants
A list of symbol variants.
std::map< wxString, LIB_SYMBOL *, LibSymbolMapSort > LIB_SYMBOL_MAP
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ USER
The field ID hasn't been set yet; field is invalid.
@ INTERSHEET_REFS
Global label cross-reference page numbers.
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
#define SHEET_MANDATORY_FIELDS
#define GLOBALLABEL_MANDATORY_FIELDS
wxString GetCanonicalFieldName(FIELD_T aFieldType)
KIBIS top(path, &reporter)
std::vector< std::vector< std::string > > table
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
static constexpr double IU_PER_MM
Mock up a conversion function.
const VECTOR2I CalcArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
VECTOR2< int32_t > VECTOR2I