repeat layout: fixup net names of copied vias

When replicating a layout with the multichannel tool
the net names of vias are now updated to reflect the
potentially different connections in the target area.

Fixes https://gitlab.com/kicad/code/kicad/issues/20334

(cherry picked from commit 4bc099429c)
This commit is contained in:
Alexander Boehm
2025-04-23 17:10:36 -04:00
committed by Wayne Stambaugh
parent aa69aa63be
commit a12bcbb6ea
2 changed files with 15 additions and 11 deletions
+13 -9
View File
@@ -745,6 +745,11 @@ bool MULTICHANNEL_TOOL::copyRuleAreaContents( TMATCH::COMPONENT_MATCHES& aMatche
BOARD_ITEM* copied = static_cast<BOARD_ITEM*>( item->Clone() );
if( item->Type() == PCB_VIA_T )
{
fixupNet( static_cast<BOARD_CONNECTED_ITEM*>( item ), static_cast<BOARD_CONNECTED_ITEM*>( copied ),
aMatches );
}
copied->Move( disp );
copied->SetParentGroup( nullptr );
aGroupableItems.insert( copied );
@@ -848,7 +853,7 @@ bool MULTICHANNEL_TOOL::copyRuleAreaContents( TMATCH::COMPONENT_MATCHES& aMatche
continue;
ZONE* targetZone = static_cast<ZONE*>( item->Clone() );
fixupZoneNets( zone, targetZone, aMatches );
fixupNet( zone, targetZone, aMatches );
copied = targetZone;
}
@@ -924,19 +929,18 @@ bool MULTICHANNEL_TOOL::copyRuleAreaContents( TMATCH::COMPONENT_MATCHES& aMatche
return true;
}
/**
* @brief Attempts to modify the assigned net of a copied zone
* @brief Attempts to modify the assigned net of copied items, especially intended for zones and vias
*
*/
void MULTICHANNEL_TOOL::fixupZoneNets( ZONE* aRefZone, ZONE* aTargetZone,
TMATCH::COMPONENT_MATCHES& aComponentMatches )
void MULTICHANNEL_TOOL::fixupNet( BOARD_CONNECTED_ITEM* aRef, BOARD_CONNECTED_ITEM* aTarget,
TMATCH::COMPONENT_MATCHES& aComponentMatches )
{
auto connectivity = board()->GetConnectivity();
const std::vector<BOARD_CONNECTED_ITEM*> refZoneConnectedPads =
connectivity->GetNetItems( aRefZone->GetNetCode(), { PCB_PAD_T } );
const std::vector<BOARD_CONNECTED_ITEM*> refConnectedPads =
connectivity->GetNetItems( aRef->GetNetCode(), { PCB_PAD_T } );
for( const BOARD_CONNECTED_ITEM* refConItem : refZoneConnectedPads )
for( const BOARD_CONNECTED_ITEM* refConItem : refConnectedPads )
{
if( refConItem->Type() != PCB_PAD_T )
continue;
@@ -952,7 +956,7 @@ void MULTICHANNEL_TOOL::fixupZoneNets( ZONE* aRefZone, ZONE* aTargetZone,
if( !targetFpPads.empty() )
{
int targetNetCode = targetFpPads[0]->GetNet()->GetNetCode();
aTargetZone->SetNetCode( targetNetCode );
aTarget->SetNetCode( targetNetCode );
break;
}
+2 -2
View File
@@ -145,8 +145,8 @@ private:
std::shared_ptr<CONNECTIVITY_DATA> aConnectivity,
const SHAPE_POLY_SET& aRAPoly, RULE_AREA* aRA, FOOTPRINT* aFp,
const REPEAT_LAYOUT_OPTIONS& aOpts ) const;
void fixupZoneNets( ZONE* aRefZone, ZONE* aTargetZone,
TMATCH::COMPONENT_MATCHES& aComponentMatches );
void fixupNet( BOARD_CONNECTED_ITEM* aRef, BOARD_CONNECTED_ITEM* aTarget,
TMATCH::COMPONENT_MATCHES& aComponentMatches );
bool pruneExistingGroups( COMMIT& aCommit, const std::unordered_set<BOARD_ITEM*>& aItemsToCheck );