Skip to content

Commit fe3818d

Browse files
committedMar 28, 2023
Expose QgsMapRendererCache for map canvases to PyQGIS
1 parent 03e1d90 commit fe3818d

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
 

‎python/gui/auto_generated/qgsmapcanvas.sip.in

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,21 @@ as a result of an ongoing canvas render) will not be returned, and instead ``Non
132132
%Docstring
133133
Set whether to cache images of rendered layers
134134

135+
.. seealso:: :py:func:`isCachingEnabled`
136+
137+
.. seealso:: :py:func:`cache`
138+
135139
.. versionadded:: 2.4
136140
%End
137141

138142
bool isCachingEnabled() const;
139143
%Docstring
140144
Check whether images of rendered layers are curerently being cached
141145

146+
.. seealso:: :py:func:`setCachingEnabled`
147+
148+
.. seealso:: :py:func:`cache`
149+
142150
.. versionadded:: 2.4
143151
%End
144152

@@ -149,6 +157,17 @@ Make sure to remove any rendered images from cache (does nothing if cache is not
149157
.. versionadded:: 2.4
150158
%End
151159

160+
QgsMapRendererCache *cache();
161+
%Docstring
162+
Returns the map renderer cache, if caching is enabled.
163+
164+
.. seealso:: :py:func:`isCachingEnabled`
165+
166+
.. seealso:: :py:func:`setCachingEnabled`
167+
168+
.. versionadded:: 3.32
169+
%End
170+
152171

153172
void waitWhileRendering();
154173
%Docstring

‎src/gui/qgsmapcanvas.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,11 @@ void QgsMapCanvas::clearCache()
652652
mRenderedItemResults.reset();
653653
}
654654

655+
QgsMapRendererCache *QgsMapCanvas::cache()
656+
{
657+
return mCache;
658+
}
659+
655660
void QgsMapCanvas::setParallelRenderingEnabled( bool enabled )
656661
{
657662
mUseParallelRendering = enabled;

‎src/gui/qgsmapcanvas.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,20 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView, public QgsExpressionContex
187187

188188
/**
189189
* Set whether to cache images of rendered layers
190+
*
191+
* \see isCachingEnabled()
192+
* \see cache()
193+
*
190194
* \since QGIS 2.4
191195
*/
192196
void setCachingEnabled( bool enabled );
193197

194198
/**
195199
* Check whether images of rendered layers are curerently being cached
200+
*
201+
* \see setCachingEnabled()
202+
* \see cache()
203+
*
196204
* \since QGIS 2.4
197205
*/
198206
bool isCachingEnabled() const;
@@ -203,6 +211,16 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView, public QgsExpressionContex
203211
*/
204212
void clearCache();
205213

214+
/**
215+
* Returns the map renderer cache, if caching is enabled.
216+
*
217+
* \see isCachingEnabled()
218+
* \see setCachingEnabled()
219+
*
220+
* \since QGIS 3.32
221+
*/
222+
QgsMapRendererCache *cache();
223+
206224
/**
207225
* Cancel any rendering job, in a blocking way. Used for application closing.
208226
* \note not available in Python bindings

0 commit comments

Comments
 (0)
Please sign in to comment.