From c24f70ba1ecf9da730faaf9b6f4ba304af7e9026 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 11 Nov 2018 11:28:37 -0800 Subject: [PATCH] GRID_HELPER: Filter targets based on dragging Filtering based on selection ignores the use case where we are measuring to a selected item. This utilizes the dragged flag to prevent snapping based on the current state of the item drag. Fixes: lp:1801089 * https://bugs.launchpad.net/kicad/+bug/1801089 --- pcbnew/tools/edit_tool.cpp | 6 ++++++ pcbnew/tools/grid_helper.cpp | 7 +++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 1b33fdcda8..f567fa0961 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -438,6 +438,9 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) } } + for( auto item : selection ) + item->SetFlags( IS_DRAGGED ); //todo: flags structure rework + editFrame->UndoRedoBlock( true ); m_cursor = controls->GetCursorPosition(); @@ -558,6 +561,9 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) if( unselect || restore_state ) m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); + for( auto item : selection ) + item->ClearFlags( IS_DRAGGED ); //todo: flags structure rework + if( restore_state ) m_commit->Revert(); else diff --git a/pcbnew/tools/grid_helper.cpp b/pcbnew/tools/grid_helper.cpp index 99782fdadb..7b663c20e7 100644 --- a/pcbnew/tools/grid_helper.cpp +++ b/pcbnew/tools/grid_helper.cpp @@ -241,12 +241,11 @@ std::set GRID_HELPER::queryVisible( const BOX2I& aArea ) const BOARD_ITEM* item = static_cast( it.first ); // The item must be visible and on an active layer - // It cannot be selected because this routine is used to calculate snapping, - // so the selected it is what we are snapping _from_ and should not be - // considered a snap target + // It cannot be moving as a moving item is being snapped _from_ + // rather than considered a potential target if( view->IsVisible( item ) && ( !isHighContrast || activeLayers.count( it.second ) ) - && !item->IsSelected() ) + && !item->IsDragging() ) items.insert ( item ); }