Commit af350eb1 authored by Maciej Suminski's avatar Maciej Suminski

RN_DATA::GetNets() -> RN_DATA::GetNet() with an assert to check if someone...

RN_DATA::GetNets() -> RN_DATA::GetNet() with an assert to check if someone calls it for the unconnected net.
Only items that belong to a net are removed from ratsnest.
parent b52e5fab
......@@ -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<TRACK*>( 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<SEGVIA*>( aBoardItem );
m_Track.Remove( via );
m_ratsnest->GetNets()[via->GetNet()].RemoveItem( via );
if( via->GetNet() > 0 )
m_ratsnest->GetNet( via->GetNet() ).RemoveItem( via );
}
break;
......
......@@ -573,13 +573,26 @@ public:
void Recalculate( int aNet = -1 );
/**
* Function GetNets()
* Function GetNetCount()
* Returns the number of nets handled by the ratsnest.
* @return Number of the nets.
*/
int GetNetCount() const
{
return m_nets.size();
}
/**
* Function GetNet()
* Returns ratsnest grouped by net numbers.
* @return Vector of ratsnest grouped by net numbers.
* @param aNetCode is the net code.
* @return Ratsnest data for a specified net.
*/
std::vector<RN_NET>& GetNets()
RN_NET& GetNet( int aNetCode )
{
return m_nets;
assert( aNetCode > 0 ); // ratsnest does not handle the unconnected net
return m_nets[aNetCode];
}
protected:
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment