Don't allow pins with NC electrical type to join other nets

Fixes https://gitlab.com/kicad/code/kicad/-/issues/1826
This commit is contained in:
Jon Evans 2020-07-06 20:10:08 -04:00
parent 23ce2d2e36
commit d8be5f9ecf
5 changed files with 57 additions and 1 deletions

View File

@ -326,6 +326,9 @@ void DIALOG_ERC::TestErc( REPORTER& aReporter )
if( settings.IsTestEnabled( ERCE_UNRESOLVED_VARIABLE ) )
tester.TestTextVars( m_parent->GetCanvas()->GetView()->GetWorksheet() );
if( settings.IsTestEnabled( ERCE_NOCONNECT_CONNECTED ) )
tester.TestNoConnectPins();
// Display diags:
m_markerTreeModel->SetProvider( m_markerProvider );

View File

@ -525,6 +525,46 @@ void ERC_TESTER::TestOthersItems( NETLIST_OBJECT_LIST* aList, unsigned aNetItemR
}
}
int ERC_TESTER::TestNoConnectPins()
{
int err_count = 0;
for( const SCH_SHEET_PATH& sheet : m_schematic->GetSheets() )
{
std::map<wxPoint, std::vector<SCH_PIN*>> pinMap;
for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
{
SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item );
for( SCH_PIN* pin : comp->GetSchPins( &sheet ) )
pinMap[pin->GetPosition()].emplace_back( pin );
}
for( auto& pair : pinMap )
{
if( pair.second.size() > 1 )
{
err_count++;
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_CONNECTED );
ercItem->SetItems( pair.second[0], pair.second[1],
pair.second.size() > 2 ? pair.second[2] : nullptr,
pair.second.size() > 3 ? pair.second[3] : nullptr );
ercItem->SetErrorMessage( _( "Pins with \"no connection\" type are connected" ) );
SCH_MARKER* marker = new SCH_MARKER( ercItem, pair.first );
sheet.LastScreen()->Append( marker );
}
}
}
return err_count;
}
// this code try to detect similar labels, i.e. labels which are identical
// when they are compared using case insensitive coparisons.

View File

@ -99,6 +99,13 @@ public:
*/
int TestMultiunitFootprints();
/**
* In KiCad 5 and earlier, you could connect stuff up to pins with NC electrical type.
* In KiCad 6, this no longer results in those pins joining the net, so we need to warn about it
* @return the error count
*/
int TestNoConnectPins();
private:
/**
* Performs ERC testing and creates an ERC marker to show the ERC problem for aNetItemRef

View File

@ -141,4 +141,8 @@ bool SCH_PIN::HitTest( const wxPoint& aPosition, int aAccuracy ) const
}
bool SCH_PIN::ConnectionPropagatesTo( const EDA_ITEM* aItem ) const
{
// Reciprocal checking is done in CONNECTION_GRAPH anyway
return !( m_libPin->GetType() == ELECTRICAL_PINTYPE::PT_NC );
}

View File

@ -107,6 +107,8 @@ public:
bool IsPowerConnection() const { return m_libPin->IsPowerConnection(); }
bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override {}