Skip to content

Commit 041244d

Browse files
committedFeb 1, 2014
[composer] Disable snapping when item is rotated for now (not yet implemented)
1 parent e0a1d09 commit 041244d

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed
 

‎src/core/composer/qgscomposermousehandles.cpp

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,8 @@ void QgsComposerMouseHandles::dragMouseMove( const QPointF& currentPosition, boo
777777
QPointF upperLeftPoint( mBeginHandlePos.x() + moveX, mBeginHandlePos.y() + moveY );
778778

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

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

828-
//subtract cursor edge offset from begin mouse event and current cursor position, so that snapping occurs to edge of mouse handles
829-
//rather then cursor position
830-
QPointF beginMousePos = mapFromScene( QPointF( mBeginMouseEventPos.x() - mCursorOffset.width(), mBeginMouseEventPos.y() - mCursorOffset.height() ) );
831-
QPointF snappedPosition = snapPoint( QPointF( currentPosition.x() - mCursorOffset.width(), currentPosition.y() - mCursorOffset.height() ), QgsComposerMouseHandles::Point );
832-
snappedPosition = mapFromScene( snappedPosition );
829+
QPointF beginMousePos;
830+
QPointF finalPosition;
831+
if ( rotation() == 0 )
832+
{
833+
//snapping only occurs if handles are not rotated for now
834+
835+
//subtract cursor edge offset from begin mouse event and current cursor position, so that snapping occurs to edge of mouse handles
836+
//rather then cursor position
837+
beginMousePos = mapFromScene( QPointF( mBeginMouseEventPos.x() - mCursorOffset.width(), mBeginMouseEventPos.y() - mCursorOffset.height() ) );
838+
QPointF snappedPosition = snapPoint( QPointF( currentPosition.x() - mCursorOffset.width(), currentPosition.y() - mCursorOffset.height() ), QgsComposerMouseHandles::Point );
839+
finalPosition = mapFromScene( snappedPosition );
840+
}
841+
else
842+
{
843+
//no snapping for rotated items for now
844+
beginMousePos = mapFromScene( mBeginMouseEventPos );
845+
finalPosition = mapFromScene( currentPosition );
846+
}
833847

834-
double diffX = snappedPosition.x() - beginMousePos.x();
835-
double diffY = snappedPosition.y() - beginMousePos.y();
848+
double diffX = finalPosition.x() - beginMousePos.x();
849+
double diffY = finalPosition.y() - beginMousePos.y();
836850

837851
double ratio = 0;
838852
if ( lockRatio && mBeginHandleHeight != 0 )

0 commit comments

Comments
 (0)
Please sign in to comment.