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.
This commit is contained in:
Maciej Suminski 2014-01-29 15:24:19 +01:00
parent b52e5fabda
commit af350eb1e6
3 changed files with 34 additions and 11 deletions

View File

@ -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;

View File

@ -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<RN_NET>& 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:

View File

@ -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;