Class: QgsMapRendererCache¶
-
class
qgis.core.
QgsMapRendererCache
¶ Bases:
PyQt5.QtCore.QObject
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).
Methods
Returns the cached image for the specified
cacheKey
.Invalidates the cache contents, clearing all cached images.
Removes an image from the cache with matching
cacheKey
.Returns a list of map layers on which an image in the cache depends.
Returns
True
if the cache contains an image with the specifiedcacheKey
.Initialize cache: set new parameters and clears the cache if any parameters have changed since last initialization.
Set the cached
image
for a particularcacheKey
.-
cacheImage
(self, cacheKey: str) → QImage¶ Returns the cached image for the specified
cacheKey
. ThecacheKey
usually matches the QgsMapLayer.id() which the image is a render of. Returns a null image if it is not cached.See also
See also
- Parameters
cacheKey (str) –
- Return type
QImage
-
childEvent
(self, QChildEvent)¶
-
clear
(self)¶ Invalidates the cache contents, clearing all cached images.
See also
-
clearCacheImage
(self, cacheKey: str)¶ Removes an image from the cache with matching
cacheKey
.See also
- Parameters
cacheKey (str) –
-
connectNotify
(self, QMetaMethod)¶
-
customEvent
(self, QEvent)¶
-
dependentLayers
(self, cacheKey: str) → List[QgsMapLayer]¶ Returns a list of map layers on which an image in the cache depends.
New in version 3.0.
- Parameters
cacheKey (str) –
- Return type
List[QgsMapLayer]
-
disconnectNotify
(self, QMetaMethod)¶
-
hasCacheImage
(self, cacheKey: str) → bool¶ Returns
True
if the cache contains an image with the specifiedcacheKey
.See also
New in version 3.0.
- Parameters
cacheKey (str) –
- Return type
bool
-
init
(self, extent: QgsRectangle, scale: float) → bool¶ Initialize cache: set new parameters and clears the cache if any parameters have changed since last initialization.
- Return type
bool
- Returns
flag whether the parameters are the same as last time
- Parameters
extent (QgsRectangle) –
scale (float) –
-
isSignalConnected
(self, QMetaMethod) → bool¶
-
receivers
(self, PYQT_SIGNAL) → int¶
-
sender
(self) → QObject¶
-
senderSignalIndex
(self) → int¶
-
setCacheImage
(self, cacheKey: str, image: QImage, dependentLayers: Iterable[QgsMapLayer] = [])¶ Set the cached
image
for a particularcacheKey
. ThecacheKey
usually matches the QgsMapLayer.id() which the image is a render of. A list ofdependentLayers
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
- Parameters
cacheKey (str) –
image (QImage) –
dependentLayers (Iterable[QgsMapLayer] = []) –
-
timerEvent
(self, QTimerEvent)¶
-