From c3d46c1cb5e7e73c7fcd69fb4839a3851761b309 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 7 Jan 2021 21:54:54 +0000 Subject: [PATCH] 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 --- eeschema/connection_graph.cpp | 8 ++--- .../netlist_exporter_xml.cpp | 35 ++++++++++++++++--- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 4139f180b3..38f9628727 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -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 ); diff --git a/eeschema/netlist_exporters/netlist_exporter_xml.cpp b/eeschema/netlist_exporters/netlist_exporter_xml.cpp index a999f57bc0..439c92fbea 100644 --- a/eeschema/netlist_exporters/netlist_exporter_xml.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_xml.cpp @@ -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 MEMBER_RECORD; typedef std::pair> NET_RECORD; std::vector nets; - std::vector noConnects; + std::vector 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() ) ); - net_record = noConnects.back(); + ncNets.push_back( new NET_RECORD( NC_PREFIX, std::vector() ) ); + net_record = ncNets.back(); } else { - nets.emplace_back( new NET_RECORD( net_name, std::vector() ) ); + nets.push_back( new NET_RECORD( net_name, std::vector() ) ); 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( 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() ) ); + 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 ) {