From 46f7011463fb0124a25147f87edae4a9d97b183d Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 8 Oct 2018 06:27:41 -0700 Subject: [PATCH] pcbnew: Zone selection heuristic continuity for edge If the user is carefully selecting the zone edge, we do not filter the zone preemptively from our disambiguation list in the same manner as we do for selecting on zone copper. Fixes: lp:1796719 * https://bugs.launchpad.net/kicad/+bug/1796719 (cherry picked from commit f11cb736e5cacac561e33ebaaf7d215f1a2a4503) --- pcbnew/tools/selection_tool.cpp | 10 +++++++--- pcbnew/tools/selection_tool.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 24e028fa61..9d67cb7d9d 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -527,7 +527,7 @@ bool SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag, // Apply some ugly heuristics to avoid disambiguation menus whenever possible if( !m_skip_heuristics ) { - guessSelectionCandidates( collector ); + guessSelectionCandidates( collector, aWhere ); if( collector.GetCount() == 1 ) { @@ -1956,7 +1956,8 @@ double calcRatio( double a, double b ) // We currently check for pads and text mostly covering a footprint, but we don’t check for // smaller footprints mostly covering a larger footprint. // -void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) const +void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector, + const VECTOR2I& aWhere ) const { std::set rejected; std::set forced; @@ -2015,8 +2016,11 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c { for( int i = aCollector.GetCount() - 1; i >= 0; i-- ) { - if( aCollector[i]->Type() == PCB_ZONE_AREA_T ) + if( aCollector[i]->Type() == PCB_ZONE_AREA_T && !static_cast + ( aCollector[i] )->HitTestForEdge( wxPoint( aWhere.x, aWhere.y ) ) ) + { aCollector.Remove( i ); + } } } diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index d990c56891..b7df77392e 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -326,8 +326,9 @@ private: * Tries to guess best selection candidates in case multiple items are clicked, by * doing some braindead heuristics. * @param aCollector is the collector that has a list of items to be queried. + * @param aWhere is the selection point to consider */ - void guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) const; + void guessSelectionCandidates( GENERAL_COLLECTOR& aCollector, const VECTOR2I& aWhere ) const; /** * Event handler to update the selection VIEW_ITEM.