Count pins instead of using netcount as a proxy.

Fixes: lp:1703155
* https://bugs.launchpad.net/kicad/+bug/1703155
This commit is contained in:
Jeff Young 2018-03-26 19:55:59 +01:00
parent ca4e4aead4
commit 778a3a4777
4 changed files with 36 additions and 5 deletions

View File

@ -676,7 +676,7 @@ void CVPCB_MAINFRAME::DisplayStatus()
msg.Empty(); msg.Empty();
if( component ) if( component )
msg = wxString::Format( wxT( "%i" ), component->GetNetCount() ); msg = wxString::Format( wxT( "%i" ), component->GetPinCount() );
if( !filters.IsEmpty() ) if( !filters.IsEmpty() )
filters += wxT( ", " ); filters += wxT( ", " );

View File

@ -140,7 +140,7 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a
filter.FilterByFootprintFilters( aComponent->GetFootprintFilters() ); filter.FilterByFootprintFilters( aComponent->GetFootprintFilters() );
if( aFilterType & FILTERING_BY_PIN_COUNT && aComponent ) if( aFilterType & FILTERING_BY_PIN_COUNT && aComponent )
filter.FilterByPinCount( aComponent->GetNetCount() ); filter.FilterByPinCount( aComponent->GetPinCount() );
if( aFilterType & FILTERING_BY_LIBRARY ) if( aFilterType & FILTERING_BY_LIBRARY )
filter.FilterByLibrary( aLibName ); filter.FilterByLibrary( aLibName );

View File

@ -407,6 +407,7 @@ void KICAD_NETLIST_PARSER::parseLibPartList()
wxString libPartName; wxString libPartName;
wxArrayString footprintFilters; wxArrayString footprintFilters;
wxArrayString aliases; wxArrayString aliases;
int pinCount = 0;
// The last token read was libpart, so read the next token // The last token read was libpart, so read the next token
while( (token = NextTok()) != T_RIGHT ) while( (token = NextTok()) != T_RIGHT )
@ -442,7 +443,6 @@ void KICAD_NETLIST_PARSER::parseLibPartList()
footprintFilters.Add( FROM_UTF8( CurText() ) ); footprintFilters.Add( FROM_UTF8( CurText() ) );
NeedRIGHT(); NeedRIGHT();
} }
break; break;
case T_aliases: case T_aliases:
@ -459,6 +459,22 @@ void KICAD_NETLIST_PARSER::parseLibPartList()
NeedRIGHT(); NeedRIGHT();
} }
break; 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: default:
// Skip not used data (i.e all other tokens) // Skip not used data (i.e all other tokens)
skipCurrent(); skipCurrent();
@ -472,12 +488,18 @@ void KICAD_NETLIST_PARSER::parseLibPartList()
component = m_netlist->GetComponent( i ); component = m_netlist->GetComponent( i );
if( component->IsLibSource( libName, libPartName ) ) if( component->IsLibSource( libName, libPartName ) )
{
component->SetFootprintFilters( footprintFilters ); component->SetFootprintFilters( footprintFilters );
component->SetPinCount( pinCount );
}
for( unsigned jj = 0; jj < aliases.GetCount(); jj++ ) for( unsigned jj = 0; jj < aliases.GetCount(); jj++ )
{ {
if( component->IsLibSource( libName, aliases[jj] ) ) if( component->IsLibSource( libName, aliases[jj] ) )
{
component->SetFootprintFilters( footprintFilters ); component->SetFootprintFilters( footprintFilters );
component->SetPinCount( pinCount );
}
} }
} }

View File

@ -84,6 +84,7 @@ class COMPONENT
{ {
COMPONENT_NETS m_nets; COMPONENT_NETS m_nets;
wxArrayString m_footprintFilters; ///< Footprint filters found in netlist. 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_reference; ///< The component reference designator found in netlist.
wxString m_value; ///< The component value found in netlist. wxString m_value; ///< The component value found in netlist.
@ -121,6 +122,7 @@ public:
m_fpid = aFPID; m_fpid = aFPID;
m_reference = aReference; m_reference = aReference;
m_value = aValue; m_value = aValue;
m_pinCount = 0;
m_timeStamp = aTimeStamp; m_timeStamp = aTimeStamp;
m_footprintChanged = false; m_footprintChanged = false;
} }
@ -174,6 +176,13 @@ public:
const wxArrayString& GetFootprintFilters() const { return m_footprintFilters; } 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 ) MODULE* GetModule( bool aRelease = false )
{ {
return ( aRelease ) ? m_footprint.release() : m_footprint.get(); return ( aRelease ) ? m_footprint.release() : m_footprint.get();