From e3c4f425dc199599c48bca2a06fbda09a348bae6 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 9 Jul 2014 14:23:13 +0200 Subject: [PATCH] Fixed wrong reference point for copied items in subsequent module editor invocations (GAL). --- pcbnew/loadcmp.cpp | 1 + pcbnew/tools/edit_tool.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index a794f3f685..6d6f6395b7 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -107,6 +107,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule ) SetCrossHairPosition( wxPoint( 0, 0 ) ); PlaceModule( newModule, NULL ); + newModule->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized at the moment // Put it on FRONT layer, // because this is the default in ModEdit, and in libs diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 1eb1b37bee..6b833b2290 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -453,7 +453,7 @@ int EDIT_TOOL::CopyItems( TOOL_EVENT& aEvent ) frame->DisplayToolMsg( _( "Select reference point" ) ); bool cancelled = false; - VECTOR2I cursorPos; + VECTOR2I cursorPos = getViewControls()->GetCursorPosition(); while( OPT_TOOL_EVENT evt = Wait() ) { @@ -490,8 +490,10 @@ int EDIT_TOOL::CopyItems( TOOL_EVENT& aEvent ) module.Add( clone ); } - // Set the new relative internal local coordinates of footprint items - wxPoint moveVector = module.GetPosition() - wxPoint( cursorPos.x, cursorPos.y ); + // Set the new relative internal local coordinates of copied items + MODULE* editedModule = getModel()->m_Modules; + wxPoint moveVector = module.GetPosition() + editedModule->GetPosition() - + wxPoint( cursorPos.x, cursorPos.y ); module.MoveAnchorPosition( moveVector ); io.Format( &module, 0 ); @@ -499,7 +501,7 @@ int EDIT_TOOL::CopyItems( TOOL_EVENT& aEvent ) m_toolMgr->SaveClipboard( data ); } - frame->DisplayToolMsg( wxString::Format( _( "Copied %d items" ), selection.Size() ) ); + frame->DisplayToolMsg( wxString::Format( _( "Copied %d item(s)" ), selection.Size() ) ); controls->SetSnapping( false ); controls->ShowCursor( false ); controls->SetAutoPan( false );