Improved ratsnest updating in GAL.

This commit is contained in:
Maciej Suminski 2014-06-03 16:08:23 +02:00
parent 2af3e5f6e9
commit 79631def2c
3 changed files with 54 additions and 15 deletions

View File

@ -34,6 +34,8 @@
#include <class_board.h>
#include <class_board_item.h>
#include <ratsnest_data.h>
BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ) :
BOARD_ITEM( aParent, idtype ), m_netinfo( &NETINFO_LIST::ORPHANED ),
m_Subnet( 0 ), m_ZoneSubnet( 0 )
@ -53,18 +55,29 @@ BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( const BOARD_CONNECTED_ITEM& aItem )
void BOARD_CONNECTED_ITEM::SetNetCode( int aNetCode )
{
BOARD* board = GetBoard();
NETINFO_ITEM* oldNetInfo = m_netinfo;
NETINFO_ITEM* newNetInfo;
if( board )
{
m_netinfo = board->FindNet( aNetCode );
newNetInfo = board->FindNet( aNetCode );
// The requested net does not exist, mark it as unconnected
if( m_netinfo == NULL )
m_netinfo = board->FindNet( NETINFO_LIST::UNCONNECTED );
if( newNetInfo == NULL )
newNetInfo = board->FindNet( NETINFO_LIST::UNCONNECTED );
}
else
{
// There is no board that contains list of nets, the item is orphaned
m_netinfo = &NETINFO_LIST::ORPHANED;
newNetInfo = &NETINFO_LIST::ORPHANED;
}
// Update ratsnest, if necessary
if( oldNetInfo != newNetInfo && board )
{
board->GetRatsnest()->Remove( this );
m_netinfo = newNetInfo;
board->GetRatsnest()->Add( this );
}
}

View File

@ -44,6 +44,7 @@
#include <class_board.h>
#include <class_module.h>
#include <ratsnest_data.h>
#include <pcbnew.h>
#include <io_mgr.h>
@ -121,7 +122,7 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
{
module->RunOnChildren( boost::bind( &KIGFX::VIEW::Add, view, _1 ) );
GetGalCanvas()->GetView()->Add( module );
view->Add( module );
}
if( aDeleteUnconnectedTracks && GetBoard()->m_Track )
@ -131,7 +132,11 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
}
// Rebuild the board connectivity:
Compile_Ratsnest( NULL, true );
if( IsGalCanvasActive() )
GetBoard()->GetRatsnest()->Recalculate();
else
Compile_Ratsnest( NULL, true );
SetMsgPanel( GetBoard() );
m_canvas->Refresh();
}

View File

@ -841,8 +841,7 @@ void RN_DATA::Add( const BOARD_ITEM* aItem )
if( net < 1 ) // do not process unconnected items
return;
// Autoresize
if( net >= (int) m_nets.size() )
if( net >= (int) m_nets.size() ) // Autoresize
m_nets.resize( net + 1 );
}
else if( aItem->Type() == PCB_MODULE_T )
@ -851,11 +850,11 @@ void RN_DATA::Add( const BOARD_ITEM* aItem )
for( const D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
{
net = pad->GetNetCode();
if( net < 1 ) // do not process unconnected items
continue;
// Autoresize
if( net >= (int) m_nets.size() )
if( net >= (int) m_nets.size() ) // Autoresize
m_nets.resize( net + 1 );
m_nets[net].AddItem( pad );
@ -897,8 +896,19 @@ void RN_DATA::Remove( const BOARD_ITEM* aItem )
if( aItem->IsConnected() )
{
net = static_cast<const BOARD_CONNECTED_ITEM*>( aItem )->GetNetCode();
if( net < 1 ) // do not process unconnected items
return;
#ifdef NDEBUG
if( net >= (int) m_nets.size() ) // Autoresize
{
m_nets.resize( net + 1 );
return; // if it was resized, then surely the item had not been added before
}
#endif
assert( net < (int) m_nets.size() );
}
else if( aItem->Type() == PCB_MODULE_T )
{
@ -906,9 +916,20 @@ void RN_DATA::Remove( const BOARD_ITEM* aItem )
for( const D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
{
net = pad->GetNetCode();
if( net < 1 ) // do not process unconnected items
continue;
#ifdef NDEBUG
if( net >= (int) m_nets.size() ) // Autoresize
{
m_nets.resize( net + 1 );
return; // if it was resized, then surely the item had not been added before
}
#endif
assert( net < (int) m_nets.size() );
m_nets[net].RemoveItem( pad );
}
@ -993,14 +1014,14 @@ void RN_DATA::ProcessBoard()
void RN_DATA::Recalculate( int aNet )
{
if( m_board->GetNetCount() > m_nets.size() )
m_nets.resize( m_board->GetNetCount() );
unsigned int netCount = m_board->GetNetCount();
if( netCount > m_nets.size() )
m_nets.resize( netCount );
if( aNet < 0 ) // Recompute everything
{
unsigned int i, netCount;
netCount = m_board->GetNetCount();
unsigned int i;
#ifdef USE_OPENMP
#pragma omp parallel shared(netCount) private(i)
{