55#include <api/schematic/schematic_rules.pb.h>
79#include <wx/filename.h>
89 m_netChains = std::make_unique<SCH_CONNECTIVITY::NETCHAIN_MANAGER>(
this );
114 if( !symbol || aProperty->
Name() !=
_HKI(
"Text" ) )
120 wxString newValue = aItem->
Get<wxString>( aProperty );
129 symbol->
SetRef( &sheetPath, newValue );
137 wxString ref = symbol->
GetRef( &sheetPath );
143 std::vector<SCH_SYMBOL*> otherUnits;
149 switch( field->
GetId() )
156 aCommit->
Modify( otherUnit, sheet.LastScreen() );
158 otherUnit->GetField( field->
GetId() )->SetText( newValue );
215 if(
project.m_ErcSettings && !
project.m_ErcSettings->m_ErcExclusionsLegacy.empty() )
220 project.m_ErcSettings =
nullptr;
223 delete project.m_SchematicSettings;
224 project.m_SchematicSettings =
nullptr;
236 project.m_SchematicSettings->LoadFromFile();
237 project.m_SchematicSettings->m_NgspiceSettings->LoadFromFile();
238 project.m_ErcSettings->LoadFromFile();
250 std::shared_ptr<REFDES_TRACKER> refdesTracker =
m_project->GetProjectFile().m_SchematicSettings->m_refDesTracker;
259 refdesTracker->Insert( ref.GetCanonicalRef(
false ).ToStdString() );
280 int unit = aReference.GetSymbol()->GetUnitCount() > 1 ? aReference.GetUnit() : 0;
281 return std::make_pair( aReference.GetComposedRef(), unit );
284 return std::any_of( references.
begin(), references.
end(),
287 return packageUnit( ref ) == packageUnit( aRef );
342 rootSheetPath.push_back( rootSheet );
343 rootSheetPath.SetPageNumber( wxT(
"1" ) );
368 if( aResetConnectionGraph )
382 m_variantNames.insert( variantNames.begin(), variantNames.end() );
389 for(
const auto& [
name, description] :
Settings().m_VariantDescriptions )
397 wxCHECK_RET( !aSheets.empty(), wxS(
"Cannot set empty top-level sheets!" ) );
403 std::vector<SCH_SHEET*> validSheets;
404 validSheets.reserve( aSheets.size() );
409 if( sheet && sheet->m_Uuid !=
niluuid )
410 validSheets.push_back( sheet );
413 if( validSheets.empty() )
416 if( !wasAlreadySetting )
425 std::set<SCH_SHEET*> desiredSheets( validSheets.begin(), validSheets.end() );
433 if( sheet && !desiredSheets.contains( sheet ) )
459 if( validSheets.size() > 1 )
468 wxCHECK_RET( aContent.connectionGraph && aContent.connectionGraph->m_ownedNetChains,
469 wxS(
"AdoptContent requires a staged graph with its own netchain manager" ) );
476 wxCHECK_RET( !aContent.screen || aContent.topLevelSheets.empty(),
477 wxS(
"AdoptContent cannot replace both the screen and the top level sheets" ) );
481 wxCHECK_RET( !aContent.screen || target !=
m_rootSheet,
482 wxS(
"AdoptContent cannot replace the virtual root screen" ) );
486 wxCHECK_RET( aContent.topLevelSheets.empty() || target ==
m_rootSheet,
487 wxS(
"AdoptContent can only replace the top level sheets through the virtual root" ) );
491 if( aContent.screen )
495 aContent.screen->m_uuid = target->
m_Uuid;
496 aContent.screen->IncRefCount();
497 outgoingScreen = std::exchange( target->
m_screen, aContent.screen.release() );
501 screen->m_rtree = std::move( aContent.screenItems );
503 if( aContent.screenLibSymbols )
504 screen->m_libSymbols.swap( aContent.screenLibSymbols->m_libSymbols );
506 --screen->m_modification_sync;
507 screen->BumpConnectivityRevision();
510 for( std::unique_ptr<SCH_ITEM>& item : aContent.itemOwners )
514 std::vector<SCH_SHEET*> outgoingTopLevelSheets;
516 if( !aContent.topLevelSheets.empty() )
528 if( aContent.currentSheet )
536 std::unique_ptr<SCH_CONNECTIVITY::NETCHAIN_MANAGER> outgoingNetChains;
538 if( aContent.preserveNetChains )
548 for(
SCH_SHEET* sheet : outgoingTopLevelSheets )
556 delete outgoingScreen;
559 if( aContent.embeddedFiles )
562 Settings().m_SchDrawingSheetFileName.swap( aContent.drawingSheetFileName );
573 for(
SCH_ITEM* item : screen->Items() )
579 for( std::unique_ptr<SCH_PIN>&
pin : symbol->GetRawPins() )
590 delete outgoingGraph;
647 wxString suffix =
path.ComposeRefSuffix();
651 if( !suffix.IsEmpty() )
676 return suffix ? *suffix : wxString();
691 return wxEmptyString;
720 return wxEmptyString;
732 return wxEmptyString;
744 return wxEmptyString;
754 if(
auto unit =
group->second.find( aUnit ); unit !=
group->second.end() )
777 std::map<KIID_PATH, std::vector<std::pair<KIID, wxString>>> packagesOn;
780 packagesOn[key.second].emplace_back( key.first, suffix );
786 const wxString sheet =
path.PathAsString();
787 reply += sheet.ToStdString() +
"\t" + std::string(
GetRefSuffix(
path ).ToUTF8() ) +
"\n";
790 for(
const auto& [symbol, suffix] : packagesOn[
path.Path()] )
791 reply += ( sheet + symbol.AsString() ).ToStdString() +
"\t" + std::string( suffix.ToUTF8() ) +
"\n";
832 std::map<std::pair<wxString, wxString>, std::vector<MEMBER>> groups;
833 std::map<std::pair<wxString, wxString>, std::set<int>> units;
834 std::set<std::pair<wxString, wxString>> repeated;
835 std::map<KIID, int> firstUnit;
838 std::unordered_map<const SCH_SCREEN*, std::vector<const SCH_SYMBOL*>> multiUnitSymbols;
844 auto [screenSymbols, scan] = multiUnitSymbols.try_emplace(
path.LastScreen() );
853 screenSymbols->second.push_back( symbol );
857 for(
const SCH_SYMBOL* symbol : screenSymbols->second )
864 if(
auto [it, inserted] = firstUnit.emplace( symbol->
m_Uuid, instance.
m_Unit );
865 !inserted && it->second != instance.
m_Unit )
875 if( !units[key].insert( instance.
m_Unit ).second )
876 repeated.insert( key );
880 groups[key].push_back( { symbol->
m_Uuid,
path.PathRef(), instance.
m_Unit, suffix ? *suffix : wxString() } );
887 for(
const auto& [key, members] : groups )
889 if( repeated.count( key ) )
892 wxString lowest = members.front().suffix;
894 for(
const MEMBER& member : members )
895 lowest = std::min( lowest, member.suffix );
897 for(
const MEMBER& member : members )
899 if( member.suffix != lowest )
903 if( std::ranges::any_of( members, [&](
const MEMBER& m ) {
return m.suffix != lowest; } ) )
905 for(
const MEMBER& member : members )
916 std::vector<std::pair<SCH_SHEET_PATH, SCH_SHEET_PATH>> collisions;
917 std::map<std::pair<const SCH_SCREEN*, wxString>,
const SCH_SHEET_PATH*> firstUse;
923 if( suffix.IsEmpty() && !aIncludeEmpty )
926 auto [it, inserted] = firstUse.emplace( std::make_pair(
path.LastScreen(), suffix ), &
path );
929 collisions.emplace_back(
path, *it->second );
939 [&](
const wxString& aVar )
942 aVars->push_back( aVar );
947 add( wxT(
"SHEETPATH" ) );
948 add( wxT(
"SHEETNAME" ) );
949 add( wxT(
"FILENAME" ) );
950 add( wxT(
"FILEPATH" ) );
951 add( wxT(
"PROJECTNAME" ) );
952 add( wxT(
"VARIANT" ) );
953 add( wxT(
"VARIANT_DESC" ) );
958 for( std::pair<wxString, wxString> entry :
m_project->GetTextVars() )
965 wxCHECK( aSheetPath,
false );
967 if( token->IsSameAs( wxT(
"#" ) ) )
972 else if( token->IsSameAs( wxT(
"##" ) ) )
977 i += sheet->CountSheets();
979 *token = wxString::Format(
"%i", i );
982 else if( token->IsSameAs( wxT(
"SHEETPATH" ) ) )
987 else if( token->IsSameAs( wxT(
"SHEETNAME" ) ) )
992 else if( token->IsSameAs( wxT(
"FILENAME" ) ) )
995 *token = fn.GetFullName();
998 else if( token->IsSameAs( wxT(
"FILEPATH" ) ) )
1001 *token = fn.GetFullPath();
1004 else if( token->IsSameAs( wxT(
"PROJECTNAME" ) ) )
1009 else if( token->IsSameAs( wxT(
"VARIANTNAME" ) ) || token->IsSameAs( wxT(
"VARIANT" ) ) )
1014 else if( token->IsSameAs( wxT(
"VARIANT_DESC" ) ) )
1027 if(
m_project->TextVarResolver( token ) )
1039 return wxString( wxEmptyString );
1044 return wxString( wxEmptyString );
1053 return defaultSettings;
1056 return *
m_project->GetProjectFile().m_SchematicSettings;
1063 return *
m_project->GetProjectFile().m_ErcSettings;
1087 if( !inserted && !comment.empty() && it->GetComment().empty() )
1099 using GROUP_ANCHOR = std::variant<KIID, std::pair<int, int>>;
1100 using GROUP_KEY = std::tuple<int, KIID_PATH, GROUP_ANCHOR>;
1101 std::map<GROUP_KEY, SCH_MARKER*> groupMarkers;
1104 std::optional<NC_GROUPS> ncGroups;
1105 std::optional<std::map<GROUP_KEY, KIID>> ncFlagGroups;
1106 std::optional<std::map<GROUP_KEY, KIID>> hierarchyGroups;
1107 std::optional<std::vector<SCH_CONNECTIVITY::LABEL_WIRE_CONFLICT>> labelWireGroups;
1108 std::optional<std::vector<SCH_CONNECTIVITY::FOUR_WAY_JUNCTION>> fourWayGroups;
1110 const auto groupKey =
1111 [&](
const SCH_MARKER& aMarker ) -> std::optional<GROUP_KEY>
1113 const auto error = std::static_pointer_cast<ERC_ITEM>( aMarker.GetRCItem() );
1116 && !error->MainItemHasSheetPath() && !error->AuxItemHasSheetPath();
1124 if( !
ADVANCED_CFG::GetCfg().m_ConnectivityEngine || !groupedCodes.contains( error->GetErrorCode() )
1125 || !error->IsSheetSpecific() )
1127 return std::nullopt;
1132 if( error->MainItemHasSheetPath() || error->AuxItemHasSheetPath() )
1133 return std::nullopt;
1135 if( !fourWayGroups )
1138 const KIID_PATH&
path = error->GetSpecificSheetPath().PathRef();
1139 const VECTOR2I position = aMarker.GetPosition();
1140 const auto group = std::lower_bound( fourWayGroups->begin(), fourWayGroups->end(),
1141 std::tie(
path, position.
x, position.
y ),
1142 [](
const auto& junction,
const auto&
location )
1144 return std::tie( junction.sheet, junction.position.x, junction.position.y ) < location;
1147 if(
group == fourWayGroups->end() ||
group->sheet !=
path ||
group->position != position )
1148 return std::nullopt;
1150 for(
const KIID&
id : error->GetIDs() )
1152 if( !std::binary_search(
group->equivalentItems.begin(),
group->equivalentItems.end(),
id ) )
1153 return std::nullopt;
1161 if( !
main ||
main->GetPosition() != aMarker.GetPosition() )
1162 return std::nullopt;
1167 return std::nullopt;
1170 if(
static_cast<const SCH_PIN*
>(
main )->GetParentSymbol()->IsPower() )
1171 return std::nullopt;
1174 const KIID_PATH&
path = error->GetSpecificSheetPath().PathRef();
1178 return std::nullopt;
1185 || error->MainItemHasSheetPath()
1186 || error->AuxItemHasSheetPath() )
1188 return std::nullopt;
1191 if( !labelWireGroups )
1194 const auto group = std::find_if( labelWireGroups->begin(), labelWireGroups->end(),
1195 [&](
const auto& conflict )
1197 return conflict.sheet == path
1198 && conflict.position == aMarker.GetPosition();
1201 if(
group == labelWireGroups->end() )
1202 return std::nullopt;
1204 for(
const KIID&
id : error->GetIDs() )
1206 if(
id !=
main->m_Uuid && !std::binary_search(
group->wires.begin(),
group->wires.end(),
id ) )
1207 return std::nullopt;
1215 if( !error->MainItemHasSheetPath()
1216 || error->AuxItemHasSheetPath()
1217 || error->GetMainItemSheetPath().PathRef() !=
path )
1219 return std::nullopt;
1222 if( !hierarchyGroups )
1224 hierarchyGroups.emplace();
1226 for(
const auto& diagnostic :
m_connectivity->Engine().HierarchyErrors() )
1228 for(
const KIID&
id : diagnostic.equivalentItems )
1238 if( found == hierarchyGroups->end() )
1239 return std::nullopt;
1251 ncGroups->emplace( std::make_pair(
group.sheet,
group.position ), std::move(
group ) );
1254 const auto found = ncGroups->find( {
path, aMarker.GetPosition() } );
1256 if( found == ncGroups->end() )
1257 return std::nullopt;
1259 const auto&
group = found->second;
1261 [&](
const KIID& id )
1263 return std::binary_search(
group.pins.begin(),
group.pins.end(),
id );
1266 if( !isPin( error->GetMainItemID() ) )
1267 return std::nullopt;
1269 for(
const KIID&
id : error->GetIDs() )
1275 || ( !isPin(
id ) && !std::binary_search(
group.others.begin(),
group.others.end(),
id ) ) )
1277 return std::nullopt;
1281 return GROUP_KEY{ error->GetErrorCode(),
path,
group.pins.front() };
1287 if( !error->MainItemHasSheetPath()
1288 || error->AuxItemHasSheetPath()
1289 || error->GetMainItemSheetPath().PathRef() !=
path )
1291 return std::nullopt;
1296 for(
const KIID&
id : error->GetIDs() )
1304 const auto& islandOf =
m_connectivity->Published().Auxiliary().IslandOf();
1305 const auto flagIsland = islandOf.find( {
flag, *instance } );
1307 if( flagIsland == islandOf.end() )
1308 return std::nullopt;
1312 ncFlagGroups.emplace();
1314 for(
const auto& diagnostic :
m_connectivity->Engine().NoConnectFlagErrors() )
1316 const auto inst =
m_connectivity->Keys().FindInstance( diagnostic.sheet );
1317 const auto record = inst ? islandOf.find( { diagnostic.flag, *inst } ) : islandOf.end();
1319 if( record == islandOf.end() )
1324 ncFlagGroups->emplace( GROUP_KEY{ code, diagnostic.sheet, record->second.anchor },
1329 const auto group = ncFlagGroups->find( { error->GetErrorCode(),
path, flagIsland->second.anchor } );
1331 if(
group == ncFlagGroups->end() )
1332 return std::nullopt;
1335 const auto flagRow =
rows.find( {
flag, *instance } );
1337 if( flagRow ==
rows.end() )
1338 return std::nullopt;
1340 for(
const KIID&
id : error->GetIDs() )
1346 const auto row =
rows.find( { id, *instance } );
1349 || row ==
rows.end()
1350 || row->second.component != flagRow->second.component
1353 return std::nullopt;
1357 return GROUP_KEY{ error->GetErrorCode(),
path,
group->second };
1360 const auto& islands =
m_connectivity->Published().Auxiliary().IslandOf();
1361 std::optional<GROUP_KEY> key;
1363 for(
const KIID&
id : error->GetIDs() )
1368 const auto island = islands.find( { id, *instance } );
1371 || island == islands.end()
1372 || ( key && std::get<2>( *key ) != GROUP_ANCHOR{ island->second.anchor } ) )
1374 return std::nullopt;
1377 key = GROUP_KEY{ error->GetErrorCode(),
path, island->second.anchor };
1383 std::set<ERC_EXCLUSION, ERC_EXCLUSION_COMPARE> legacyPathlessExclusions;
1384 std::optional<std::vector<SCH_CONNECTIVITY::OFF_GRID_ENDPOINT>> offGridEndpoints;
1386 const auto findPathless =
1389 kiapi::schematic::ErcExclusion legacy = aLookup.ToProto();
1390 legacy.mutable_marker()->clear_sheet_specific_path();
1391 legacy.mutable_marker()->clear_main_item_sheet_path();
1392 legacy.mutable_marker()->clear_aux_item_sheet_path();
1396 legacyPathlessExclusions.insert( *found );
1409 const auto error = std::static_pointer_cast<ERC_ITEM>( marker->
GetRCItem() );
1413 && error->IsSheetSpecific()
1414 && error->GetSpecificSheetPath().PathRef() == sheet.PathRef() )
1417 const bool hasMain = error->MainItemHasSheetPath();
1418 const bool hasAux = error->AuxItemHasSheetPath();
1419 const bool mainHere = hasMain && error->GetMainItemSheetPath().PathRef() == sheet.PathRef();
1420 const bool auxHere = hasAux && error->GetAuxItemSheetPath().PathRef() == sheet.PathRef();
1422 switch( error->GetErrorCode() )
1425 if( engine && !hasMain && !hasAux && sheet.Last()->IsTopLevelSheet() )
1431 it = findPathless( lookup );
1441 if( !marker->
IsExcluded() && mainHere && !hasAux )
1444 kiapi::schematic::ErcExclusion previous = lookup.
ToProto();
1445 previous.mutable_marker()->clear_main_item_sheet_path();
1460 if( !marker->
IsExcluded() && mainHere && !hasAux )
1461 it = findPathless( lookup );
1469 if( !offGridEndpoints )
1477 if( endpoint.sheet != sheet.PathRef()
1478 || endpoint.item != error->GetMainItemID()
1484 for(
const auto& [
pin, position] : endpoint.equivalentPins )
1487 alternate->SetItems( std::vector<KIID>{
pin } );
1488 alternate->SetSheetSpecificPath( sheet );
1489 alternate->SetItemsSheetPaths( sheet );
1490 SCH_MARKER witness( std::move( alternate ), position );
1495 it = findPathless( candidate );
1509 if( !marker->
IsExcluded() && mainHere && auxHere )
1510 it = findPathless( lookup );
1516 if( hasMain && auxHere )
1517 it = findPathless( lookup );
1530 if( !legacyPathlessExclusions.contains( *it ) )
1535 if(
const std::optional<GROUP_KEY> key = groupKey( *marker ) )
1536 groupMarkers.emplace( *key, marker );
1541 for(
const ERC_EXCLUSION& exclusion : legacyPathlessExclusions )
1544 std::vector<SCH_MARKER*> newMarkers;
1553 if(
const std::optional<GROUP_KEY> key = groupKey( *marker ) )
1555 const auto current = groupMarkers.find( *key );
1556 const auto itemCount =
1559 return std::ranges::count_if( aMarker.GetRCItem()->GetIDs(),
1560 [](
const KIID&
id )
1562 return id != niluuid;
1566 if( current != groupMarkers.end()
1567 && itemCount( *current->second ) == itemCount( *marker ) )
1569 current->second->SetExcluded(
true, exclusion.
GetComment() );
1570 groupMarkers.erase( current );
1577 newMarkers.push_back( marker );
1595 const auto& alias = *it;
1597 if( alias && alias->GetName() == aLabel )
1610 auto sameDefinition =
1611 [&](
const std::shared_ptr<BUS_ALIAS>& candidate ) ->
bool
1614 && candidate->GetName() == aAlias->GetName()
1615 && candidate->Members() == aAlias->Members();
1621 std::rotate( it, std::next( it ),
m_busAliases.end() );
1631 std::vector<std::shared_ptr<BUS_ALIAS>> aliases;
1633 for(
const std::shared_ptr<BUS_ALIAS>& alias : aAliases )
1638 std::shared_ptr<BUS_ALIAS> clone = alias->Clone();
1640 auto sameDefinition =
1641 [&](
const std::shared_ptr<BUS_ALIAS>& candidate ) ->
bool
1644 && candidate->GetName() == clone->GetName()
1645 && candidate->Members() == clone->Members();
1648 auto it = std::find_if( aliases.begin(), aliases.end(), sameDefinition );
1650 if( it != aliases.end() )
1651 std::rotate( it, std::next( it ), aliases.end() );
1653 aliases.push_back( clone );
1661 m_project->GetProjectFile().m_BusAliasesDefined =
true;
1681 const std::map<wxString, std::vector<wxString>>& projectAliases =
m_project->GetProjectFile().m_BusAliases;
1683 for(
const auto& [
name, members] : projectAliases )
1685 std::shared_ptr<BUS_ALIAS> busAlias = std::make_shared<BUS_ALIAS>();
1687 busAlias->SetName(
name );
1688 busAlias->SetMembers( members );
1709 m_project->GetProjectFile().m_BusAliasesDefined =
true;
1713 std::map<wxString, std::vector<wxString>> inUse;
1715 for(
const std::shared_ptr<BUS_ALIAS>& alias :
m_busAliases )
1718 inUse.insert_or_assign( alias->GetName(), alias->Members() );
1733 std::map<wxString, std::vector<wxString>>& projectAliases =
m_project->GetProjectFile().m_BusAliases;
1735 projectAliases.clear();
1737 for(
const std::shared_ptr<BUS_ALIAS>& alias :
m_busAliases )
1742 projectAliases.insert_or_assign( alias->GetName(), alias->Members() );
1749 std::set<wxString> names;
1756 if( std::ranges::all_of(
group.instances,
1759 return net.Items().empty();
1765 const auto& net =
group.instances.front();
1770 names.insert(
group.name );
1784 names.insert( key.Name );
1809 wxString ref = token->BeforeFirst(
':', &remainder );
1813 if(
path.size() > 0 )
1819 if(
path.size() > 1 )
1827 wxString variantName;
1828 wxString fieldName = remainder;
1829 int colonPos = remainder.Find(
':' );
1831 if( colonPos != wxNOT_FOUND )
1833 fieldName = remainder.Left( colonPos );
1834 variantName = remainder.Mid( colonPos + 1 );
1846 if( refSymbol->
ResolveTextVar( &sheetPath, &fieldName, variantName, aDepth + 1 ) )
1848 *token = std::move( fieldName );
1853 *token = wxString::Format( wxT(
"<Unresolved: %s:%s>" ),
1854 refSymbol->
GetRef( &sheetPath,
false ),
1866 if( refSheet->
ResolveTextVar( &sheetPath, &remainder, aDepth + 1 ) )
1868 *token = std::move( remainder );
1873 *token = wxString::Format( wxT(
"<Unresolved: %s:%s>" ),
1897 const wxString baseRef = symbol->
GetRef( &sheet,
false );
1903 if( symbol->
GetRef( &sheet,
true ) == ref )
1905 foundSymbol = symbol;
1912 if( !foundSymbol && baseRef == ref )
1914 foundSymbol = symbol;
1925 if( foundSymbol->
ResolveTextVar( &foundPath, &fieldName, variantName, aDepth + 1 ) )
1927 *token = std::move( fieldName );
1932 *token = wxString::Format( wxT(
"<Unresolved: %s:%s>" ),
1933 foundSymbol->
GetRef( &foundPath,
false ),
1941 *token = wxString::Format( wxT(
"<Unresolved: %s>" ), ref );
1946 *token = wxString::Format( wxT(
"<Unknown reference: %s>" ), ref );
1953 std::map<int, wxString> namesMap;
1957 if( sheet.size() == 1 )
1958 namesMap[sheet.GetVirtualPageNumber()] =
_(
"<root sheet>" );
1960 namesMap[sheet.GetVirtualPageNumber()] = sheet.Last()->GetName();
1969 std::map<int, wxString> pagesMap;
1972 pagesMap[sheet.GetVirtualPageNumber()] = sheet.GetPageNumber();
1981 size_t sourceLen = aSource.length();
1983 for(
size_t i = 0; i < sourceLen; ++i )
1987 if( aSource[i] ==
'\\' && i + 2 < sourceLen && aSource[i + 2] ==
'{' &&
1988 ( aSource[i + 1] ==
'$' || aSource[i + 1] ==
'@' ) )
1991 newbuf.append( aSource[i] );
1992 newbuf.append( aSource[i + 1] );
1993 newbuf.append( aSource[i + 2] );
1998 for( i = i + 1; i < sourceLen && braceDepth > 0; ++i )
2000 if( aSource[i] ==
'{' )
2002 else if( aSource[i] ==
'}' )
2005 newbuf.append( aSource[i] );
2011 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i + 1] ==
'{' )
2014 bool isCrossRef =
false;
2017 for( i = i + 2; i < sourceLen; ++i )
2019 if( aSource[i] ==
'{' && ( aSource[i - 1] ==
'_' || aSource[i - 1] ==
'^' || aSource[i - 1] ==
'~' ) )
2024 if( aSource[i] ==
'}' )
2032 if( aSource[i] ==
':' )
2035 token.append( aSource[i] );
2041 wxString ref = token.BeforeFirst(
':', &remainder );
2046 for(
size_t jj = 0; jj < references.
GetCount(); jj++ )
2048 SCH_SYMBOL* refSymbol = references[jj].GetSymbol();
2050 if( ref == refSymbol->
GetRef( &references[jj].GetSheetPath(),
true ) )
2055 token =
path.AsString() + wxS(
":" ) + remainder;
2061 newbuf.append( wxS(
"${" ) + token + wxS(
"}" ) );
2065 newbuf.append( aSource[i] );
2076 size_t sourceLen = aSource.length();
2078 for(
size_t i = 0; i < sourceLen; ++i )
2082 if( aSource[i] ==
'\\' && i + 2 < sourceLen && aSource[i + 2] ==
'{' &&
2083 ( aSource[i + 1] ==
'$' || aSource[i + 1] ==
'@' ) )
2086 newbuf.append( aSource[i] );
2087 newbuf.append( aSource[i + 1] );
2088 newbuf.append( aSource[i + 2] );
2093 for( i = i + 1; i < sourceLen && braceDepth > 0; ++i )
2095 if( aSource[i] ==
'{' )
2097 else if( aSource[i] ==
'}' )
2100 newbuf.append( aSource[i] );
2106 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i + 1] ==
'{' )
2109 bool isCrossRef =
false;
2111 for( i = i + 2; i < sourceLen; ++i )
2113 if( aSource[i] ==
'}' )
2116 if( aSource[i] ==
':' )
2119 token.append( aSource[i] );
2125 wxString ref = token.BeforeFirst(
':', &remainder );
2131 if(
path.size() > 1 )
2140 token = refSymbol->
GetRef( &sheetPath,
true ) + wxS(
":" ) + remainder;
2144 newbuf.append( wxS(
"${" ) + token + wxS(
"}" ) );
2148 newbuf.append( aSource[i] );
2171 size_t startIdx = 0;
2177 return wxEmptyString;
2183 wxString topFileName;
2188 if( topFileName.IsEmpty() )
2191 wxFileName rootFn( topFileName );
2192 wxString filename = rootFn.GetName();
2218 sheet_count += topSheet->CountSheets();
2227 int sheet_number = 1;
2231 for( screen = s_list.
GetFirst(); screen !=
nullptr; screen = s_list.
GetNext() )
2249 if( sheet.Path() == current_sheetpath )
2255 for( screen = s_list.
GetFirst(); screen !=
nullptr; screen = s_list.
GetNext() )
2266 std::map<wxString, std::set<int>>& pageRefsMap =
GetPageRefsMap();
2268 pageRefsMap.clear();
2277 pageRefsMap[resolvedLabel].insert( sheet.GetVirtualPageNumber() );
2286 std::vector<SCH_GLOBALLABEL*> currentSheetGlobalLabels;
2289 currentSheetGlobalLabels.push_back(
static_cast<SCH_GLOBALLABEL*
>( item ) );
2293 std::vector<SCH_FIELD>& fields = globalLabel->GetFields();
2295 fields[0].SetVisible( show );
2299 if( fields.size() == 1 && fields[0].GetTextPos() == globalLabel->GetPosition() )
2304 for(
SCH_FIELD& field : globalLabel->GetFields() )
2305 field.ClearBoundingBoxCache();
2307 globalLabel->ClearBoundingBoxCache();
2323 auto it = screen->GetLibSymbols().find( aSchLibSymbolName );
2325 if( it != screen->GetLibSymbols().end() && it->second && it->second != &aSource )
2327 it->second->SetPinMaps( aSource.
GetPinMaps() );
2350 aCommit->
Modify( symbol, screen );
2361 wxString spiceNetName( aNetName );
2363 spiceNetName.MakeLower();
2365 if( spiceNetName == wxS(
"gnd" ) || spiceNetName == wxS(
"0" ) )
2366 return wxEmptyString;
2386 std::deque<EDA_ITEM*> allItems;
2388 for(
SCH_ITEM* item : screen->Items() )
2389 allItems.push_back( item );
2392 for(
const VECTOR2I& point : screen->GetNeededJunctions( allItems ) )
2397 screen->Append( junction );
2400 for(
SCH_LINE* wire : screen->GetBusesAndWires( point,
true ) )
2403 screen->Append( newSegment );
2406 aOnSplit( wire, newSegment );
2475 if( aErrorCode >= 0 )
2477 kiapi::schematic::ErcErrorType error = exclusion.
ToProto().marker().error_type();
2498 for(
unsigned i = 0; i < sheetList.size(); i++ )
2539 std::vector<std::pair<SCH_MARKER*, SCH_SCREEN*>> wereExcluded;
2550 wereExcluded.emplace_back( marker, screen );
2558 std::vector<SCH_MARKER*> stale;
2560 for(
auto& [marker, screen] : wereExcluded )
2562 if( !marker->IsExcluded() )
2564 screen->Remove( marker );
2565 stale.push_back( marker );
2591 for(
auto& [
name, libSym] : screen->GetLibSymbols() )
2592 aFunction( libSym->GetEmbeddedFiles() );
2599 std::set<KIFONT::OUTLINE_FONT*>
fonts;
2605 for(
SCH_ITEM* item : sheet.LastScreen()->Items() )
2620 fonts.insert( outline );
2640 wxLogTrace(
"EMBED",
"Failed to add font file: %s", font->GetFileName() );
2651 std::set<const SCH_SCREEN*> retv;
2664 const std::vector<SCH_SYMBOL_INSTANCE> symbolInstances = symbol->
GetInstances();
2668 if( !hierarchy.
HasPath( instance.m_Path ) )
2670 retv.insert( screen );
2675 if( retv.count( screen ) )
2692 wxCHECK2( screen,
continue );
2694 if( screen->GetRefCount() > 1 )
2705 std::vector<SCH_LINE*> lines;
2706 std::vector<SCH_JUNCTION*> junctions;
2707 std::vector<SCH_NO_CONNECT*> ncs;
2708 std::vector<SCH_ITEM*> items_to_remove;
2709 std::unordered_set<SCH_LINE*> generatedLines;
2710 std::vector<std::unique_ptr<SCH_LINE>> retiredLines;
2711 bool changed =
true;
2713 if( aScreen ==
nullptr )
2725 if( aItem->IsSelected() && selectionTool )
2731 aScreen->
Remove( aItem );
2735 if( aItem->Type() ==
SCH_LINE_T && generatedLines.erase(
static_cast<SCH_LINE*
>( aItem ) )
2736 && !aCommit->
GetStatus( aItem, aScreen ) )
2739 retiredLines.emplace_back(
static_cast<SCH_LINE*
>( aItem ) );
2751 items_to_remove.push_back( item );
2754 junctions.push_back(
static_cast<SCH_JUNCTION*
>( item ) );
2757 for(
SCH_ITEM* item : items_to_remove )
2758 remove_item( item );
2766 if( ( aFirst->GetEditFlags() & STRUCT_DELETED )
2767 || ( aSecond->GetEditFlags() & STRUCT_DELETED ) )
2773 remove_item( aSecond );
2779 if( ( aFirst->GetEditFlags() & STRUCT_DELETED )
2780 || ( aSecond->GetEditFlags() & STRUCT_DELETED ) )
2786 remove_item( aSecond );
2793 return std::min( l->GetStartPoint().x, l->GetEndPoint().x );
2799 return std::max( l->GetStartPoint().x, l->GetEndPoint().x );
2805 return std::min( l->GetStartPoint().y, l->GetEndPoint().y );
2811 return std::max( l->GetStartPoint().y, l->GetEndPoint().y );
2824 lines.push_back(
static_cast<SCH_LINE*
>( item ) );
2828 std::sort( lines.begin(), lines.end(),
2831 return minX( a ) < minX( b );
2834 for(
auto it1 = lines.begin(); it1 != lines.end(); ++it1 )
2841 if( firstLine->
IsNull() )
2843 remove_item( firstLine );
2847 int firstRightXEdge = maxX( firstLine );
2850 for( ++it2; it2 != lines.end(); ++it2 )
2853 int secondLeftXEdge = minX( secondLine );
2856 if( secondLeftXEdge > firstRightXEdge )
2860 if( !( std::max( minY( firstLine ), minY( secondLine ) )
2861 <= std::min( maxY( firstLine ), maxY( secondLine ) ) ) )
2879 remove_item( secondLine );
2887 if( mergedLine !=
nullptr )
2889 remove_item( firstLine );
2890 remove_item( secondLine );
2892 if( m_schematicHolder )
2894 m_schematicHolder->AddToScreen( mergedLine, aScreen );
2898 aScreen->Append( mergedLine );
2901 generatedLines.insert( mergedLine );
2902 aCommit->Added( mergedLine, aScreen );
2905 selectionTool->AddItemToSel( mergedLine,
true );
2916 const std::set<SCH_SCREEN*>& aLocalScreens )
2923 if( aLocalScreens.empty() )
2933 std::unordered_set<SCH_SCREEN*> cleanedScreens;
2939 if( cleanedScreens.insert( screen ).second )
2948 wxLogTrace(
"CONN_PROFILE",
"SchematicCleanUp() %0.4f ms", timer.
msecs() );
2950 if(
Settings().m_IntersheetRefsShow )
2964 m_project->GetProjectFile().NetSettings()->ClearAllCaches();
2965 std::unordered_set<SCH_SCREEN*> screens;
2970 screens.insert( screen );
2978 aChangedItemHandler ? *aChangedItemHandler
2979 : std::function<
void(
SCH_ITEM* )>() );
2991 std::function<
void(
SCH_ITEM* )>* aChangedItemHandler,
2997 aCommit = &localCommit;
3008 if( !localCommit.
Empty() )
3015 std::unordered_set<SCH_SCREEN*> screens;
3018 screens.insert(
path.LastScreen() );
3023 if( !localCommit.
Empty() )
3026 m_connectivity->Recalculate( *
this,
false, aChangedItemHandler ? *aChangedItemHandler
3027 : std::function<
void(
SCH_ITEM* )>() );
3034 if( !localCommit.
Empty() )
3050 std::set<SCH_ITEM*> changed_items;
3051 std::set<VECTOR2I> pts;
3052 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> item_paths;
3055 std::unordered_set<SCH_SCREEN*> changed_screens;
3056 std::set<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> changed_rule_areas;
3057 std::vector<CHANGED_ITEM> changed_connectable_items;
3060 auto addItemToChangeSet =
3061 [&changed_items, &pts, &item_paths]( CHANGED_ITEM itemData )
3063 std::vector<SCH_SHEET_PATH>& paths = itemData.screen->GetClientSheetPaths();
3065 std::vector<VECTOR2I> tmp_pts = itemData.item->GetConnectionPoints();
3066 pts.insert( tmp_pts.begin(), tmp_pts.end() );
3067 changed_items.insert( itemData.item );
3070 item_paths.insert( std::make_pair(
path, itemData.item ) );
3072 if( !itemData.linked_item || !itemData.linked_item->IsConnectable() )
3075 tmp_pts = itemData.linked_item->GetConnectionPoints();
3076 pts.insert( tmp_pts.begin(), tmp_pts.end() );
3077 changed_items.insert( itemData.linked_item );
3084 changed_items.insert( pins.begin(), pins.end() );
3088 item_paths.insert( std::make_pair(
path, itemData.linked_item ) );
3092 for(
unsigned ii = 0; ii < aLastChangeList->
GetCount(); ++ii )
3110 changed_screens.insert( screen );
3115 changed_rule_areas.insert( { ruleArea, screen } );
3120 changed_connectable_items.push_back( { item, linked_item, screen } );
3126 std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> forceUpdateRuleAreas =
3129 std::for_each( forceUpdateRuleAreas.begin(), forceUpdateRuleAreas.end(),
3130 [&]( std::pair<SCH_RULE_AREA*, SCH_SCREEN*>& updatedRuleArea )
3132 changed_rule_areas.insert( updatedRuleArea );
3137 std::unordered_map<KIID, EDA_ITEM*> itemMap;
3138 list.FillItemMap( itemMap );
3140 auto addPastAndPresentContainedItems =
3145 if( itemMap.contains( pastItem ) )
3146 addItemToChangeSet( {
static_cast<SCH_ITEM*
>( itemMap[pastItem] ),
nullptr, screen } );
3150 addItemToChangeSet( { containedItem,
nullptr, screen } );
3153 for(
const auto& [changedRuleArea, screen] : changed_rule_areas )
3154 addPastAndPresentContainedItems( changedRuleArea, screen );
3157 for( CHANGED_ITEM& changed_item : changed_connectable_items )
3159 addItemToChangeSet( changed_item );
3165 const std::vector<VECTOR2I> labelConnectionPoints = changed_item.item->GetConnectionPoints();
3167 auto candidateRuleAreas = changed_item.screen->Items()
3170 for(
SCH_ITEM* candidateRuleArea : candidateRuleAreas )
3175 addPastAndPresentContainedItems( ruleArea, changed_item.screen );
3185 if( !item->IsConnectable() )
3193 if( item->HitTest( pt ) )
3195 changed_items.insert( item );
3198 item_paths.insert( std::make_pair(
path, item ) );
3201 else if( item->Type() ==
SCH_SYMBOL_T && item->IsConnected( pt ) )
3206 changed_items.insert( pins.begin(), pins.end() );
3211 item_paths.insert( std::make_pair(
path,
pin ) );
3218 wxCHECK2( sheet,
continue );
3220 std::vector<SCH_SHEET_PIN*> sheetPins = sheet->
GetPins();
3221 changed_items.insert( sheetPins.begin(), sheetPins.end() );
3226 item_paths.insert( std::make_pair(
path,
pin ) );
3231 if( item->IsConnected( pt ) )
3233 changed_items.insert( item );
3236 item_paths.insert( std::make_pair(
path, item ) );
3242 std::set<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> all_items =
3245 all_items.insert( item_paths.begin(), item_paths.end() );
3251 std::shared_ptr<NET_SETTINGS> netSettings =
m_project->GetProjectFile().NetSettings();
3253 std::set<wxString> affectedNets;
3255 for(
auto& [
path, item] : all_items )
3257 wxCHECK2( item,
continue );
3258 item->SetConnectivityDirty();
3262 affectedNets.insert( conn->
Name() );
3267 for(
const CHANGED_ITEM& changedItem : changed_connectable_items )
3271 const wxString& driverName = label->GetCachedDriverName();
3273 if( !driverName.IsEmpty() )
3274 affectedNets.insert( driverName );
3279 const wxString& driverName = linkedLabel->GetCachedDriverName();
3281 if( !driverName.IsEmpty() )
3282 affectedNets.insert( driverName );
3287 for(
const wxString& netName : affectedNets )
3288 netSettings->ClearCacheForNet( netName );
3290 new_graph.
Recalculate( list,
false, aChangedItemHandler, aProgressReporter );
3294 if( !localCommit.
Empty() )
3335 size_t index =
static_cast<size_t>( aIndex );
3346 std::vector<TOP_LEVEL_SHEET_INFO> infos;
3351 if( !sheet->GetScreen() )
3355 wxFileName sheetFn( sheet->GetScreen()->GetFileName() );
3357 if( sheetFn.IsAbsolute() )
3358 sheetFn.MakeRelativeTo( projectPath );
3360 infos.emplace_back( sheet->m_Uuid, sheet->GetName(), sheetFn.GetFullPath() );
3371 if( loaded.size() != aSheets.size() )
3376 for(
size_t ii = 0; ii < loaded.size(); ++ii )
3378 wxFileName have( loaded[ii].filename );
3379 have.MakeAbsolute( projectPath );
3384 if( ( aSheets[ii].uuid !=
niluuid && aSheets[ii].uuid != loaded[ii].uuid )
3385 || aSheets[ii].
name != loaded[ii].
name || !have.SameAs( want ) )
3399 fn.MakeAbsolute( aProjectPath );
3419 if( sheet && sheet->m_Uuid == aUuid )
3448 wxCHECK_RET( aSheet, wxS(
"Cannot add null sheet!" ) );
3449 wxCHECK_RET( aSheet->
GetScreen(), wxS(
"Cannot add virtual root as top-level sheet!" ) );
3482 m_rootSheet->GetScreen()->Remove( aSheet,
false );
3509 wxLogTrace(
traceSchSheetPaths,
"BuildSheetListSortedByPageNumbers: %zu top-level sheets",
3521 wxLogTrace(
traceSchSheetPaths,
" Top-level sheet: '%s' (UUID=%s, isVirtualRoot=%d)", sheet->GetName(),
3522 sheet->m_Uuid.AsString(), sheet->m_Uuid ==
niluuid ? 1 : 0 );
3531 hierarchy.push_back(
path );
3557 sheets.push_back(
path );
3568 wxArrayString variantNames;
3574 variantNames.Add(
name );
3578 return variantNames;
3585 return wxEmptyString;
3595 if(
name.CmpNoCase( aVariantName ) == 0 )
3605 wxString newVariant;
3609 newVariant = aVariantName;
3621 for(
SCH_ITEM* item : screen->Items() )
3622 item->ClearCaches();
3641 if( descriptions.find( aVariantName ) == descriptions.end() )
3642 descriptions[aVariantName] = wxEmptyString;
3670 wxCHECK( !aOldName.IsEmpty() && !aNewName.IsEmpty(), );
3678 if( descriptions.count( aOldName ) )
3680 descriptions[aNewName] = descriptions[aOldName];
3681 descriptions.erase( aOldName );
3698 wxCHECK( !aSourceVariant.IsEmpty() && !aNewVariant.IsEmpty(), );
3706 if( descriptions.count( aSourceVariant ) )
3707 descriptions[aNewVariant] = descriptions[aSourceVariant];
3710 allScreens.
CopyVariant( aSourceVariant, aNewVariant, aCommit );
3717 auto it = descriptions.find( aVariantName );
3719 if( it != descriptions.end() )
3722 return wxEmptyString;
3730 if( aDescription.IsEmpty() )
3731 descriptions.erase( aVariantName );
3733 descriptions[aVariantName] = aDescription;
3746 m_variantNames.insert( variantNames.begin(), variantNames.end() );
3751 for(
const wxString&
name : variantNames )
3753 if( descriptions.find(
name ) == descriptions.end() )
3754 descriptions[
name] = wxEmptyString;
3759 for(
const auto& [
name, description] : descriptions )
3767 std::set<wxString> before;
3788 wxString projPath =
m_project->GetProjectPath();
3790 if( projPath.IsEmpty() )
3794 if( !projPath.IsSameAs( aProjectPath ) )
3796 wxLogTrace(
traceAutoSave, wxS(
"[history] sch saver skipping - project path mismatch: %s vs %s" ), projPath,
3801 if( !projPath.EndsWith( wxFILE_SEP_PATH ) )
3802 projPath += wxFILE_SEP_PATH;
3808 KICAD_FORMAT::FORMAT_MODE mode = KICAD_FORMAT::FORMAT_MODE::NORMAL;
3811 mode = KICAD_FORMAT::FORMAT_MODE::COMPACT_TEXT_PROPERTIES;
3824 if( !sheet || !screen )
3835 wxString absPath = abs.GetFullPath();
3837 if( absPath.IsEmpty()
3838 || !absPath.Left( projPath.length() ).IsSameAs( projPath, wxFileName::IsCaseSensitive() ) )
3841 wxString rel = absPath.Mid( projPath.length() );
3853 aFileData.push_back( std::move( entry ) );
3856 wxS(
"[history] sch saver serialized %zu bytes for '%s' -> '%s'" ),
3857 aFileData.back().content.size(), absPath, rel );
3861 wxLogTrace(
traceAutoSave, wxS(
"[history] sch saver serialize failed for '%s': %s" ),
3862 absPath, wxString::FromUTF8( ioe.
What() ) );
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void SetPageCount(int aPageCount)
void SetPageNumber(const wxString &aPageNumber)
bool IsContentModified() const
void SetVirtualPageNumber(int aPageNumber)
Represent a set of changes (additions, deletions or modifications) of a data model (e....
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Returns status of an item.
bool AutosaveUsesLocalHistory() const
The backup format is the single switch that selects the autosave mechanism: the incremental format re...
Calculate the connectivity of a schematic and generate netlists.
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Update the connection graph for the given list of sheets.
std::set< std::pair< SCH_SHEET_PATH, SCH_ITEM * > > ExtractAffectedItems(const std::set< SCH_ITEM * > &aItems)
For a set of items, this will remove the connected items and their associated data including subgraph...
void SetLastCodes(const CONNECTION_GRAPH *aOther)
void Merge(CONNECTION_GRAPH &aGraph)
Combine the input graph contents into the current graph.
A subgraph is a set of items that are electrically connected on a single sheet.
static PRIORITY GetDriverPriority(SCH_ITEM *aDriver)
Return the priority (higher is more important) of a candidate driver.
const SCH_CONNECTION * GetDriverConnection() const
EDA_ITEM_FLAGS GetEditFlags() const
KICAD_T Type() const
Returns the type of object.
EDA_ITEM * GetParent() const
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM_FLAGS GetFlags() const
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
SHAPE_POLY_SET & GetPolyShape()
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
EE_TYPE OfType(KICAD_T aType) const
EMBEDDED_FILE * AddFile(const wxFileName &aName, bool aOverwrite)
Load a file from disk and adds it to the collection.
Container for an ERC exclusion, which is a SCH_MARKER plus an optional comment.
static ERC_EXCLUSION FromLegacyStrings(const SCH_SHEET_LIST &aSheetList, const wxString &aMarkerData, const wxString &aComment)
const kiapi::schematic::ErcExclusion & ToProto() const
void SetComment(const wxString &aComment)
static ERC_EXCLUSION FromMarker(const SCH_MARKER &aMarker)
wxString GetComment() const
std::string GetSortKey() const
static ERC_EXCLUSION FromProto(const kiapi::schematic::ErcExclusion &aMessage)
static std::shared_ptr< ERC_ITEM > Create(int aErrorCode)
Constructs an ERC_ITEM for the given error code.
Container for ERC settings.
std::set< std::pair< wxString, wxString > > m_ErcExclusionsLegacy
std::set< ERC_EXCLUSION, ERC_EXCLUSION_COMPARE > m_ErcExclusions
Class that other classes need to inherit from, in order to be inspectable.
wxAny Get(PROPERTY_BASE *aProperty) const
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()
FONT is an abstract base class for both outline and stroke fonts.
virtual bool IsStroke() const
Implement outline font drawing.
EMBEDDING_PERMISSION GetEmbeddingPermission() const
A logical library item identifier and consists of various portions much like a URI.
Define a library symbol object.
const PIN_MAP_SET & GetPinMaps() const
Pin-to-pad mapping (issue #2282).
const std::vector< ASSOCIATED_FOOTPRINT > & GetAssociatedFootprints() const
std::shared_ptr< RC_ITEM > GetRCItem() const
void SetExcluded(bool aExcluded, const wxString &aComment=wxEmptyString)
static void ConvertToSpiceMarkup(wxString *aNetName)
Convert an escaped schematic net name to SPICE, preserving literal slashes when mapping ground names.
virtual COMMON_SETTINGS * GetCommonSettings() const
A holder to handle information on schematic or board items.
UNDO_REDO GetPickedItemStatus(unsigned int aIdx) const
EDA_ITEM * GetPickedItemLink(unsigned int aIdx) const
unsigned GetCount() const
BASE_SCREEN * GetScreenForItem(unsigned int aIdx) const
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
A small class to help profiling.
void Stop()
Save the time when this function was called, and set the counter stane to stop.
double msecs(bool aSinceLast=false)
A progress reporter interface for use in multi-threaded environments.
The backing store for a PROJECT, in JSON format.
Container for project specific data.
const wxString & Name() const
static PROPERTY_MANAGER & Instance()
class PROPERTY_LISTENER_SUBSCRIPTION RegisterListener(TYPE_ID aType, PROPERTY_LISTENER aListenerFunc)
Register a listener for the given type and return a move-only subscription that auto-unregisters in i...
virtual void OnSchItemsRemoved(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem)
virtual void OnSchItemsChanged(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem)
virtual void OnSchSelectionChanged(SCHEMATIC &aSch)
virtual void OnSchSheetChanged(SCHEMATIC &aSch)
virtual void OnSchItemsAdded(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem)
These are loaded from Eeschema settings but then overwritten by the project settings.
bool m_IntersheetRefsShow
std::map< wxString, wxString > m_VariantDescriptions
A map of variant names to their descriptions.
void DeleteVariantDefinition(const wxString &aVariantName)
Delete the definition of a variant.
void SetCurrentVariant(const wxString &aVariantName)
bool m_settingTopLevelSheets
Re-entry guard to prevent infinite recursion between ensureDefaultTopLevelSheet and RefreshHierarchy ...
std::unique_ptr< SCH_CONNECTIVITY::NETCHAIN_MANAGER > m_netChains
void updatePackageSuffixes() const
Rebuild m_packageSuffixes when a reference changed; the caller holds m_packageSuffixesMutex.
wxString GetUnitRefSuffix(const SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aPath, int aUnit) const
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
std::set< const SCH_SCREEN * > GetSchematicsSharedByMultipleProjects() const
Return a list of schematic files in the current project that contain instance data for multiple proje...
std::map< std::pair< KIID, KIID_PATH >, wxString > m_packageSuffixes
Package suffix of each instance whose package spans suffixes and is not its own sheet's.
void CreateDefaultScreens()
void SetLegacySymbolInstanceData()
Update the symbol value and footprint instance data for legacy designs.
void OnItemsAdded(std::vector< SCH_ITEM * > &aNewItems)
Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for listeners.
CONNECTION_GRAPH * m_connectionGraph
Hold and calculate connectivity information of this schematic.
bool IsTopLevelSheet(const SCH_SHEET *aSheet) const
Check if a sheet is a top-level sheet (direct child of virtual root).
void loadBusAliasesFromProject()
std::unordered_map< size_t, wxString > m_refSuffixesBySheetHash
Every hierarchy path's suffix by its cached sheet path hash, which SCH_SHEET_PATH equality also relie...
void AddTopLevelSheet(SCH_SHEET *aSheet)
Add a new top-level sheet to the schematic.
SCH_SHEET_LIST m_hierarchy
Cache of the entire schematic hierarchy sorted by sheet page number.
@ TABLE_REMOVED
The reread file has no table; the one in use is kept, even empty, and saved back.
@ CHANGED
The project table changed the aliases in use, so connectivity needs a rebuild.
void rebuildHierarchyState(bool aResetConnectionGraph)
void ResolveERCExclusionsPostUpdate()
Update markers to match recorded exclusions.
void RecomputeIntersheetRefs()
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
std::vector< SCH_MARKER * > ReloadERCExclusions()
Resolve exclusions again after the project file was reread.
void CacheExistingAnnotation()
Store all existing annotations in the REFDES_TRACKER.
wxString GetVariantDescription(const wxString &aVariantName) const
Return the description for a variant.
void LoadVariants()
This is a throw away method for variant testing.
SCH_SHEET_LIST BuildSheetListSortedByPageNumbers() const
void RemoveListener(SCHEMATIC_LISTENER *aListener)
Remove the specified listener.
bool HasVariant(const wxString &aVariantName) const
Return true if a variant with this name exists in the schematic (case-insensitively).
std::set< KIID > m_unitSplitSymbols
Symbols whose copies select different units.
std::vector< std::pair< SCH_SHEET_PATH, SCH_SHEET_PATH > > RefSuffixCollisions(bool aIncludeEmpty) const
Find instances of one sheet file whose composed reference suffixes collide.
bool resolveCrossReference(wxString *aToken, int aDepth) const
bool IsComplexHierarchy() const
Test if the schematic is a complex hierarchy.
void OnSchSheetChanged()
Notify the schematic and its listeners that the current sheet has been changed.
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
SCH_SHEET_PATH * m_currentSheet
The sheet path of the sheet currently being edited or displayed.
std::vector< SCH_SHEET * > m_topLevelSheets
List of top-level sheets (direct children of virtual root)
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
void CleanUp(SCH_COMMIT *aCommit, SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
void CopyVariant(const wxString &aSourceVariant, const wxString &aNewVariant, SCH_COMMIT *aCommit)
Copy a variant from aSourceVariant to aNewVariant.
bool TopLevelSheetsMatch(const std::vector< TOP_LEVEL_SHEET_INFO > &aSheets) const
Check a project file's top-level sheet list against the sheets this schematic loaded.
bool IsTopLevelSheetUuid(const KIID &aUuid) const
Check if a UUID names one of this schematic's top level sheets.
void OnItemsRemoved(std::vector< SCH_ITEM * > &aRemovedItems)
Must be used if Remove() is used using a BULK_x REMOVE_MODE to generate a change event for listeners.
void AddVariant(const wxString &aVariantName)
void OnSchSelectionChanged()
Notify the schematic and its listeners that the editor selection has changed.
std::string FormatRefSuffixes() const
void AdoptContent(SCHEMATIC_CONTENT &&aContent) noexcept
Take a staged schematic over from an importer in one indivisible step.
bool m_hasRefSuffixFields
std::shared_ptr< BUS_ALIAS > GetBusAlias(const wxString &aLabel) const
Return a pointer to a bus alias object for the given label, or null if one doesn't exist.
bool HasRefSuffixes() const
True when suffix numbering is enabled and a hierarchy path has a composed suffix.
std::vector< SCH_MARKER * > ResolveERCExclusions()
void SaveToHistory(const wxString &aProjectPath, std::vector< HISTORY_FILE_DATA > &aFileData)
Serialize schematic sheets into HISTORY_FILE_DATA for non-blocking history commit.
const wxString * findRefSuffix(const SCH_SHEET_PATH &aPath) const
The cached suffix of aPath, or nullptr when it has none.
void EmbedFonts() override
Embed fonts in the schematic.
SCHEMATIC_SETTINGS & Settings() const
wxString GetPackageRefSuffix(const SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aPath) const
Return the suffix the package of a multi-unit symbol's instance composes with.
SCH_SCREEN * GetCurrentScreen() const
wxString ConvertKIIDsToRefs(const wxString &aSource) const
SCH_ITEM * ResolveItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr, bool aAllowNullptrReturn=false) const
void ensureCurrentSheetIsTopLevel()
void SyncLibSymbolPinMaps(const wxString &aSchLibSymbolName, const LIB_SYMBOL &aSource, SCH_COMMIT *aCommit)
void RecordERCExclusions()
Scan existing markers and record data from any that are Excluded.
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
std::map< std::pair< wxString, wxString >, std::map< int, wxString > > m_packageUnitSuffixes
Sheet suffix of each placed unit of a package spanning suffixes, keyed by base and LIB_ID.
wxString m_currentVariant
std::map< wxString, std::set< int > > & GetPageRefsMap()
SCH_SHEET_LIST BuildUnorderedSheetList() const
std::unordered_map< KIID_PATH, wxString > m_refSuffixes
Composed reference suffix of each hierarchy path that has one.
std::map< wxString, std::set< int > > m_labelToPageRefsMap
Holds a map of labels to the page sequence (virtual page number) that they appear on.
std::mutex m_packageSuffixesMutex
std::set< KIFONT::OUTLINE_FONT * > GetFonts() const override
Get a set of fonts used in the schematic.
SCH_SHEET * GetTopLevelSheet(int aIndex=0) const
bool RemoveTopLevelSheet(SCH_SHEET *aSheet)
Remove a top-level sheet from the schematic.
std::optional< IMPORT_NET_MAP > m_importNetMap
bool Contains(const SCH_REFERENCE &aRef) const
Check if the schematic contains the specified reference.
std::optional< wxString > spanningPackageSuffix(const SCH_SYMBOL *aSymbol, const KIID_PATH &aPath) const
The suffix of a package spanning sheets that aSymbol on aPath belongs to, if any.
void ClearUnresolvedERCExclusions(int aErrorCode=-1)
std::vector< ERC_EXCLUSION > m_unresolvedErcExclusions
Exclusions whose saved identity cannot currently be reconstructed as a marker.
SCH_CONNECTIVITY::FACADE & Connectivity() const
wxString ConvertRefsToKIIDs(const wxString &aSource) const
void SetProject(PROJECT *aPrj)
void DeleteVariant(const wxString &aVariantName, SCH_COMMIT *aCommit)
Delete all information for aVariantName.
bool IsHierarchyModified() const
True when any sheet in the hierarchy has unsaved changes.
wxString GetCurrentVariant() const
Return the current variant being edited.
void AddListener(SCHEMATIC_LISTENER *aListener)
Add a listener to the schematic to receive calls whenever something on the schematic has been modifie...
void CleanUpConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, const std::set< SCH_SCREEN * > &aLocalScreens={})
std::map< int, wxString > GetVirtualPageToSheetPagesMap() const
EMBEDDED_FILES * GetEmbeddedFiles() override
wxString GetRefSuffix(const SCH_SHEET_PATH &aPath) const
Return the composed reference suffix of aPath as of the last RefreshHierarchy().
CONNECTION_GRAPH * ConnectionGraph() const
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
bool ResolveTextVar(const SCH_SHEET_PATH *aSheetPath, wxString *token, int aDepth) const
std::set< wxString > GetNetClassAssignmentCandidates()
Return the set of netname candidates for netclass assignment.
std::vector< std::shared_ptr< BUS_ALIAS > > m_busAliases
bool ReloadProjectVariants()
Take the variant list from the project file again after it was reread.
void RefreshRefSuffixes()
Recompose the reference suffix of every sheet path in the hierarchy.
void InvokeListeners(Func &&aFunc, Args &&... args)
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
void updateProjectBusAliases()
void SetVariantDescription(const wxString &aVariantName, const wxString &aDescription)
Set the description for a variant.
void RemoveAllListeners()
Remove all listeners.
std::optional< uint64_t > m_packageSuffixesGeneration
void SetTopLevelSheets(const std::vector< SCH_SHEET * > &aSheets)
Replace the top level sheets, rebuilding the hierarchy and connectivity around them.
void RebuildConnectivity(std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr, KIGFX::SCH_VIEW *aSchView=nullptr)
std::unique_ptr< class SCHEMATIC_TEXT_VAR_ADAPTER > m_textVarAdapter
Reactive text-variable dependency adapter.
void RenameVariant(const wxString &aOldName, const wxString &aNewName, SCH_COMMIT *aCommit)
Rename a variant from aOldName to aNewName.
bool HasProjectBusAliases() const
PROPERTY_LISTENER_SUBSCRIPTION m_fieldListenerSubscription
PROPERTY_MANAGER listener subscription installed in the ctor.
BUS_ALIAS_RELOAD ReloadProjectBusAliases()
Take the bus aliases from the project file again after it was reread.
void GetContextualTextVars(wxArrayString *aVars) const
void ensureDefaultTopLevelSheet()
std::set< KIID > SplitUnitSymbols() const
Symbols whose copies select different units, for loops that change references as they go.
std::map< int, wxString > GetVirtualPageToSheetNamesMap() const
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, TOOL_MANAGER *aToolManager, PROGRESS_REPORTER *aProgressReporter=nullptr, KIGFX::SCH_VIEW *aSchView=nullptr, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PICKED_ITEMS_LIST *aLastChangeList=nullptr, bool aCleanupDone=false)
Generate the connection data for the entire schematic hierarchy.
void AddBusAlias(std::shared_ptr< BUS_ALIAS > aAlias)
std::vector< SCH_SHEET * > GetTopLevelSheets() const
Get the list of top-level sheets.
wxArrayString GetVariantNamesForUI() const
Return an array of variant names for using in wxWidgets UI controls.
bool CopiesSelectDifferentUnits(const SCH_SYMBOL *aSymbol) const
void RunOnNestedEmbeddedFiles(const std::function< void(EMBEDDED_FILES *)> &aFunction) override
Provide access to nested embedded files, such as symbols in schematics and footprints in boards.
std::unique_ptr< SCH_CONNECTIVITY::FACADE > m_connectivity
SCHEMATIC_HOLDER * m_schematicHolder
What currently "Holds" the schematic, i.e.
wxString GetUniqueFilenameForCurrentSheet()
Get the unique file name for the current sheet.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void SetBusAliases(const std::vector< std::shared_ptr< BUS_ALIAS > > &aAliases)
std::vector< SCHEMATIC_LISTENER * > m_listeners
Currently installed listeners.
void AppendRefSuffix(wxString &aRef, const SCH_SHEET_PATH &aPath) const
Append the composed reference suffix of aPath to aRef without copying it.
SCH_SHEET_PATH & CurrentSheet() const
bool m_busAliasesFromTable
The aliases in use came from a project table rather than from the sheets.
std::vector< TOP_LEVEL_SHEET_INFO > TopLevelSheetInfos() const
The top-level sheets as the project file records them, with file names relative to the project.
bool ResolveCrossReference(wxString *token, int aDepth) const
Resolves text vars that refer to other items.
int FixupJunctionsAfterImport(const std::function< void(SCH_LINE *, SCH_LINE *)> &aOnSplit={})
Add junctions to this schematic where required.
KIID_PATH NormalizeInstancePath(const KIID_PATH &aPath) const
Strip the leading virtual root from a stored instance path, which SCH_SHEET_PATH::Path() omits but st...
std::map< wxString, double > m_operatingPoints
Simulation operating points for text variable substitution.
ERC_SETTINGS & ErcSettings() const
std::set< wxString > m_variantNames
std::map< std::pair< KIID, KIID_PATH >, wxString > PackageRefSuffixes() const
Symbol and sheet path of each instance whose package suffix is another sheet's, with that suffix.
void OnItemsChanged(std::vector< SCH_ITEM * > &aItems)
Notify the schematic and its listeners that an item on the schematic has been modified in some way.
static wxFileName TopLevelSheetFile(const TOP_LEVEL_SHEET_INFO &aSheet, const wxString &aProjectPath, bool aLegacy)
The file loaded for a listed top-level sheet. A legacy project reads it under the legacy extension.
SCH_SHEET * m_rootSheet
The virtual root sheet (has no screen, contains all top-level sheets)
bool IsInstancePathInProject(const KIID_PATH &aPath) const
Test whether an instance path is rooted in this schematic's top level sheets.
Commit for the schematic and symbol editors.
void RemovedForCleanup(SCH_ITEM *aItem, SCH_SCREEN *aScreen)
Retain the pre-edit state of an item already removed from its screen by cleanup.
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString Name(bool aIgnoreSheet=false) const
SCH_ITEM * Driver() const
A SCH_IO derivation for loading schematic files using the new s-expression file format.
void FormatSchematicToFormatter(OUTPUTFORMATTER *aOut, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const std::map< std::string, UTF8 > *aProperties=nullptr)
Serialize a schematic sheet to an OUTPUTFORMATTER without file I/O or Prettify.
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual bool IsConnectable() const
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
VECTOR2I GetPosition() const override
wxString GetShownText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, int aDepth=0) const override
Segment description base class to describe items which have 2 end points (track, wire,...
SCH_LINE * NonGroupAware_BreakAt(const VECTOR2I &aPoint)
This version should only be used when importing files.
bool IsParallel(const SCH_LINE *aLine) const
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
SCH_LINE * MergeOverlap(SCH_SCREEN *aScreen, SCH_LINE *aLine, bool aCheckJunctions)
Check line against aLine to see if it overlaps and merge if it does.
bool IsStrokeEquivalent(const SCH_LINE *aLine)
bool IsEndPoint(const VECTOR2I &aPoint) const override
Test if aPt is an end point of this schematic object.
static SCH_MARKER * FromProto(const kiapi::schematic::ErcMarker &aMsg, const SCH_SHEET_LIST &aSheetList)
VECTOR2I GetPosition() const override
VECTOR2I GetPosition() const override
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
A helper to define a symbol's reference designator in a schematic.
const std::unordered_set< SCH_ITEM * > & GetContainedItems() const
Return a set of all items contained within the rule area.
static std::vector< std::pair< SCH_RULE_AREA *, SCH_SCREEN * > > UpdateRuleAreasInScreens(std::unordered_set< SCH_SCREEN * > &screens, KIGFX::SCH_VIEW *view)
Update all rule area connectvity / caches in the given sheet paths.
const std::unordered_set< KIID > & GetPastContainedItems() const
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
void CopyVariant(const wxString &aSourceVariant, const wxString &aNewVariant, SCH_COMMIT *aCommit=nullptr)
void RenameVariant(const wxString &aOldName, const wxString &aNewName, SCH_COMMIT *aCommit=nullptr)
std::set< wxString > GetVariantNames() const
void DeleteVariant(const wxString &aVariantName, SCH_COMMIT *aCommit=nullptr)
void SetLegacySymbolInstanceData()
Update the symbol value and footprint instance data for legacy designs.
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
std::vector< SCH_SHEET_PATH > & GetClientSheetPaths()
Return the number of times this screen is used.
EE_RTREE & Items()
Get the full RTree, usually for iterating.
const wxString & GetFileName() const
bool IsExplicitJunctionAllowed(const VECTOR2I &aPosition) const
Indicate that a junction dot may be placed at the given location.
void BumpConnectivityRevision(KICAD_T aChangedType=TYPE_NOT_INIT)
Increment the connectivity revisions of this screen.
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
TITLE_BLOCK & GetTitleBlock()
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Refresh a changed item in the tree and invalidate connectivity.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
std::optional< SCH_SHEET_PATH > GetSheetPathByKIIDPath(const KIID_PATH &aPath, bool aIncludeLastSheet=true) const
Finds a SCH_SHEET_PATH that matches the provided KIID_PATH.
SCH_ITEM * ResolveItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr, bool aAllowNullptrReturn=false) const
Fetch a SCH_ITEM by ID.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
void BuildSheetList(SCH_SHEET *aSheet, bool aCheckIntegrity)
Build the list of sheets and their sheet path from aSheet.
bool HasPath(const KIID_PATH &aPath) const
void GetSymbols(SCH_REFERENCE_LIST &aReferences, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
size_t GetCurrentHash() const
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCH_SCREEN * LastScreen()
wxString GetPageNumber() const
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
void SetVirtualPageNumber(int aPageNumber)
Set the sheet instance virtual page number.
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false, bool aEscapeSheetNames=false) const
Return the sheet path in a human readable form made from the sheet names.
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
const KIID_PATH & PathRef() const
Borrow the cached path until this sheet path is modified or destroyed.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
size_t size() const
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.
wxString GetFileName() const
Return the filename corresponding to this sheet.
void SyncUuidToScreen()
Take the identity of the screen this sheet owns.
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
SCH_SCREEN * GetScreen() const
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
std::vector< SCH_SHEET_PIN * > & GetPins()
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
wxString BaseRefFromUser(const SCH_SHEET_PATH &aSheet, const wxString &aText, wxString &aBase, const SCHEMATIC *aSchematic=nullptr) const
Convert a reference typed on aSheet to the base reference.
wxString GetSchSymbolLibraryName() const
wxString GetBaseRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the base reference for the given sheet path for this symbol.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
const LIB_ID & GetLibId() const override
void SetUserRef(const SCH_SHEET_PATH &aSheet, const wxString &aBase)
Set a base reference chosen by the user on aSheet.
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit, int aBodyStyle) const override
bool GetInstance(SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
static uint64_t RefGeneration()
Count of changes to any symbol's references, units, library links or placement.
static void BumpRefGeneration()
Mark every cache built from references as stale.
int GetUnitCount() const override
Return the number of units per package of the symbol.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
bool CollideEdge(const VECTOR2I &aPoint, VERTEX_INDEX *aClosestVertex=nullptr, int aClearance=0) const
Check whether aPoint collides with any edge of any of the contours of the polygon.
Helper class to handle Spice way of expressing values (e.g. 10.5 Meg)
wxString ToString() const
Return string value as when converting double to string (e.g.
A text evaluation frame with one frozen clock and memoized external queries.
bool IsCollectingSources() const
static ENVIRONMENT * Current()
void RecordCrossReference(const CROSS_REFERENCE_KEY &aKey, const CROSS_REFERENCE_VALUE &aValue)
std::pair< wxString, int > CROSS_REFERENCE_KEY
bool TextVarResolver(wxString *aToken, const PROJECT *aProject, RESOLUTION_CONTEXT aContext) const
static void GetContextualTextVars(wxArrayString *aVars)
static bool empty(const wxTextEntryBase *aCtrl)
#define SELECTED_BY_DRAG
Item was algorithmically selected as a dragged item.
#define STRUCT_DELETED
flag indication structures to be erased
@ ERCE_VARIANT_SYMBOL_INCOMPATIBLE
Variant symbol override fails pin compatibility.
@ ERCE_ENDPOINT_OFF_GRID
Pin or wire-end off grid.
@ ERCE_BUS_TO_BUS_CONFLICT
A connection between bus objects doesn't share at least one net.
@ ERCE_FOOTPRINT_LINK_ISSUES
The footprint link is invalid, or points to a missing (or inactive) footprint or library.
@ ERCE_BUS_TO_NET_CONFLICT
A bus wire is graphically connected to a net port/pin (or vice versa).
@ ERCE_NOCONNECT_NOT_CONNECTED
A no connect symbol is not connected to anything.
@ ERCE_FOUR_WAY_JUNCTION
A four-way junction was found.
@ ERCE_PIN_NOT_CONNECTED
Pin not connected and not no connect symbol.
@ ERCE_UNDEFINED_NETCLASS
A netclass was referenced but not defined.
@ ERCE_UNRESOLVED_VARIABLE
A text variable could not be resolved.
@ ERCE_SIMULATION_MODEL
An error was found in the simulation model.
@ ERCE_LIB_SYMBOL_MISMATCH
Symbol doesn't match copy in library.
@ ERCE_DIFFERENT_UNIT_FP
Different units of the same symbol have different footprints assigned.
@ ERCE_NOCONNECT_CONNECTED
A no connect symbol is connected to more than 1 pin.
@ ERCE_DUPLICATE_SHEET_NAME
Duplicate sheet names within a given sheet.
@ ERCE_LIB_SYMBOL_ISSUES
Symbol not found in active libraries.
@ ERCE_FOOTPRINT_FILTERS
The assigned footprint doesn't match the footprint filters.
@ ERCE_HIERACHICAL_LABEL
Mismatch between hierarchical labels and pins sheets.
@ ERCE_WIRE_DANGLING
Some wires are not connected to anything else.
@ ERCE_VARIANT_SYMBOL_INVALID
Variant symbol override LIB_ID cannot be resolved.
@ ERCE_PIN_MAP_UNMAPPED_PIN
A connected pin resolves to no footprint pad.
@ ERCE_LABEL_MULTIPLE_WIRES
A label is connected to more than one wire.
bool m_ConnectivityEngine
Use the schematic connectivity engine instead of CONNECTION_GRAPH.
static const std::string LegacySchematicFileExtension
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
void ignore_unused(const T &)
#define MAIL_SCH_REF_SUFFIXES_TAG
First line of a MAIL_SCH_GET_REF_SUFFIXES reply, so a schematic with no sheets still answers.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
void for_all_pairs(_InputIterator __first, _InputIterator __last, _Function __f)
Apply a function to every possible pair of elements of a sequence.
PGM_BASE & Pgm()
The global program "get" accessor.
static LIB_SYMBOL * findSymbol(const wxString &aName, LEGACY_SYMBOL_LIBS *aLibs, bool aCached)
Search the libraries for the first symbol with a given name.
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
void CollectOtherUnits(const wxString &aRef, int aUnit, const LIB_ID &aLibId, SCH_SHEET_PATH &aSheet, std::vector< SCH_SYMBOL * > *otherUnits)
#define SKIP_CONNECTIVITY
#define DELETE_REMOVED_ITEMS
@ SYMBOL_FILTER_NON_POWER
wxString GetDefaultVariantName()
int SortVariantNames(const wxString &aLhs, const wxString &aRhs)
Data produced by a registered saver on the UI thread, consumed by either the background local-history...
std::string content
Serialized content (mutually exclusive with sourcePath)
KICAD_FORMAT::FORMAT_MODE formatMode
wxString relativePath
Destination path relative to the project root.
A schematic staged off to the side by an importer, ready to be swapped into a live SCHEMATIC in one s...
Pins of type no-connect that touch other items at one position.
A wire end, a bus entry end or a symbol pin that is not on the connection grid.
A simple container for schematic symbol instance information.
Information about a top-level schematic sheet.
wxString filename
Relative path to the sheet file.
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ SHEET_REF_SUFFIX
Optional sheet field appended to the references of the sheet's symbols.
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
std::vector< DATABASE_CONNECTION::ROW > rows
wxLogTrace helper definitions.
VECTOR2< int32_t > VECTOR2I
Definition of file extensions used in Kicad.