|
@@ -507,6 +507,7 @@ void QgsMapCanvas::refreshMap() |
|
|
QgsDebugMsgLevel( "CANVAS refresh!", 3 ); |
|
|
|
|
|
stopRendering(); // if any... |
|
|
stopPreviewJobs(); |
|
|
|
|
|
//build the expression context |
|
|
QgsExpressionContext expressionContext; |
|
@@ -628,6 +629,7 @@ void QgsMapCanvas::rendererJobFinished() |
|
|
p.end(); |
|
|
|
|
|
mMap->setContent( img, imageRect( img, mSettings ) ); |
|
|
startPreviewJobs(); |
|
|
} |
|
|
|
|
|
// now we are in a slot called from mJob - do not delete it immediately |
|
@@ -638,6 +640,17 @@ void QgsMapCanvas::rendererJobFinished() |
|
|
emit mapCanvasRefreshed(); |
|
|
} |
|
|
|
|
|
void QgsMapCanvas::previewJobFinished() |
|
|
{ |
|
|
QgsMapRendererQImageJob *job = qobject_cast<QgsMapRendererQImageJob *>( sender() ); |
|
|
Q_ASSERT( job ); |
|
|
|
|
|
if ( mMap ) |
|
|
{ |
|
|
mMap->addPreviewImage( job->renderedImage(), job->mapSettings().extent() ); |
|
|
} |
|
|
} |
|
|
|
|
|
QgsRectangle QgsMapCanvas::imageRect( const QImage &img, const QgsMapSettings &mapSettings ) |
|
|
{ |
|
|
// This is a hack to pass QgsMapCanvasItem::setRect what it |
|
@@ -2113,3 +2126,56 @@ const QgsLabelingEngineSettings &QgsMapCanvas::labelingEngineSettings() const |
|
|
{ |
|
|
return mSettings.labelingEngineSettings(); |
|
|
} |
|
|
|
|
|
void QgsMapCanvas::startPreviewJobs() |
|
|
{ |
|
|
stopPreviewJobs(); //just in case still running |
|
|
|
|
|
QgsRectangle mapRect = mSettings.visibleExtent(); |
|
|
|
|
|
for ( int j = 0; j < 3; ++j ) |
|
|
{ |
|
|
for ( int i = 0; i < 3; ++i ) |
|
|
{ |
|
|
if ( i == 1 && j == 1 ) |
|
|
{ |
|
|
continue; |
|
|
} |
|
|
|
|
|
|
|
|
//copy settings, only update extent |
|
|
QgsMapSettings jobSettings = mSettings; |
|
|
|
|
|
double dx = ( i - 1 ) * mapRect.width(); |
|
|
double dy = ( 1 - j ) * mapRect.height(); |
|
|
QgsRectangle jobExtent = mapRect; |
|
|
jobExtent.setXMaximum( jobExtent.xMaximum() + dx ); |
|
|
jobExtent.setXMinimum( jobExtent.xMinimum() + dx ); |
|
|
jobExtent.setYMaximum( jobExtent.yMaximum() + dy ); |
|
|
jobExtent.setYMinimum( jobExtent.yMinimum() + dy ); |
|
|
|
|
|
jobSettings.setExtent( jobExtent ); |
|
|
jobSettings.setFlag( QgsMapSettings::DrawLabeling, false ); |
|
|
|
|
|
QgsMapRendererQImageJob *job = new QgsMapRendererParallelJob( jobSettings ); |
|
|
mPreviewJobs.append( job ); |
|
|
connect( job, &QgsMapRendererJob::finished, this, &QgsMapCanvas::previewJobFinished ); |
|
|
job->start(); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
void QgsMapCanvas::stopPreviewJobs() |
|
|
{ |
|
|
QList< QgsMapRendererQImageJob * >::const_iterator it = mPreviewJobs.constBegin(); |
|
|
for ( ; it != mPreviewJobs.constEnd(); ++it ) |
|
|
{ |
|
|
if ( *it ) |
|
|
{ |
|
|
disconnect( *it, &QgsMapRendererJob::finished, this, &QgsMapCanvas::previewJobFinished ); |
|
|
connect( *it, &QgsMapRendererQImageJob::finished, *it, &QgsMapRendererQImageJob::deleteLater ); |
|
|
( *it )->cancelWithoutBlocking(); |
|
|
} |
|
|
} |
|
|
mPreviewJobs.clear(); |
|
|
} |