Skip to content
Permalink
Browse files

More flexible API for preview job determination

  • Loading branch information
nyalldawson committed Dec 2, 2017
1 parent 16a1bd7 commit 01e8ed85e31916abe8e5bc94d03e78728ee87852
Showing with 25 additions and 4 deletions.
  1. +1 −0 python/core/qgsdataprovider.sip
  2. +2 −2 src/core/qgsdataprovider.cpp
  3. +18 −1 src/core/qgsdataprovider.h
  4. +4 −1 src/gui/qgsmapcanvas.cpp
@@ -380,6 +380,7 @@ Current time stamp of data source
.. versionadded:: 3.0
%End


signals:

void fullExtentCalculated();
@@ -42,7 +42,7 @@ void QgsDataProvider::setListening( bool isListening )
Q_UNUSED( isListening );
}

bool QgsDataProvider::renderInPreview( double lastRenderingTimeMS, double maxRenderingTimeMS )
bool QgsDataProvider::renderInPreview( QgsDataProvider::PreviewContext context )
{
return lastRenderingTimeMS <= maxRenderingTimeMS;
return context.lastRenderingTimeMs <= context.maxRenderingTimeMs;
}
@@ -461,6 +461,23 @@ class CORE_EXPORT QgsDataProvider : public QObject
*/
virtual void setListening( bool isListening );

#ifndef SIP_RUN

/**
* Stores settings related to the context in which a preview job runs.
* \note Not available in Python bindings
* \since QGIS 3.0
*/
struct PreviewContext
{
//! Previous rendering time for the layer, in ms
double lastRenderingTimeMs = -1;

//! Default maximum allowable render time, in ms
double maxRenderingTimeMs = MAXIMUM_LAYER_PREVIEW_TIME_MS;
};
#endif

/**
* Returns whether the layer must be rendered in preview jobs.
*
@@ -474,7 +491,7 @@ class CORE_EXPORT QgsDataProvider : public QObject
*
* \note not available in Python bindings
*/
virtual bool renderInPreview( double lastRenderingTimeMS, double maxRenderingTimeMS ); // SIP_SKIP
virtual bool renderInPreview( QgsDataProvider::PreviewContext context ); // SIP_SKIP

signals:

@@ -2273,9 +2273,12 @@ void QgsMapCanvas::startPreviewJob( int number )
// truncate preview layers to fast layers
const QList<QgsMapLayer *> layers = jobSettings.layers();
QList< QgsMapLayer * > previewLayers;
QgsDataProvider::PreviewContext context;
context.maxRenderingTimeMs = MAXIMUM_LAYER_PREVIEW_TIME_MS;
for ( QgsMapLayer *layer : layers )
{
if ( !layer->dataProvider()->renderInPreview( mLastLayerRenderTime.value( layer->id() ), MAXIMUM_LAYER_PREVIEW_TIME_MS ) )
context.lastRenderingTimeMs = mLastLayerRenderTime.value( layer->id() );
if ( !layer->dataProvider()->renderInPreview( context ) )
{
QgsDebugMsgLevel( QString( "Layer %1 not rendered because it does not match the renderInPreview criterion %2" ).arg( layer->id() ).arg( mLastLayerRenderTime.value( layer->id() ) ), 3 );
continue;

0 comments on commit 01e8ed8

Please sign in to comment.
You can’t perform that action at this time.