From 778a3a4777f9a2de4b7edfc85e3fc910eb4987fd Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 26 Mar 2018 19:55:59 +0100 Subject: [PATCH] Count pins instead of using netcount as a proxy. Fixes: lp:1703155 * https://bugs.launchpad.net/kicad/+bug/1703155 --- cvpcb/cvpcb_mainframe.cpp | 2 +- cvpcb/footprints_listbox.cpp | 2 +- pcbnew/kicad_netlist_reader.cpp | 24 +++++++++++++++++++++++- pcbnew/pcb_netlist.h | 13 +++++++++++-- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index 88735a1a9c..a36d19f438 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -676,7 +676,7 @@ void CVPCB_MAINFRAME::DisplayStatus() msg.Empty(); if( component ) - msg = wxString::Format( wxT( "%i" ), component->GetNetCount() ); + msg = wxString::Format( wxT( "%i" ), component->GetPinCount() ); if( !filters.IsEmpty() ) filters += wxT( ", " ); diff --git a/cvpcb/footprints_listbox.cpp b/cvpcb/footprints_listbox.cpp index fef6774ee6..06d0874bc2 100644 --- a/cvpcb/footprints_listbox.cpp +++ b/cvpcb/footprints_listbox.cpp @@ -140,7 +140,7 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a filter.FilterByFootprintFilters( aComponent->GetFootprintFilters() ); if( aFilterType & FILTERING_BY_PIN_COUNT && aComponent ) - filter.FilterByPinCount( aComponent->GetNetCount() ); + filter.FilterByPinCount( aComponent->GetPinCount() ); if( aFilterType & FILTERING_BY_LIBRARY ) filter.FilterByLibrary( aLibName ); diff --git a/pcbnew/kicad_netlist_reader.cpp b/pcbnew/kicad_netlist_reader.cpp index 089b781483..6ff7f6beba 100644 --- a/pcbnew/kicad_netlist_reader.cpp +++ b/pcbnew/kicad_netlist_reader.cpp @@ -407,6 +407,7 @@ void KICAD_NETLIST_PARSER::parseLibPartList() wxString libPartName; wxArrayString footprintFilters; wxArrayString aliases; + int pinCount = 0; // The last token read was libpart, so read the next token while( (token = NextTok()) != T_RIGHT ) @@ -442,7 +443,6 @@ void KICAD_NETLIST_PARSER::parseLibPartList() footprintFilters.Add( FROM_UTF8( CurText() ) ); NeedRIGHT(); } - break; case T_aliases: @@ -459,6 +459,22 @@ void KICAD_NETLIST_PARSER::parseLibPartList() NeedRIGHT(); } break; + + case T_pins: + while( (token = NextTok()) != T_RIGHT ) + { + if( token == T_LEFT ) + token = NextTok(); + + if( token != T_pin ) + Expecting( T_pin ); + + pinCount++; + + skipCurrent(); + } + break; + default: // Skip not used data (i.e all other tokens) skipCurrent(); @@ -472,12 +488,18 @@ void KICAD_NETLIST_PARSER::parseLibPartList() component = m_netlist->GetComponent( i ); if( component->IsLibSource( libName, libPartName ) ) + { component->SetFootprintFilters( footprintFilters ); + component->SetPinCount( pinCount ); + } for( unsigned jj = 0; jj < aliases.GetCount(); jj++ ) { if( component->IsLibSource( libName, aliases[jj] ) ) + { component->SetFootprintFilters( footprintFilters ); + component->SetPinCount( pinCount ); + } } } diff --git a/pcbnew/pcb_netlist.h b/pcbnew/pcb_netlist.h index e6d4046853..efd589d6b2 100644 --- a/pcbnew/pcb_netlist.h +++ b/pcbnew/pcb_netlist.h @@ -84,6 +84,7 @@ class COMPONENT { COMPONENT_NETS m_nets; wxArrayString m_footprintFilters; ///< Footprint filters found in netlist. + int m_pinCount; ///< Number of pins found in netlist. wxString m_reference; ///< The component reference designator found in netlist. wxString m_value; ///< The component value found in netlist. @@ -121,6 +122,7 @@ public: m_fpid = aFPID; m_reference = aReference; m_value = aValue; + m_pinCount = 0; m_timeStamp = aTimeStamp; m_footprintChanged = false; } @@ -161,11 +163,11 @@ public: m_altFpid = aFPID; } - const LIB_ID& GetFPID() const { return m_fpid; } + const LIB_ID& GetFPID() const { return m_fpid; } const LIB_ID& GetAltFPID() const { return m_altFpid; } - const wxString& GetTimeStamp() const { return m_timeStamp; } + const wxString& GetTimeStamp() const { return m_timeStamp; } void SetFootprintFilters( const wxArrayString& aFilterList ) { @@ -174,6 +176,13 @@ public: const wxArrayString& GetFootprintFilters() const { return m_footprintFilters; } + void SetPinCount( int aPinCount ) + { + m_pinCount = aPinCount; + } + + int GetPinCount() const { return m_pinCount; } + MODULE* GetModule( bool aRelease = false ) { return ( aRelease ) ? m_footprint.release() : m_footprint.get();