Remove overly-complex snapping layer for moving objects.

We now have a hotkey to select Active Layer vs All Layers,
which gives the user more control.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16683
This commit is contained in:
Jeff Young 2024-01-20 22:04:39 +00:00
parent 5c4313587b
commit 37c185f437
4 changed files with 8 additions and 49 deletions

View File

@ -298,36 +298,13 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit
{ {
sTool->FilterCollectorForMarkers( aCollector ); sTool->FilterCollectorForMarkers( aCollector );
sTool->FilterCollectorForHierarchy( aCollector, true ); sTool->FilterCollectorForHierarchy( aCollector, true );
sTool->FilterCollectorForFreePads( aCollector );
}, },
// Prompt user regarding locked items if in board editor and in free-pad-mode (if true /* prompt user regarding locked items */ );
// we're not in free-pad mode we delay this until the second RequestSelection()).
!m_isFootprintEditor && cfg->m_AllowFreePads );
if( m_dragging || selection.Empty() ) if( m_dragging || selection.Empty() )
return false; return false;
LSET item_layers = selection.GetSelectionLayers();
bool is_hover = selection.IsHover(); // N.B. This must be saved before the second call
// to RequestSelection() below
VECTOR2I pickedReferencePoint;
// Now filter out pads if not in free pads mode. We cannot do this in the first
// RequestSelection() as we need the item_layers when a pad is the selection front.
if( !m_isFootprintEditor && !cfg->m_AllowFreePads )
{
selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
{
sTool->FilterCollectorForMarkers( aCollector );
sTool->FilterCollectorForHierarchy( aCollector, true );
sTool->FilterCollectorForFreePads( aCollector );
},
true /* prompt user regarding locked items */ );
}
if( selection.Empty() )
return false;
editFrame->PushTool( aEvent ); editFrame->PushTool( aEvent );
Activate(); Activate();
@ -376,7 +353,7 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit
{ {
if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item ) ) if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item ) )
{ {
if( !is_hover ) if( !selection.IsHover() )
orig_items.push_back( boardItem ); orig_items.push_back( boardItem );
sel_items.push_back( boardItem ); sel_items.push_back( boardItem );
@ -393,10 +370,12 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit
} }
} }
VECTOR2I pickedReferencePoint;
if( moveWithReference && !pickReferencePoint( _( "Select reference point for move..." ), "", "", if( moveWithReference && !pickReferencePoint( _( "Select reference point for move..." ), "", "",
pickedReferencePoint ) ) pickedReferencePoint ) )
{ {
if( is_hover ) if( selection.IsHover() )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
editFrame->PopTool( aEvent ); editFrame->PopTool( aEvent );
@ -431,6 +410,7 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit
VECTOR2D bboxMovement; VECTOR2D bboxMovement;
BOX2I originalBBox; BOX2I originalBBox;
bool updateBBox = true; bool updateBBox = true;
LSET layers( editFrame->GetActiveLayer() );
PCB_GRID_HELPER grid( m_toolMgr, editFrame->GetMagneticItemsSettings() ); PCB_GRID_HELPER grid( m_toolMgr, editFrame->GetMagneticItemsSettings() );
TOOL_EVENT copy = aEvent; TOOL_EVENT copy = aEvent;
TOOL_EVENT* evt = &copy; TOOL_EVENT* evt = &copy;
@ -480,7 +460,7 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit
VECTOR2I mousePos( controls->GetMousePosition() ); VECTOR2I mousePos( controls->GetMousePosition() );
m_cursor = grid.BestSnapAnchor( mousePos, item_layers, m_cursor = grid.BestSnapAnchor( mousePos, layers,
grid.GetSelectionGrid( selection ), sel_items ); grid.GetSelectionGrid( selection ), sel_items );
if( controls->GetSettings().m_lastKeyboardCursorPositionValid ) if( controls->GetSettings().m_lastKeyboardCursorPositionValid )

View File

@ -105,17 +105,3 @@ const std::vector<KIGFX::VIEW_ITEM*> PCB_SELECTION::updateDrawList() const
return items; return items;
} }
const LSET PCB_SELECTION::GetSelectionLayers()
{
LSET retval;
for( EDA_ITEM* item : m_items )
{
if( BOARD_ITEM* board_item = dynamic_cast<BOARD_ITEM*>( item ) )
retval |= board_item->GetLayerSet();
}
return retval;
}

View File

@ -34,8 +34,6 @@ public:
EDA_ITEM* GetTopLeftItem( bool aFootprintsOnly = false ) const override; EDA_ITEM* GetTopLeftItem( bool aFootprintsOnly = false ) const override;
const std::vector<KIGFX::VIEW_ITEM*> updateDrawList() const override; const std::vector<KIGFX::VIEW_ITEM*> updateDrawList() const override;
const LSET GetSelectionLayers();
}; };
#endif // PCB_SELECTION_H #endif // PCB_SELECTION_H

View File

@ -528,11 +528,6 @@ const std::vector<KIGFX::VIEW_ITEM*> PCB_SELECTION::updateDrawList() const
} }
const LSET PCB_SELECTION::GetSelectionLayers()
{
return LSET();
}
#if 0 #if 0
#include <3d_canvas/board_adapter.h> #include <3d_canvas/board_adapter.h>