Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Consider multi pages in snap to grid function
  • Loading branch information
mhugent committed Jul 17, 2012
1 parent 7230ec9 commit b45d853
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/core/composer/qgscomposition.cpp
Expand Up @@ -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 )
Expand Down

0 comments on commit b45d853

Please sign in to comment.