From 328d3d0d77e7859a0a9a5cf66791df03448f6ee3 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sat, 23 Oct 2021 22:46:31 -0400 Subject: [PATCH] PNS: Fix rule resolution when starting from PTH Have to use the routing start layer, not the first layer of the PTH, to get the appropriate sizes --- pcbnew/router/pns_kicad_iface.cpp | 16 ++++++++++------ pcbnew/router/pns_kicad_iface.h | 4 ++++ pcbnew/router/router_tool.cpp | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index b18b9286ef..6c8941e587 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -450,6 +450,9 @@ bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM* BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings(); PNS::CONSTRAINT constraint; + if( aStartItem && m_startLayer < 0 ) + m_startLayer = aStartItem->Layer(); + aSizes.SetMinClearance( bds.m_MinClearance ); int trackWidth = bds.m_TrackMinWidth; @@ -466,7 +469,7 @@ bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM* if( !found && bds.UseNetClassTrack() && aStartItem ) { if( m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_WIDTH, aStartItem, nullptr, - aStartItem->Layer(), &constraint ) ) + m_startLayer, &constraint ) ) { trackWidth = std::max( trackWidth, constraint.m_Value.Opt() ); found = true; @@ -499,13 +502,13 @@ bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM* if( bds.UseNetClassVia() && aStartItem ) // netclass value { if( m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_VIA_DIAMETER, aStartItem, - nullptr, aStartItem->Layer(), &constraint ) ) + nullptr, m_startLayer, &constraint ) ) { viaDiameter = std::max( viaDiameter, constraint.m_Value.Opt() ); } - if( m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_VIA_HOLE, aStartItem, - nullptr, aStartItem->Layer(), &constraint ) ) + if( m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_VIA_HOLE, aStartItem, nullptr, + m_startLayer, &constraint ) ) { viaDrill = std::max( viaDrill, constraint.m_Value.Opt() ); } @@ -533,13 +536,13 @@ bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM* if( bds.UseNetClassDiffPair() && aStartItem ) { if( !found && m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_WIDTH, aStartItem, - nullptr, aStartItem->Layer(), &constraint ) ) + nullptr, m_startLayer, &constraint ) ) { diffPairWidth = std::max( diffPairWidth, constraint.m_Value.Opt() ); } if( m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_GAP, aStartItem, - nullptr, aStartItem->Layer(), &constraint ) ) + nullptr, m_startLayer, &constraint ) ) { diffPairGap = std::max( diffPairGap, constraint.m_Value.Opt() ); diffPairViaGap = std::max( diffPairViaGap, constraint.m_Value.Opt() ); @@ -833,6 +836,7 @@ PNS_KICAD_IFACE_BASE::PNS_KICAD_IFACE_BASE() m_board = nullptr; m_world = nullptr; m_debugDecorator = nullptr; + m_startLayer = -1; } diff --git a/pcbnew/router/pns_kicad_iface.h b/pcbnew/router/pns_kicad_iface.h index fe9e24a6c3..51d5cc36ea 100644 --- a/pcbnew/router/pns_kicad_iface.h +++ b/pcbnew/router/pns_kicad_iface.h @@ -72,6 +72,8 @@ public: void SetDebugDecorator( PNS::DEBUG_DECORATOR* aDec ); + void SetStartLayer( int aLayer ) { m_startLayer = aLayer; } + virtual PNS::NODE* GetWorld() const override { return m_world; @@ -101,6 +103,7 @@ protected: protected: PNS::NODE* m_world; BOARD* m_board; + int m_startLayer; }; class PNS_KICAD_IFACE : public PNS_KICAD_IFACE_BASE @@ -127,6 +130,7 @@ public: void UpdateNet( int aNetCode ) override; + private: struct OFFSET { diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index b2d0f6e704..975476ed89 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -1014,6 +1014,7 @@ bool ROUTER_TOOL::prepareInteractive() PNS::SIZES_SETTINGS sizes( m_router->Sizes() ); + m_iface->SetStartLayer( routingLayer ); m_iface->ImportSizes( sizes, m_startItem, -1 ); sizes.AddLayerPair( frame()->GetScreen()->m_Route_Layer_TOP, frame()->GetScreen()->m_Route_Layer_BOTTOM );