80class ERC_MARKER_PLACER
83 explicit ERC_MARKER_PLACER(
const SCHEMATIC& aSchematic ) :
84 m_schematic( aSchematic )
88 const SCH_SHEET_PATH* Find(
const KIID_PATH& aSheet )
92 m_hierarchy = m_schematic.Hierarchy();
95 for(
const SCH_SHEET_PATH&
path : m_hierarchy )
96 m_paths->emplace(
path.PathRef(), &
path );
99 if(
const auto found = m_paths->find( aSheet ); found != m_paths->end() )
100 return found->second;
102 wxLogTrace(
"KICAD_CONNECTIVITY",
"ERC connectivity references unknown sheet instance %s", aSheet.
AsString() );
106 void Place( std::shared_ptr<ERC_ITEM> aItem,
const KIID_PATH& aSheet,
const VECTOR2I& aPosition,
107 ITEM_PATHS aItemPaths = ITEM_PATHS::NONE,
bool aSheetSpecific =
true )
109 const SCH_SHEET_PATH* sheet = Find( aSheet );
114 if( aItemPaths == ITEM_PATHS::BOTH && aItem->GetAuxItemID() !=
niluuid )
115 aItem->SetItemsSheetPaths( *sheet, *sheet );
116 else if( aItemPaths != ITEM_PATHS::NONE )
117 aItem->SetItemsSheetPaths( *sheet );
119 append( std::move( aItem ), *sheet, aPosition, aSheetSpecific );
122 void Place( std::shared_ptr<ERC_ITEM> aItem,
const KIID_PATH& aSheet,
const VECTOR2I& aPosition,
123 const KIID_PATH& aMainItemSheet,
const KIID_PATH& aAuxItemSheet )
125 const SCH_SHEET_PATH* sheet = Find( aSheet );
126 const SCH_SHEET_PATH*
main = Find( aMainItemSheet );
127 const SCH_SHEET_PATH* aux = Find( aAuxItemSheet );
129 if( !sheet || !
main || !aux )
132 aItem->SetItemsSheetPaths( *
main, *aux );
133 append( std::move( aItem ), *sheet, aPosition );
136 void Report(
int aCode,
const std::vector<KIID>& aItems,
const KIID_PATH& aSheet,
const VECTOR2I& aPosition,
137 ITEM_PATHS aItemPaths = ITEM_PATHS::NONE,
const wxString& aMessage = wxEmptyString )
140 item->SetItems( aItems );
142 if( !aMessage.empty() )
143 item->SetErrorMessage( aMessage );
145 Place( std::move( item ), aSheet, aPosition, aItemPaths );
148 int Count()
const {
return m_count; }
151 void append( std::shared_ptr<ERC_ITEM> aItem,
const SCH_SHEET_PATH& aSheet,
const VECTOR2I& aPosition,
152 bool aSheetSpecific =
true )
155 aItem->SetSheetSpecificPath( aSheet );
157 aSheet.
LastScreen()->
Append(
new SCH_MARKER( std::move( aItem ), aPosition ) );
162 SCH_SHEET_LIST m_hierarchy;
163 std::optional<std::map<KIID_PATH, const SCH_SHEET_PATH*>> m_paths;
172 std::vector<SCH_CONNECTIVITY::FOOTPRINT_SOURCE>
result;
178 const auto& symbol = *
static_cast<SCH_SYMBOL*
>( item );
179 const auto&
library = symbol.GetLibSymbolRef();
180 result.push_back( {
path.PathRef(), symbol.m_Uuid, symbol.GetPosition(),
189template <
typename LOCATION>
190int reportSourceErrors(
SCHEMATIC& aSchematic,
int aCode,
const std::vector<LOCATION>& aSources )
192 ERC_MARKER_PLACER markers( aSchematic );
194 for(
const auto&
source : aSources )
195 markers.Report( aCode, {
source.item },
source.sheet,
source.position, ITEM_PATHS::MAIN );
197 return markers.Count();
200std::vector<SCH_CONNECTIVITY::NAMED_ITEM> collectNamedItems(
SCHEMATIC& aSchematic,
bool aSimilar )
206 std::vector<SCH_CONNECTIVITY::NAMED_ITEM>
result;
214 for(
SCH_ITEM* item : subgraph->GetItems() )
220 result.push_back( { sheet.
PathRef(), item->m_Uuid, item->GetPosition(),
221 label->GetShownText( &sheet,
FOR_NETNAME ), item->Type(),
229 if( !
pin->IsPower() || !symbol )
244void reportNameConflict( ERC_MARKER_PLACER& aMarkers,
ERC_SETTINGS& aSettings,
ERCE_T aCode,
251 item->SetItems( aMain.
item, aAux.
item );
277 _(
"Bidirectional Pin" ),
278 _(
"Tri-State Pin" ),
281 _(
"Unspecified Pin" ),
282 _(
"Power Input Pin" ),
283 _(
"Power Output Pin" ),
284 _(
"Open Collector" ),
294 _(
"Bidirectional Pin" ),
295 _(
"Tri-State Pin" ),
298 _(
"Unspecified Pin" ),
299 _(
"Power Input Pin" ),
300 _(
"Power Output Pin" ),
301 _(
"Open Collector" ),
340 m_sheetList( aSchematic->BuildSheetListSortedByPageNumbers() ),
342 m_nets( aSchematic->ConnectionGraph()->GetNetMap() ),
357 const auto errors =
m_schematic->Connectivity().Engine().DuplicateSheetNames();
360 for(
const auto& error : errors )
366 return markers.Count();
372 std::vector<SCH_SHEET*> list;
375 list.push_back(
static_cast<SCH_SHEET*
>( item ) );
377 for(
size_t i = 0; i < list.size(); i++ )
381 for(
size_t j = i + 1; j < list.size(); j++ )
388 const wxString variant =
m_schematic->GetCurrentVariant();
389 const wxString
name =
391 const wxString other =
394 if(
name.IsSameAs( other,
false ) )
399 ercItem->SetItems( sheet, test_item );
400 ercItem->SetSheetSpecificPath(
path );
401 ercItem->SetItemsSheetPaths(
path,
path );
428 std::map<wxString, std::set<wxString>> padCache;
431 [&](
const wxString& aFootprintId ) ->
const std::set<wxString>&
433 auto it = padCache.find( aFootprintId );
435 if( it != padCache.end() )
438 std::set<wxString>& pads = padCache[aFootprintId];
440 if( padFetcher && !aFootprintId.IsEmpty() )
441 padFetcher( aFootprintId, aProject, pads );
450 std::vector<SCH_CONNECTIVITY::PIN_MAP_FACT> sources;
454 sources =
m_schematic->Connectivity().Engine().PinMapSymbols( screen->ConnectivityId() );
461 sources.push_back( std::move( *
source ) );
468 const std::set<wxString>& pinNumbers =
source.pinNumbers;
471 auto sharesJumperGroup =
472 [&](
const wxString& aPinA,
const wxString& aPinB )
476 if(
group.Contains( aPinA ) &&
group.Contains( aPinB ) )
489 if( pinNumbers.count( entry.m_PinNumber ) )
494 msg.Printf(
_(
"Pin map '%s' references unknown symbol pin '%s'" ),
498 ercItem->SetItems(
source.id );
499 ercItem->SetErrorMessage( msg );
508 std::map<wxString, wxString> padToPin;
511 for(
const wxString& pinNumber : pinNumbers )
513 if( !map.HasEntry( pinNumber ) )
514 padToPin[pinNumber] = pinNumber;
521 auto it = padToPin.find(
pad );
523 if( it == padToPin.end() )
525 padToPin[
pad] = entry.m_PinNumber;
527 else if( it->second != entry.m_PinNumber
528 && !sharesJumperGroup( it->second, entry.m_PinNumber ) )
532 msg.Printf(
_(
"Symbol pins '%s' and '%s' both map to pad '%s'" ),
537 ercItem->SetItems(
source.id );
538 ercItem->SetErrorMessage( msg );
547 if( checkBadPad && padFetcher )
565 if( pads.count(
pad ) )
570 msg.Printf(
_(
"Pin map '%s' references pad '%s' not present on footprint '%s'" ),
575 ercItem->SetItems(
source.id );
576 ercItem->SetErrorMessage( msg );
590 const wxString& footprint )
594 msg.Printf(
_(
"Pin '%s' is connected but maps to no pad on footprint '%s'" ),
598 error->SetItems(
pin );
599 error->SetSheetSpecificPath( sheet );
600 error->SetItemsSheetPaths( sheet );
601 error->SetErrorMessage( msg );
610 for(
const auto&
pin :
m_schematic->Connectivity().Engine().UnmappedPinCandidates() )
618 footprint.
Parse(
pin.footprint,
true );
622 report( *sheet,
pin.item,
pin.position,
pin.number,
pin.footprint );
643 if( fpText.IsEmpty() || fpId.
Parse( fpText,
true ) >= 0 )
653 if(
pin->IsDangling() )
657 pin->GetEffectivePadNumber( sheet, variant, fpId, &pads, &state );
659 if( state != SCH_PIN::PAD_RESOLUTION::UNMAPPED )
662 report( sheet,
pin->m_Uuid,
pin->GetPosition(),
pin->GetNumber(), fpText );
678 static wxRegEx varRefRegEx( wxT(
"(^|[^\\\\])\\$\\{.*\\}.*" ) );
680 auto reportAssertions =
682 const std::vector<SCH_CONNECTIVITY::TEXT_ASSERTION>& assertions,
const VECTOR2I& pos )
684 for(
const auto& assertion : assertions )
687 wxString
message = assertion.message;
691 ercItem->SetItems( std::vector<KIID>{ item } );
692 ercItem->SetItemsSheetPaths( sheet );
696 message +=
_(
" (in drawing sheet)" );
699 ercItem->SetSheetSpecificPath( sheet );
700 ercItem->SetErrorMessage(
message );
701 screen->Append(
new SCH_MARKER( std::move( ercItem ), pos ) );
704 return !assertions.empty();
723 ?
m_schematic->Connectivity().TextChecks( sheet.PathRef() )
726 for(
const auto&
source : sources )
728 if( reportAssertions(
source.assertionItem, sheet, screen,
source.assertions,
source.assertionPosition ) )
731 if( !varRefRegEx.Matches(
source.shownText ) )
735 ercItem->SetItems( std::vector<KIID>{
source.item } );
736 ercItem->SetSheetSpecificPath( sheet );
737 ercItem->SetItemsSheetPaths( sheet );
743 for(
const auto&
source :
m_schematic->Connectivity().TextChecks( sheet.PathRef(),
true ) )
745 if( reportAssertions(
niluuid, sheet, screen,
source.assertions,
source.assertionPosition ) )
748 if( varRefRegEx.Matches(
source.shownText ) )
751 ercItem->SetErrorMessage(
_(
"Unresolved text variable in drawing sheet" ) );
752 ercItem->SetSheetSpecificPath( sheet );
762 if( reportAssertions(
niluuid, sheet, screen,
764 text->GetPosition() ) )
774 ercItem->SetErrorMessage(
_(
"Unresolved text variable in drawing sheet" ) );
775 ercItem->SetSheetSpecificPath( sheet );
791 m_schematic->Connectivity().Engine().EmptyPowerValues() );
806 if( !
pin->IsGlobalPower() && !
pin->IsLocalPower() )
809 const SYMBOL* parent =
pin->GetLibPin() ?
pin->GetLibPin()->GetParentSymbol() :
nullptr;
817 if(
name.Trim(
false ).Trim(
true ).IsEmpty() )
820 ercItem->SetItems(
pin );
821 ercItem->SetItemsSheetPaths( sheet );
822 ercItem->SetSheetSpecificPath( sheet );
843 m_schematic->Connectivity().Engine().EmptyLabels() );
862 text.Trim(
false ).Trim(
true );
867 ercItem->SetItems( label );
868 ercItem->SetItemsSheetPaths( sheet );
869 ercItem->SetSheetSpecificPath( sheet );
889 const auto errors =
m_schematic->Connectivity().Engine().InvalidFieldNames();
892 for(
const auto& error : errors )
895 error.field.position, ITEM_PATHS::BOTH,
896 wxString::Format(
_(
"Field name has leading or trailing whitespace: '%s'" ),
897 error.field.name ) );
900 return markers.Count();
913 wxString trimmedFieldName = field.GetName();
914 trimmedFieldName.Trim();
915 trimmedFieldName.Trim(
false );
917 if( field.GetName() != trimmedFieldName )
920 ercItem->SetItems( symbol, &field );
921 ercItem->SetItemsSheetPaths( sheet, sheet );
922 ercItem->SetSheetSpecificPath( sheet );
923 ercItem->SetErrorMessage(
925 _(
"Field name has leading or trailing whitespace: '%s'" ),
941 wxString trimmedFieldName = field.GetName();
942 trimmedFieldName.Trim();
943 trimmedFieldName.Trim(
false );
945 if( field.GetName() != trimmedFieldName )
948 ercItem->SetItems( subSheet, &field );
949 ercItem->SetItemsSheetPaths( sheet, sheet );
950 ercItem->SetSheetSpecificPath( sheet );
951 ercItem->SetErrorMessage(
953 _(
"Field name has leading or trailing whitespace: '%s'" ),
973 return m_schematic->Connectivity().Engine().MultiUnitSymbols();
975 std::vector<MULTI_UNIT_GROUP>
result;
977 for(
const auto& [reference, refs] :
m_refMap )
979 if( refs.GetCount() == 0 )
983 group.reference = reference;
986 for(
size_t i = 0; i < refs.GetCount(); ++i )
1010 for(
const auto& unit :
group.instances )
1012 if( !unit.footprint.IsEmpty() )
1023 for(
const auto& unit :
group.instances )
1025 if( unit.item == reference->
item && unit.footprint == reference->
footprint
1026 && unit.name == reference->
name && unit.sheet < reference->
sheet )
1032 for(
const auto& unit :
group.instances )
1034 if( unit.footprint.IsEmpty() || unit.footprint == reference->
footprint )
1038 error->SetErrorMessage( wxString::Format(
_(
"Different footprints assigned to %s and %s" ),
1039 reference->
name, unit.name ) );
1040 error->SetItems( std::vector<KIID>{ reference->
item, unit.item } );
1041 markers.Place( std::move( error ), unit.sheet, unit.position, reference->
sheet, unit.sheet );
1045 return markers.Count();
1063 ercItem->SetErrorMessage( aMsg );
1068 ercItem->SetItems( aItemA->
GetSymbol() );
1075 return markers.Count();
1082 const bool suffixMode =
m_schematic->Settings().m_AnnotateReusedSheetSuffixes;
1085 for(
const auto& [
path, first] :
m_schematic->RefSuffixCollisions( suffixMode ) )
1090 otherParent.pop_back();
1093 ercItem->SetItems(
path.Last(), first.Last() );
1094 markers.Place( std::move( ercItem ), parent,
path.Last()->GetPosition(), parent, otherParent );
1097 return markers.Count();
1104 const bool suffixMode =
m_schematic->Settings().m_AnnotateReusedSheetSuffixes;
1106 std::map<const SCH_SCREEN*, const SCH_SHEET_PATH*> firstPath;
1110 auto [first, isFirst] = firstPath.emplace(
path.LastScreen(), &
path );
1125 msg = wxString::Format(
_(
"Reference %s was saved without the suffix %s" ), instance.
m_Reference,
1128 else if( suffixMode && !isFirst && !
m_schematic->CopiesSelectDifferentUnits( symbol )
1134 msg = wxString::Format(
_(
"Reference %s does not share the base of %s" ), symbol->
GetRef( &
path ),
1135 symbol->
GetRef( &firstUse ) );
1143 ercItem->SetErrorMessage( msg );
1144 ercItem->SetItems( symbol );
1145 markers.Place( std::move( ercItem ),
path.Path(), symbol->
GetPosition(), ITEM_PATHS::MAIN );
1149 return markers.Count();
1159 if(
group.instances.empty() )
1162 const auto& base =
group.instances.front();
1163 std::set<int> placed;
1165 for(
const auto& instance :
group.instances )
1166 placed.insert( instance.unit );
1168 std::set<int> missing;
1169 std::set<int> power;
1170 std::set<int> input;
1171 std::set<int> bidirectional;
1173 for(
size_t i = 0; i <
group.units.size(); ++i )
1175 const int unit =
static_cast<int>( i ) + 1;
1177 if( placed.contains( unit ) )
1180 missing.insert( unit );
1182 if(
group.units[i].powerInput )
1183 power.insert( unit );
1185 if(
group.units[i].input )
1186 input.insert( unit );
1188 if(
group.units[i].bidirectional )
1189 bidirectional.insert( unit );
1193 [&](
const std::set<int>& units,
const wxString&
message,
int code )
1195 if( units.empty() || !
m_settings.IsTestEnabled( code ) )
1198 wxString names = wxS(
"[ " );
1201 for(
int unit : units )
1207 names += wxS(
", " );
1209 names +=
group.units[unit - 1].name;
1212 if( units.size() > 3 )
1213 names += wxS(
", ..." );
1215 names += wxS(
" ]" );
1216 markers.Report( code, { base.item }, base.sheet, base.position, ITEM_PATHS::MAIN,
1220 report( missing,
_(
"Symbol %s has unplaced units %s" ),
1222 report( power,
_(
"Symbol %s has input power pins in units %s that are not placed" ),
1224 report( input,
_(
"Symbol %s has input pins in units %s that are not placed" ),
1226 report( bidirectional,
_(
"Symbol %s has bidirectional pins in units %s that are not placed" ),
1230 return markers.Count();
1237 std::shared_ptr<NET_SETTINGS>& settings =
m_schematic->Project().GetProjectFile().NetSettings();
1238 wxString defaultNetclass = settings->GetDefaultNetclass()->GetName();
1247 ercItem->SetItems( std::vector<KIID>{ item } );
1248 ercItem->SetSheetSpecificPath( sheet );
1249 ercItem->SetItemsSheetPaths( sheet );
1250 ercItem->SetErrorMessage( wxString::Format(
_(
"Netclass %s is not defined" ), netclass ) );
1260 for(
const auto& reference :
m_schematic->Connectivity().Engine().NetclassReferences() )
1262 if( reference.name == defaultNetclass || settings->HasNetclass( reference.name ) )
1265 if(
const SCH_SHEET_PATH* sheet = sheets.Find( reference.sheet ) )
1266 logError( *sheet, reference.item, reference.position, reference.name );
1276 item->RunOnChildren(
1288 if( !netclass.empty()
1289 && !netclass.IsSameAs( defaultNetclass )
1290 && !settings->HasNetclass( netclass ) )
1292 logError( sheet, item->m_Uuid, item->GetPosition(), netclass );
1315 for(
const auto& conflict :
m_schematic->Connectivity().Engine().LabelWireConflicts() )
1317 std::vector<KIID> witnesses{ conflict.label };
1318 witnesses.insert( witnesses.end(), conflict.wires.begin(),
1319 conflict.wires.begin() + std::min<std::ptrdiff_t>( 3, std::ssize( conflict.wires ) ) );
1321 wxString::Format(
_(
"Label connects more than one wire at %d, %d" ),
1322 conflict.position.x, conflict.position.y ) );
1325 return markers.Count();
1330 std::map<VECTOR2I, std::vector<SCH_ITEM*>> connMap;
1337 connMap[pt].emplace_back( label );
1340 for(
const std::pair<
const VECTOR2I, std::vector<SCH_ITEM*>>& pair : connMap )
1342 std::vector<SCH_ITEM*> lines;
1353 lines.emplace_back( line );
1356 if( lines.size() > 1 )
1363 ercItem->SetItems( pair.second.front(), lines[0], lines[1], lines[2] );
1364 ercItem->SetErrorMessage( wxString::Format(
_(
"Label connects more than one wire at %d, %d" ),
1365 pair.first.x, pair.first.y ) );
1366 ercItem->SetSheetSpecificPath( sheet );
1386 for(
const auto& junction :
m_schematic->Connectivity().Engine().FourWayJunctions() )
1389 junction.sheet, junction.position, ITEM_PATHS::NONE,
1390 wxString::Format(
_(
"Four items connected at %d, %d" ),
1391 junction.position.x, junction.position.y ) );
1394 return markers.Count();
1397 auto pinStackAlreadyRepresented =
1398 [](
SCH_PIN*
pin, std::vector<SCH_ITEM*>& collection ) ->
bool
1400 for(
SCH_ITEM*& item : collection )
1402 if( item->Type() ==
SCH_PIN_T && item->GetParentSymbol() ==
pin->GetParentSymbol() )
1416 std::map<VECTOR2I, std::vector<SCH_ITEM*>> connMap;
1425 std::vector<SCH_ITEM*>& entry = connMap[
pin->GetPosition()];
1428 if( pinStackAlreadyRepresented(
pin, entry ) )
1431 entry.emplace_back(
pin );
1443 connMap[pt].emplace_back( line );
1446 for(
const std::pair<
const VECTOR2I, std::vector<SCH_ITEM*>>& pair : connMap )
1448 if( pair.second.size() >= 4 )
1454 ercItem->SetItems( pair.second[0], pair.second[1], pair.second[2], pair.second[3] );
1456 ercItem->SetErrorMessage( wxString::Format(
_(
"Four items connected at %d, %d" ),
1457 pair.first.x, pair.first.y ) );
1459 ercItem->SetSheetSpecificPath( sheet );
1482 for(
const auto& conflict :
m_schematic->Connectivity().Engine().NoConnectPinConflicts() )
1485 const auto witnessPins = std::min<std::ptrdiff_t>( 3, std::ssize( conflict.pins ) );
1486 std::vector<KIID> items( conflict.pins.begin(), conflict.pins.begin() + witnessPins );
1487 const auto witnessOthers = std::min<std::ptrdiff_t>( 4 - witnessPins, std::ssize( conflict.others ) );
1488 items.insert( items.end(), conflict.others.begin(), conflict.others.begin() + witnessOthers );
1490 _(
"Pin with 'no connection' type is connected" ) );
1493 return markers.Count();
1498 std::map<VECTOR2I, std::vector<SCH_ITEM*>> pinMap;
1503 if( pinMap.count( pt ) )
1504 pinMap[pt].emplace_back( aOther );
1514 pinMap[
pin->GetPosition()].emplace_back(
pin );
1527 addOther(
pin->GetPosition(),
pin );
1532 for(
const VECTOR2I& pt : item->GetConnectionPoints() )
1533 addOther( pt, item );
1537 for(
const std::pair<
const VECTOR2I, std::vector<SCH_ITEM*>>& pair : pinMap )
1539 if( pair.second.size() > 1 )
1543 for(
SCH_ITEM* item : pair.second )
1567 ercItem->SetItems( pair.second[0], pair.second[1],
1568 pair.second.size() > 2 ? pair.second[2] :
nullptr,
1569 pair.second.size() > 3 ? pair.second[3] :
nullptr );
1570 ercItem->SetErrorMessage(
_(
"Pin with 'no connection' type is connected" ) );
1571 ercItem->SetSheetSpecificPath( sheet );
1597 std::map<wxString, const SCH_CONNECTIVITY::ERC_PIN_NET*> byName;
1598 std::set<wxString> powerDriven;
1600 ERC_MARKER_PLACER markers( aSchematic );
1603 [](
const PIN& a,
const PIN& b )
1605 int order =
StrNumCmp( a.reference, b.reference );
1608 order =
StrNumCmp( a.pin.number, b.pin.number );
1614 if( a.sheet != b.sheet )
1615 return a.sheet < b.sheet;
1617 return a.pin.id < b.pin.id;
1620 const auto mismatch =
1621 [&](
const PIN& a,
const PIN& b )
1628 const auto reportPair =
1631 std::shared_ptr<ERC_ITEM> item =
ERC_ITEM::Create( ercErrorCode( pinError ) );
1633 item->SetItems( std::vector<KIID>{ a.pin.id, b.pin.id } );
1637 item->SetErrorMessage( wxString::Format(
_(
"Pins of type %s and %s are connected" ),
1643 item->SetErrorMessage( wxString::Format(
_(
"Pins of type %s and %s are connected via "
1649 markers.Place( std::move( item ), a.sheet, a.pin.position, a.sheet, b.sheet );
1652 const auto passiveOrNic =
1667 for(
auto& net : nets )
1669 std::sort( net.pins.begin(), net.pins.end(), less );
1670 byName.emplace( net.name, &net );
1672 if( net.powerDriven )
1673 powerDriven.insert( net.name );
1676 for(
const auto& net : nets )
1678 const std::vector<PIN>& pins = net.pins;
1679 const bool powerNet = std::ranges::any_of( pins,
1684 const PIN* preferred =
nullptr;
1685 std::vector<const PIN*> needsDriver;
1686 std::vector<const PIN*> nonPowerInputs;
1687 std::vector<const PIN*> powerInputs;
1688 std::vector<MISMATCH> mismatches;
1689 std::map<size_t, int> weights;
1690 bool hasDriver = net.powerDriven;
1692 for(
size_t i = 0; i < pins.size(); ++i )
1694 const PIN&
pin = pins[i];
1700 needsDriver.push_back( &
pin );
1702 if( !
pin.pin.globalPower && !
pin.pin.localPower )
1703 nonPowerInputs.push_back( &
pin );
1706 powerInputs.push_back( &
pin );
1709 || ( preferred->pin.invisible && !
pin.pin.invisible )
1717 for(
size_t j = i + 1; j < pins.size(); ++j )
1719 const PIN& other = pins[j];
1720 const bool stacked =
pin.sheet == other.sheet
1721 &&
pin.owner == other.owner
1722 &&
pin.pin.position == other.pin.position
1723 &&
pin.pin.name == other.pin.name
1724 && (
pin.pin.type == other.pin.type
1725 || passiveOrNic(
pin.pin.type )
1726 || passiveOrNic( other.pin.type ) );
1736 mismatches.push_back( { i, j, error } );
1752 std::vector<std::pair<int, size_t>> worst;
1754 for(
const auto& [
index, weight] : weights )
1755 worst.emplace_back( weight,
index );
1757 std::stable_sort( worst.begin(), worst.end(),
1758 [](
const auto& a,
const auto& b )
1760 return a.first > b.first;
1763 for(
const auto& [weight,
index] : worst )
1766 const PIN* nearest =
nullptr;
1768 std::optional<double> nearestDistance;
1770 std::erase_if( mismatches,
1771 [&](
const MISMATCH& candidate )
1773 if( candidate.first !=
index && candidate.second !=
index )
1776 const PIN& other = pins[candidate.first ==
index ? candidate.second : candidate.first];
1779 if( other.sheet !=
pin.sheet )
1781 if( !nearestDistance )
1784 error = candidate.error;
1787 else if(
const double distance =
pin.pin.position.Distance( other.pin.position );
1788 !nearestDistance ||
distance < *nearestDistance )
1792 error = candidate.error;
1799 reportPair(
pin, *nearest, error, wxString() );
1802 if( !preferred || hasDriver || net.noConnect )
1805 bool chainDriver =
false;
1809 for(
const auto&
chain : chains )
1811 if( !
chain || !
chain->GetNets().contains( net.name ) )
1814 chainDriver = std::ranges::any_of(
chain->GetNets(),
1815 [&](
const wxString&
name )
1817 return name != net.name && powerDriven.contains( name );
1828 if( aShowAllErrors )
1830 const auto& selected = powerNet && !powerInputs.empty() ? powerInputs
1831 : !nonPowerInputs.empty() ? nonPowerInputs
1834 for(
const PIN*
pin : selected )
1835 markers.Report( code, {
pin->pin.id },
pin->sheet,
pin->pin.position, ITEM_PATHS::MAIN );
1839 const PIN&
pin = powerNet && !powerInputs.empty() ? *powerInputs.front()
1841 markers.Report( code, {
pin.pin.id },
pin.sheet,
pin.pin.position, ITEM_PATHS::MAIN );
1845 for(
const std::unique_ptr<SCH_NETCHAIN>&
chain : chains )
1853 const wxString* net;
1855 std::vector<CHAIN_PIN> pins;
1857 for(
const wxString&
name :
chain->GetNets() )
1859 const auto net = byName.find(
name );
1861 if( net == byName.end() )
1864 for(
const PIN&
pin : net->second->pins )
1865 pins.push_back( { &
pin, &net->first } );
1868 std::sort( pins.begin(), pins.end(),
1869 [&](
const CHAIN_PIN& a,
const CHAIN_PIN& b )
1871 return less( *a.pin, *b.pin );
1874 for(
size_t i = 0; i < pins.size(); ++i )
1876 for(
size_t j = i + 1; j < pins.size(); ++j )
1878 if( *pins[i].net == *pins[j].net )
1882 reportPair( *pins[i].
pin, *pins[j].
pin, error,
chain->GetName() );
1887 return markers.Count();
1898 std::set<wxString> powerDrivenNets;
1900 if( !
m_schematic->ConnectionGraph()->GetCommittedNetChains().empty() )
1902 for(
const auto& [key, subgraphs] :
m_nets )
1906 for(
SCH_ITEM* item : subgraph->GetItems() )
1914 powerDrivenNets.insert( key.Name );
1923 std::unordered_map<wxString, std::vector<ERC_SCH_PIN_CONTEXT>> netToPins;
1927 using iterator_t = std::vector<ERC_SCH_PIN_CONTEXT>::iterator;
1928 std::vector<ERC_SCH_PIN_CONTEXT> pins;
1929 std::unordered_map<EDA_ITEM*, SCH_SCREEN*> pinToScreenMap;
1930 bool has_noconnect =
false;
1935 has_noconnect =
true;
1941 pins.emplace_back(
static_cast<SCH_PIN*
>( item ), subgraph->
GetSheet() );
1942 netToPins[ net.first.Name ].emplace_back(
static_cast<SCH_PIN*
>( item ), subgraph->
GetSheet() );
1948 std::sort( pins.begin(), pins.end(),
1951 int ret = StrNumCmp( lhs.Pin()->GetParentSymbol()->GetRef( &lhs.Sheet() ),
1952 rhs.Pin()->GetParentSymbol()->GetRef( &rhs.Sheet() ) );
1955 ret = StrNumCmp( lhs.Pin()->GetNumber(), rhs.Pin()->GetNumber() );
1957 return ret != 0 ? ret < 0 : lhs < rhs;
1962 bool hasDriver =
false;
1963 std::vector<ERC_SCH_PIN_CONTEXT*> pinsNeedingDrivers;
1964 std::vector<ERC_SCH_PIN_CONTEXT*> nonPowerPinsNeedingDrivers;
1965 std::vector<ERC_SCH_PIN_CONTEXT*> powerInPinsNeedingDrivers;
1970 bool ispowerNet =
false;
1981 std::vector<std::tuple<iterator_t, iterator_t, PIN_ERROR>> pin_mismatches;
1982 std::map<iterator_t, int> pin_mismatch_counts;
1984 for(
auto refIt = pins.begin(); refIt != pins.end(); ++refIt )
1994 pinsNeedingDrivers.push_back( &refPin );
1997 nonPowerPinsNeedingDrivers.push_back( &refPin );
2000 powerInPinsNeedingDrivers.push_back( &refPin );
2002 if( !needsDriver.
Pin()
2007 needsDriver = refPin;
2008 needsDriverType = needsDriver.
Pin()->
GetType();
2017 for(
auto testIt = refIt + 1; testIt != pins.end(); ++testIt )
2038 pin_mismatches.emplace_back( std::tuple<iterator_t, iterator_t,
2039 PIN_ERROR>{ refIt, testIt, pinError } );
2043 pin_mismatch_counts[refIt] =
m_settings.GetPinTypeWeight( refIt->Pin()->GetType() );
2044 pin_mismatch_counts[testIt] =
m_settings.GetPinTypeWeight( testIt->Pin()->GetType() );
2048 if( !pin_mismatch_counts.contains( testIt ) )
2049 pin_mismatch_counts.emplace( testIt, 1 );
2051 pin_mismatch_counts[testIt]++;
2053 if( !pin_mismatch_counts.contains( refIt ) )
2054 pin_mismatch_counts.emplace( refIt, 1 );
2056 pin_mismatch_counts[refIt]++;
2062 std::multimap<size_t, iterator_t, std::greater<size_t>> pins_dsc;
2064 std::transform( pin_mismatch_counts.begin(), pin_mismatch_counts.end(),
2065 std::inserter( pins_dsc, pins_dsc.begin() ),
2068 return std::pair<size_t, iterator_t>( p.second, p.first );
2071 for(
const auto& [amount, pinItBind] : pins_dsc )
2073 auto& pinIt = pinItBind;
2075 if( pin_mismatches.empty() )
2081 iterator_t nearest_pin = pins.end();
2082 double smallest_distance = std::numeric_limits<double>::infinity();
2087 [&](
const auto& tuple )
2091 if( pinIt == std::get<0>( tuple ) )
2092 other = std::get<1>( tuple );
2093 else if( pinIt == std::get<1>( tuple ) )
2094 other = std::get<0>( tuple );
2098 if( ( *pinIt ).Sheet().Cmp( ( *other ).Sheet() ) != 0 )
2100 if( std::isinf( smallest_distance ) )
2102 nearest_pin = other;
2103 pinError = std::get<2>( tuple );
2110 if( std::isinf( smallest_distance ) ||
distance < smallest_distance )
2113 nearest_pin = other;
2114 pinError = std::get<2>( tuple );
2121 if( nearest_pin != pins.end() )
2123 SCH_PIN* other_pin = nearest_pin->Pin();
2124 std::shared_ptr<ERC_ITEM> ercItem =
ERC_ITEM::Create( ercErrorCode( pinError ) );
2126 ercItem->SetItems(
pin, other_pin );
2127 ercItem->SetSheetSpecificPath( pinIt->Sheet() );
2128 ercItem->SetItemsSheetPaths( pinIt->Sheet(), nearest_pin->Sheet() );
2130 ercItem->SetErrorMessage( wxString::Format(
_(
"Pins of type %s and %s are connected" ),
2135 pinToScreenMap[
pin]->Append( marker );
2140 if( needsDriver.
Pin() && !hasDriver && !has_noconnect )
2148 bool suppressForNetChainDriver =
false;
2152 const wxString& thisNetName = net.first.Name;
2153 const auto& netChains =
m_schematic->ConnectionGraph()->GetCommittedNetChains();
2155 for(
const auto& sig : netChains )
2160 const auto& sigNets = sig->GetNets();
2161 bool containsThisNet = std::find( sigNets.begin(), sigNets.end(), thisNetName ) != sigNets.end();
2163 if( !containsThisNet )
2167 for(
const wxString& otherNet : sigNets )
2169 if( otherNet == thisNetName )
2172 if( powerDrivenNets.contains( otherNet ) )
2174 suppressForNetChainDriver =
true;
2183 if( !suppressForNetChainDriver &&
m_settings.IsTestEnabled( err_code ) )
2185 std::vector<ERC_SCH_PIN_CONTEXT*> pinsToMark;
2194 if( ispowerNet && !powerInPinsNeedingDrivers.empty() )
2195 pinsToMark = powerInPinsNeedingDrivers;
2196 else if( !nonPowerPinsNeedingDrivers.empty() )
2197 pinsToMark = nonPowerPinsNeedingDrivers;
2199 pinsToMark = pinsNeedingDrivers;
2203 if( ispowerNet && !powerInPinsNeedingDrivers.empty() )
2204 pinsToMark.push_back( powerInPinsNeedingDrivers.front() );
2206 pinsToMark.push_back( &needsDriver );
2213 ercItem->SetItems( pinCtx->Pin() );
2214 ercItem->SetSheetSpecificPath( pinCtx->Sheet() );
2215 ercItem->SetItemsSheetPaths( pinCtx->Sheet() );
2218 pinToScreenMap[pinCtx->Pin()]->Append( marker );
2233 auto& netChains =
m_schematic->ConnectionGraph()->GetCommittedNetChains();
2234 wxLogTrace(
traceSchNetChain,
"ERC TestPinToPin: cross-chain phase start chains=%zu",
2237 for(
const auto& sig : netChains )
2242 const wxString chainName = sig->GetName();
2243 const auto& sigNets = sig->GetNets();
2249 const wxString* net;
2251 std::vector<CHAIN_PIN> netChainPins;
2252 netChainPins.reserve( sigNets.size() * 4 );
2254 for(
const wxString& n : sigNets )
2256 auto it = netToPins.find( n );
2257 if( it != netToPins.end() )
2260 netChainPins.push_back( { context, &it->first } );
2264 if( netChainPins.size() < 2 )
2268 "ERC TestPinToPin: chain '%s' nets=%zu collectedPins=%zu",
2269 TO_UTF8( chainName ), sigNets.size(), netChainPins.size() );
2272 std::sort( netChainPins.begin(), netChainPins.end(),
2273 [](
const CHAIN_PIN&
left,
const CHAIN_PIN&
right )
2275 const auto& lhs = left.context;
2276 const auto& rhs = right.context;
2277 int ret = StrNumCmp( lhs.Pin()->GetParentSymbol()->GetRef( &lhs.Sheet() ),
2278 rhs.Pin()->GetParentSymbol()->GetRef( &rhs.Sheet() ) );
2280 ret = StrNumCmp( lhs.Pin()->GetNumber(), rhs.Pin()->GetNumber() );
2281 return ret != 0 ? ret < 0 : lhs < rhs;
2284 for(
size_t i = 0; i < netChainPins.size(); ++i )
2286 const auto& aContext = netChainPins[i].context;
2287 SCH_PIN* aPin = aContext.Pin();
2289 const wxString& aNet = *netChainPins[i].net;
2291 for(
size_t j = i + 1; j < netChainPins.size(); ++j )
2293 const auto& bContext = netChainPins[j].context;
2294 SCH_PIN* bPin = bContext.Pin();
2295 const wxString& bNet = *netChainPins[j].net;
2305 std::shared_ptr<ERC_ITEM> ercItem =
ERC_ITEM::Create( ercErrorCode( pinError ) );
2307 ercItem->SetItems( aPin, bPin );
2308 ercItem->SetSheetSpecificPath( aContext.Sheet() );
2309 ercItem->SetItemsSheetPaths( aContext.Sheet(), bContext.Sheet() );
2310 ercItem->SetErrorMessage( wxString::Format(
_(
"Pins of type %s and %s are connected via "
2316 aContext.Sheet().LastScreen()->Append( marker );
2336 for(
const auto& conflict :
m_schematic->Connectivity().Engine().MultiUnitPinConflicts() )
2339 ercItem->SetErrorMessage( wxString::Format(
_(
"Pin %s is connected to both %s and %s" ),
2342 conflict.firstNet ) );
2343 ercItem->SetItems( std::vector<KIID>{ conflict.other.item, conflict.first.item } );
2344 markers.Place( std::move( ercItem ), conflict.other.sheet, conflict.other.position, conflict.other.sheet,
2345 conflict.first.sheet );
2348 return markers.Count();
2358 std::unordered_map<wxString, std::vector<PIN_ON_NET>> pinToNetMap;
2362 const wxString& netName = net.first.Name;
2373 if( !
pin->GetParentSymbol()->IsMultiUnit() )
2376 wxString
name =
pin->GetParentSymbol()->GetRef( &sheet ) +
":" +
pin->GetShownNumber();
2378 pinToNetMap[
name].push_back( { netName,
pin, sheet } );
2387 std::vector<wxString> conflicted;
2389 for(
const auto& [
name, pins] : pinToNetMap )
2391 for(
const PIN_ON_NET& candidate : pins )
2393 if( candidate.m_netName != pins.front().m_netName )
2395 conflicted.push_back(
name );
2401 std::sort( conflicted.begin(), conflicted.end() );
2403 for(
const wxString&
name : conflicted )
2405 std::vector<PIN_ON_NET> pins = pinToNetMap[
name];
2407 std::sort( pins.begin(), pins.end(),
2408 [](
const PIN_ON_NET& a,
const PIN_ON_NET& b )
2410 if( a.m_netName != b.m_netName )
2411 return a.m_netName < b.m_netName;
2413 return a.m_pin->m_Uuid < b.m_pin->m_Uuid;
2416 const PIN_ON_NET& first = pins.front();
2418 for(
const PIN_ON_NET& other : pins )
2420 if( other.m_netName == first.m_netName )
2425 ercItem->SetErrorMessage( wxString::Format(
_(
"Pin %s is connected to both %s and %s" ),
2426 other.m_pin->GetShownNumber(),
2428 first.m_netName ) );
2430 ercItem->SetItems( other.m_pin, first.m_pin );
2431 ercItem->SetSheetSpecificPath( other.m_sheet );
2432 ercItem->SetItemsSheetPaths( other.m_sheet, first.m_sheet );
2435 other.m_sheet.LastScreen()->Append( marker );
2449 ERC_MARKER_PLACER markers( aSchematic );
2456 ercItem->SetItems(
pin.item );
2457 markers.Place( std::move( ercItem ),
pin.sheet,
pin.position, ITEM_PATHS::MAIN );
2466 ercItem->SetItems( conflict.first, conflict.second );
2467 ercItem->SetErrorMessage( wxString::Format(
_(
"Both %s and %s are attached to the same items; "
2468 "%s will be used in the netlist" ),
2470 conflict.secondName,
2471 conflict.firstName ) );
2472 markers.Place( std::move( ercItem ), conflict.sheet, conflict.position, ITEM_PATHS::BOTH );
2481 ercItem->SetItems( endpoint.item );
2482 ercItem->SetErrorMessage( endpoint.busEntry ?
_(
"Unconnected wire to bus entry" )
2483 :
_(
"Unconnected wire endpoint" ) );
2484 markers.Place( std::move( ercItem ), endpoint.sheet, endpoint.position );
2493 ercItem->SetItems( conflict.net, conflict.bus );
2494 markers.Place( std::move( ercItem ), conflict.sheet, conflict.position );
2503 ercItem->SetItems( conflict.canonical, conflict.other );
2505 if( conflict.mixedShapes )
2506 ercItem->SetErrorMessage(
_(
"Bus vector and bus group are graphically connected" ) );
2508 markers.Place( std::move( ercItem ), conflict.sheet, conflict.position );
2517 ercItem->SetItems( conflict.entry, conflict.bus );
2518 ercItem->SetErrorMessage( wxString::Format(
_(
"Net %s is graphically connected to bus %s but is not a"
2519 " member of that bus" ),
2522 markers.Place( std::move( ercItem ), conflict.sheet, conflict.position );
2535 markers.Report( code,
2536 diagnostic.pin ==
niluuid ? std::vector<KIID>{ diagnostic.flag }
2537 : std::vector<KIID>{ diagnostic.pin, diagnostic.flag },
2538 diagnostic.sheet, diagnostic.position, ITEM_PATHS::MAIN );
2554 const bool mismatch = error.kind == ERROR_KIND::MISSING_LABEL || error.kind == ERROR_KIND::MISSING_PIN;
2561 ercItem->SetItems( std::vector<KIID>{ error.item } );
2564 switch( error.kind )
2566 case ERROR_KIND::ROOT_LABEL:
2567 ercItem->SetErrorMessage( wxString::Format(
_(
"Hierarchical label '%s' in root sheet cannot be "
2568 "connected to non-existent parent sheet" ),
2572 case ERROR_KIND::MISSING_LABEL:
2573 ercItem->SetErrorMessage( wxString::Format(
_(
"Sheet pin %s has no matching hierarchical label "
2574 "inside the sheet" ),
2578 case ERROR_KIND::MISSING_PIN:
2579 ercItem->SetErrorMessage( wxString::Format(
_(
"Hierarchical label %s has no matching sheet pin "
2580 "in the parent sheet" ),
2584 case ERROR_KIND::DANGLING_PIN:
2589 const bool rootLabel = error.kind == ERROR_KIND::ROOT_LABEL;
2590 markers.Place( std::move( ercItem ), error.sheet, error.position,
2591 rootLabel ? ITEM_PATHS::NONE : ITEM_PATHS::MAIN, !rootLabel );
2602 markers.Report( code, { label.item }, label.sheet, label.position );
2627 return markers.Count();
2651 std::vector<SCH_PIN*> pins = symbol->
GetPins( &sheet );
2653 std::map<wxString, std::vector<std::pair<SCH_PIN*, wxString>>> pinsByNumber;
2660 netName =
pin->GetConnectionName( &sheet ).value_or( wxString() );
2662 netName = conn->GetNetName();
2664 pinsByNumber[
pin->GetNumber()].emplace_back(
pin, netName );
2667 for(
const auto& [pinNumber, pinNetPairs] : pinsByNumber )
2669 if( pinNetPairs.size() < 2 )
2672 wxString firstNet = pinNetPairs[0].second;
2673 bool hasDifferentNets =
false;
2674 SCH_PIN* conflictPin =
nullptr;
2676 for(
size_t i = 1; i < pinNetPairs.size(); i++ )
2678 if( pinNetPairs[i].second != firstNet )
2680 hasDifferentNets =
true;
2681 conflictPin = pinNetPairs[i].first;
2686 if( hasDifferentNets )
2691 msg.Printf(
_(
"Pin %s on symbol '%s' is connected to different nets: %s and %s" ),
2693 symbol->
GetRef( &sheet ),
2694 firstNet.IsEmpty() ?
_(
"<no net>" ) : firstNet,
2695 pinNetPairs[1].second.IsEmpty() ?
_(
"<no net>" ) : pinNetPairs[1].second );
2697 ercItem->SetErrorMessage( msg );
2698 ercItem->SetItems( pinNetPairs[0].first, conflictPin );
2699 ercItem->SetSheetSpecificPath( sheet );
2700 ercItem->SetItemsSheetPaths( sheet, sheet );
2702 SCH_MARKER* marker =
new SCH_MARKER( std::move( ercItem ), pinNetPairs[0].first->GetPosition() );
2703 screen->
Append( marker );
2722 for(
const auto& mismatch :
m_schematic->Connectivity().Engine().GroundPinErrors() )
2726 wxString::Format(
_(
"Pin %s not connected to ground net" ), mismatch.name ) );
2729 return markers.Count();
2733 [](
const wxString& txt )
2735 wxString upper = txt.Upper();
2737 return upper.Contains( wxT(
"GND" ) )
2738 || upper == wxT(
"EARTH" )
2739 || upper.StartsWith( wxT(
"EARTH_" ) )
2740 || upper == wxT(
"VSS" )
2741 || upper == wxT(
"VSSA" );
2751 bool hasGroundNet =
false;
2752 std::vector<SCH_PIN*> mismatched;
2764 const wxString net = conn ? conn->
Name(
true ) : wxString();
2765 const bool netIsGround = isGround( net );
2768 hasGroundNet =
true;
2770 if( isGround(
pin->GetShownName() ) && !netIsGround )
2771 mismatched.push_back(
pin );
2780 ercItem->SetErrorMessage( wxString::Format(
_(
"Pin %s not connected to ground net" ),
2781 pin->GetShownName() ) );
2782 ercItem->SetItems(
pin );
2783 ercItem->SetSheetSpecificPath( sheet );
2784 ercItem->SetItemsSheetPaths( sheet );
2787 screen->
Append( marker );
2803 m_schematic->Connectivity().Engine().InvalidPinNotation() );
2819 pin->GetStackedPinNumbers( &valid );
2824 ercItem->SetItems(
pin );
2825 ercItem->SetSheetSpecificPath( sheet );
2826 ercItem->SetItemsSheetPaths( sheet );
2829 screen->
Append( marker );
2843 std::map<wxString, NAMED_ITEM> globalLabels;
2844 std::map<wxString, NAMED_ITEM> localLabels;
2851 auto& labels = item.global ? globalLabels : localLabels;
2852 auto found = labels.find( item.name );
2855 if( found == labels.end()
2856 || item.item < found->second.item
2857 || ( item.item == found->second.item && item.sheet < found->second.sheet ) )
2859 labels[item.name] = item;
2865 for(
const auto& [
name, global] : globalLabels )
2867 const auto local = localLabels.find(
name );
2869 if( local == localLabels.end() )
2874 reportNameConflict( markers,
m_settings, code, global, local->second );
2877 return markers.Count();
2884 std::map<wxString, std::vector<NAMED_ITEM>> generalMap;
2886 auto normalizeLabel =
2887 [](
const wxString& aLabel )
2889 wxString stripped = aLabel.Strip( wxString::leading ).Strip( wxString::trailing );
2896 if( prefix == wxT(
"+" ) )
2897 prefix = wxEmptyString;
2900 units.Replace( wxS(
"µ" ),
'u' );
2901 units.Replace( wxS(
"μ" ),
'u' );
2903 return prefix.Lower() + value.Lower() + units.Lower();
2907 generalMap[normalizeLabel( item.name )].push_back( item );
2911 for(
auto& [
name, entries] : generalMap )
2916 if( a.sheet != b.sheet )
2917 return a.sheet.AsString() < b.sheet.AsString();
2919 return a.item < b.item;
2923 for(
size_t ii = 0; ii < entries.size(); ++ii )
2925 for(
size_t jj = ii + 1; jj < entries.size(); ++jj )
2944 reportNameConflict( markers,
m_settings, code, a, b );
2949 return markers.Count();
2963 struct LIBRARY_ISSUE
2972 std::vector<LIBRARY_ISSUE> issues;
2976 if( !optRow || ( *optRow )->Disabled() )
2981 wxString::Format(
_(
"The current configuration does not include the "
2982 "symbol library '%s'" ),
2995 wxCHECK2( uri.has_value(), uri = wxEmptyString );
2997 wxString::Format(
_(
"The symbol library '%s' was not found at '%s'" ),
3013 wxString::Format(
_(
"Symbol '%s' not found in symbol library '%s'" ),
3025 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->
Flatten();
3026 const int flags =
m_schematic->Settings().SymbolCompareFlags();
3027 bool mismatch =
false;
3039 wxCHECK( aSymbol && aSymbol->GetLibSymbolRef(), issues );
3041 LIB_SYMBOL* embedded = aSymbol->GetLibSymbolRef().get();
3042 std::vector<wxString> messages;
3051 mismatch = messages.empty() && flattenedSymbol->Compare( *embedded, flags ) != 0;
3057 wxString::Format(
_(
"Symbol '%s' doesn't match copy in library '%s'" ),
3067 std::map<std::pair<const SCH_SCREEN*, KIID>, std::vector<LIBRARY_ISSUE>> results;
3072 std::vector<SCH_CONNECTIVITY::LIBRARY_SYMBOL_FACT> sources;
3075 std::vector<const SCH_SYMBOL*> symbols;
3079 sources =
m_schematic->Connectivity().Engine().LibrarySymbols(
path.PathRef() );
3092 symbols.push_back( symbol );
3096 std::vector<SCH_MARKER*> markers;
3098 for(
size_t ii = 0; ii < sources.size(); ++ii )
3100 const auto&
source = sources[ii];
3102 if( !
source.hasEmbeddedSymbol )
3107 if(
result == results.end() )
3109 const SCH_SYMBOL* symbol = captured ? nullptr : symbols[ii];
3110 result = results.emplace( std::make_pair( screen,
source.id ), check(
source, symbol ) ).first;
3113 for(
const LIBRARY_ISSUE& issue :
result->second )
3116 ercItem->SetItems( std::vector<KIID>{
source.id } );
3117 ercItem->SetSheetSpecificPath(
path );
3118 ercItem->SetItemsSheetPaths(
path );
3119 ercItem->SetErrorMessage( issue.message );
3120 markers.emplace_back(
new SCH_MARKER( std::move( ercItem ),
source.position ) );
3126 screen->
Append( marker );
3139 if( std::optional<LIBRARY_MANAGER_ADAPTER*> adapter =
3142 ( *adapter )->BlockUntilLoaded();
3151 if(
source.footprint.IsEmpty() )
3159 msg.Printf(
_(
"'%s' is not a valid footprint identifier" ),
source.footprint );
3165 const int ret = linkTester(
source.footprint, aProject );
3169 msg.Printf(
_(
"The current configuration does not include the footprint library '%s'" ),
3174 msg.Printf(
_(
"The footprint library '%s' is not enabled in the current configuration" ),
3179 msg.Printf(
_(
"Footprint '%s' not found in library '%s'" ), fpName, libName );
3191 return markers.Count();
3202 if(
source.filters.empty() )
3205 const wxString lowerId =
source.footprint.Lower();
3209 if( footprint.
Parse( lowerId ) > 0 )
3213 const bool found = std::ranges::any_of(
source.filters,
3214 [&](
const wxString&
filter )
3217 return filter.Contains( wxS(
":" ) ) ? lowerId.Matches( filter.Lower() )
3218 : lowerItemName.Matches( filter.Lower() );
3225 wxString::Format(
_(
"Assigned footprint (%s) doesn't match footprint filters (%s)" ),
3229 return markers.Count();
3242 const int gridSize =
m_schematic->Settings().m_ConnectionGridSize;
3247 std::vector<SCH_MARKER*> markers;
3249 for(
SCH_ITEM* item : screen->Items() )
3251 if( item->Type() ==
SCH_LINE_T && item->IsConnectable() )
3259 ercItem->SetItems( line );
3267 ercItem->SetItems( line );
3278 if( ( point.x % gridSize ) != 0
3279 || ( point.y % gridSize ) != 0 )
3282 ercItem->SetItems( entry );
3284 markers.emplace_back(
new SCH_MARKER( std::move( ercItem ), point ) );
3299 if( ( pinPos.
x % gridSize ) != 0 || ( pinPos.
y % gridSize ) != 0 )
3302 ercItem->SetItems(
pin );
3304 markers.emplace_back(
new SCH_MARKER( std::move( ercItem ), pinPos ) );
3313 screen->Append( marker );
3327 wxString variant =
m_schematic->GetCurrentVariant();
3334 std::vector<SCH_MARKER*> markers;
3336 for(
const auto&
source : sources )
3343 wxString msg =
reporter.GetMessages();
3349 ercItem->SetErrorMessage( msg );
3350 ercItem->SetItems(
source.id );
3351 ercItem->SetSheetSpecificPath( sheet );
3352 ercItem->SetItemsSheetPaths( sheet );
3354 markers.emplace_back(
new SCH_MARKER( std::move( ercItem ),
source.position ) );
3381 std::map<wxString, std::unique_ptr<LIB_SYMBOL>> flatAltCache;
3390 std::vector<SCH_MARKER*> markers;
3391 std::vector<SCH_CONNECTIVITY::VARIANT_SYMBOL_FACT> sources;
3392 std::vector<SCH_CONNECTIVITY::LIBRARY_SYMBOL_FACT> libraries;
3398 if( sources.empty() )
3413 auto& base = libraries.emplace_back();
3418 base.id = symbol->
m_Uuid;
3421 sources.push_back( std::move( *
source ) );
3424 std::sort( libraries.begin(), libraries.end(),
3425 [](
const auto& a,
const auto& b )
3431 for(
const auto&
source : sources )
3433 const auto base = std::lower_bound( libraries.begin(), libraries.end(),
source.id,
3434 [](
const auto& a,
const KIID&
id )
3439 if( base == libraries.end() || base->id !=
source.id )
3443 [&](
int aErrorCode,
const wxString& aMessage )
3447 ercItem->SetItems( std::vector<KIID>{
source.id } );
3448 ercItem->SetSheetSpecificPath( sheet );
3449 ercItem->SetItemsSheetPaths( sheet );
3450 ercItem->SetErrorMessage( aMessage );
3452 markers.emplace_back(
new SCH_MARKER( std::move( ercItem ), base->position ) );
3456 for(
const auto& [variantName, libId] :
source.overrides )
3458 wxString libIdStr = libId.Format();
3461 if( libId == base->library )
3464 auto cacheIt = flatAltCache.find( libIdStr );
3466 if( cacheIt == flatAltCache.end() )
3468 std::unique_ptr<LIB_SYMBOL> flatAlt;
3473 flatAlt = altSymbol->Flatten();
3479 cacheIt = flatAltCache.emplace( libIdStr, std::move( flatAlt ) ).first;
3482 const LIB_SYMBOL* flatAlt = cacheIt->second.get();
3489 wxString::Format(
_(
"Variant '%s': symbol '%s' not found in libraries" ),
3490 variantName, libIdStr ) );
3499 if( !base->hasEmbeddedSymbol )
3502 std::vector<VARIANT_COMPAT_RESULT> issues =
3508 wxString::Format(
_(
"Variant '%s', alternate '%s': %s" ),
3509 variantName, libIdStr, issue.detail ) );
3515 screen->
Append( marker );
3545 m_schematic->RebuildConnectivity(
nullptr, aProgressReporter );
3564 if( aProgressReporter )
3565 aProgressReporter->
AdvancePhase(
_(
"Checking sheet names..." ) );
3583 if( aProgressReporter )
3584 aProgressReporter->
AdvancePhase(
_(
"Checking pin maps..." ) );
3589 if( aProgressReporter )
3590 aProgressReporter->
AdvancePhase(
_(
"Checking conflicts..." ) );
3597 if( aProgressReporter )
3598 aProgressReporter->
AdvancePhase(
_(
"Checking units..." ) );
3603 if( aProgressReporter )
3604 aProgressReporter->
AdvancePhase(
_(
"Checking footprints..." ) );
3617 if( aProgressReporter )
3647 if( aProgressReporter )
3648 aProgressReporter->
AdvancePhase(
_(
"Checking similar labels..." ) );
3656 if( aProgressReporter )
3657 aProgressReporter->
AdvancePhase(
_(
"Checking local and global labels..." ) );
3664 if( aProgressReporter )
3665 aProgressReporter->
AdvancePhase(
_(
"Checking for unresolved variables..." ) );
3672 if( aProgressReporter )
3673 aProgressReporter->
AdvancePhase(
_(
"Checking field names..." ) );
3680 if( aProgressReporter )
3681 aProgressReporter->
AdvancePhase(
_(
"Checking for empty power symbol values..." ) );
3688 if( aProgressReporter )
3689 aProgressReporter->
AdvancePhase(
_(
"Checking for empty label names..." ) );
3696 if( aProgressReporter )
3697 aProgressReporter->
AdvancePhase(
_(
"Checking SPICE models..." ) );
3704 if( aProgressReporter )
3705 aProgressReporter->
AdvancePhase(
_(
"Checking no connect pins for connections..." ) );
3713 if( aProgressReporter )
3714 aProgressReporter->
AdvancePhase(
_(
"Checking for library symbol issues..." ) );
3721 if( aProgressReporter )
3722 aProgressReporter->
AdvancePhase(
_(
"Checking for footprint link issues..." ) );
3729 if( aProgressReporter )
3730 aProgressReporter->
AdvancePhase(
_(
"Checking footprint assignments against footprint filters..." ) );
3737 if( aProgressReporter )
3738 aProgressReporter->
AdvancePhase(
_(
"Checking for off grid pins and wires..." ) );
3745 if( aProgressReporter )
3746 aProgressReporter->
AdvancePhase(
_(
"Checking for four way junctions..." ) );
3753 if( aProgressReporter )
3754 aProgressReporter->
AdvancePhase(
_(
"Checking for labels on more than one wire..." ) );
3761 if( aProgressReporter )
3762 aProgressReporter->
AdvancePhase(
_(
"Checking for undefined netclasses..." ) );
3770 if( aProgressReporter )
3771 aProgressReporter->
AdvancePhase(
_(
"Checking variant symbols..." ) );
constexpr EDA_IU_SCALE schIUScale
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
const NET_MAP & GetNetMap() const
A subgraph is a set of items that are electrically connected on a single sheet.
const std::set< SCH_ITEM * > & GetItems() const
Provide a read-only reference to the items in the subgraph.
const SCH_ITEM * GetNoConnect() const
const SCH_SHEET_PATH & GetSheet() const
Base class to handle basic graphic items.
Store the list of graphic items: rect, lines, polygons and texts to draw/plot the title block and fra...
DS_DRAW_ITEM_BASE * GetFirst()
void BuildDrawItemsList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Drawing or plot the drawing sheet.
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
void SetSheetLayer(const wxString &aSheetLayer)
Set the sheet layer to draw/plot.
void SetSheetCount(int aSheetCount)
Set the value of the count of sheets, for basic inscriptions.
void SetPageNumber(const wxString &aPageNumber)
Set the value of the sheet number.
DS_DRAW_ITEM_BASE * GetNext()
void SetProject(const PROJECT *aProject)
const PAGE_INFO & GetPageInfo()
const TITLE_BLOCK & GetTitleBlock()
KICAD_T Type() const
Returns the type of object.
virtual const wxString & GetText() const
Return the string associated with the text object.
EE_TYPE Overlapping(const BOX2I &aRect) const
EE_TYPE OfType(KICAD_T aType) const
static std::shared_ptr< ERC_ITEM > Create(int aErrorCode)
Constructs an ERC_ITEM for the given error code.
A class used to associate a SCH_PIN with its owning SCH_SHEET_PATH, in order to handle ERC checks acr...
const SCH_SHEET_PATH & Sheet() const
Get the SCH_SHEET_PATH context for the paired SCH_PIN.
SCH_PIN * Pin() const
Get the SCH_PIN for this context.
Container for ERC settings.
bool IsTestEnabled(int aErrorCode) const
ERC_PIN_SORTING_METRIC GetERCSortingMetric() const
Get the type of sorting metric the ERC checker should use to resolve multi-pin errors.
PIN_ERROR GetPinMapValue(int aFirstType, int aSecondType) const
int GetPinTypeWeight(ELECTRICAL_PINTYPE aPinType) const
Get the weight for an electrical pin type.
int TestLibSymbolIssues()
Test symbols for changed library symbols and broken symbol library links.
int TestStackedPinNotation()
Checks for pin numbers that resemble stacked pin notation but are invalid.
int TestAnnotation()
Test the annotation of every symbol: unannotated, duplicate and mismatched units.
ERC_TESTER(SCHEMATIC *aSchematic, bool aShowAllErrors=false)
void TestTextVars(DS_PROXY_VIEW_ITEM *aDrawingSheet)
Check for any unresolved text variable references.
int TestPinToPin()
Checks the full netlist against the pin-to-pin connectivity requirements.
int TestSimilarLabels()
Checks for labels that differ only in capitalization.
SCH_MULTI_UNIT_REFERENCE_MAP m_refMap
int TestEmptyLabelNames()
Check for labels with empty or whitespace-only names.
int TestDuplicateSheetSuffixes()
Test that the instances of each reused sheet compose distinct reference suffixes.
int TestRefSuffixMismatch()
Report symbols whose saved reference lacked the reference suffix of their sheet instance.
int TestFootprintLinkIssues(KIFACE *aCvPcb, PROJECT *aProject)
Test footprint links against the current footprint libraries.
static int TestConnectivity(SCHEMATIC &aSchematic)
int TestOffGridEndpoints()
Test pins and wire ends for being off grid.
int TestDuplicateSheetNames(bool aCreateMarker)
Inside a given sheet, one cannot have sheets with duplicate names (file names can be duplicated).
int TestSameLocalGlobalLabel()
Checks for global and local labels with the same name.
int TestMultUnitPinConflicts()
Checks if shared pins on multi-unit symbols have been connected to different nets.
int TestEmptyPowerValues()
Check for power symbols whose value resolves to nothing, leaving their net unnamed.
int TestNoConnectPins()
In KiCad 5 and earlier, you could connect stuff up to pins with NC electrical type.
int TestFootprintFilters()
Test symbols to ensure that assigned footprint passes any given footprint filters.
int TestPinMap(KIFACE *aCvPcb, PROJECT *aProject)
Check pin-to-pad maps (issue #2282): stale pin references, duplicate pad targets, bad pads and unmapp...
int TestFieldNameWhitespace()
Check for field names with leading or trailing whitespace.
int TestDuplicatePinNets()
Checks if duplicate pin numbers within a symbol are connected to different nets.
ERC_SETTINGS & m_settings
int TestFourWayJunction()
Test to see if there are potentially confusing 4-way junctions in the schematic.
int TestMissingNetclasses()
Tests for netclasses that are referenced but not defined.
int TestSimModelIssues()
Test SPICE models for various issues.
SCH_SHEET_LIST m_sheetList
int TestGroundPins()
Checks for ground-labeled pins not on a ground net while another pin is.
std::vector< SCH_CONNECTIVITY::MULTI_UNIT_GROUP > multiUnitSources() const
void RunTests(DS_PROXY_VIEW_ITEM *aDrawingSheet, SCH_EDIT_FRAME *aEditFrame, KIFACE *aCvPcb, PROJECT *aProject, PROGRESS_REPORTER *aProgressReporter)
int TestMissingUnits()
Test for uninstantiated units of multi unit symbols.
int TestLabelMultipleWires()
Test to see if there are labels that are connected to more than one wire.
int TestVariantSymbols()
Test all variant symbol overrides for resolution and pin compatibility.
int TestMultiunitFootprints()
Test if all units of each multiunit symbol have the same footprint assigned.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Represents an (ordered) list of JUMPER_GROUP objects.
const std::vector< JUMPER_GROUP > & GetAll() const
Represents a group of jumper pins or pads, keyed by name.
wxString AsString() const
bool IsLibraryLoaded(const wxString &aNickname)
std::optional< wxString > GetFullURI(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false)
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
std::optional< LIBRARY_TABLE_ROW * > GetRow(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH)
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.
wxString GetUniStringLibId() const
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Define a library symbol object.
const std::vector< ASSOCIATED_FOOTPRINT > & GetEffectiveAssociatedFootprints() const
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
bool GetDuplicatePinNumbersAreJumpers() const
virtual LIBRARY_MANAGER & GetLibraryManager() const
A symbol-owned ordered set of named pin maps.
const std::vector< PIN_MAP > & GetAll() const
const PIN_MAP * FindByName(const wxString &aName) const
const std::vector< PIN_MAP_ENTRY > & GetEntries() const
const wxString & GetName() const
A progress reporter interface for use in multi-threaded environments.
virtual void AdvancePhase()=0
Use the next available virtual zone of the dialog progress bar.
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
Container for project specific data.
Holds all the data relating to one schematic.
SCH_CONNECTIVITY::NETCHAIN_MANAGER & NetChains() const
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
SCH_CONNECTIVITY::FACADE & Connectivity() const
CONNECTION_GRAPH * ConnectionGraph() const
ERC_SETTINGS & ErcSettings() const
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Class for a wire to bus entry.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString Name(bool aIgnoreSheet=false) const
std::vector< ERC_PIN_NET > PinNets() const
Active pins for each named net, in net name order.
std::vector< NAMED_ITEM > NamedItems() const
Every label and power pin with its resolved name, on every instance.
std::vector< FOOTPRINT_SOURCE > FootprintSources() const
Resolved footprint and filters of every symbol on every instance.
const ENGINE & Engine() const
const std::vector< std::unique_ptr< SCH_NETCHAIN > > & GetCommittedNetChains() const
Return user-created (committed) net chains (legacy accessor retained under net-chain API).
Schematic editor (Eeschema) main window.
bool RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, PROGRESS_REPORTER *aProgressReporter=nullptr, bool aCleanupDone=false)
Generate the connection data for the entire schematic hierarchy.
wxString GetUntranslatedName() const
Get the untranslated field name for storage, variable look-up, etc.
wxString GetShownText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString, int aDepth=0) const
Base class for any item which can be embedded within the SCHEMATIC container class,...
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Segment description base class to describe items which have 2 end points (track, wire,...
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
bool IsEndPoint(const VECTOR2I &aPoint) const override
Test if aPt is an end point of this schematic object.
bool IsGraphicLine() const
Return if the line is a graphic (non electrical line)
PAD_RESOLUTION
Outcome of pin-to-pad resolution (issue #2282).
VECTOR2I GetPosition() const override
bool IsStacked(const SCH_PIN *aPin) const
static bool HasIdentityPad(const wxString &aPinNumber, const std::set< wxString > &aPads)
bool IsPower() const
Check if the pin is either a global or local power pin.
ELECTRICAL_PINTYPE GetType() const
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
int CheckAnnotation(ANNOTATION_ERROR_HANDLER aErrorHandler)
Check for annotations errors.
A helper to define a symbol's reference designator in a schematic.
const SCH_SHEET_PATH & GetSheetPath() const
const wxString GetFootprint() const
SCH_SYMBOL * GetSymbol() const
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
const SCH_SHEET * GetSheet(unsigned aIndex) const
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCH_SCREEN * LastScreen()
const KIID_PATH & PathRef() const
Borrow the cached path until this sheet path is modified or destroyed.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the sheet's fields.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
VECTOR2I GetPosition() const override
bool IsAnnotated(const SCH_SHEET_PATH *aSheet) const
Check if the symbol has a valid annotation (reference) for the given sheet path.
const wxString GetFootprintFieldText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString) const
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
wxString GetBaseRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
bool IsGlobalPower() const override
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
VECTOR2I GetPosition() const override
const LIB_ID & GetLibId() const override
bool GetInstance(SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
const wxString GetValue(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString) const override
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
VECTOR2I GetPosition() const override
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, std::span< const wxString > aPins, REPORTER &aReporter)
An interface to the global shared library manager that is schematic-specific and linked to one projec...
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
A base class for LIB_SYMBOL and SCH_SYMBOL.
virtual bool IsGlobalPower() const =0
virtual bool IsLocalPower() const =0
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
A wrapper for reporting to a wxString object.
void CheckDuplicatePins(LIB_SYMBOL *aSymbol, std::vector< wxString > &aMessages, UNITS_PROVIDER *aUnitsProvider)
const wxString CommentERC_V[]
const wxString CommentERC_H[]
const std::set< ELECTRICAL_PINTYPE > DrivenPinTypes
const std::set< ELECTRICAL_PINTYPE > DrivingPinTypes
const std::set< ELECTRICAL_PINTYPE > DrivingPowerPinTypes
@ ERCE_POWERPIN_NOT_DRIVEN
Power input pin connected to some others pins but no power out pin to drive it.
@ ERCE_DRIVER_CONFLICT
Conflicting drivers (labels, etc) on a subgraph.
@ ERCE_SIMILAR_POWER
2 power pins are equal for case insensitive comparisons.
@ ERCE_MISSING_POWER_INPUT_PIN
Symbol has power input pins that are not placed on the schematic.
@ ERCE_EMPTY_POWER_VALUE
Power symbol has no value, so it names no net.
@ ERCE_UNCONNECTED_WIRE_ENDPOINT
A label is connected to more than one wire.
@ ERCE_GROUND_PIN_NOT_GROUND
A ground-labeled pin is not on a ground net while another pin is.
@ ERCE_SIMILAR_LABELS
2 labels are equal for case insensitive comparisons.
@ ERCE_VARIANT_SYMBOL_INCOMPATIBLE
Variant symbol override fails pin compatibility.
@ ERCE_STACKED_PIN_SYNTAX
Pin name resembles stacked pin notation.
@ ERCE_LABEL_NOT_CONNECTED
Label not connected to any pins.
@ ERCE_ENDPOINT_OFF_GRID
Pin or wire-end off grid.
@ ERCE_REF_SUFFIX_MISMATCH
Saved reference lacks the suffix of its reused sheet.
@ ERCE_EMPTY_LABEL_NAME
Label has an empty or whitespace-only name.
@ ERCE_SAME_LOCAL_GLOBAL_LABEL
2 labels are equal for case insensitive comparisons.
@ ERCE_BUS_TO_BUS_CONFLICT
A connection between bus objects doesn't share at least one net.
@ ERCE_SIMILAR_LABEL_AND_POWER
label and pin are equal for case insensitive comparisons.
@ ERCE_SAME_LOCAL_GLOBAL_POWER
Local power port and global power port have the same name.
@ ERCE_PIN_MAP_BAD_PAD
Pin map references a pad absent from the footprint.
@ ERCE_LABEL_SINGLE_PIN
A label is connected only to a single pin.
@ ERCE_BUS_ENTRY_CONFLICT
A wire connected to a bus doesn't match the bus.
@ ERCE_FOOTPRINT_LINK_ISSUES
The footprint link is invalid, or points to a missing (or inactive) footprint or library.
@ ERCE_PIN_MAP_DUPLICATE_PAD
Two symbol pins map to one pad (not stacked/jumper).
@ ERCE_BUS_TO_NET_CONFLICT
A bus wire is graphically connected to a net port/pin (or vice versa).
@ ERCE_DUPLICATE_PIN_ERROR
@ ERCE_NOCONNECT_NOT_CONNECTED
A no connect symbol is not connected to anything.
@ ERCE_DIFFERENT_UNIT_NET
Shared pin in a multi-unit symbol is connected to more than one net.
@ 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_DUPLICATE_SHEET_SUFFIX
Two uses of one sheet file share a reference suffix.
@ 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_PIN_TO_PIN_WARNING
@ ERCE_PIN_NOT_DRIVEN
Pin connected to some others pins but no pin to drive it.
@ ERCE_MISSING_INPUT_PIN
Symbol has input pins that are not placed.
@ ERCE_MISSING_UNIT
Symbol has units that are not placed on the schematic.
@ ERCE_FIELD_NAME_WHITESPACE
Field name has leading or trailing whitespace.
@ ERCE_DUPLICATE_SHEET_NAME
Duplicate sheet names within a given sheet.
@ ERCE_PIN_MAP_STALE_PIN
Pin map references a pin number not on the symbol.
@ ERCE_MISSING_BIDI_PIN
Symbol has bi-directional pins that are not placed.
@ 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_SINGLE_GLOBAL_LABEL
A label only exists once in the schematic.
@ 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.
@ ERCE_WIRED_IMPLICIT_POWER
Wired hidden power input also joins its global net by name.
PIN_ERROR
The values a pin-to-pin entry in the pin matrix can take on.
bool m_ConnectivityEngine
Use the schematic connectivity engine instead of CONNECTION_GRAPH.
const wxChar *const traceSchNetChain
Flag to enable tracing of schematic net chain rebuild and ERC cross-chain checks.
@ KIFACE_TEST_FOOTPRINT_LINK_LIBRARY_NOT_ENABLED
@ KIFACE_TEST_FOOTPRINT_LINK_NO_LIBRARY
@ KIFACE_TEST_FOOTPRINT_LINK_NO_FOOTPRINT
Service::Type GetKifaceService(KIFACE *aKiface)
Look up a service exported by a KIFACE.
@ MISMATCH
Entries name the host with another key of this type, and none with this one.
Value keys and the key session of the schematic connectivity engine.
SOURCE_LOCATION UNCONNECTED_PIN
std::optional< PIN_MAP_FACT > ExtractPinMapFacts(const SCH_SYMBOL &aSymbol)
std::vector< SIMULATION_MODEL_FACT > ExtractSimulationModelFacts(const SCH_SHEET_PATH &aPath, const wxString &aVariantName)
std::vector< TEXT_CHECK_FACT > ExtractTextChecks(const SCH_SCREEN &aScreen, const SCH_SHEET_PATH &aPath)
SOURCE_LOCATION LABEL_LOCATION
LIBRARY_SYMBOL_FACT ExtractLibrarySymbolFact(const LIB_SYMBOL &aSymbol)
std::vector< TEXT_ASSERTION > ExtractTextAssertions(const wxString &aText)
std::optional< VARIANT_SYMBOL_FACT > ExtractVariantSymbolFact(const SCH_SYMBOL &aSymbol, const SCH_SHEET_PATH &aPath)
std::vector< UNIT_FACT > ExtractUnitFacts(const LIB_SYMBOL &aSymbol)
PGM_BASE & Pgm()
The global program "get" accessor.
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
@ PT_INPUT
usual pin input: must be connected
@ PT_NC
not connected (must be left open)
@ PT_TRISTATE
tri state bus pin
@ PT_NIC
not internally connected (may be connected to anything)
@ PT_BIDI
input or output (like port for a microprocessor)
@ PT_POWER_OUT
output of a regulator: intended to be connected to power input pins
@ 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.
wxString ElectricalPinTypeGetText(ELECTRICAL_PINTYPE)
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
static const std::vector< KICAD_T > labelTypes
@ SYMBOL_FILTER_NON_POWER
int StrNumCmp(const wxString &aString1, const wxString &aString2, CMP_T aCaseSensitivity)
Compare two strings with alphanumerical content.
std::vector< wxString > ExpandStackedPinNotation(const wxString &aPinName, bool *aValid)
Expand stacked pin notation like [1,2,3], [1-4], [A1-A4], or [AA1-AA3,AB4,CD12-CD14] into individual ...
wxString UnescapeString(const wxString &aSource)
int SplitString(const wxString &strToSplit, wxString *strBeginning, wxString *strDigits, wxString *strEnd)
Break a string into three parts: he alphabetic preamble, the numeric part, and any alphabetic ending.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
void(*)(const wxString &, PROJECT *, std::set< wxString > &) Type
Implement a participant in the KIWAY alchemy.
bool duplicatePinNumbersAreJumpers
One symbol-pin to footprint-pad mapping inside a PIN_MAP.
Two bus claims on one island that share no member, or a bus vector joined to a bus group.
A bus wire entry whose net is not a member of the bus it touches.
An island that mixes net and bus items.
Two different strong names on one island.
One active symbol pin on one sheet instance, with the reference of its symbol.
Up to four wires and bus entries of one island that has no driver.
A hierarchical label or sheet pin with no partner, or a dangling sheet pin.
A label that connects to nothing, or to only one pin.
bool HasDuplicatePins() const
bool Matches(const LIBRARY_SYMBOL_FACT &aOther, int aCompareFlags) const
LIB_SYMBOL_ATTRIBUTES attributes
All placed units that share one reference, with the unit table of the library symbol.
One placed unit of an annotated multi-unit symbol.
A label or a power pin with its resolved net name.
A no-connect flag on a net with more than one pin, or on a net with no pin and no label.
One item on one sheet instance, for a diagnostic that needs only a location.
One dangling end of a wire or a bus wire entry.
A simple container for schematic symbol instance information.
bool m_RefLacksSuffix
Set at load when the saved reference lacked its sheet suffix, cleared when the reference changes.
IbisParser parser & reporter
static std::set< FOOTPRINT * > collectFootprints(const PCB_GROUP *aGroup)
const SHAPE_LINE_CHAIN chain
wxString result
Test unit parsing edge cases and error handling.
wxLogTrace helper definitions.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
std::vector< VARIANT_COMPAT_RESULT > ValidateVariantSymbolCompatibility(const LIB_SYMBOL &aBase, const LIB_SYMBOL &aCandidate)
Check whether aCandidate can be used as a variant symbol override for aBase.
VECTOR2< int32_t > VECTOR2I