From 47547713de643fa1724b3cae5b46a663f769f9ec Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 6 Oct 2022 15:49:58 +0100 Subject: [PATCH] Broaden reset-sizes-after-layer-switch algorithm. Fixes https://gitlab.com/kicad/code/kicad/issues/12576 (cherry picked from commit 40ad5b6de3f809d508794e8ba7ae6e44c2ef5610) --- pcbnew/router/router_tool.cpp | 11 ++++++++--- pcbnew/router/router_tool.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index ba96d42164..c0b22ade8b 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -618,10 +618,13 @@ void ROUTER_TOOL::switchLayerOnViaPlacement() m_router->SwitchLayer( *newLayer ); m_lastTargetLayer = *newLayer; - // NB: track and diff-pair values may have changed if layer-specific rules are in play + updateSizesAfterLayerSwitch( ToLAYER_ID( *newLayer ) ); +} - PCB_LAYER_ID targetLayer = ToLAYER_ID( *newLayer ); - std::vector nets = m_router->GetCurrentNets(); + +void ROUTER_TOOL::updateSizesAfterLayerSwitch( PCB_LAYER_ID targetLayer ) +{ + std::vector nets = m_router->GetCurrentNets(); PNS::SIZES_SETTINGS sizes = m_router->Sizes(); BOARD_DESIGN_SETTINGS& bds = board()->GetDesignSettings(); @@ -829,6 +832,7 @@ int ROUTER_TOOL::handleLayerSwitch( const TOOL_EVENT& aEvent, bool aForceVia ) if( !aForceVia && m_router && m_router->SwitchLayer( targetLayer ) ) { + updateSizesAfterLayerSwitch( targetLayer ); updateEndItem( aEvent ); m_router->Move( m_endSnapPoint, m_endItem ); // refresh return 0; @@ -1511,6 +1515,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent ) else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) ) { m_router->SwitchLayer( frame->GetActiveLayer() ); + updateSizesAfterLayerSwitch( frame->GetActiveLayer() ); updateStartItem( *evt ); } else if( evt->IsKeyPressed() ) diff --git a/pcbnew/router/router_tool.h b/pcbnew/router/router_tool.h index c0dd04719e..1111c08446 100644 --- a/pcbnew/router/router_tool.h +++ b/pcbnew/router/router_tool.h @@ -75,6 +75,7 @@ private: int getStartLayer( const PNS::ITEM* aItem ); void switchLayerOnViaPlacement(); + void updateSizesAfterLayerSwitch( PCB_LAYER_ID targetLayer ); int onLayerCommand( const TOOL_EVENT& aEvent ); int onViaCommand( const TOOL_EVENT& aEvent );