From 3475d0cebd5a62a6627c7d2d8f46ec0ff2379bf4 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 6 Jun 2021 14:16:31 -0400 Subject: [PATCH] PNS: Grab start item based on clearance if no direct hits found Fixes annoying "routing start point violates DRC" messages when entering the router from the hotkey and not directly over a track. --- pcbnew/router/pns_router.cpp | 24 ++++++++++++++++++++++-- pcbnew/router/pns_router.h | 2 +- pcbnew/router/pns_tool_base.cpp | 3 +++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 1c13a2a960..d939ebbcca 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -118,10 +118,30 @@ bool ROUTER::RoutingInProgress() const } -const ITEM_SET ROUTER::QueryHoverItems( const VECTOR2I& aP ) +const ITEM_SET ROUTER::QueryHoverItems( const VECTOR2I& aP, bool aUseClearance ) { if( m_state == IDLE || m_placer == nullptr ) - return m_world->HitTest( aP ); + { + if( aUseClearance ) + { + SEGMENT test( SEG( aP, aP ), -1 ); + test.SetWidth( 1 ); + test.SetLayers( LAYER_RANGE::All() ); + NODE::OBSTACLES obs; + m_world->QueryColliding( &test, obs, ITEM::ANY_T, -1, false ); + + PNS::ITEM_SET ret; + + for( OBSTACLE& obstacle : obs ) + ret.Add( obstacle.m_item, false ); + + return ret; + } + else + { + return m_world->HitTest( aP ); + } + } else return m_placer->CurrentNode()->HitTest( aP ); } diff --git a/pcbnew/router/pns_router.h b/pcbnew/router/pns_router.h index 867a38df5c..5102bc51cf 100644 --- a/pcbnew/router/pns_router.h +++ b/pcbnew/router/pns_router.h @@ -173,7 +173,7 @@ public: bool IsPlacingVia() const; - const ITEM_SET QueryHoverItems( const VECTOR2I& aP ); + const ITEM_SET QueryHoverItems( const VECTOR2I& aP, bool aUseClearance = false ); bool StartDragging( const VECTOR2I& aP, ITEM* aItem, int aDragMode = DM_ANY ); bool StartDragging( const VECTOR2I& aP, ITEM_SET aItems, int aDragMode = DM_COMPONENT ); diff --git a/pcbnew/router/pns_tool_base.cpp b/pcbnew/router/pns_tool_base.cpp index c412e3f751..6ec92399a5 100644 --- a/pcbnew/router/pns_tool_base.cpp +++ b/pcbnew/router/pns_tool_base.cpp @@ -113,6 +113,9 @@ ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, b ITEM_SET candidates = m_router->QueryHoverItems( aWhere ); + if( candidates.Empty() ) + candidates = m_router->QueryHoverItems( aWhere, true ); + for( ITEM* item : candidates.Items() ) { if( !item->IsRoutable() )