From 39ac5e0af82faf35c7cecd3782fbc70f429ea46e Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 3 Jun 2018 22:55:03 -0700 Subject: [PATCH] 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. --- pcbnew/class_board.cpp | 6 ++++-- pcbnew/class_board.h | 3 ++- pcbnew/dialogs/dialog_select_net_from_list.cpp | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index af2bab6877..ad1a945335 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -1019,14 +1019,16 @@ 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; diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 95a2a223b1..1ca95a6345 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -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 diff --git a/pcbnew/dialogs/dialog_select_net_from_list.cpp b/pcbnew/dialogs/dialog_select_net_from_list.cpp index 46c4f5a923..6ec6cde44e 100644 --- a/pcbnew/dialogs/dialog_select_net_from_list.cpp +++ b/pcbnew/dialogs/dialog_select_net_from_list.cpp @@ -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