QGIS API Documentation
3.4.15-Madeira (e83d02e274)
|
This class is responsible for keeping cache of rendered images resulting from a map rendering job. More...
#include <qgsmaprenderercache.h>
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 | setCacheImage (const QString &cacheKey, const QImage &image, const QList< QgsMapLayer * > &dependentLayers=QList< QgsMapLayer * >()) |
Set the cached image for a particular cacheKey. More... | |
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).
Definition at line 42 of file qgsmaprenderercache.h.
QgsMapRendererCache::QgsMapRendererCache | ( | ) |
Definition at line 21 of file qgsmaprenderercache.cpp.
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.
Definition at line 129 of file qgsmaprenderercache.cpp.
void QgsMapRendererCache::clear | ( | ) |
Invalidates the cache contents, clearing all cached images.
Definition at line 26 of file qgsmaprenderercache.cpp.
void QgsMapRendererCache::clearCacheImage | ( | const QString & | cacheKey | ) |
Removes an image from the cache with matching cacheKey.
Definition at line 167 of file qgsmaprenderercache.cpp.
QList< QgsMapLayer * > QgsMapRendererCache::dependentLayers | ( | const QString & | cacheKey | ) | const |
Returns a list of map layers on which an image in the cache depends.
Definition at line 135 of file qgsmaprenderercache.cpp.
bool QgsMapRendererCache::hasCacheImage | ( | const QString & | cacheKey | ) | const |
Returns true if the cache contains an image with the specified cacheKey.
Definition at line 124 of file qgsmaprenderercache.cpp.
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.
Definition at line 81 of file qgsmaprenderercache.cpp.
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.
Definition at line 99 of file qgsmaprenderercache.cpp.