Add ncPins to the list of no_connect_ nets.

This allows the info to be acted upon in PCBNew (for instance, clearance
rules).

Fixes https://gitlab.com/kicad/code/kicad/issues/6991
This commit is contained in:
Jeff Young 2021-01-07 21:54:54 +00:00
parent af2745af26
commit c3d46c1cb5
2 changed files with 34 additions and 9 deletions

View File

@ -734,7 +734,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
if( connection->SubgraphCode() == 0 )
{
auto subgraph = new CONNECTION_SUBGRAPH( this );
CONNECTION_SUBGRAPH* subgraph = new CONNECTION_SUBGRAPH( this );
subgraph->m_code = m_last_subgraph_code++;
subgraph->m_sheet = sheet;
@ -749,7 +749,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
auto get_items =
[&]( SCH_ITEM* aItem ) -> bool
{
auto* conn = aItem->Connection( &sheet );
SCH_CONNECTION* conn = aItem->Connection( &sheet );
if( !conn )
conn = aItem->InitializeConnection( sheet, this );
@ -761,12 +761,12 @@ void CONNECTION_GRAPH::buildConnectionGraph()
item->ConnectedItems( sheet ).end(),
std::back_inserter( members ), get_items );
for( auto connected_item : members )
for( SCH_ITEM* connected_item : members )
{
if( connected_item->Type() == SCH_NO_CONNECT_T )
subgraph->m_no_connect = connected_item;
auto connected_conn = connected_item->Connection( &sheet );
SCH_CONNECTION* connected_conn = connected_item->Connection( &sheet );
wxASSERT( connected_conn );

View File

@ -557,6 +557,9 @@ XNODE* NETLIST_EXPORTER_XML::makeLibParts()
}
#define NC_PREFIX "no_connect_"
XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl )
{
XNODE* xnets = node( "nets" ); // auto_ptr if exceptions ever get used.
@ -576,7 +579,7 @@ XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl )
typedef std::pair<SCH_PIN*, SCH_SHEET_PATH> MEMBER_RECORD;
typedef std::pair<wxString, std::vector<MEMBER_RECORD>> NET_RECORD;
std::vector<NET_RECORD*> nets;
std::vector<NET_RECORD*> noConnects;
std::vector<NET_RECORD*> ncNets;
for( const auto& it : m_schematic->ConnectionGraph()->GetNetMap() )
{
@ -589,12 +592,12 @@ XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl )
if( !subgraphs[0]->m_strong_driver && subgraphs[0]->m_no_connect )
{
noConnects.emplace_back( new NET_RECORD( "no_connect_", std::vector<MEMBER_RECORD>() ) );
net_record = noConnects.back();
ncNets.push_back( new NET_RECORD( NC_PREFIX, std::vector<MEMBER_RECORD>() ) );
net_record = ncNets.back();
}
else
{
nets.emplace_back( new NET_RECORD( net_name, std::vector<MEMBER_RECORD>() ) );
nets.push_back( new NET_RECORD( net_name, std::vector<MEMBER_RECORD>() ) );
net_record = nets.back();
}
@ -622,6 +625,28 @@ XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl )
}
}
// Add no_connect_* nets for no-connect pins.
SCH_SHEET_LIST sheetList = m_schematic->GetSheets();
for( unsigned ii = 0; ii < sheetList.size(); ii++ )
{
SCH_SHEET_PATH& sheet = sheetList[ii];
for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
{
SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( item );
for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
{
if( pin->GetType() == ELECTRICAL_PINTYPE::PT_NC )
{
ncNets.push_back( new NET_RECORD( NC_PREFIX, std::vector<MEMBER_RECORD>() ) );
ncNets.back()->second.emplace_back( pin, sheet );
}
}
}
}
// Netlist ordering: Net name, then ref des, then pin name
std::sort( nets.begin(), nets.end(),
[]( const NET_RECORD* a, const NET_RECORD*b )
@ -629,7 +654,7 @@ XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl )
return StrNumCmp( a->first, b->first ) < 0;
} );
nets.insert( nets.end(), noConnects.begin(), noConnects.end() );
nets.insert( nets.end(), ncNets.begin(), ncNets.end() );
for( int i = 0; i < (int) nets.size(); ++i )
{