QGIS API Documentation  3.14.0-Pi (9f7028fd23)
Classes | Public Member Functions | List of all members
QgsMapRendererCache Class Reference

#include <qgsmaprenderercache.h>

Inheritance diagram for QgsMapRendererCache:
Inheritance graph
[legend]

Public Member Functions

 QgsMapRendererCache ()
 
QImage cacheImage (const QString &cacheKey) const
 Returns the cached image for the specified cacheKey. More...
 
void clear ()
 Invalidates the cache contents, clearing all cached images. More...
 
void clearCacheImage (const QString &cacheKey)
 Removes an image from the cache with matching cacheKey. More...
 
QList< QgsMapLayer * > dependentLayers (const QString &cacheKey) const
 Returns a list of map layers on which an image in the cache depends. More...
 
bool hasCacheImage (const QString &cacheKey) const
 Returns true if the cache contains an image with the specified cacheKey. More...
 
bool init (const QgsRectangle &extent, double scale)
 Initialize cache: set new parameters and clears the cache if any parameters have changed since last initialization. More...
 
void invalidateCacheForLayer (QgsMapLayer *layer)
 Invalidates cached images which relate to the specified map layer. More...
 
void setCacheImage (const QString &cacheKey, const QImage &image, const QList< QgsMapLayer * > &dependentLayers=QList< QgsMapLayer * >())
 Set the cached image for a particular cacheKey. More...
 

Detailed Description

This class is responsible for keeping cache of rendered images resulting from a map rendering job.

Once a job has a rendered image stored in the cache (using setCacheImage(...)), the cache listens to repaintRequested() signals from dependent layers. If triggered, the cache removes the rendered image (and disconnects from the layers).

The class is thread-safe (multiple classes can access the same instance safely).

Since
QGIS 2.4

Definition at line 42 of file qgsmaprenderercache.h.

Constructor & Destructor Documentation

◆ QgsMapRendererCache()

QgsMapRendererCache::QgsMapRendererCache ( )

Definition at line 21 of file qgsmaprenderercache.cpp.

Member Function Documentation

◆ cacheImage()

QImage QgsMapRendererCache::cacheImage ( const QString &  cacheKey) const

Returns the cached image for the specified cacheKey.

The cacheKey usually matches the QgsMapLayer::id() which the image is a render of. Returns a null image if it is not cached.

See also
setCacheImage()
hasCacheImage()

Definition at line 133 of file qgsmaprenderercache.cpp.

◆ clear()

void QgsMapRendererCache::clear ( )

Invalidates the cache contents, clearing all cached images.

See also
clearCacheImage()

Definition at line 26 of file qgsmaprenderercache.cpp.

◆ clearCacheImage()

void QgsMapRendererCache::clearCacheImage ( const QString &  cacheKey)

Removes an image from the cache with matching cacheKey.

See also
clear()

Definition at line 177 of file qgsmaprenderercache.cpp.

◆ dependentLayers()

QList< QgsMapLayer * > QgsMapRendererCache::dependentLayers ( const QString &  cacheKey) const

Returns a list of map layers on which an image in the cache depends.

Since
QGIS 3.0

Definition at line 139 of file qgsmaprenderercache.cpp.

◆ hasCacheImage()

bool QgsMapRendererCache::hasCacheImage ( const QString &  cacheKey) const

Returns true if the cache contains an image with the specified cacheKey.

See also
cacheImage()
Since
QGIS 3.0

Definition at line 128 of file qgsmaprenderercache.cpp.

◆ init()

bool QgsMapRendererCache::init ( const QgsRectangle extent,
double  scale 
)

Initialize cache: set new parameters and clears the cache if any parameters have changed since last initialization.

Returns
flag whether the parameters are the same as last time

Definition at line 84 of file qgsmaprenderercache.cpp.

◆ invalidateCacheForLayer()

void QgsMapRendererCache::invalidateCacheForLayer ( QgsMapLayer layer)

Invalidates cached images which relate to the specified map layer.

Since
QGIS 3.14

Definition at line 155 of file qgsmaprenderercache.cpp.

◆ setCacheImage()

void QgsMapRendererCache::setCacheImage ( const QString &  cacheKey,
const QImage &  image,
const QList< QgsMapLayer * > &  dependentLayers = QList< QgsMapLayer * >() 
)

Set the cached image for a particular cacheKey.

The cacheKey usually matches the QgsMapLayer::id() which the image is a render of. A list of dependentLayers should be passed containing all layer on which this cache image is dependent. If any of these layers triggers a repaint then the cache image will be cleared.

See also
cacheImage()

Definition at line 102 of file qgsmaprenderercache.cpp.


The documentation for this class was generated from the following files: