Constrain move tool when set

Move tool works slightly differently from other tools when figuring out
new locations.  This uses the global 45 enable flag to set proper item
locations when the user is requesting a 45° constraint on movement
This commit is contained in:
Seth Hillbrand 2021-09-06 07:05:25 -07:00
parent 7312bb4584
commit 56ccaf6482
1 changed files with 19 additions and 0 deletions

View File

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