diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index eb139efb9b..9de4c9c744 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -838,6 +838,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) } bool restore_state = false; + VECTOR2I originalPos; VECTOR2I totalMovement; PCB_GRID_HELPER grid( m_toolMgr, editFrame->GetMagneticItemsSettings() ); TOOL_EVENT* evt = &aEvent; @@ -885,6 +886,15 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) m_cursor.x = prevPos.x; } + if( !selection.HasReferencePoint() ) + originalPos = m_cursor; + + if( Is45Limited() ) + { + VECTOR2I moveVector = m_cursor - originalPos; + m_cursor = originalPos + GetVectorSnapped45( moveVector ); + } + controls->ForceCursorPosition( true, m_cursor ); selection.SetReferencePoint( m_cursor ); @@ -965,6 +975,12 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) // start moving with the reference point attached to the cursor grid.SetAuxAxes( false ); + if( Is45Limited() ) + { + VECTOR2I moveVector = m_cursor - originalPos; + m_cursor = originalPos + GetVectorSnapped45( moveVector ); + } + movement = m_cursor - selection.GetReferencePoint(); // Drag items to the current cursor position @@ -1005,6 +1021,9 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) selection.SetReferencePoint( m_cursor ); grid.SetAuxAxes( true, m_cursor ); } + + originalPos = m_cursor; + } controls->SetCursorPosition( m_cursor, false );