QgsMapRendererCache class
This class is responsible for keeping cache of rendered images resulting from a map rendering job.
Contents
- Reference
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).
Public functions
- auto cacheImage(const QString& cacheKey) const -> QImage
- Returns the cached image for the specified cacheKey.
- void clear()
- Invalidates the cache contents, clearing all cached images.
- void clearCacheImage(const QString& cacheKey)
- Removes an image from the cache with matching cacheKey.
- auto dependentLayers(const QString& cacheKey) const -> QList<QgsMapLayer*>
- Returns a list of map layers on which an image in the cache depends.
- auto hasCacheImage(const QString& cacheKey) const -> bool
- Returns true if the cache contains an image with the specified cacheKey.
- auto init(const QgsRectangle& extent, double scale) -> bool
- Initialize cache: set new parameters and clears the cache if any parameters have changed since last initialization.
- void setCacheImage(const QString& cacheKey, const QImage& image, const QList<QgsMapLayer*>& dependentLayers = QList<QgsMapLayer*>())
- Set the cached image for a particular cacheKey.
Function documentation
QImage QgsMapRendererCache:: cacheImage(const QString& cacheKey) const
Returns the cached image for the specified cacheKey.
The cacheKey usually matches the QgsMapLayer::
void QgsMapRendererCache:: clear()
Invalidates the cache contents, clearing all cached images.
void QgsMapRendererCache:: clearCacheImage(const QString& cacheKey)
Removes an image from the cache with matching cacheKey.
QList<QgsMapLayer*> QgsMapRendererCache:: dependentLayers(const QString& cacheKey) const
Returns a list of map layers on which an image in the cache depends.
bool QgsMapRendererCache:: hasCacheImage(const QString& cacheKey) const
Returns true if the cache contains an image with the specified cacheKey.
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 |
|---|
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::