From e490b8eda4a5b15e79ec28724b897a3965b2e6e1 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 25 Oct 2020 17:09:32 -0400 Subject: [PATCH] Bring back Copy with Reference as a new action Fixes https://gitlab.com/kicad/code/kicad/-/issues/5916 --- pcbnew/tools/edit_tool.cpp | 18 ++++++++++++++++-- pcbnew/tools/pcb_actions.cpp | 5 +++++ pcbnew/tools/pcb_actions.h | 3 +++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index d8af4c815a..3cef008fa4 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -1820,8 +1820,21 @@ int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent ) for( EDA_ITEM* item : selection ) items.push_back( static_cast( item ) ); - VECTOR2I refPoint = grid.BestDragOrigin( getViewControls()->GetCursorPosition( false ), - items ); + VECTOR2I refPoint; + + if( aEvent.IsAction( &PCB_ACTIONS::copyWithReference ) ) + { + if( !pickReferencePoint( _( "Select reference point for the copy..." ), + _( "Selection copied" ), + _( "Copy cancelled" ), + refPoint ) ) + return 0; + } + else + { + refPoint = grid.BestDragOrigin( getViewControls()->GetCursorPosition( false ), items ); + } + selection.SetReferencePoint( refPoint ); io.SetBoard( board() ); @@ -1873,6 +1886,7 @@ void EDIT_TOOL::setTransitions() Go( &EDIT_TOOL::FilletTracks, PCB_ACTIONS::filletTracks.MakeEvent() ); Go( &EDIT_TOOL::copyToClipboard, ACTIONS::copy.MakeEvent() ); + Go( &EDIT_TOOL::copyToClipboard, PCB_ACTIONS::copyWithReference.MakeEvent() ); Go( &EDIT_TOOL::cutToClipboard, ACTIONS::cut.MakeEvent() ); } diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index 7768ccf75e..5dd362e8fe 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -246,6 +246,11 @@ TOOL_ACTION PCB_ACTIONS::moveWithReference( "pcbnew.InteractiveMove.moveWithRefe _( "Moves the selected item(s) with a specified starting point" ), move_xpm, AF_ACTIVATE ); +TOOL_ACTION PCB_ACTIONS::copyWithReference( "pcbnew.InteractiveMove.copyWithReference", + AS_GLOBAL, 0, "", _( "Copy with Reference" ), + _( "Copy selected item(s) to clipboard with a specified starting point" ), + copy_xpm, AF_ACTIVATE ); + TOOL_ACTION PCB_ACTIONS::duplicateIncrement( "pcbnew.InteractiveEdit.duplicateIncrementPads", AS_GLOBAL, MD_SHIFT + MD_CTRL + 'D', LEGACY_HK_NAME( "Duplicate Item and Increment" ), diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 6d70791337..dad9dd4222 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -97,6 +97,9 @@ public: /// move with a reference point static TOOL_ACTION moveWithReference; + /// copy command with manual reference point selection + static TOOL_ACTION copyWithReference; + /// Rotation of selected objects static TOOL_ACTION rotateCw; static TOOL_ACTION rotateCcw;