Skip to content

Commit

Permalink
Initially draw 'rendering' text while waiting for first cache of comp…
Browse files Browse the repository at this point in the history
…oser maps
  • Loading branch information
nyalldawson committed May 6, 2017
1 parent 4ec56bc commit 57b1a39
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions src/core/composer/qgscomposermap.cpp
Expand Up @@ -332,23 +332,36 @@ void QgsComposerMap::paint( QPainter *painter, const QStyleOptionGraphicsItem *,
{
if ( !mCacheFinalImage || mCacheFinalImage->isNull() )
{
// No initial render available - so draw some preview text alerting user
drawBackground( painter );
painter->setBrush( QBrush( QColor( 125, 125, 125, 125 ) ) );
painter->drawRect( thisPaintRect );
painter->setBrush( Qt::NoBrush );
QFont messageFont;
messageFont.setPointSize( 12 );
painter->setFont( messageFont );
painter->setPen( QColor( 255, 255, 255, 255 ) );
painter->drawText( thisPaintRect, Qt::AlignCenter | Qt::AlignHCenter, tr( "Rendering map" ) );


cache();
return;
}
else
{
//Background color is already included in cached image, so no need to draw

//Background color is already included in cached image, so no need to draw

double imagePixelWidth = mCacheFinalImage->width(); //how many pixels of the image are for the map extent?
double scale = rect().width() / imagePixelWidth;
double imagePixelWidth = mCacheFinalImage->width(); //how many pixels of the image are for the map extent?
double scale = rect().width() / imagePixelWidth;

painter->save();
painter->save();

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

//restore rotation
painter->restore();
//restore rotation
painter->restore();
}
}
else if ( mComposition->plotStyle() == QgsComposition::Print ||
mComposition->plotStyle() == QgsComposition::Postscript )
Expand Down

0 comments on commit 57b1a39

Please sign in to comment.