From 6cbc3fb97d1f3295bce4910218da12c947996b1b Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Mon, 29 Mar 2021 19:41:17 -0400 Subject: [PATCH] Fix a minor inconsistency between router and DRC Also make sure collision highlighting runs at the starting location of a drag. See: https://gitlab.com/kicad/code/kicad/-/issues/7672 --- pcbnew/router/pns_kicad_iface.cpp | 13 +++++++++---- pcbnew/router/router_tool.cpp | 3 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index a2a4a59399..b18430a740 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -91,6 +91,7 @@ private: TRACK m_dummyTrack; ARC m_dummyArc; VIA m_dummyVia; + int m_clearanceEpsilon; std::map, int> m_clearanceCache; std::map, int> m_holeClearanceCache; @@ -106,6 +107,10 @@ PNS_PCBNEW_RULE_RESOLVER::PNS_PCBNEW_RULE_RESOLVER( BOARD* aBoard, m_dummyArc( aBoard ), m_dummyVia( aBoard ) { + if( aBoard ) + m_clearanceEpsilon = aBoard->GetDesignSettings().GetDRCEpsilon(); + else + m_clearanceEpsilon = 0; } @@ -291,7 +296,7 @@ int PNS_PCBNEW_RULE_RESOLVER::Clearance( const PNS::ITEM* aA, const PNS::ITEM* a if( isCopper( aA ) && ( !aB || isCopper( aB ) ) ) { if( QueryConstraint( PNS::CONSTRAINT_TYPE::CT_CLEARANCE, aA, aB, layer, &constraint ) ) - rv = constraint.m_Value.Min(); + rv = constraint.m_Value.Min() - m_clearanceEpsilon; } if( isEdge( aA ) || ( aB && isEdge( aB ) ) ) @@ -299,7 +304,7 @@ int PNS_PCBNEW_RULE_RESOLVER::Clearance( const PNS::ITEM* aA, const PNS::ITEM* a if( QueryConstraint( PNS::CONSTRAINT_TYPE::CT_EDGE_CLEARANCE, aA, aB, layer, &constraint ) ) { if( constraint.m_Value.Min() > rv ) - rv = constraint.m_Value.Min(); + rv = constraint.m_Value.Min() - m_clearanceEpsilon; } } @@ -326,7 +331,7 @@ int PNS_PCBNEW_RULE_RESOLVER::HoleClearance( const PNS::ITEM* aA, const PNS::ITE layer = aB->Layer(); if( QueryConstraint( PNS::CONSTRAINT_TYPE::CT_HOLE_CLEARANCE, aA, aB, layer, &constraint ) ) - rv = constraint.m_Value.Min(); + rv = constraint.m_Value.Min() - m_clearanceEpsilon; m_holeClearanceCache[ key ] = rv; return rv; @@ -351,7 +356,7 @@ int PNS_PCBNEW_RULE_RESOLVER::HoleToHoleClearance( const PNS::ITEM* aA, const PN layer = aB->Layer(); if( QueryConstraint( PNS::CONSTRAINT_TYPE::CT_HOLE_TO_HOLE, aA, aB, layer, &constraint ) ) - rv = constraint.m_Value.Min(); + rv = constraint.m_Value.Min() - m_clearanceEpsilon; m_holeToHoleClearanceCache[ key ] = rv; return rv; diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 950ef65b1e..636f38cb8c 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -1636,6 +1636,9 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent ) // Set initial cursor setCursor(); + // Send an initial movement to prime the collision detection + m_router->Move( p, nullptr ); + while( TOOL_EVENT* evt = Wait() ) { setCursor();