eeschema: Update anchor position of pasted items after initial move

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9534
This commit is contained in:
Roberto Fernandez Bautista 2021-11-06 16:03:41 +00:00
parent d1bab3116d
commit b572781a8a
3 changed files with 15 additions and 3 deletions

View File

@ -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<SCH_ITEM*>( item )->IsMoving();
isMoving |= static_cast<SCH_ITEM*>( item )->IsMoving();
if( !item->IsType( aFilterList ) )
{

View File

@ -1865,11 +1865,11 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
const_cast<KIID&>( 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 );
}

View File

@ -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