Skip to content
Permalink
Browse files

Consider multi pages in snap to grid function

  • Loading branch information
mhugent committed Jul 17, 2012
1 parent 7230ec9 commit b45d853ca5fc60c8301fb022f2d8bf74d85c097d
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/core/composer/qgscomposition.cpp
@@ -795,11 +795,16 @@ QPointF QgsComposition::snapPointToGrid( const QPointF& scenePoint ) const
return scenePoint;
}

//snap x coordinate //todo: add support for x- and y- offset
//y offset to current page
int pageNr = ( int )( scenePoint.y() / ( mPageHeight + mSpaceBetweenPages ) );
double yOffset = pageNr * ( mPageHeight + mSpaceBetweenPages );
double yPage = scenePoint.y() - yOffset; //y-coordinate relative to current page

//snap x coordinate
int xRatio = ( int )(( scenePoint.x() - mSnapGridOffsetX ) / mSnapGridResolution + 0.5 );
int yRatio = ( int )(( scenePoint.y() - mSnapGridOffsetY ) / mSnapGridResolution + 0.5 );
int yRatio = ( int )(( yPage - mSnapGridOffsetY ) / mSnapGridResolution + 0.5 );

return QPointF( xRatio * mSnapGridResolution + mSnapGridOffsetX, yRatio * mSnapGridResolution + mSnapGridOffsetY );
return QPointF( xRatio * mSnapGridResolution + mSnapGridOffsetX, yRatio * mSnapGridResolution + mSnapGridOffsetY + yOffset );
}

int QgsComposition::boundingRectOfSelectedItems( QRectF& bRect )

0 comments on commit b45d853

Please sign in to comment.
You can’t perform that action at this time.