Skip to content

Commit

Permalink
[composer] Disable snapping when item is rotated for now (not yet imp…
Browse files Browse the repository at this point in the history
…lemented)
  • Loading branch information
nyalldawson committed Feb 1, 2014
1 parent e0a1d09 commit 041244d
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/core/composer/qgscomposermousehandles.cpp
Expand Up @@ -777,7 +777,8 @@ void QgsComposerMouseHandles::dragMouseMove( const QPointF& currentPosition, boo
QPointF upperLeftPoint( mBeginHandlePos.x() + moveX, mBeginHandlePos.y() + moveY );

QPointF snappedLeftPoint;
if ( !preventSnap )
//no snapping for rotated items for now
if ( !preventSnap && rotation() == 0 )
{
//snap to grid and guides
snappedLeftPoint = snapPoint( upperLeftPoint, QgsComposerMouseHandles::Item );
Expand Down Expand Up @@ -825,14 +826,27 @@ void QgsComposerMouseHandles::resizeMouseMove( const QPointF& currentPosition, b

double mx = 0.0, my = 0.0, rx = 0.0, ry = 0.0;

//subtract cursor edge offset from begin mouse event and current cursor position, so that snapping occurs to edge of mouse handles
//rather then cursor position
QPointF beginMousePos = mapFromScene( QPointF( mBeginMouseEventPos.x() - mCursorOffset.width(), mBeginMouseEventPos.y() - mCursorOffset.height() ) );
QPointF snappedPosition = snapPoint( QPointF( currentPosition.x() - mCursorOffset.width(), currentPosition.y() - mCursorOffset.height() ), QgsComposerMouseHandles::Point );
snappedPosition = mapFromScene( snappedPosition );
QPointF beginMousePos;
QPointF finalPosition;
if ( rotation() == 0 )
{
//snapping only occurs if handles are not rotated for now

//subtract cursor edge offset from begin mouse event and current cursor position, so that snapping occurs to edge of mouse handles
//rather then cursor position
beginMousePos = mapFromScene( QPointF( mBeginMouseEventPos.x() - mCursorOffset.width(), mBeginMouseEventPos.y() - mCursorOffset.height() ) );
QPointF snappedPosition = snapPoint( QPointF( currentPosition.x() - mCursorOffset.width(), currentPosition.y() - mCursorOffset.height() ), QgsComposerMouseHandles::Point );
finalPosition = mapFromScene( snappedPosition );
}
else
{
//no snapping for rotated items for now
beginMousePos = mapFromScene( mBeginMouseEventPos );
finalPosition = mapFromScene( currentPosition );
}

double diffX = snappedPosition.x() - beginMousePos.x();
double diffY = snappedPosition.y() - beginMousePos.y();
double diffX = finalPosition.x() - beginMousePos.x();
double diffY = finalPosition.y() - beginMousePos.y();

double ratio = 0;
if ( lockRatio && mBeginHandleHeight != 0 )
Expand Down

0 comments on commit 041244d

Please sign in to comment.