Subgroup: Map

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).

New in version 2.4: Methods

blockSignals
cacheImage Returns the cached image for the specified cacheKey.
childEvent
children
clear Invalidates the cache contents, clearing all cached images.
clearCacheImage Removes an image from the cache with matching cacheKey.
connectNotify
customEvent
deleteLater
dependentLayers Returns a list of map layers on which an image in the cache depends.
disconnect
disconnectNotify
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
event
eventFilter
findChild findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject
findChildren findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]
hasCacheImage Returns true if the cache contains an image with the specified cacheKey.
inherits
init Initialize cache: set new parameters and clears the cache if any parameters have changed since last initialization.
installEventFilter
isSignalConnected
isWidgetType
isWindowType
killTimer
metaObject
moveToThread
objectName
parent
property
pyqtConfigure Each keyword argument is either the name of a Qt property or a Qt signal.
receivers
removeEventFilter
sender
senderSignalIndex
setCacheImage Set the cached image for a particular cacheKey.
setObjectName
setParent
setProperty
signalsBlocked
startTimer
thread
timerEvent
tr

Attributes

destroyed destroyed(self, QObject = None) [signal]
objectNameChanged objectNameChanged(self, str) [signal]
staticMetaObject
cacheImage(self, cacheKey: str) → QImage

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()

See also

hasCacheImage()

childEvent()
clear(self)

Invalidates the cache contents, clearing all cached images.

clearCacheImage(self, cacheKey: str)

Removes an image from the cache with matching cacheKey.

See also

clear()

connectNotify()
customEvent()
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.

disconnectNotify()
hasCacheImage(self, cacheKey: str) → bool

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

New in version 3.0.

See also

cacheImage()

init(self, extent: QgsRectangle, scale: float) → bool

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
isSignalConnected()
receivers()
sender()
senderSignalIndex()
setCacheImage(self, cacheKey: str, image: QImage, dependentLayers: Iterable[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()

timerEvent()