Skip to content

Commit

Permalink
Draw cached composer map image respecting any content movement
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 6, 2017
1 parent b7ca787 commit 4ec56bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/composer/qgscomposermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ void QgsComposerMap::painterJobFinished()
mPainter.reset( nullptr );
mCacheUpdated = true;
mCacheFinalImage = std::move( mCacheRenderingImage );
mLastRenderedImageOffsetX = 0;
mLastRenderedImageOffsetY = 0;
updateItem();
}

Expand Down Expand Up @@ -341,7 +343,7 @@ void QgsComposerMap::paint( QPainter *painter, const QStyleOptionGraphicsItem *,

painter->save();

painter->translate( mXOffset, mYOffset );
painter->translate( mLastRenderedImageOffsetX + mXOffset, mLastRenderedImageOffsetY + mYOffset );
painter->scale( scale, scale );
painter->drawImage( 0, 0, *mCacheFinalImage );

Expand Down Expand Up @@ -599,6 +601,8 @@ void QgsComposerMap::resize( double dx, double dy )

void QgsComposerMap::moveContent( double dx, double dy )
{
mLastRenderedImageOffsetX -= dx;
mLastRenderedImageOffsetY -= dy;
if ( !mDrawing )
{
transformShift( dx, dy );
Expand Down
3 changes: 3 additions & 0 deletions src/core/composer/qgscomposermap.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,9 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
//! Offset in y direction for showing map cache image
double mYOffset = 0.0;

double mLastRenderedImageOffsetX = 0.0;
double mLastRenderedImageOffsetY = 0.0;

//! Map rotation
double mMapRotation = 0;

Expand Down

0 comments on commit 4ec56bc

Please sign in to comment.