2727#include " qgsrectangle.h"
2828#include " qgsvectorsimplifymethod.h"
2929#include " qgsexpressioncontext.h"
30+ #include " qgsfeaturefilterprovider.h"
3031
3132class QPainter ;
32-
3333class QgsAbstractGeometry ;
3434class QgsLabelingEngine ;
3535class QgsMapSettings ;
36- class QgsFeatureFilterProvider ;
3736
3837
3938/* * \ingroup core
@@ -50,8 +49,6 @@ class CORE_EXPORT QgsRenderContext
5049 QgsRenderContext ( const QgsRenderContext& rh );
5150 QgsRenderContext& operator =( const QgsRenderContext& rh );
5251
53- ~QgsRenderContext ();
54-
5552 /* * Enumeration of flags that affect rendering operations.
5653 * @note added in QGIS 2.14
5754 */
@@ -103,6 +100,10 @@ class CORE_EXPORT QgsRenderContext
103100
104101 // getters
105102
103+ /* *
104+ * Returns the destination QPainter for the render operation.
105+ * @see setPainter()
106+ */
106107 QPainter* painter () {return mPainter ;}
107108 const QPainter* constPainter () const { return mPainter ; }
108109
@@ -115,6 +116,12 @@ class CORE_EXPORT QgsRenderContext
115116
116117 const QgsMapToPixel& mapToPixel () const {return mMapToPixel ;}
117118
119+ /* *
120+ * Returns the scaling factor for the render to convert painter units
121+ * to physical sizes. This is usually equal to the number of pixels
122+ * per millimeter.
123+ * @see setScaleFactor()
124+ */
118125 double scaleFactor () const {return mScaleFactor ;}
119126
120127 bool renderingStopped () const {return mRenderingStopped ;}
@@ -131,6 +138,11 @@ class CORE_EXPORT QgsRenderContext
131138
132139 bool drawEditingInformation () const ;
133140
141+ /* *
142+ * Returns the renderer map scale. This will match the desired scale denominator
143+ * for the rendered map, eg 1000.0 for a 1:1000 map render.
144+ * @see setRendererScale()
145+ */
134146 double rendererScale () const {return mRendererScale ;}
135147
136148 // ! Get access to new labeling engine (may be nullptr)
@@ -157,8 +169,28 @@ class CORE_EXPORT QgsRenderContext
157169 void setDrawEditingInformation ( bool b );
158170
159171 void setRenderingStopped ( bool stopped ) {mRenderingStopped = stopped;}
172+
173+ /* *
174+ * Sets the scaling factor for the render to convert painter units
175+ * to physical sizes. This should usually be equal to the number of pixels
176+ * per millimeter.
177+ * @see scaleFactor()
178+ */
160179 void setScaleFactor ( double factor ) {mScaleFactor = factor;}
180+
181+ /* *
182+ * Sets the renderer map scale. This should match the desired scale denominator
183+ * for the rendered map, eg 1000.0 for a 1:1000 map render.
184+ * @see rendererScale()
185+ */
161186 void setRendererScale ( double scale ) {mRendererScale = scale;}
187+
188+ /* *
189+ * Sets the destination QPainter for the render operation. Ownership of the painter
190+ * is not transferred and the QPainter destination must stay alive for the duration
191+ * of any rendering operations.
192+ * @see painter()
193+ */
162194 void setPainter ( QPainter* p ) {mPainter = p;}
163195
164196 void setForceVectorOutput ( bool force );
@@ -225,7 +257,7 @@ class CORE_EXPORT QgsRenderContext
225257 * @note added in QGIS 2.14
226258 * @see setFeatureFilterProvider()
227259 */
228- const QgsFeatureFilterProvider* featureFilterProvider () const { return mFeatureFilterProvider ; }
260+ const QgsFeatureFilterProvider* featureFilterProvider () const ;
229261
230262 /* * Sets the segmentation tolerance applied when rendering curved geometries
231263 @param tolerance the segmentation tolerance*/
@@ -244,7 +276,7 @@ class CORE_EXPORT QgsRenderContext
244276 Flags mFlags ;
245277
246278 // ! Painter for rendering operations
247- QPainter* mPainter ;
279+ QPainter* mPainter = nullptr ;
248280
249281 // ! For transformation between coordinate systems. Can be invalid if on-the-fly reprojection is not used
250282 QgsCoordinateTransform mCoordTransform ;
@@ -254,16 +286,16 @@ class CORE_EXPORT QgsRenderContext
254286 QgsMapToPixel mMapToPixel ;
255287
256288 // ! True if the rendering has been canceled
257- bool mRenderingStopped ;
289+ bool mRenderingStopped = false ;
258290
259291 // ! Factor to scale line widths and point marker sizes
260- double mScaleFactor ;
292+ double mScaleFactor = 1.0 ;
261293
262294 // ! Map scale
263- double mRendererScale ;
295+ double mRendererScale = 1.0 ;
264296
265297 // ! Newer labeling engine implementation (can be nullptr)
266- QgsLabelingEngine* mLabelingEngine ;
298+ QgsLabelingEngine* mLabelingEngine = nullptr ;
267299
268300 // ! Color used for features that are marked as selected
269301 QColor mSelectionColor ;
@@ -275,14 +307,14 @@ class CORE_EXPORT QgsRenderContext
275307 QgsExpressionContext mExpressionContext ;
276308
277309 // ! Pointer to the (unsegmentized) geometry
278- const QgsAbstractGeometry* mGeometry ;
310+ const QgsAbstractGeometry* mGeometry = nullptr ;
279311
280312 // ! The feature filter provider
281- const QgsFeatureFilterProvider* mFeatureFilterProvider ;
313+ QScopedPointer< QgsFeatureFilterProvider > mFeatureFilterProvider ;
282314
283- double mSegmentationTolerance ;
315+ double mSegmentationTolerance = M_PI_2 / 90 ;
284316
285- QgsAbstractGeometry::SegmentationToleranceType mSegmentationToleranceType ;
317+ QgsAbstractGeometry::SegmentationToleranceType mSegmentationToleranceType = QgsAbstractGeometry::MaximumAngle ;
286318};
287319
288320Q_DECLARE_OPERATORS_FOR_FLAGS ( QgsRenderContext::Flags )
0 commit comments