From fac48ddafb0aaa8d7a24f463f28bab5fbfbd123c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 28 Sep 2021 10:41:39 +0100 Subject: [PATCH] Don't include stale nets in net counts. Fixes bug reported by Franck. --- pcbnew/board.cpp | 55 +++++++++++++++-------------------- pcbnew/board.h | 5 ---- pcbnew/pcb_draw_panel_gal.cpp | 46 ++++++++++++++++------------- 3 files changed, 49 insertions(+), 57 deletions(-) diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 783c8384f7..7dbc1aeab4 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -1165,35 +1165,39 @@ EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const void BOARD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { - wxString txt; - int viasCount = 0; - int trackSegmentsCount = 0; + int padCount = 0; + int viaCount = 0; + int trackSegmentCount = 0; + std::set netCodes; + int unconnected = GetConnectivity()->GetUnconnectedCount(); for( PCB_TRACK* item : m_tracks ) { if( item->Type() == PCB_VIA_T ) - viasCount++; + viaCount++; else - trackSegmentsCount++; + trackSegmentCount++; + + if( item->GetNetCode() > 0 ) + netCodes.insert( item->GetNetCode() ); } - txt.Printf( wxT( "%d" ), GetPadCount() ); - aList.emplace_back( _( "Pads" ), txt ); + for( FOOTPRINT* footprint : Footprints() ) + { + for( PAD* pad : footprint->Pads() ) + { + padCount++; - txt.Printf( wxT( "%d" ), viasCount ); - aList.emplace_back( _( "Vias" ), txt ); + if( pad->GetNetCode() > 0 ) + netCodes.insert( pad->GetNetCode() ); + } + } - txt.Printf( wxT( "%d" ), trackSegmentsCount ); - aList.emplace_back( _( "Track Segments" ), txt ); - - txt.Printf( wxT( "%d" ), GetNodesCount() ); - aList.emplace_back( _( "Nodes" ), txt ); - - txt.Printf( wxT( "%d" ), m_NetInfo.GetNetCount() - 1 /* Don't include "No Net" in count */ ); - aList.emplace_back( _( "Nets" ), txt ); - - txt.Printf( wxT( "%d" ), GetConnectivity()->GetUnconnectedCount() ); - aList.emplace_back( _( "Unrouted" ), txt ); + aList.emplace_back( _( "Pads" ), wxString::Format( "%d", padCount ) ); + aList.emplace_back( _( "Vias" ), wxString::Format( "%d", viaCount ) ); + aList.emplace_back( _( "Track Segments" ), wxString::Format( "%d", trackSegmentCount ) ); + aList.emplace_back( _( "Nets" ), wxString::Format( "%d", (int) netCodes.size() ) ); + aList.emplace_back( _( "Unrouted" ), wxString::Format( "%d", unconnected ) ); } @@ -1925,17 +1929,6 @@ const std::vector BOARD::GetPads() const } -unsigned BOARD::GetPadCount() const -{ - unsigned retval = 0; - - for( FOOTPRINT* footprint : Footprints() ) - retval += footprint->Pads().size(); - - return retval; -} - - const std::vector BOARD::AllConnectedItems() { std::vector items; diff --git a/pcbnew/board.h b/pcbnew/board.h index bcc4389fca..bdfb28f44f 100644 --- a/pcbnew/board.h +++ b/pcbnew/board.h @@ -645,11 +645,6 @@ public: */ unsigned GetUnconnectedNetCount() const; - /** - * @return the number of pads in board. - */ - unsigned GetPadCount() const; - /** * Return a reference to a list of all the pads. * diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index 6990f5ffb9..e1d9d44cf6 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -442,36 +442,40 @@ void PCB_DRAW_PANEL_GAL::SyncLayersVisibility( const BOARD* aBoard ) void PCB_DRAW_PANEL_GAL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { - BOARD* board = static_cast( GetParentEDAFrame() )->GetBoard(); - wxString txt; - int viasCount = 0; - int trackSegmentsCount = 0; + BOARD* board = static_cast( GetParentEDAFrame() )->GetBoard(); + int padCount = 0; + int viaCount = 0; + int trackSegmentCount = 0; + std::set netCodes; + int unconnected = board->GetConnectivity()->GetUnconnectedCount(); for( PCB_TRACK* item : board->Tracks() ) { if( item->Type() == PCB_VIA_T ) - viasCount++; + viaCount++; else - trackSegmentsCount++; + trackSegmentCount++; + + if( item->GetNetCode() > 0 ) + netCodes.insert( item->GetNetCode() ); } - txt.Printf( wxT( "%d" ), board->GetPadCount() ); - aList.emplace_back( _( "Pads" ), txt ); + for( FOOTPRINT* footprint : board->Footprints() ) + { + for( PAD* pad : footprint->Pads() ) + { + padCount++; - txt.Printf( wxT( "%d" ), viasCount ); - aList.emplace_back( _( "Vias" ), txt ); + if( pad->GetNetCode() > 0 ) + netCodes.insert( pad->GetNetCode() ); + } + } - txt.Printf( wxT( "%d" ), trackSegmentsCount ); - aList.emplace_back( _( "Track Segments" ), txt ); - - txt.Printf( wxT( "%d" ), board->GetNodesCount() ); - aList.emplace_back( _( "Nodes" ), txt ); - - txt.Printf( wxT( "%d" ), board->GetNetCount() - 1 /* don't include "No Net" in count */ ); - aList.emplace_back( _( "Nets" ), txt ); - - txt.Printf( wxT( "%d" ), board->GetConnectivity()->GetUnconnectedCount() ); - aList.emplace_back( _( "Unrouted" ), txt ); + aList.emplace_back( _( "Pads" ), wxString::Format( "%d", padCount ) ); + aList.emplace_back( _( "Vias" ), wxString::Format( "%d", viaCount ) ); + aList.emplace_back( _( "Track Segments" ), wxString::Format( "%d", trackSegmentCount ) ); + aList.emplace_back( _( "Nets" ), wxString::Format( "%d", (int) netCodes.size() ) ); + aList.emplace_back( _( "Unrouted" ), wxString::Format( "%d", unconnected ) ); }