pcbnew: Fix multiple issues with BOARD_CONNECTED_ITEM

Modules are not members of BOARD_CONNECTED_ITEM, so we cannot use this
as a proxy for membership in the connectivity or ratsnest calculations.

Fixes https://gitlab.com/kicad/code/kicad/issues/5140
This commit is contained in:
Seth Hillbrand 2020-08-10 12:52:36 -07:00
parent 00547b7aac
commit 0fd1214dea
3 changed files with 18 additions and 28 deletions

View File

@ -39,11 +39,6 @@
bool CN_CONNECTIVITY_ALGO::Remove( BOARD_ITEM* aItem ) bool CN_CONNECTIVITY_ALGO::Remove( BOARD_ITEM* aItem )
{ {
BOARD_CONNECTED_ITEM* citem = dyn_cast<BOARD_CONNECTED_ITEM*>( aItem );
if( !citem )
return false;
markItemNetAsDirty( aItem ); markItemNetAsDirty( aItem );
switch( aItem->Type() ) switch( aItem->Type() )
@ -51,35 +46,35 @@ bool CN_CONNECTIVITY_ALGO::Remove( BOARD_ITEM* aItem )
case PCB_MODULE_T: case PCB_MODULE_T:
for( auto pad : static_cast<MODULE*>( aItem ) -> Pads() ) for( auto pad : static_cast<MODULE*>( aItem ) -> Pads() )
{ {
m_itemMap[pad].MarkItemsAsInvalid(); m_itemMap[ static_cast<BOARD_CONNECTED_ITEM*>( pad ) ].MarkItemsAsInvalid();
m_itemMap.erase( pad ); m_itemMap.erase( static_cast<BOARD_CONNECTED_ITEM*>( pad ) );
} }
m_itemList.SetDirty( true ); m_itemList.SetDirty( true );
break; break;
case PCB_PAD_T: case PCB_PAD_T:
m_itemMap[citem].MarkItemsAsInvalid(); m_itemMap[ static_cast<BOARD_CONNECTED_ITEM*>( aItem ) ].MarkItemsAsInvalid();
m_itemMap.erase( citem ); m_itemMap.erase( static_cast<BOARD_CONNECTED_ITEM*>( aItem ) );
m_itemList.SetDirty( true ); m_itemList.SetDirty( true );
break; break;
case PCB_TRACE_T: case PCB_TRACE_T:
m_itemMap[citem].MarkItemsAsInvalid(); m_itemMap[ static_cast<BOARD_CONNECTED_ITEM*>( aItem ) ].MarkItemsAsInvalid();
m_itemMap.erase( citem ); m_itemMap.erase( static_cast<BOARD_CONNECTED_ITEM*>( aItem ) );
m_itemList.SetDirty( true ); m_itemList.SetDirty( true );
break; break;
case PCB_VIA_T: case PCB_VIA_T:
m_itemMap[citem].MarkItemsAsInvalid(); m_itemMap[ static_cast<BOARD_CONNECTED_ITEM*>( aItem ) ].MarkItemsAsInvalid();
m_itemMap.erase( citem ); m_itemMap.erase( static_cast<BOARD_CONNECTED_ITEM*>( aItem ) );
m_itemList.SetDirty( true ); m_itemList.SetDirty( true );
break; break;
case PCB_ZONE_AREA_T: case PCB_ZONE_AREA_T:
{ {
m_itemMap[citem].MarkItemsAsInvalid(); m_itemMap[ static_cast<BOARD_CONNECTED_ITEM*>( aItem ) ].MarkItemsAsInvalid();
m_itemMap.erase ( citem ); m_itemMap.erase ( static_cast<BOARD_CONNECTED_ITEM*>( aItem ) );
m_itemList.SetDirty( true ); m_itemList.SetDirty( true );
break; break;
} }

View File

@ -666,11 +666,6 @@ const std::vector<CN_EDGE> CONNECTIVITY_DATA::GetRatsnestForItems( std::vector<B
for( auto item : aItems ) for( auto item : aItems )
{ {
BOARD_CONNECTED_ITEM* conn_item = dyn_cast<BOARD_CONNECTED_ITEM*>( item );
if( !conn_item )
continue;
if( item->Type() == PCB_MODULE_T ) if( item->Type() == PCB_MODULE_T )
{ {
auto component = static_cast<MODULE*>( item ); auto component = static_cast<MODULE*>( item );
@ -681,8 +676,9 @@ const std::vector<CN_EDGE> CONNECTIVITY_DATA::GetRatsnestForItems( std::vector<B
item_set.insert( pad ); item_set.insert( pad );
} }
} }
else else if( auto conn_item = dyn_cast<BOARD_CONNECTED_ITEM*>( item ) )
{ {
item_set.insert( conn_item );
nets.insert( conn_item->GetNetCode() ); nets.insert( conn_item->GetNetCode() );
} }
} }

View File

@ -1272,13 +1272,7 @@ void PCB_EDITOR_CONTROL::calculateSelectionRatsnest()
for( auto item : selection ) for( auto item : selection )
{ {
auto board_item = static_cast<BOARD_CONNECTED_ITEM*>( item ); if( item->Type() == PCB_MODULE_T )
if( board_item->Type() != PCB_MODULE_T && board_item->GetLocalRatsnestVisible() )
{
items.push_back( board_item );
}
else if( board_item->Type() == PCB_MODULE_T )
{ {
for( auto pad : static_cast<MODULE*>( item )->Pads() ) for( auto pad : static_cast<MODULE*>( item )->Pads() )
{ {
@ -1286,6 +1280,11 @@ void PCB_EDITOR_CONTROL::calculateSelectionRatsnest()
items.push_back( pad ); items.push_back( pad );
} }
} }
else if( BOARD_CONNECTED_ITEM* boardItem = dyn_cast<BOARD_CONNECTED_ITEM*>( item ) )
{
if( boardItem->GetLocalRatsnestVisible() )
items.push_back( boardItem );
}
} }
connectivity->ComputeDynamicRatsnest( items ); connectivity->ComputeDynamicRatsnest( items );