From d3e7efcd66931cd7bbc1647096ee208680e6f36a Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 16 Mar 2018 18:00:57 +0000 Subject: [PATCH] Ignore pads when selecting drag candidates in router tool. Fixes: lp:1747156 * https://bugs.launchpad.net/kicad/+bug/1747156 --- pcbnew/router/pns_tool_base.cpp | 9 ++++++--- pcbnew/router/pns_tool_base.h | 5 +++-- pcbnew/router/router_tool.cpp | 6 +++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pcbnew/router/pns_tool_base.cpp b/pcbnew/router/pns_tool_base.cpp index f9c56bf207..fef94736c8 100644 --- a/pcbnew/router/pns_tool_base.cpp +++ b/pcbnew/router/pns_tool_base.cpp @@ -113,7 +113,7 @@ void TOOL_BASE::Reset( RESET_REASON aReason ) } -ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer ) +ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, bool aIgnorePads ) { int tl = getView()->GetTopLayer(); @@ -143,6 +143,9 @@ ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer ) { if( item->OfKind( ITEM::VIA_T | ITEM::SOLID_T ) ) { + if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads ) + continue; + if( !prioritized[2] ) prioritized[2] = item; if( item->Layers().Overlaps( tl ) ) @@ -227,7 +230,7 @@ bool TOOL_BASE::checkSnap( ITEM *aItem ) return doSnap; } -void TOOL_BASE::updateStartItem( TOOL_EVENT& aEvent ) +void TOOL_BASE::updateStartItem( TOOL_EVENT& aEvent, bool aIgnorePads ) { int tl = getView()->GetTopLayer(); VECTOR2I cp = controls()->GetCursorPosition(); @@ -247,7 +250,7 @@ void TOOL_BASE::updateStartItem( TOOL_EVENT& aEvent ) p = cp; } - m_startItem = pickSingleItem( p ); + m_startItem = pickSingleItem( p, -1, -1, aIgnorePads ); if( !snapEnabled && m_startItem && !m_startItem->Layers().Overlaps( tl ) ) m_startItem = nullptr; diff --git a/pcbnew/router/pns_tool_base.h b/pcbnew/router/pns_tool_base.h index 327c7ac332..ba86f7b777 100644 --- a/pcbnew/router/pns_tool_base.h +++ b/pcbnew/router/pns_tool_base.h @@ -56,9 +56,10 @@ public: protected: bool checkSnap( ITEM* aItem ); const VECTOR2I snapToItem( bool aEnabled, ITEM* aItem, VECTOR2I aP); - virtual ITEM* pickSingleItem( const VECTOR2I& aWhere, int aNet = -1, int aLayer = -1 ); + virtual ITEM* pickSingleItem( const VECTOR2I& aWhere, int aNet = -1, int aLayer = -1, + bool aIgnorePads = false ); virtual void highlightNet( bool aEnabled, int aNetcode = -1 ); - virtual void updateStartItem( TOOL_EVENT& aEvent ); + virtual void updateStartItem( TOOL_EVENT& aEvent, bool aIgnorePads = false ); virtual void updateEndItem( const TOOL_EVENT& aEvent ); void deleteTraces( ITEM* aStartItem, bool aWholeTrack ); diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index c0d8c08c27..024cfac814 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -893,17 +893,17 @@ int ROUTER_TOOL::mainLoop( PNS::ROUTER_MODE aMode ) } else if( evt->IsAction( &PCB_ACTIONS::dragFreeAngle ) ) { - updateStartItem( *evt ); + updateStartItem( *evt, true ); performDragging( PNS::DM_ANY | PNS::DM_FREE_ANGLE ); } else if( evt->IsAction( &PCB_ACTIONS::drag45Degree ) ) { - updateStartItem( *evt ); + updateStartItem( *evt, true ); performDragging( PNS::DM_ANY ); } else if( evt->IsAction( &PCB_ACTIONS::breakTrack ) ) { - updateStartItem( *evt ); + updateStartItem( *evt, true ); breakTrack( ); } else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &ACT_NewTrack ) )