34#include <wx/mstream.h>
35#include <wx/tokenzr.h>
64using namespace TSCHEMATIC_T;
68 unsigned aLineCount,
SCH_SHEET* aRootSheet,
70 SCHEMATIC_LEXER( aLineReader ),
71 m_requiredVersion( 0 ),
75 m_appending( aIsAppending ),
76 m_progressReporter( aProgressReporter ),
77 m_lineReader( aLineReader ),
78 m_lastProgressLine( 0 ),
79 m_lineCount( aLineCount ),
80 m_rootSheet( aRootSheet )
87 const unsigned PROGRESS_DELTA = 250;
109 KIID id( FromUTF8() );
126 else if( token == T_no )
129 Expecting(
"yes or no" );
143 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
145 if( token != T_LEFT )
150 if( token == T_symbol )
155 aSymbolLibMap[symbol->
GetName()] = symbol;
159 Expecting(
"symbol" );
167 wxCHECK_MSG( CurTok() == T_symbol,
nullptr,
168 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a symbol." ) );
174 wxString unitDisplayName;
176 std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>( wxEmptyString );
179 symbol->SetUnitCount( 1 );
186 if( !IsSymbol( token ) )
188 THROW_PARSE_ERROR(
_(
"Invalid symbol name" ), CurSource(), CurLine(), CurLineNumber(),
199 if(
static_cast<int>(
name.size() ) > bad_pos )
202 _(
"Symbol %s contains invalid character '%c'" ),
name,
210 CurLineNumber(), CurOffset() );
215 symbol->SetLibId(
id );
217 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
219 if( token != T_LEFT )
238 if( token != T_hide )
241 symbol->SetShowPinNumbers(
false );
251 symbol->SetIncludeOnBoard(
parseBool() );
263 if( !IsSymbol( token ) )
266 CurLineNumber(), CurOffset() );
270 auto it = aSymbolLibMap.find(
name );
272 if( it == aSymbolLibMap.end() )
274 error.Printf(
_(
"No parent for extended symbol %s" ),
name.c_str() );
275 THROW_PARSE_ERROR( error, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
278 symbol->SetParent( it->second );
287 if( !IsSymbol( token ) )
290 CurLineNumber(), CurOffset() );
297 error.Printf(
_(
"Invalid symbol unit name prefix %s" ),
name.c_str() );
298 THROW_PARSE_ERROR( error, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
303 wxStringTokenizer tokenizer(
name,
"_" );
305 if( tokenizer.CountTokens() != 2 )
307 error.Printf(
_(
"Invalid symbol unit name suffix %s" ),
name.c_str() );
308 THROW_PARSE_ERROR( error, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
311 if( !tokenizer.GetNextToken().ToLong( &tmp ) )
313 error.Printf(
_(
"Invalid symbol unit number %s" ),
name.c_str() );
314 THROW_PARSE_ERROR( error, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
317 m_unit =
static_cast<int>( tmp );
319 if( !tokenizer.GetNextToken().ToLong( &tmp ) )
321 error.Printf(
_(
"Invalid symbol convert number %s" ),
name.c_str() );
322 THROW_PARSE_ERROR( error, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
328 symbol->SetConversion(
true,
false );
330 if(
m_unit > symbol->GetUnitCount() )
331 symbol->SetUnitCount(
m_unit,
false );
333 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
335 if( token != T_LEFT )
345 if( IsSymbol( token ) )
347 unitDisplayName = FromUTF8();
348 symbol->SetUnitDisplayName(
m_unit, unitDisplayName );
363 wxCHECK_MSG( item,
nullptr,
"Invalid draw item pointer." );
366 symbol->AddDrawItem( item,
false );
370 Expecting(
"arc, bezier, circle, pin, polyline, rectangle, or text" );
389 wxCHECK_MSG( item,
nullptr,
"Invalid draw item pointer." );
392 symbol->AddDrawItem( item,
false );
396 Expecting(
"pin_names, pin_numbers, arc, bezier, circle, pin, polyline, "
397 "rectangle, or text" );
401 symbol->GetDrawItems().sort();
404 return symbol.release();
445 Expecting(
"arc, bezier, circle, pin, polyline, rectangle, or text" );
459 constexpr double int_limit = std::numeric_limits<int>::max() * 0.7071;
461 return KiROUND( Clamp<double>( -int_limit, retval, int_limit ) );
469 constexpr double int_limit = std::numeric_limits<int>::max() * 0.7071;
471 return KiROUND( Clamp<double>( -int_limit, retval, int_limit ) );
478 strokeParser.SyncLineReaderWith( *
this );
481 SyncLineReaderWith( strokeParser );
487 wxCHECK_RET( CurTok() == T_fill,
"Cannot parse " + GetTokenString( CurTok() ) +
" as a fill." );
490 aFill.
m_Color = COLOR4D::UNSPECIFIED;
494 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
496 if( token != T_LEFT )
513 default: Expecting(
"none, outline, color or background" );
534 Expecting(
"type or color" );
542 wxCHECK_RET( aText && ( CurTok() == T_effects || CurTok() == T_href ),
543 "Cannot parse " + GetTokenString( CurTok() ) +
" as an EDA_TEXT." );
559 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
561 if( token == T_LEFT )
567 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
569 if( token == T_LEFT )
576 faceName = FromUTF8();
618 Expecting(
"face, size, thickness, line_spacing, bold, or italic" );
622 if( !faceName.IsEmpty() )
631 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
640 case T_mirror:
break;
641 default: Expecting(
"left, right, top, bottom, or mirror" );
650 wxString hyperlink = FromUTF8();
655 CurSource(), CurLine(), CurLineNumber(), CurOffset() );
671 Expecting(
"font, justify, hide or href" );
679 wxCHECK_RET( CurTok() == aHeaderType,
680 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a header." ) );
686 if( tok == T_version )
719 wxCHECK_RET( CurTok() == T_pin_names,
720 "Cannot parse " + GetTokenString( CurTok() ) +
" as a pin_name token." );
724 if( token == T_LEFT )
728 if( token != T_offset )
729 Expecting(
"offset" );
736 if( token == T_hide )
738 aSymbol->SetShowPinNames(
false );
741 else if( token != T_RIGHT )
744 CurLineNumber(), CurOffset() );
751 wxCHECK_MSG( CurTok() == T_property,
nullptr,
752 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a property." ) );
753 wxCHECK( aSymbol,
nullptr );
757 std::unique_ptr<LIB_FIELD> field = std::make_unique<LIB_FIELD>( aSymbol.get(),
762 if( !IsSymbol( token ) )
764 THROW_PARSE_ERROR(
_(
"Invalid property name" ), CurSource(), CurLine(), CurLineNumber(),
772 THROW_PARSE_ERROR(
_(
"Empty property name" ), CurSource(), CurLine(), CurLineNumber(),
776 field->SetName(
name );
791 if( !IsSymbol( token ) )
793 THROW_PARSE_ERROR(
_(
"Invalid property value" ), CurSource(), CurLine(), CurLineNumber(),
800 field->SetText( value );
802 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
804 if( token != T_LEFT )
812 field->SetId(
parseInt(
"field ID" ) );
817 field->SetPosition(
parseXY() );
827 field->SetNameShown();
831 case T_do_not_autoplace:
832 field->SetCanAutoplace(
false );
837 Expecting(
"id, at, show_name, do_not_autoplace, or effects" );
846 int nextAvailableId = field->GetId() + 1;
849 nextAvailableId += 1;
851 field->SetId( nextAvailableId );
858 existingField = aSymbol->GetFieldById( field->GetId() );
860 *existingField = *field;
862 return existingField;
864 else if(
name ==
"ki_keywords" )
867 aSymbol->SetKeyWords( value );
870 else if(
name ==
"ki_description" )
873 aSymbol->SetDescription( value );
876 else if(
name ==
"ki_fp_filters" )
879 wxArrayString filters;
880 wxStringTokenizer tokenizer( value );
882 while( tokenizer.HasMoreTokens() )
885 filters.Add( curr_token );
888 aSymbol->SetFPFilters( filters );
891 else if(
name ==
"ki_locked" )
895 aSymbol->LockUnits(
true );
901 existingField = aSymbol->FindField( field->GetCanonicalName() );
912 for(
int ii = 1; ii < 10 && existingField; ii++ )
914 wxString newname = base_name;
915 newname <<
'_' << ii;
917 existingField = aSymbol->FindField( newname );
920 field->SetName( newname );
926 aSymbol->AddDrawItem( field.get(),
false );
928 return field.release();
941 wxCHECK_MSG( CurTok() == T_arc,
nullptr,
942 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as an arc." ) );
948 bool hasMidPoint =
false;
956 bool hasAngles =
false;
958 std::unique_ptr<LIB_SHAPE> arc = std::make_unique<LIB_SHAPE>(
nullptr,
SHAPE_T::ARC );
965 if( token == T_private )
967 arc->SetPrivate(
true );
971 for( ; token != T_RIGHT; token = NextTok() )
973 if( token != T_LEFT )
997 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
999 if( token != T_LEFT )
1000 Expecting( T_LEFT );
1028 Expecting(
"at, length, or angles" );
1036 arc->SetStroke( stroke );
1042 arc->SetFillColor( fill.
m_Color );
1046 Expecting(
"start, mid, end, radius, stroke, or fill" );
1052 arc->SetArcGeometry( startPoint, midPoint, endPoint );
1062 EDA_ANGLE arc_start, arc_end, arc_angle;
1063 arc->CalcArcAngles( arc_start, arc_end );
1064 arc_angle = arc_end - arc_start;
1069 arc->SetStart( endPoint );
1070 arc->SetEnd( startPoint );
1073 arc->SetCenter( new_center );
1079 arc->SetCenter( new_center );
1083 else if( hasAngles )
1085 arc->SetCenter( center );
1091 arc->SetStart( endPoint );
1092 arc->SetEnd( startPoint );
1096 EDA_ANGLE arc_start, arc_end, arc_angle;
1097 arc->CalcArcAngles( arc_start, arc_end );
1098 arc_angle = arc_end - arc_start;
1104 arc->SetStart( startPoint );
1105 arc->SetEnd( endPoint );
1109 arc->SetStart( startPoint );
1110 arc->SetEnd( endPoint );
1113 arc->SetCenter( new_center );
1118 wxFAIL_MSG(
"Setting arc without either midpoint or angles not implemented." );
1121 return arc.release();
1127 wxCHECK_MSG( CurTok() == T_bezier,
nullptr,
1128 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a bezier." ) );
1134 std::unique_ptr<LIB_SHAPE> bezier = std::make_unique<LIB_SHAPE>(
nullptr,
SHAPE_T::BEZIER );
1136 bezier->SetUnit(
m_unit );
1141 if( token == T_private )
1143 bezier->SetPrivate(
true );
1147 for( ; token != T_RIGHT; token = NextTok() )
1149 if( token != T_LEFT )
1150 Expecting( T_LEFT );
1160 for( token = NextTok(); token != T_RIGHT; token = NextTok(), ++ii )
1162 if( token != T_LEFT )
1163 Expecting( T_LEFT );
1172 case 0: bezier->SetStart(
parseXY() );
break;
1173 case 1: bezier->SetBezierC1(
parseXY() );
break;
1174 case 2: bezier->SetBezierC2(
parseXY() );
break;
1175 case 3: bezier->SetEnd(
parseXY() );
break;
1176 default: Unexpected(
"control point" );
break;
1186 bezier->SetStroke( stroke );
1192 bezier->SetFillColor( fill.
m_Color );
1196 Expecting(
"pts, stroke, or fill" );
1200 bezier->RebuildBezierToSegmentsPointsList( bezier->GetWidth() );
1202 return bezier.release();
1208 wxCHECK_MSG( CurTok() == T_circle,
nullptr,
1209 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a circle." ) );
1217 std::unique_ptr<LIB_SHAPE> circle = std::make_unique<LIB_SHAPE>(
nullptr,
SHAPE_T::CIRCLE );
1219 circle->SetUnit(
m_unit );
1224 if( token == T_private )
1226 circle->SetPrivate(
true );
1230 for( ; token != T_RIGHT; token = NextTok() )
1232 if( token != T_LEFT )
1233 Expecting( T_LEFT );
1251 circle->SetStroke( stroke );
1257 circle->SetFillColor( fill.
m_Color );
1261 Expecting(
"center, radius, stroke, or fill" );
1265 circle->SetCenter( center );
1266 circle->SetEnd(
VECTOR2I( center.
x + radius, center.
y ) );
1268 return circle.release();
1293 Expecting(
"input, output, bidirectional, tri_state, passive, "
1294 "unspecified, power_in, power_out, open_collector, "
1295 "open_emitter, free or no_connect" );
1315 Expecting(
"line, inverted, clock, inverted_clock, input_low, "
1316 "clock_low, output_low, edge_clock_high, non_logic" );
1321 wxCHECK_MSG( CurTok() == T_pin,
nullptr,
1322 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a pin token." ) );
1327 std::unique_ptr<LIB_PIN>
pin = std::make_unique<LIB_PIN>(
nullptr );
1334 pin->SetType( parseType( token ) );
1340 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
1342 if( token == T_hide )
1344 pin->SetVisible(
false );
1348 if( token != T_LEFT )
1349 Expecting( T_LEFT );
1358 switch(
parseInt(
"pin orientation" ) )
1361 case 90:
pin->SetOrientation(
PIN_UP );
break;
1364 default: Expecting(
"0, 90, 180, or 270" );
1378 if( !IsSymbol( token ) )
1387 pin->SetName( FromUTF8() );
1391 if( token != T_RIGHT )
1395 if( token == T_effects )
1402 pin->SetNameTextSize(
text.GetTextHeight() );
1407 Expecting(
"effects" );
1416 if( !IsSymbol( token ) )
1419 CurLineNumber(), CurOffset() );
1422 pin->SetNumber( FromUTF8() );
1425 if( token != T_RIGHT )
1429 if( token == T_effects )
1436 pin->SetNumberTextSize(
text.GetTextHeight() );
1441 Expecting(
"effects" );
1453 if( !IsSymbol( token ) )
1456 CurLineNumber(), CurOffset() );
1462 alt.
m_Type = parseType( token );
1467 pin->GetAlternates()[ alt.
m_Name ] = alt;
1474 Expecting(
"at, name, number, length, or alternate" );
1478 return pin.release();
1484 wxCHECK_MSG( CurTok() == T_polyline,
nullptr,
1485 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a poly." ) );
1490 std::unique_ptr<LIB_SHAPE> poly = std::make_unique<LIB_SHAPE>(
nullptr,
SHAPE_T::POLY );
1497 if( token == T_private )
1499 poly->SetPrivate(
true );
1503 for( ; token != T_RIGHT; token = NextTok() )
1505 if( token != T_LEFT )
1506 Expecting( T_LEFT );
1513 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
1515 if( token != T_LEFT )
1516 Expecting( T_LEFT );
1532 poly->SetStroke( stroke );
1538 poly->SetFillColor( fill.
m_Color );
1542 Expecting(
"pts, stroke, or fill" );
1546 return poly.release();
1552 wxCHECK_MSG( CurTok() == T_rectangle,
nullptr,
1553 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a rectangle." ) );
1558 std::unique_ptr<LIB_SHAPE> rectangle = std::make_unique<LIB_SHAPE>(
nullptr,
SHAPE_T::RECT );
1560 rectangle->SetUnit(
m_unit );
1565 if( token == T_private )
1567 rectangle->SetPrivate(
true );
1571 for( ; token != T_RIGHT; token = NextTok() )
1573 if( token != T_LEFT )
1574 Expecting( T_LEFT );
1581 rectangle->SetPosition(
parseXY() );
1586 rectangle->SetEnd(
parseXY() );
1592 rectangle->SetStroke( stroke );
1598 rectangle->SetFillColor( fill.
m_Color );
1602 Expecting(
"start, end, stroke, or fill" );
1606 return rectangle.release();
1612 wxCHECK_MSG( CurTok() == T_text,
nullptr,
1613 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a text token." ) );
1616 std::unique_ptr<LIB_TEXT>
text = std::make_unique<LIB_TEXT>(
nullptr );
1622 if( token == T_private )
1624 text->SetPrivate(
true );
1628 if( !IsSymbol( token ) )
1630 THROW_PARSE_ERROR(
_(
"Invalid text string" ), CurSource(), CurLine(), CurLineNumber(),
1634 text->SetText( FromUTF8() );
1636 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
1638 if( token != T_LEFT )
1639 Expecting( T_LEFT );
1657 Expecting(
"at or effects" );
1661 return text.release();
1667 wxCHECK_MSG( CurTok() == T_text_box,
nullptr,
1668 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a text box." ) );
1674 bool foundEnd =
false;
1675 bool foundSize =
false;
1678 std::unique_ptr<LIB_TEXTBOX> textBox = std::make_unique<LIB_TEXTBOX>(
nullptr );
1682 if( token == T_private )
1684 textBox->SetPrivate(
true );
1688 if( !IsSymbol( token ) )
1690 THROW_PARSE_ERROR(
_(
"Invalid text string" ), CurSource(), CurLine(), CurLineNumber(),
1694 textBox->SetText( FromUTF8() );
1696 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
1698 if( token != T_LEFT )
1699 Expecting( T_LEFT );
1730 textBox->SetStroke( stroke );
1736 textBox->SetFillColor( fill.
m_Color );
1744 Expecting(
"at, size, stroke, fill or effects" );
1748 textBox->SetPosition( pos );
1751 textBox->SetEnd( end );
1752 else if( foundSize )
1753 textBox->SetEnd( pos + size );
1755 Expecting(
"size" );
1757 return textBox.release();
1763 wxCHECK_RET( ( CurTok() == T_page &&
m_requiredVersion <= 20200506 ) || CurTok() == T_paper,
1764 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a PAGE_INFO." ) );
1770 wxString pageType = FromUTF8();
1772 if( !aPageInfo.
SetType( pageType ) )
1774 THROW_PARSE_ERROR(
_(
"Invalid page type" ), CurSource(), CurLine(), CurLineNumber(),
1801 if( token == T_portrait )
1806 else if( token != T_RIGHT )
1808 Expecting(
"portrait" );
1815 wxCHECK_RET( CurTok() == T_title_block,
1816 "Cannot parse " + GetTokenString( CurTok() ) +
" as a TITLE_BLOCK." );
1820 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
1822 if( token != T_LEFT )
1823 Expecting( T_LEFT );
1831 aTitleBlock.
SetTitle( FromUTF8() );
1836 aTitleBlock.
SetDate( FromUTF8() );
1851 int commentNumber =
parseInt(
"comment" );
1853 switch( commentNumber )
1902 CurLine(), CurLineNumber(), CurOffset() );
1909 Expecting(
"title, date, rev, company, or comment" );
1919 wxCHECK_MSG( CurTok() == T_property,
nullptr,
1920 "Cannot parse " + GetTokenString( CurTok() ) +
" as a property token." );
1922 T token = NextTok();
1924 if( !IsSymbol( token ) )
1926 THROW_PARSE_ERROR(
_(
"Invalid property name" ), CurSource(), CurLine(), CurLineNumber(),
1930 wxString
name = FromUTF8();
1932 if(
name.IsEmpty() )
1934 THROW_PARSE_ERROR(
_(
"Empty property name" ), CurSource(), CurLine(), CurLineNumber(),
1940 if( !IsSymbol( token ) )
1942 THROW_PARSE_ERROR(
_(
"Invalid property value" ), CurSource(), CurLine(), CurLineNumber(),
1947 wxString value = FromUTF8();
1949 std::unique_ptr<SCH_FIELD> field = std::make_unique<SCH_FIELD>( wxDefaultPosition, -1,
1952 field->SetText( value );
1953 field->SetVisible(
true );
1980 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
1982 if( token != T_LEFT )
1983 Expecting( T_LEFT );
1990 field->SetId(
parseInt(
"field ID" ) );
1995 field->SetPosition(
parseXY() );
2005 field->SetNameShown();
2009 case T_do_not_autoplace:
2010 field->SetCanAutoplace(
false );
2015 Expecting(
"id, at, show_name, do_not_autoplace or effects" );
2019 return field.release();
2025 wxCHECK_MSG( aSheet !=
nullptr,
nullptr,
"" );
2026 wxCHECK_MSG( CurTok() == T_pin,
nullptr,
2027 "Cannot parse " + GetTokenString( CurTok() ) +
" as a sheet pin token." );
2029 T token = NextTok();
2031 if( !IsSymbol( token ) )
2033 THROW_PARSE_ERROR(
_(
"Invalid sheet pin name" ), CurSource(), CurLine(), CurLineNumber(),
2037 wxString
name = FromUTF8();
2039 if(
name.IsEmpty() )
2041 THROW_PARSE_ERROR(
_(
"Empty sheet pin name" ), CurSource(), CurLine(), CurLineNumber(),
2045 auto sheetPin = std::make_unique<SCH_SHEET_PIN>( aSheet,
VECTOR2I( 0, 0 ),
name );
2057 Expecting(
"input, output, bidirectional, tri_state, or passive" );
2060 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2062 if( token != T_LEFT )
2063 Expecting( T_LEFT );
2071 sheetPin->SetPosition(
parseXY() );
2077 else if(
angle == 90.0 )
2079 else if(
angle == 180.0 )
2081 else if(
angle == 270.0 )
2084 Expecting(
"0, 90, 180, or 270" );
2101 Expecting(
"at, uuid or effects" );
2105 return sheetPin.release();
2111 wxCHECK_RET( CurTok() == T_sheet_instances,
2112 "Cannot parse " + GetTokenString( CurTok() ) +
" as an instances token." );
2113 wxCHECK( aScreen, );
2117 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2119 if( token != T_LEFT )
2120 Expecting( T_LEFT );
2138 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2140 if( token != T_LEFT )
2141 Expecting( T_LEFT );
2145 std::vector<wxString> whitespaces = { wxT(
"\r" ), wxT(
"\n" ), wxT(
"\t" ),
2148 size_t numReplacements = 0;
2166 for( wxString ch : whitespaces )
2167 numReplacements += instance.
m_PageNumber.Replace( ch, wxEmptyString );
2172 if( numReplacements > 0 )
2179 Expecting(
"path or page" );
2184 && ( instance.
m_Path.empty() ) )
2200 Expecting(
"path" );
2208 wxCHECK_RET( CurTok() == T_symbol_instances,
2209 "Cannot parse " + GetTokenString( CurTok() ) +
" as an instances token." );
2210 wxCHECK( aScreen, );
2215 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2217 if( token != T_LEFT )
2218 Expecting( T_LEFT );
2235 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2237 if( token != T_LEFT )
2238 Expecting( T_LEFT );
2257 instance.
m_Value = FromUTF8();
2268 Expecting(
"path, unit, value or footprint" );
2277 Expecting(
"path" );
2285 wxCHECK( aSheet !=
nullptr, );
2289 wxCHECK( screen !=
nullptr, );
2291 if( aIsCopyableOnly )
2294 bool fileHasUuid =
false;
2298 if( !aIsCopyableOnly )
2303 if( CurTok() != T_kicad_sch )
2304 Expecting(
"kicad_sch" );
2316 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2318 if( aIsCopyableOnly && token == T_EOF )
2321 if( token != T_LEFT )
2322 Expecting( T_LEFT );
2352 if( aIsCopyableOnly )
2353 Unexpected( T_paper );
2363 if( aIsCopyableOnly )
2364 Unexpected( T_page );
2368 NeedSYMBOLorNUMBER();
2369 NeedSYMBOLorNUMBER();
2376 if( aIsCopyableOnly )
2377 Unexpected( T_title_block );
2391 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2393 if( token != T_LEFT )
2394 Expecting( T_LEFT );
2407 Expecting(
"symbol" );
2504 case T_netclass_flag:
2509 case T_global_label:
2510 case T_hierarchical_label:
2511 case T_directive_label:
2519 case T_sheet_instances:
2523 case T_symbol_instances:
2528 if( aIsCopyableOnly )
2529 Unexpected( T_bus_alias );
2535 Expecting(
"symbol, paper, page, title_block, bitmap, sheet, junction, no_connect, "
2536 "bus_entry, line, bus, text, label, class_label, global_label, "
2537 "hierarchical_label, symbol_instances, or bus_alias" );
2558 wxCHECK_MSG( CurTok() == T_symbol,
nullptr,
2559 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a symbol." ) );
2564 std::unique_ptr<SCH_SYMBOL> symbol = std::make_unique<SCH_SYMBOL>();
2566 std::set<int> fieldIDsRead;
2569 symbol->ClearFieldsAutoplaced();
2574 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2576 if( token != T_LEFT )
2577 Expecting( T_LEFT );
2589 if( !IsSymbol( token ) )
2592 CurLineNumber(), CurOffset() );
2595 libName = FromUTF8();
2604 if( !IsSymbol( token ) && token != T_NUMBER )
2605 Expecting(
"symbol|number" );
2608 wxString
name = FromUTF8();
2613 if(
static_cast<int>(
name.size() ) > bad_pos )
2616 _(
"Symbol %s contains invalid character '%c'" ),
name,
2623 CurLineNumber(), CurOffset() );
2626 symbol->SetLibId( libId );
2632 symbol->SetPosition(
parseXY() );
2634 switch(
static_cast<int>(
parseDouble(
"symbol orientation" ) ) )
2637 case 90: transform =
TRANSFORM( 0, -1, -1, 0 );
break;
2638 case 180: transform =
TRANSFORM( -1, 0, 0, 1 );
break;
2639 case 270: transform =
TRANSFORM( 0, 1, 1, 0 );
break;
2640 default: Expecting(
"0, 90, 180, or 270" );
2643 symbol->SetTransform( transform );
2652 else if( token == T_y )
2655 Expecting(
"x or y" );
2661 symbol->SetUnit(
parseInt(
"symbol unit" ) );
2666 symbol->SetConvert(
parseInt(
"symbol convert" ) );
2676 symbol->SetIncludeOnBoard(
parseBool() );
2685 case T_fields_autoplaced:
2686 symbol->SetFieldsAutoplaced();
2696 case T_default_instance:
2700 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2702 if( token != T_LEFT )
2703 Expecting( T_LEFT );
2722 symbol->SetValueFieldText( FromUTF8() );
2728 symbol->SetFootprintFieldText( FromUTF8() );
2733 Expecting(
"reference, unit, value or footprint" );
2742 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2744 if( token != T_LEFT )
2745 Expecting( T_LEFT );
2749 if( token != T_project )
2750 Expecting(
"project" );
2754 wxString projectName = FromUTF8();
2756 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2758 if( token != T_LEFT )
2759 Expecting( T_LEFT );
2763 if( token != T_path )
2764 Expecting(
"path" );
2773 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2775 if( token != T_LEFT )
2776 Expecting( T_LEFT );
2795 symbol->SetValueFieldText( FromUTF8() );
2801 symbol->SetFootprintFieldText( FromUTF8() );
2806 Expecting(
"reference, unit, value or footprint" );
2809 symbol->AddHierarchicalReference( instance );
2824 int nextAvailableId = field->
GetId() + 1;
2827 nextAvailableId += 1;
2829 field->
SetId( nextAvailableId );
2832 if( symbol->GetFieldById( field->
GetId() ) )
2833 *symbol->GetFieldById( field->
GetId() ) = *field;
2835 symbol->AddField( *field );
2838 symbol->UpdatePrefix();
2853 number = FromUTF8();
2855 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2857 if( token != T_LEFT )
2858 Expecting( T_LEFT );
2882 Expecting(
"alternate or uuid" );
2886 symbol->GetRawPins().emplace_back( std::make_unique<SCH_PIN>( symbol.get(),
2889 const_cast<KIID&
>( symbol->GetRawPins().back()->m_Uuid ) = uuid;
2894 Expecting(
"lib_id, lib_name, at, mirror, uuid, on_board, in_bom, dnp, "
2895 "default_instance, property, pin, or instances" );
2899 if( !libName.IsEmpty() && ( symbol->GetLibId().Format().wx_str() != libName ) )
2900 symbol->SetSchSymbolLibraryName( libName );
2903 symbol->ClearFlags();
2905 return symbol.release();
2911 wxCHECK_MSG( CurTok() == T_image,
nullptr,
2912 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as an image." ) );
2915 std::unique_ptr<SCH_BITMAP> bitmap = std::make_unique<SCH_BITMAP>();
2917 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
2919 if( token != T_LEFT )
2920 Expecting( T_LEFT );
2927 bitmap->SetPosition(
parseXY() );
2932 bitmap->GetImage()->SetScale(
parseDouble(
"image scale factor" ) );
2934 if( !std::isnormal( bitmap->GetImage()->GetScale() ) )
2935 bitmap->GetImage()->SetScale( 1.0 );
2954 data.reserve( 1 << 17 );
2956 while( token != T_RIGHT )
2958 if( !IsSymbol( token ) )
2959 Expecting(
"base64 image data" );
2965 wxMemoryBuffer buffer = wxBase64Decode( data );
2966 wxMemoryOutputStream stream( buffer.GetData(), buffer.GetBufSize() );
2967 wxImage*
image =
new wxImage();
2968 wxMemoryInputStream istream( stream );
2969 image->LoadFile( istream, wxBITMAP_TYPE_PNG );
2970 bitmap->GetImage()->SetImage(
image );
2975 Expecting(
"at, scale, uuid or data" );
2979 return bitmap.release();
2985 wxCHECK_MSG( CurTok() == T_sheet,
nullptr,
2986 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a sheet." ) );
2992 std::vector<SCH_FIELD> fields;
2993 std::unique_ptr<SCH_SHEET> sheet = std::make_unique<SCH_SHEET>();
2994 std::set<int> fieldIDsRead;
2997 sheet->ClearFieldsAutoplaced();
2999 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3001 if( token != T_LEFT )
3002 Expecting( T_LEFT );
3009 sheet->SetPosition(
parseXY() );
3018 sheet->SetSize( size );
3023 case T_fields_autoplaced:
3024 sheet->SetFieldsAutoplaced();
3030 sheet->SetBorderWidth( stroke.
GetWidth() );
3031 sheet->SetBorderColor( stroke.
GetColor() );
3036 sheet->SetBackgroundColor( fill.
m_Color );
3053 if( fields.empty() )
3067 if( field->
GetId() < 0 )
3070 while( !fieldIDsRead.insert( field->
GetId() ).second )
3073 fields.emplace_back( *field );
3083 std::vector<SCH_SHEET_INSTANCE> instances;
3085 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3087 if( token != T_LEFT )
3088 Expecting( T_LEFT );
3092 if( token != T_project )
3093 Expecting(
"project" );
3097 wxString projectName = FromUTF8();
3099 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3101 if( token != T_LEFT )
3102 Expecting( T_LEFT );
3106 if( token != T_path )
3107 Expecting(
"path" );
3116 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3118 if( token != T_LEFT )
3119 Expecting( T_LEFT );
3139 std::vector<wxString> whitespaces = { wxT(
"\r" ), wxT(
"\n" ),
3140 wxT(
"\t" ), wxT(
" " ) };
3142 for( wxString ch : whitespaces )
3151 Expecting(
"page" );
3155 instances.emplace_back( instance );
3159 sheet->setInstances( instances );
3164 Expecting(
"at, size, stroke, background, instances, uuid, property, or pin" );
3168 sheet->SetFields( fields );
3170 return sheet.release();
3176 wxCHECK_MSG( CurTok() == T_junction,
nullptr,
3177 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a junction." ) );
3180 std::unique_ptr<SCH_JUNCTION> junction = std::make_unique<SCH_JUNCTION>();
3182 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3184 if( token != T_LEFT )
3185 Expecting( T_LEFT );
3192 junction->SetPosition(
parseXY() );
3210 junction->SetColor(
color );
3222 Expecting(
"at, diameter, color or uuid" );
3226 return junction.release();
3232 wxCHECK_MSG( CurTok() == T_no_connect,
nullptr,
3233 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a no connect." ) );
3236 std::unique_ptr<SCH_NO_CONNECT> no_connect = std::make_unique<SCH_NO_CONNECT>();
3238 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3240 if( token != T_LEFT )
3241 Expecting( T_LEFT );
3248 no_connect->SetPosition(
parseXY() );
3259 Expecting(
"at or uuid" );
3263 return no_connect.release();
3269 wxCHECK_MSG( CurTok() == T_bus_entry,
nullptr,
3270 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a bus entry." ) );
3274 std::unique_ptr<SCH_BUS_WIRE_ENTRY> busEntry = std::make_unique<SCH_BUS_WIRE_ENTRY>();
3276 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3278 if( token != T_LEFT )
3279 Expecting( T_LEFT );
3286 busEntry->SetPosition(
parseXY() );
3296 busEntry->SetSize( size );
3303 busEntry->SetStroke( stroke );
3313 Expecting(
"at, size, uuid or stroke" );
3317 return busEntry.release();
3328 std::unique_ptr<SCH_SHAPE> polyline = std::make_unique<SCH_SHAPE>(
SHAPE_T::POLY, layer );
3330 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3332 if( token != T_LEFT )
3333 Expecting( T_LEFT );
3340 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3342 if( token != T_LEFT )
3343 Expecting( T_LEFT );
3350 polyline->AddPoint(
parseXY() );
3358 polyline->SetStroke( stroke );
3364 polyline->SetFillColor( fill.
m_Color );
3374 Expecting(
"pts, uuid, stroke, or fill" );
3378 return polyline.release();
3397 wxCHECK_MSG(
false,
nullptr,
"Cannot parse " + GetTokenString( CurTok() ) +
" as a line." );
3400 std::unique_ptr<SCH_LINE> line = std::make_unique<SCH_LINE>(
VECTOR2I(), layer );
3402 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3404 if( token != T_LEFT )
3405 Expecting( T_LEFT );
3418 line->SetStartPoint(
parseXY() );
3426 line->SetEndPoint(
parseXY() );
3433 line->SetStroke( stroke );
3443 Expecting(
"at, uuid or stroke" );
3447 return line.release();
3453 wxCHECK_MSG( CurTok() == T_arc,
nullptr,
3454 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as an arc." ) );
3462 std::unique_ptr<SCH_SHAPE> arc = std::make_unique<SCH_SHAPE>(
SHAPE_T::ARC );
3464 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3466 if( token != T_LEFT )
3467 Expecting( T_LEFT );
3490 arc->SetStroke( stroke );
3496 arc->SetFillColor( fill.
m_Color );
3501 const_cast<KIID&
>( arc->m_Uuid ) =
KIID( FromUTF8() );
3506 Expecting(
"start, mid, end, stroke, fill or uuid" );
3510 arc->SetArcGeometry( startPoint, midPoint, endPoint );
3512 return arc.release();
3518 wxCHECK_MSG( CurTok() == T_circle,
nullptr,
3519 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a circle." ) );
3526 std::unique_ptr<SCH_SHAPE> circle = std::make_unique<SCH_SHAPE>(
SHAPE_T::CIRCLE );
3528 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3530 if( token != T_LEFT )
3531 Expecting( T_LEFT );
3549 circle->SetStroke( stroke );
3555 circle->SetFillColor( fill.
m_Color );
3560 const_cast<KIID&
>( circle->m_Uuid ) =
KIID( FromUTF8() );
3565 Expecting(
"center, radius, stroke, fill or uuid" );
3569 circle->SetCenter( center );
3570 circle->SetEnd(
VECTOR2I( center.
x + radius, center.
y ) );
3572 return circle.release();
3578 wxCHECK_MSG( CurTok() == T_rectangle,
nullptr,
3579 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a rectangle." ) );
3584 std::unique_ptr<SCH_SHAPE> rectangle = std::make_unique<SCH_SHAPE>(
SHAPE_T::RECT );
3586 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3588 if( token != T_LEFT )
3589 Expecting( T_LEFT );
3596 rectangle->SetPosition(
parseXY() );
3601 rectangle->SetEnd(
parseXY() );
3607 rectangle->SetStroke( stroke );
3613 rectangle->SetFillColor( fill.
m_Color );
3618 const_cast<KIID&
>( rectangle->m_Uuid ) =
KIID( FromUTF8() );
3623 Expecting(
"start, end, stroke, fill or uuid" );
3627 return rectangle.release();
3633 wxCHECK_MSG( CurTok() == T_bezier,
nullptr,
3634 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a bezier." ) );
3639 std::unique_ptr<SCH_SHAPE> bezier = std::make_unique<SCH_SHAPE>(
SHAPE_T::BEZIER );
3641 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3643 if( token != T_LEFT )
3644 Expecting( T_LEFT );
3651 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3653 if( token != T_LEFT )
3654 Expecting( T_LEFT );
3661 bezier->AddPoint(
parseXY() );
3670 bezier->SetStroke( stroke );
3676 bezier->SetFillColor( fill.
m_Color );
3681 const_cast<KIID&
>( bezier->m_Uuid ) =
KIID( FromUTF8() );
3686 Expecting(
"pts, stroke, fill or uuid" );
3690 return bezier.release();
3697 std::unique_ptr<SCH_TEXT>
text;
3701 case T_text:
text = std::make_unique<SCH_TEXT>();
break;
3702 case T_label:
text = std::make_unique<SCH_LABEL>();
break;
3703 case T_global_label:
text = std::make_unique<SCH_GLOBALLABEL>();
break;
3704 case T_hierarchical_label:
text = std::make_unique<SCH_HIERLABEL>();
break;
3705 case T_netclass_flag:
text = std::make_unique<SCH_DIRECTIVE_LABEL>();
break;
3706 case T_directive_label:
text = std::make_unique<SCH_DIRECTIVE_LABEL>();
break;
3708 wxCHECK_MSG(
false,
nullptr,
"Cannot parse " + GetTokenString( CurTok() ) +
" as text." );
3712 text->ClearFieldsAutoplaced();
3716 text->SetText( FromUTF8() );
3718 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3720 if( token != T_LEFT )
3721 Expecting( T_LEFT );
3730 switch(
static_cast<int>(
parseDouble(
"text angle" ) ) )
3748 Unexpected( T_shape );
3766 Expecting(
"input, output, bidirectional, tri_state, passive, dot, round, diamond"
3777 Unexpected( T_length );
3786 case T_fields_autoplaced:
3787 text->SetFieldsAutoplaced();
3798 &&
text->GetTextAngle().IsVertical() )
3805 &&
text->GetTextAngle().IsHorizontal() )
3837 Unexpected( T_property );
3860 Expecting(
"at, shape, iref, uuid or effects" );
3866 if( label && label->
GetFields().empty() )
3869 return text.release();
3875 wxCHECK_MSG( CurTok() == T_text_box,
nullptr,
3876 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a text box." ) );
3882 bool foundEnd =
false;
3883 bool foundSize =
false;
3886 std::unique_ptr<SCH_TEXTBOX> textBox = std::make_unique<SCH_TEXTBOX>();
3890 textBox->SetText( FromUTF8() );
3892 for( token = NextTok(); token != T_RIGHT; token = NextTok() )
3894 if( token != T_LEFT )
3895 Expecting( T_LEFT );
3926 textBox->SetStroke( stroke );
3932 textBox->SetFillColor( fill.
m_Color );
3941 const_cast<KIID&
>( textBox->m_Uuid ) =
KIID( FromUTF8() );
3946 Expecting(
"at, size, stroke, fill, effects or uuid" );
3950 textBox->SetPosition( pos );
3953 textBox->SetEnd( end );
3954 else if( foundSize )
3955 textBox->SetEnd( pos + size );
3957 Expecting(
"size" );
3959 return textBox.release();
3965 wxCHECK_RET( CurTok() == T_bus_alias,
3966 wxT(
"Cannot parse " ) + GetTokenString( CurTok() ) + wxT(
" as a bus alias." ) );
3967 wxCHECK( aScreen, );
3970 std::shared_ptr<BUS_ALIAS> busAlias = std::make_shared<BUS_ALIAS>( aScreen );
3981 busAlias->SetName( alias );
3986 if( token != T_members )
3987 Expecting(
"members" );
3991 while( token != T_RIGHT )
3993 if( !IsSymbol( token ) )
3994 Expecting(
"quoted string" );
3996 member = FromUTF8();
4001 busAlias->Members().emplace_back( member );
constexpr EDA_IU_SCALE schIUScale
void SetContentModified(bool aModified=true)
KICAD_T Type() const
Returns the type of object.
virtual void SetParent(EDA_ITEM *aParent)
SHAPE_POLY_SET & GetPolyShape()
int GetPointCount() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
void SetTextColor(const COLOR4D &aColor)
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetTextPos(const VECTOR2I &aPoint)
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
virtual void SetVisible(bool aVisible)
void SetLineSpacing(double aLineSpacing)
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 SetHyperlink(wxString aLink)
void SetTextSize(const VECTOR2I &aNewSize)
virtual void SetText(const wxString &aText)
void SetItalic(bool aItalic)
void SetFont(KIFONT::FONT *aFont)
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Simple container to manage fill parameters.
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
A color representation with 4 components: red, green, blue, alpha.
Field object used in symbol libraries.
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
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.
The base class for drawable items used by schematic library symbols.
Define a library symbol object.
wxString GetName() const override
int UpdateFieldOrdinals()
Order optional field indices.
Define a symbol library graphical text item.
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
virtual unsigned LineNumber() const
Return the line number of the last line read from this LINE_READER.
Describe the page size and margins of a paper page on which to eventually print or plot.
void SetWidthMils(int aWidthInMils)
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
static const wxChar Custom[]
"User" defined page type
void SetHeightMils(int aHeightInMils)
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
A progress reporter interface for use in multi-threaded environments.
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void SetCurrentProgress(double aProgress)=0
Set the progress value to aProgress (0..1).
Object to handle a bitmap image that can be inserted in a schematic.
Class for a wire to bus entry.
void SetPinLength(int aLength)
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
const wxString & GetInternalName()
Get the initial name of the field set at creation (or set by SetName()).
Base class for any item which can be embedded within the SCHEMATIC container class,...
void SetFieldsAutoplaced()
void SetShape(LABEL_FLAG_SHAPE aShape) override
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 (and transfers ownership of the pointer).
void SetPageSettings(const PAGE_INFO &aPageSettings)
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.
int GetFileFormatVersionAtLoad() const
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.
std::set< int > m_fieldIDsRead
Field IDs that have been read so far for the current symbol.
void parseBusAlias(SCH_SCREEN *aScreen)
int m_convert
The current body style being parsed.
SCH_SHEET_PIN * parseSchSheetPin(SCH_SHEET *aSheet)
void parseSchSheetInstances(SCH_SHEET *aRootSheet, SCH_SCREEN *aScreen)
SCH_BUS_WIRE_ENTRY * parseBusEntry()
void ParseLib(LIB_SYMBOL_MAP &aSymbolLibMap)
SCH_JUNCTION * parseJunction()
int m_fieldId
The current field ID.
void ParseSchematic(SCH_SHEET *aSheet, bool aIsCopyablyOnly=false, int aFileVersion=SEXPR_SCHEMATIC_FILE_VERSION)
Parse the internal LINE_READER object into aSheet.
LIB_ITEM * ParseDrawItem()
void parseHeader(TSCHEMATIC_T::T aHeaderType, int aFileVersion)
SCH_NO_CONNECT * parseNoConnect()
LIB_SHAPE * parseBezier()
SCH_SHAPE * parseSchCircle()
int m_unit
The current unit being parsed.
LIB_SHAPE * parseCircle()
SCH_SHAPE * parseSchRectangle()
SCH_SYMBOL * parseSchematicSymbol()
const LINE_READER * m_lineReader
SCH_BITMAP * parseImage()
SCH_SHAPE * parseSchBezier()
SCH_SHAPE * parseSchArc()
LIB_FIELD * parseProperty(std::unique_ptr< LIB_SYMBOL > &aSymbol)
void parseStroke(STROKE_PARAMS &aStroke)
Parse stroke definition aStroke.
LIB_SHAPE * parseRectangle()
SCH_SEXPR_PARSER(LINE_READER *aLineReader=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr, unsigned aLineCount=0, SCH_SHEET *aRootSheet=nullptr, bool aIsAppending=false)
void parseTITLE_BLOCK(TITLE_BLOCK &aTitleBlock)
LIB_SHAPE * parsePolyLine()
int m_requiredVersion
Set to the symbol library file version required.
SCH_TEXTBOX * parseSchTextBox()
SCH_TEXT * parseSchText()
LIB_TEXTBOX * parseTextBox()
wxString m_symbolName
The current symbol name.
SCH_FIELD * parseSchField(SCH_ITEM *aParent)
void parseEDA_TEXT(EDA_TEXT *aText, bool aConvertOverbarSyntax)
PROGRESS_REPORTER * m_progressReporter
void parseFill(FILL_PARAMS &aFill)
void parseSchSymbolInstances(SCH_SCREEN *aScreen)
void parsePinNames(std::unique_ptr< LIB_SYMBOL > &aSymbol)
unsigned m_lastProgressLine
void parsePAGE_INFO(PAGE_INFO &aPageInfo)
LIB_SYMBOL * ParseSymbol(LIB_SYMBOL_MAP &aSymbolLibMap, int aFileVersion=SEXPR_SYMBOL_LIB_FILE_VERSION)
SCH_SHEET * m_rootSheet
The rootsheet for full project loads or null for importing a schematic.
SCH_SHAPE * parseSchPolyLine()
bool m_appending
Appending load status.
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.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslated=true)
SCH_SCREEN * GetScreen() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
SHAPE_LINE_CHAIN & Outline(int aIndex)
void ParseStroke(STROKE_PARAMS &aStroke)
Simple container to manage line stroke parameters.
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.
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
static constexpr EDA_ANGLE & ANGLE_180
static constexpr EDA_ANGLE & ANGLE_360
static constexpr EDA_ANGLE & ANGLE_90
static constexpr EDA_ANGLE & ANGLE_0
@ FILLED_WITH_BG_BODYCOLOR
#define DEFAULT_SIZE_TEXT
This is the "default-of-the-default" hardcoded text size; individual application define their own def...
#define THROW_IO_ERROR(msg)
#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 ...
int Mm2mils(double aVal)
Convert mm to mils.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
#define MIN_PAGE_SIZE_MILS
Min and max page sizes for clamping, in mils.
#define MAX_PAGE_SIZE_EESCHEMA_MILS
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
tris 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
static std::shared_ptr< SHAPE > parseShape(SHAPE_TYPE expectedType, wxStringTokenizer &aTokens)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
#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.
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 ...
Schematic and symbol library s-expression file format parser definitions.
@ SHEET_MANDATORY_FIELDS
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.
wxString UnescapeString(const wxString &aSource)
constexpr int MilsToIU(int mils) const
ELECTRICAL_PINTYPE m_Type
A simple container for sheet instance information.
A simple container for schematic symbol instance information.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
std::map< wxString, LIB_SYMBOL *, LibSymbolMapSort > LIB_SYMBOL_MAP
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
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.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
constexpr T Clamp(const T &lower, const T &value, const T &upper)
Limit value within the range lower <= value <= upper.