27
27
#include " qgsrectangle.h"
28
28
#include " qgsvectorsimplifymethod.h"
29
29
#include " qgsexpressioncontext.h"
30
+ #include " qgsfeaturefilterprovider.h"
30
31
31
32
class QPainter ;
32
-
33
33
class QgsAbstractGeometry ;
34
34
class QgsLabelingEngine ;
35
35
class QgsMapSettings ;
36
- class QgsFeatureFilterProvider ;
37
36
38
37
39
38
/* * \ingroup core
@@ -50,8 +49,6 @@ class CORE_EXPORT QgsRenderContext
50
49
QgsRenderContext ( const QgsRenderContext& rh );
51
50
QgsRenderContext& operator =( const QgsRenderContext& rh );
52
51
53
- ~QgsRenderContext ();
54
-
55
52
/* * Enumeration of flags that affect rendering operations.
56
53
* @note added in QGIS 2.14
57
54
*/
@@ -103,6 +100,10 @@ class CORE_EXPORT QgsRenderContext
103
100
104
101
// getters
105
102
103
+ /* *
104
+ * Returns the destination QPainter for the render operation.
105
+ * @see setPainter()
106
+ */
106
107
QPainter* painter () {return mPainter ;}
107
108
const QPainter* constPainter () const { return mPainter ; }
108
109
@@ -115,6 +116,12 @@ class CORE_EXPORT QgsRenderContext
115
116
116
117
const QgsMapToPixel& mapToPixel () const {return mMapToPixel ;}
117
118
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
+ */
118
125
double scaleFactor () const {return mScaleFactor ;}
119
126
120
127
bool renderingStopped () const {return mRenderingStopped ;}
@@ -131,6 +138,11 @@ class CORE_EXPORT QgsRenderContext
131
138
132
139
bool drawEditingInformation () const ;
133
140
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
+ */
134
146
double rendererScale () const {return mRendererScale ;}
135
147
136
148
// ! Get access to new labeling engine (may be nullptr)
@@ -157,8 +169,28 @@ class CORE_EXPORT QgsRenderContext
157
169
void setDrawEditingInformation ( bool b );
158
170
159
171
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
+ */
160
179
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
+ */
161
186
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
+ */
162
194
void setPainter ( QPainter* p ) {mPainter = p;}
163
195
164
196
void setForceVectorOutput ( bool force );
@@ -225,7 +257,7 @@ class CORE_EXPORT QgsRenderContext
225
257
* @note added in QGIS 2.14
226
258
* @see setFeatureFilterProvider()
227
259
*/
228
- const QgsFeatureFilterProvider* featureFilterProvider () const { return mFeatureFilterProvider ; }
260
+ const QgsFeatureFilterProvider* featureFilterProvider () const ;
229
261
230
262
/* * Sets the segmentation tolerance applied when rendering curved geometries
231
263
@param tolerance the segmentation tolerance*/
@@ -244,7 +276,7 @@ class CORE_EXPORT QgsRenderContext
244
276
Flags mFlags ;
245
277
246
278
// ! Painter for rendering operations
247
- QPainter* mPainter ;
279
+ QPainter* mPainter = nullptr ;
248
280
249
281
// ! For transformation between coordinate systems. Can be invalid if on-the-fly reprojection is not used
250
282
QgsCoordinateTransform mCoordTransform ;
@@ -254,16 +286,16 @@ class CORE_EXPORT QgsRenderContext
254
286
QgsMapToPixel mMapToPixel ;
255
287
256
288
// ! True if the rendering has been canceled
257
- bool mRenderingStopped ;
289
+ bool mRenderingStopped = false ;
258
290
259
291
// ! Factor to scale line widths and point marker sizes
260
- double mScaleFactor ;
292
+ double mScaleFactor = 1.0 ;
261
293
262
294
// ! Map scale
263
- double mRendererScale ;
295
+ double mRendererScale = 1.0 ;
264
296
265
297
// ! Newer labeling engine implementation (can be nullptr)
266
- QgsLabelingEngine* mLabelingEngine ;
298
+ QgsLabelingEngine* mLabelingEngine = nullptr ;
267
299
268
300
// ! Color used for features that are marked as selected
269
301
QColor mSelectionColor ;
@@ -275,14 +307,14 @@ class CORE_EXPORT QgsRenderContext
275
307
QgsExpressionContext mExpressionContext ;
276
308
277
309
// ! Pointer to the (unsegmentized) geometry
278
- const QgsAbstractGeometry* mGeometry ;
310
+ const QgsAbstractGeometry* mGeometry = nullptr ;
279
311
280
312
// ! The feature filter provider
281
- const QgsFeatureFilterProvider* mFeatureFilterProvider ;
313
+ QScopedPointer< QgsFeatureFilterProvider > mFeatureFilterProvider ;
282
314
283
- double mSegmentationTolerance ;
315
+ double mSegmentationTolerance = M_PI_2 / 90 ;
284
316
285
- QgsAbstractGeometry::SegmentationToleranceType mSegmentationToleranceType ;
317
+ QgsAbstractGeometry::SegmentationToleranceType mSegmentationToleranceType = QgsAbstractGeometry::MaximumAngle ;
286
318
};
287
319
288
320
Q_DECLARE_OPERATORS_FOR_FLAGS ( QgsRenderContext::Flags )
0 commit comments