diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index a4dfe1a1aa..b8b81260a1 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -188,6 +188,8 @@ bool EDIT_TOOL::Init() && notMovingCondition ); menu.AddItem( PCB_ACTIONS::unrouteSelected, SELECTION_CONDITIONS::NotEmpty && SELECTION_CONDITIONS::OnlyTypes( unroutableTypes ) ); + menu.AddItem( PCB_ACTIONS::moveIndividually, SELECTION_CONDITIONS::NotEmpty + && notMovingCondition ); menu.AddItem( PCB_ACTIONS::breakTrack, SELECTION_CONDITIONS::Count( 1 ) && SELECTION_CONDITIONS::OnlyTypes( trackTypes ) ); menu.AddItem( PCB_ACTIONS::drag45Degree, SELECTION_CONDITIONS::Count( 1 ) @@ -2238,6 +2240,7 @@ void EDIT_TOOL::setTransitions() { Go( &EDIT_TOOL::GetAndPlace, PCB_ACTIONS::getAndPlace.MakeEvent() ); Go( &EDIT_TOOL::Move, PCB_ACTIONS::move.MakeEvent() ); + Go( &EDIT_TOOL::MoveIndividually, PCB_ACTIONS::moveIndividually.MakeEvent() ); Go( &EDIT_TOOL::Drag, PCB_ACTIONS::drag45Degree.MakeEvent() ); Go( &EDIT_TOOL::Drag, PCB_ACTIONS::dragFreeAngle.MakeEvent() ); Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCw.MakeEvent() ); diff --git a/pcbnew/tools/edit_tool.h b/pcbnew/tools/edit_tool.h index e52f4e4bf0..b404f431f7 100644 --- a/pcbnew/tools/edit_tool.h +++ b/pcbnew/tools/edit_tool.h @@ -80,6 +80,11 @@ public: */ int Move( const TOOL_EVENT& aEvent ); + /** + * Move a selection of items one-at-a-time. + */ + int MoveIndividually( const TOOL_EVENT& aEvent ); + /** * Invoke the PNS router to drag tracks or do an offline resizing of an arc track * if a single arc track is selected. diff --git a/pcbnew/tools/edit_tool_move_fct.cpp b/pcbnew/tools/edit_tool_move_fct.cpp index 13225bcaae..85cb61af3a 100644 --- a/pcbnew/tools/edit_tool_move_fct.cpp +++ b/pcbnew/tools/edit_tool_move_fct.cpp @@ -392,6 +392,34 @@ int EDIT_TOOL::Move( const TOOL_EVENT& aEvent ) } +int EDIT_TOOL::MoveIndividually( const TOOL_EVENT& aEvent ) +{ + PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool(); + + if( isRouterActive() ) + { + wxBell(); + return 0; + } + + EDA_ITEMS sortedItems = selTool->GetSelection().GetItemsSortedBySelectionOrder(); + + if( sortedItems.size() == 0 ) + return 0; + + for( EDA_ITEM* item : sortedItems ) + { + selTool->ClearSelection(); + selTool->AddItemToSel( item ); + doMoveSelection( aEvent ); + } + + selTool->AddItemsToSel( &sortedItems ); + + return 0; +} + + int EDIT_TOOL::MoveWithReference( const TOOL_EVENT& aEvent ) { if( isRouterActive() ) @@ -582,7 +610,8 @@ int EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, bool aPickReference ) if( evt->IsAction( &PCB_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT ) || evt->IsAction( &ACTIONS::refreshPreview ) - || evt->IsAction( &PCB_ACTIONS::moveWithReference ) ) + || evt->IsAction( &PCB_ACTIONS::moveWithReference ) + || evt->IsAction( &PCB_ACTIONS::moveIndividually ) ) { if( m_dragging && evt->Category() == TC_MOUSE ) { @@ -703,7 +732,8 @@ int EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, bool aPickReference ) { // Prepare to start dragging if( !( evt->IsAction( &PCB_ACTIONS::move ) - || evt->IsAction( &PCB_ACTIONS::moveWithReference ) ) + || evt->IsAction( &PCB_ACTIONS::moveWithReference ) + || evt->IsAction( &PCB_ACTIONS::moveIndividually ) ) && ( editFrame->GetPcbNewSettings()->m_TrackDragAction != TRACK_DRAG_ACTION::MOVE ) ) { if( invokeInlineRouter( PNS::DM_ANY ) ) diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index d2c15e1308..4b87e6c8f4 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -270,6 +270,12 @@ TOOL_ACTION PCB_ACTIONS::move( "pcbnew.InteractiveMove.move", _( "Move" ), _( "Moves the selected item(s)" ), BITMAPS::move, AF_ACTIVATE ); +TOOL_ACTION PCB_ACTIONS::moveIndividually( "pcbnew.InteractiveMove.moveIndividually", + AS_GLOBAL, + MD_CTRL + 'M', "", + _( "Move Individually" ), _( "Moves the selected items one-by-one" ), + BITMAPS::move, AF_ACTIVATE ); + TOOL_ACTION PCB_ACTIONS::moveWithReference( "pcbnew.InteractiveMove.moveWithReference", AS_GLOBAL, 0, "", _( "Move with Reference" ), diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 81e3db1aac..3be38a9308 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -103,6 +103,9 @@ public: /// move or drag an item static TOOL_ACTION move; + /// move items one-by-one + static TOOL_ACTION moveIndividually; + /// move with a reference point static TOOL_ACTION moveWithReference;