From f11cb736e5cacac561e33ebaaf7d215f1a2a4503 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 --- 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 9ab8774e7f..60868a5dcc 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -531,7 +531,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 ) { @@ -1996,7 +1996,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; @@ -2055,8 +2056,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 3a8619d616..a7c6e91956 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -331,8 +331,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.