diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 90d8ad7b20..896e44b8f6 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -880,7 +880,8 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem ) } } - m_ratsnest->GetNets()[zone->GetNet()].RemoveItem( zone ); + if( zone->GetNet() > 0 ) + m_ratsnest->GetNet( zone->GetNet() ).RemoveItem( zone ); } break; @@ -890,7 +891,10 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem ) m_Modules.Remove( (MODULE*) aBoardItem ); for( D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() ) - m_ratsnest->GetNets()[pad->GetNet()].RemoveItem( pad ); + { + if( pad->GetNet() > 0 ) + m_ratsnest->GetNet( pad->GetNet() ).RemoveItem( pad ); + } } break; @@ -898,7 +902,9 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem ) { TRACK* track = static_cast( aBoardItem ); m_Track.Remove( track ); - m_ratsnest->GetNets()[track->GetNet()].RemoveItem( track ); + + if( track->GetNet() > 0 ) + m_ratsnest->GetNet( track->GetNet() ).RemoveItem( track ); } break; @@ -906,7 +912,9 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem ) { SEGVIA* via = static_cast( aBoardItem ); m_Track.Remove( via ); - m_ratsnest->GetNets()[via->GetNet()].RemoveItem( via ); + + if( via->GetNet() > 0 ) + m_ratsnest->GetNet( via->GetNet() ).RemoveItem( via ); } break; diff --git a/pcbnew/ratsnest_data.h b/pcbnew/ratsnest_data.h index 860fffa5fa..4340c74e78 100644 --- a/pcbnew/ratsnest_data.h +++ b/pcbnew/ratsnest_data.h @@ -573,13 +573,26 @@ public: void Recalculate( int aNet = -1 ); /** - * Function GetNets() - * Returns ratsnest grouped by net numbers. - * @return Vector of ratsnest grouped by net numbers. + * Function GetNetCount() + * Returns the number of nets handled by the ratsnest. + * @return Number of the nets. */ - std::vector& GetNets() + int GetNetCount() const { - return m_nets; + return m_nets.size(); + } + + /** + * Function GetNet() + * Returns ratsnest grouped by net numbers. + * @param aNetCode is the net code. + * @return Ratsnest data for a specified net. + */ + RN_NET& GetNet( int aNetCode ) + { + assert( aNetCode > 0 ); // ratsnest does not handle the unconnected net + + return m_nets[aNetCode]; } protected: diff --git a/pcbnew/ratsnest_viewitem.cpp b/pcbnew/ratsnest_viewitem.cpp index 634a0d57c9..0e23b00306 100644 --- a/pcbnew/ratsnest_viewitem.cpp +++ b/pcbnew/ratsnest_viewitem.cpp @@ -59,9 +59,11 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, GAL* aGal ) const aGal->SetLineWidth( 1.0 ); aGal->SetStrokeColor( COLOR4D( 0.8, 0.8, 0.8, 0.2 ) ); - // Draw the temporary ratsnest - BOOST_FOREACH( const RN_NET& net, m_data->GetNets() ) + // Draw the temporary ratsnest (skip the unconnected net [net code == 0]) + for( int i = 1; i < m_data->GetNetCount(); ++i ) { + const RN_NET& net = m_data->GetNet( i ); + if( !net.IsVisible() ) continue;