Skip to content

Commit 57b1a39

Browse files
committed
Initially draw 'rendering' text while waiting for first cache of composer maps
1 parent 4ec56bc commit 57b1a39

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

src/core/composer/qgscomposermap.cpp

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -332,23 +332,36 @@ void QgsComposerMap::paint( QPainter *painter, const QStyleOptionGraphicsItem *,
332332
{
333333
if ( !mCacheFinalImage || mCacheFinalImage->isNull() )
334334
{
335+
// No initial render available - so draw some preview text alerting user
336+
drawBackground( painter );
337+
painter->setBrush( QBrush( QColor( 125, 125, 125, 125 ) ) );
338+
painter->drawRect( thisPaintRect );
339+
painter->setBrush( Qt::NoBrush );
340+
QFont messageFont;
341+
messageFont.setPointSize( 12 );
342+
painter->setFont( messageFont );
343+
painter->setPen( QColor( 255, 255, 255, 255 ) );
344+
painter->drawText( thisPaintRect, Qt::AlignCenter | Qt::AlignHCenter, tr( "Rendering map" ) );
345+
346+
335347
cache();
336-
return;
337348
}
349+
else
350+
{
351+
//Background color is already included in cached image, so no need to draw
338352

339-
//Background color is already included in cached image, so no need to draw
340-
341-
double imagePixelWidth = mCacheFinalImage->width(); //how many pixels of the image are for the map extent?
342-
double scale = rect().width() / imagePixelWidth;
353+
double imagePixelWidth = mCacheFinalImage->width(); //how many pixels of the image are for the map extent?
354+
double scale = rect().width() / imagePixelWidth;
343355

344-
painter->save();
356+
painter->save();
345357

346-
painter->translate( mLastRenderedImageOffsetX + mXOffset, mLastRenderedImageOffsetY + mYOffset );
347-
painter->scale( scale, scale );
348-
painter->drawImage( 0, 0, *mCacheFinalImage );
358+
painter->translate( mLastRenderedImageOffsetX + mXOffset, mLastRenderedImageOffsetY + mYOffset );
359+
painter->scale( scale, scale );
360+
painter->drawImage( 0, 0, *mCacheFinalImage );
349361

350-
//restore rotation
351-
painter->restore();
362+
//restore rotation
363+
painter->restore();
364+
}
352365
}
353366
else if ( mComposition->plotStyle() == QgsComposition::Print ||
354367
mComposition->plotStyle() == QgsComposition::Postscript )

0 commit comments

Comments
 (0)