From b572781a8a4b9bb2fdb787e008a6e668a7ec66fd Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Sat, 6 Nov 2021 16:03:41 +0000 Subject: [PATCH] eeschema: Update anchor position of pasted items after initial move Fixes https://gitlab.com/kicad/code/kicad/-/issues/9534 --- eeschema/tools/ee_selection_tool.cpp | 2 +- eeschema/tools/sch_editor_control.cpp | 5 +++-- eeschema/tools/sch_move_tool.cpp | 11 +++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 87e8c79320..32e3c33c95 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -1110,7 +1110,7 @@ EE_SELECTION& EE_SELECTION_TOOL::RequestSelection( const KICAD_T aFilterList[] ) for( int i = (int) m_selection.GetSize() - 1; i >= 0; --i ) { EDA_ITEM* item = (EDA_ITEM*) m_selection.GetItem( i ); - isMoving = static_cast( item )->IsMoving(); + isMoving |= static_cast( item )->IsMoving(); if( !item->IsType( aFilterList ) ) { diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 9f58729ff7..524de53bda 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -1865,11 +1865,11 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent ) const_cast( item->m_Uuid ) = KIID(); } - item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING ); + item->SetFlags( IS_NEW | IS_PASTED ); m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), (SCH_ITEM*) item, i > 0 ); // Reset flags for subsequent move operation - item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING ); + item->SetFlags( IS_NEW | IS_PASTED ); // Start out hidden so the pasted items aren't "ghosted" in their original location // before being moved to the current location. getView()->Hide( item, true ); @@ -1930,6 +1930,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent ) SCH_ITEM* item = (SCH_ITEM*) selection.GetTopLeftItem(); selection.SetReferencePoint( item->GetPosition() ); + m_toolMgr->RunAction( EE_ACTIONS::move, false ); } diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index f1d79a9df5..2b3871f6a7 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -293,6 +293,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) if( m_anchorPos ) { VECTOR2I delta = m_cursor - (*m_anchorPos); + bool isPasted = false; // Drag items to the current cursor position for( EDA_ITEM* item : selection ) @@ -303,8 +304,18 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) moveItem( item, delta ); updateItem( item, false ); + + isPasted |= item->GetFlags() & IS_PASTED; + item->ClearFlags( IS_PASTED ); } + // The first time pasted items are moved we need to store + // the position of the cursor so that rotate while moving + // works as expected (instead of around the original anchor + // point + if( isPasted ) + selection.SetReferencePoint( m_cursor ); + m_anchorPos = m_cursor; } // For some items, moving the cursor to anchor is not good (for instance large