Pcbnew: List nets fix calculation speed

Similar to 6e5726613, we need to find net node count quickly without
iterating over all items in the board.
This commit is contained in:
Seth Hillbrand 2018-06-03 22:55:03 -07:00
parent 7343e78347
commit 39ac5e0af8
3 changed files with 9 additions and 6 deletions

View File

@ -1019,15 +1019,17 @@ int BOARD::GetNumSegmZone() const
}
unsigned BOARD::GetNodesCount()
unsigned BOARD::GetNodesCount( int aNet )
{
unsigned retval = 0;
for( auto mod : Modules() )
{
for( auto pad : mod->Pads() )
if( pad->GetNetCode() > 0 )
{
if( ( aNet == -1 && pad->GetNetCode() > 0 ) || aNet == pad->GetNetCode() )
retval++;
}
}
return retval;
}

View File

@ -689,9 +689,10 @@ public:
/**
* Function GetNodesCount
* @param aNet Only count nodes belonging to this net
* @return the number of pads members of nets (i.e. with netcode > 0)
*/
unsigned GetNodesCount();
unsigned GetNodesCount( int aNet = -1 );
/**
* Function GetUnconnectedNetCount

View File

@ -136,9 +136,9 @@ void DIALOG_SELECT_NET_FROM_LIST::buildNetsList()
continue;
}
unsigned nPads = m_brd->GetConnectivity()->GetPadCount( netcode );
unsigned nodes = m_brd->GetNodesCount( netcode );
if( !m_cbShowZeroPad->IsChecked() && nPads == 0 )
if( !m_cbShowZeroPad->IsChecked() && nodes == 0 )
continue;
if( m_netsListGrid->GetNumberRows() <= row_idx )
@ -151,7 +151,7 @@ void DIALOG_SELECT_NET_FROM_LIST::buildNetsList()
if( netcode )
{
txt.Printf( wxT( "%u" ), nPads );
txt.Printf( wxT( "%u" ), nodes );
m_netsListGrid->SetCellValue( row_idx, COL_NETINFO, txt );
}
else // For the net 0 (unconnected pads), the pad count is not known