mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Allow QgsMapLayer::triggerRepaint to defer updates
By calling QgsMapLayer::triggerRepaint( true ) any cached version of the layer will be invalidated, but a map canvas refresh won't automatically be triggered This allows invalidation of cached images while deferring the actual map update until the next canvas refresh.
This commit is contained in:
parent
92091c536b
commit
04d392b5a3
@ -634,13 +634,7 @@ class QgsMapLayer : QObject
|
|||||||
*/
|
*/
|
||||||
void setScaleBasedVisibility( const bool enabled );
|
void setScaleBasedVisibility( const bool enabled );
|
||||||
|
|
||||||
/**
|
void triggerRepaint( bool deferredUpdate = false );
|
||||||
* Will advice the map canvas (and any other interested party) that this layer requires to be repainted.
|
|
||||||
* Will emit a repaintRequested() signal.
|
|
||||||
*
|
|
||||||
* @note in 2.6 function moved from vector/raster subclasses to QgsMapLayer
|
|
||||||
*/
|
|
||||||
void triggerRepaint();
|
|
||||||
|
|
||||||
/** \brief Obtain Metadata for this layer */
|
/** \brief Obtain Metadata for this layer */
|
||||||
virtual QString metadata() const;
|
virtual QString metadata() const;
|
||||||
@ -687,10 +681,7 @@ class QgsMapLayer : QObject
|
|||||||
/** Emit a signal that layer's CRS has been reset */
|
/** Emit a signal that layer's CRS has been reset */
|
||||||
void crsChanged();
|
void crsChanged();
|
||||||
|
|
||||||
/** By emitting this signal the layer tells that either appearance or content have been changed
|
void repaintRequested( bool deferredUpdate = false );
|
||||||
* and any view showing the rendered layer should refresh itself.
|
|
||||||
*/
|
|
||||||
void repaintRequested();
|
|
||||||
|
|
||||||
/** This is used to send a request that any mapcanvas using this layer update its extents */
|
/** This is used to send a request that any mapcanvas using this layer update its extents */
|
||||||
void recalculateExtents() const;
|
void recalculateExtents() const;
|
||||||
|
@ -10408,7 +10408,7 @@ void QgisApp::layersWereAdded( const QList<QgsMapLayer *>& theLayers )
|
|||||||
|
|
||||||
if ( provider )
|
if ( provider )
|
||||||
{
|
{
|
||||||
connect( provider, &QgsDataProvider::dataChanged, layer, &QgsMapLayer::triggerRepaint );
|
connect( provider, &QgsDataProvider::dataChanged, layer, [layer] { layer->triggerRepaint(); } );
|
||||||
connect( provider, &QgsDataProvider::dataChanged, mMapCanvas, &QgsMapCanvas::refresh );
|
connect( provider, &QgsDataProvider::dataChanged, mMapCanvas, &QgsMapCanvas::refresh );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,7 +439,7 @@ void QgsBrowser::updateCurrentTab()
|
|||||||
QgsRasterLayer *rlayer = qobject_cast< QgsRasterLayer * >( mLayer );
|
QgsRasterLayer *rlayer = qobject_cast< QgsRasterLayer * >( mLayer );
|
||||||
if ( rlayer )
|
if ( rlayer )
|
||||||
{
|
{
|
||||||
connect( rlayer->dataProvider(), &QgsRasterDataProvider::dataChanged, rlayer, &QgsRasterLayer::triggerRepaint );
|
connect( rlayer->dataProvider(), &QgsRasterDataProvider::dataChanged, rlayer, [rlayer] { rlayer->triggerRepaint(); } );
|
||||||
connect( rlayer->dataProvider(), &QgsRasterDataProvider::dataChanged, mapCanvas, &QgsMapCanvas::refresh );
|
connect( rlayer->dataProvider(), &QgsRasterDataProvider::dataChanged, mapCanvas, &QgsMapCanvas::refresh );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1591,9 +1591,9 @@ QgsMapLayerStyleManager* QgsMapLayer::styleManager() const
|
|||||||
return mStyleManager;
|
return mStyleManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsMapLayer::triggerRepaint()
|
void QgsMapLayer::triggerRepaint( bool deferredUpdate )
|
||||||
{
|
{
|
||||||
emit repaintRequested();
|
emit repaintRequested( deferredUpdate );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QgsMapLayer::metadata() const
|
QString QgsMapLayer::metadata() const
|
||||||
|
@ -678,12 +678,14 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
|||||||
void setScaleBasedVisibility( const bool enabled );
|
void setScaleBasedVisibility( const bool enabled );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will advice the map canvas (and any other interested party) that this layer requires to be repainted.
|
* Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
|
||||||
* Will emit a repaintRequested() signal.
|
* Will emit a repaintRequested() signal.
|
||||||
|
* If \a deferredUpdate is true then the layer will only be repainted when the canvas is next
|
||||||
|
* re-rendered, and will not trigger any canvas redraws itself.
|
||||||
*
|
*
|
||||||
* @note in 2.6 function moved from vector/raster subclasses to QgsMapLayer
|
* @note in 2.6 function moved from vector/raster subclasses to QgsMapLayer
|
||||||
*/
|
*/
|
||||||
void triggerRepaint();
|
void triggerRepaint( bool deferredUpdate = false );
|
||||||
|
|
||||||
//! \brief Obtain Metadata for this layer
|
//! \brief Obtain Metadata for this layer
|
||||||
virtual QString metadata() const;
|
virtual QString metadata() const;
|
||||||
@ -732,8 +734,10 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
|||||||
|
|
||||||
/** By emitting this signal the layer tells that either appearance or content have been changed
|
/** By emitting this signal the layer tells that either appearance or content have been changed
|
||||||
* and any view showing the rendered layer should refresh itself.
|
* and any view showing the rendered layer should refresh itself.
|
||||||
|
* If \a deferredUpdate is true then the layer will only be repainted when the canvas is next
|
||||||
|
* re-rendered, and will not trigger any canvas redraws itself.
|
||||||
*/
|
*/
|
||||||
void repaintRequested();
|
void repaintRequested( bool deferredUpdate = false );
|
||||||
|
|
||||||
//! This is used to send a request that any mapcanvas using this layer update its extents
|
//! This is used to send a request that any mapcanvas using this layer update its extents
|
||||||
void recalculateExtents() const;
|
void recalculateExtents() const;
|
||||||
|
@ -164,7 +164,7 @@ QgsVectorLayer::QgsVectorLayer( const QString& vectorLayerPath,
|
|||||||
setDataSource( vectorLayerPath, baseName, providerKey, loadDefaultStyleFlag );
|
setDataSource( vectorLayerPath, baseName, providerKey, loadDefaultStyleFlag );
|
||||||
}
|
}
|
||||||
|
|
||||||
connect( this, &QgsVectorLayer::selectionChanged, this, &QgsVectorLayer::repaintRequested );
|
connect( this, &QgsVectorLayer::selectionChanged, this, [=]{ emit repaintRequested(); } );
|
||||||
connect( QgsProject::instance()->relationManager(), &QgsRelationManager::relationsLoaded, this, &QgsVectorLayer::onRelationsLoaded );
|
connect( QgsProject::instance()->relationManager(), &QgsRelationManager::relationsLoaded, this, &QgsVectorLayer::onRelationsLoaded );
|
||||||
|
|
||||||
// Default simplify drawing settings
|
// Default simplify drawing settings
|
||||||
|
@ -295,7 +295,7 @@ void QgsMapCanvas::setLayers( const QList<QgsMapLayer*>& layers )
|
|||||||
|
|
||||||
Q_FOREACH ( QgsMapLayer* layer, oldLayers )
|
Q_FOREACH ( QgsMapLayer* layer, oldLayers )
|
||||||
{
|
{
|
||||||
disconnect( layer, &QgsMapLayer::repaintRequested, this, &QgsMapCanvas::refresh );
|
disconnect( layer, &QgsMapLayer::repaintRequested, this, &QgsMapCanvas::layerRepaintRequested );
|
||||||
disconnect( layer, &QgsMapLayer::crsChanged, this, &QgsMapCanvas::layerCrsChange );
|
disconnect( layer, &QgsMapLayer::crsChanged, this, &QgsMapCanvas::layerCrsChange );
|
||||||
if ( QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( layer ) )
|
if ( QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( layer ) )
|
||||||
{
|
{
|
||||||
@ -307,7 +307,7 @@ void QgsMapCanvas::setLayers( const QList<QgsMapLayer*>& layers )
|
|||||||
|
|
||||||
Q_FOREACH ( QgsMapLayer* layer, layers )
|
Q_FOREACH ( QgsMapLayer* layer, layers )
|
||||||
{
|
{
|
||||||
connect( layer, &QgsMapLayer::repaintRequested, this, &QgsMapCanvas::refresh );
|
connect( layer, &QgsMapLayer::repaintRequested, this, &QgsMapCanvas::layerRepaintRequested );
|
||||||
connect( layer, &QgsMapLayer::crsChanged, this, &QgsMapCanvas::layerCrsChange );
|
connect( layer, &QgsMapLayer::crsChanged, this, &QgsMapCanvas::layerCrsChange );
|
||||||
if ( QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( layer ) )
|
if ( QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( layer ) )
|
||||||
{
|
{
|
||||||
@ -1668,6 +1668,12 @@ void QgsMapCanvas::updateDatumTransformEntries()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsMapCanvas::layerRepaintRequested( bool deferred )
|
||||||
|
{
|
||||||
|
if ( !deferred )
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QgsMapTool* QgsMapCanvas::mapTool()
|
QgsMapTool* QgsMapCanvas::mapTool()
|
||||||
|
@ -612,6 +612,10 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
|
|||||||
//! Make sure the datum transform store is properly populated
|
//! Make sure the datum transform store is properly populated
|
||||||
void updateDatumTransformEntries();
|
void updateDatumTransformEntries();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void layerRepaintRequested( bool deferred );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// this class is non-copyable
|
/// this class is non-copyable
|
||||||
|
|
||||||
|
@ -207,9 +207,10 @@ void QgsMapOverviewCanvas::mapRenderingFinished()
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsMapOverviewCanvas::layerRepaintRequested()
|
void QgsMapOverviewCanvas::layerRepaintRequested( bool deferred )
|
||||||
{
|
{
|
||||||
refresh();
|
if ( !deferred )
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,7 +75,11 @@ class GUI_EXPORT QgsMapOverviewCanvas : public QWidget
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void mapRenderingFinished();
|
void mapRenderingFinished();
|
||||||
void layerRepaintRequested();
|
|
||||||
|
/**
|
||||||
|
* Triggered when a layer in the overview requests a repaint.
|
||||||
|
*/
|
||||||
|
void layerRepaintRequested( bool deferred = false );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user