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
This commit is contained in:
Seth Hillbrand 2018-11-11 11:28:37 -08:00
parent cf20b39ddc
commit c24f70ba1e
2 changed files with 9 additions and 4 deletions

View File

@ -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 ); editFrame->UndoRedoBlock( true );
m_cursor = controls->GetCursorPosition(); m_cursor = controls->GetCursorPosition();
@ -558,6 +561,9 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
if( unselect || restore_state ) if( unselect || restore_state )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
for( auto item : selection )
item->ClearFlags( IS_DRAGGED ); //todo: flags structure rework
if( restore_state ) if( restore_state )
m_commit->Revert(); m_commit->Revert();
else else

View File

@ -241,12 +241,11 @@ std::set<BOARD_ITEM*> GRID_HELPER::queryVisible( const BOX2I& aArea ) const
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it.first ); BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it.first );
// The item must be visible and on an active layer // The item must be visible and on an active layer
// It cannot be selected because this routine is used to calculate snapping, // It cannot be moving as a moving item is being snapped _from_
// so the selected it is what we are snapping _from_ and should not be // rather than considered a potential target
// considered a snap target
if( view->IsVisible( item ) if( view->IsVisible( item )
&& ( !isHighContrast || activeLayers.count( it.second ) ) && ( !isHighContrast || activeLayers.count( it.second ) )
&& !item->IsSelected() ) && !item->IsDragging() )
items.insert ( item ); items.insert ( item );
} }