QGIS API Documentation  3.9.0-Master (224899f119)
qgsrendercontext.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrendercontext.cpp
3  --------------------
4  begin : March 16, 2008
5  copyright : (C) 2008 by Marco Hugentobler
6  email : marco dot hugentobler at karto dot baug dot ethz dot ch
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 
19 #include "qgsrendercontext.h"
20 
21 #include "qgsmapsettings.h"
22 #include "qgsexpression.h"
23 #include "qgsvectorlayer.h"
25 #include "qgslogger.h"
26 #include "qgspoint.h"
27 
28 #define POINTS_TO_MM 2.83464567
29 #define INCH_TO_MM 25.4
30 
32  : mFlags( DrawEditingInfo | UseAdvancedEffects | DrawSelection | UseRenderingOptimization )
33 {
35  // For RenderMetersInMapUnits support, when rendering in Degrees, the Ellipsoid must be set
36  // - for Previews/Icons the default Extent can be used
37  mDistanceArea.setEllipsoid( mDistanceArea.sourceCrs().ellipsoidAcronym() );
38 }
39 
41  : mFlags( rh.mFlags )
42  , mPainter( rh.mPainter )
43  , mCoordTransform( rh.mCoordTransform )
44  , mDistanceArea( rh.mDistanceArea )
45  , mExtent( rh.mExtent )
46  , mOriginalMapExtent( rh.mOriginalMapExtent )
47  , mMapToPixel( rh.mMapToPixel )
48  , mRenderingStopped( rh.mRenderingStopped )
49  , mScaleFactor( rh.mScaleFactor )
50  , mRendererScale( rh.mRendererScale )
51  , mLabelingEngine( rh.mLabelingEngine )
52  , mSelectionColor( rh.mSelectionColor )
53  , mVectorSimplifyMethod( rh.mVectorSimplifyMethod )
54  , mExpressionContext( rh.mExpressionContext )
55  , mGeometry( rh.mGeometry )
56  , mFeatureFilterProvider( rh.mFeatureFilterProvider ? rh.mFeatureFilterProvider->clone() : nullptr )
57  , mSegmentationTolerance( rh.mSegmentationTolerance )
58  , mSegmentationToleranceType( rh.mSegmentationToleranceType )
59  , mTransformContext( rh.mTransformContext )
60  , mPathResolver( rh.mPathResolver )
61  , mTextRenderFormat( rh.mTextRenderFormat )
62  , mRenderedFeatureHandlers( rh.mRenderedFeatureHandlers )
63  , mHasRenderedFeatureHandlers( rh.mHasRenderedFeatureHandlers )
64 #ifdef QGISDEBUG
65  , mHasTransformContext( rh.mHasTransformContext )
66 #endif
67 {
68 }
69 
71 {
72  mFlags = rh.mFlags;
73  mPainter = rh.mPainter;
74  mCoordTransform = rh.mCoordTransform;
75  mExtent = rh.mExtent;
76  mOriginalMapExtent = rh.mOriginalMapExtent;
77  mMapToPixel = rh.mMapToPixel;
78  mRenderingStopped = rh.mRenderingStopped;
79  mScaleFactor = rh.mScaleFactor;
80  mRendererScale = rh.mRendererScale;
81  mLabelingEngine = rh.mLabelingEngine;
82  mSelectionColor = rh.mSelectionColor;
83  mVectorSimplifyMethod = rh.mVectorSimplifyMethod;
84  mExpressionContext = rh.mExpressionContext;
85  mGeometry = rh.mGeometry;
86  mFeatureFilterProvider.reset( rh.mFeatureFilterProvider ? rh.mFeatureFilterProvider->clone() : nullptr );
87  mSegmentationTolerance = rh.mSegmentationTolerance;
88  mSegmentationToleranceType = rh.mSegmentationToleranceType;
89  mDistanceArea = rh.mDistanceArea;
90  mTransformContext = rh.mTransformContext;
91  mPathResolver = rh.mPathResolver;
92  mTextRenderFormat = rh.mTextRenderFormat;
93  mRenderedFeatureHandlers = rh.mRenderedFeatureHandlers;
94  mHasRenderedFeatureHandlers = rh.mHasRenderedFeatureHandlers;
95 #ifdef QGISDEBUG
96  mHasTransformContext = rh.mHasTransformContext;
97 #endif
98 
99  return *this;
100 }
101 
103 {
104  QgsRenderContext context;
105  context.setPainter( painter );
106  if ( painter && painter->device() )
107  {
108  context.setScaleFactor( painter->device()->logicalDpiX() / 25.4 );
109  }
110  else
111  {
112  context.setScaleFactor( 3.465 ); //assume 88 dpi as standard value
113  }
114  if ( painter && painter->renderHints() & QPainter::Antialiasing )
115  {
116  context.setFlag( QgsRenderContext::Antialiasing, true );
117  }
118  return context;
119 }
120 
122 {
123 #ifdef QGISDEBUG
124  if ( !mHasTransformContext )
125  QgsDebugMsgLevel( QStringLiteral( "No QgsCoordinateTransformContext context set for transform" ), 4 );
126 #endif
127  return mTransformContext;
128 }
129 
131 {
132  mTransformContext = context;
133 #ifdef QGISDEBUG
134  mHasTransformContext = true;
135 #endif
136 }
137 
138 void QgsRenderContext::setFlags( QgsRenderContext::Flags flags )
139 {
140  mFlags = flags;
141 }
142 
144 {
145  if ( on )
146  mFlags |= flag;
147  else
148  mFlags &= ~flag;
149 }
150 
151 QgsRenderContext::Flags QgsRenderContext::flags() const
152 {
153  return mFlags;
154 }
155 
157 {
158  return mFlags.testFlag( flag );
159 }
160 
162 {
163  QgsRenderContext ctx;
164  QgsRectangle extent = mapSettings.visibleExtent();
165  extent.grow( mapSettings.extentBuffer() );
166  ctx.setMapToPixel( mapSettings.mapToPixel() );
167  ctx.setExtent( extent );
168  ctx.setMapExtent( mapSettings.visibleExtent() );
174  ctx.setSelectionColor( mapSettings.selectionColor() );
181  ctx.setScaleFactor( mapSettings.outputDpi() / 25.4 ); // = pixels per mm
182  ctx.setRendererScale( mapSettings.scale() );
183  ctx.setExpressionContext( mapSettings.expressionContext() );
184  ctx.setSegmentationTolerance( mapSettings.segmentationTolerance() );
186  ctx.mDistanceArea.setSourceCrs( mapSettings.destinationCrs(), mapSettings.transformContext() );
187  ctx.mDistanceArea.setEllipsoid( mapSettings.ellipsoid() );
188  ctx.setTransformContext( mapSettings.transformContext() );
189  ctx.setPathResolver( mapSettings.pathResolver() );
190  ctx.setTextRenderFormat( mapSettings.textRenderFormat() );
191  ctx.setVectorSimplifyMethod( mapSettings.simplifyMethod() );
192  ctx.mRenderedFeatureHandlers = mapSettings.renderedFeatureHandlers();
193  ctx.mHasRenderedFeatureHandlers = !mapSettings.renderedFeatureHandlers().isEmpty();
194  //this flag is only for stopping during the current rendering progress,
195  //so must be false at every new render operation
196  ctx.setRenderingStopped( false );
197 
198  return ctx;
199 }
200 
202 {
203  return mFlags.testFlag( ForceVectorOutput );
204 }
205 
207 {
208  return mFlags.testFlag( UseAdvancedEffects );
209 }
210 
212 {
213  setFlag( UseAdvancedEffects, enabled );
214 }
215 
217 {
218  return mFlags.testFlag( DrawEditingInfo );
219 }
220 
222 {
223  return mFlags.testFlag( DrawSelection );
224 }
225 
227 {
228  mCoordTransform = t;
229 }
230 
232 {
233  setFlag( DrawEditingInfo, b );
234 }
235 
237 {
238  setFlag( ForceVectorOutput, force );
239 }
240 
242 {
243  setFlag( DrawSelection, showSelection );
244 }
245 
247 {
248  return mFlags.testFlag( UseRenderingOptimization );
249 }
250 
252 {
253  setFlag( UseRenderingOptimization, enabled );
254 }
255 
257 {
258  if ( ffp )
259  {
260  mFeatureFilterProvider.reset( ffp->clone() );
261  }
262  else
263  {
264  mFeatureFilterProvider.reset( nullptr );
265  }
266 }
267 
269 {
270  return mFeatureFilterProvider.get();
271 }
272 
274 {
275  double conversionFactor = 1.0;
276  switch ( unit )
277  {
279  conversionFactor = mScaleFactor;
280  break;
281 
283  conversionFactor = mScaleFactor / POINTS_TO_MM;
284  break;
285 
287  conversionFactor = mScaleFactor * INCH_TO_MM;
288  break;
289 
291  {
292  size = convertMetersToMapUnits( size );
294  // Fall through to RenderMapUnits with size in meters converted to size in MapUnits
296  }
298  {
299  double mup = scale.computeMapUnitsPerPixel( *this );
300  if ( mup > 0 )
301  {
302  conversionFactor = 1.0 / mup;
303  }
304  else
305  {
306  conversionFactor = 1.0;
307  }
308  break;
309  }
311  conversionFactor = 1.0;
312  break;
313 
316  //no sensible value
317  conversionFactor = 1.0;
318  break;
319  }
320 
321  double convertedSize = size * conversionFactor;
322 
323  if ( unit == QgsUnitTypes::RenderMapUnits )
324  {
325  //check max/min size
326  if ( scale.minSizeMMEnabled )
327  convertedSize = std::max( convertedSize, scale.minSizeMM * mScaleFactor );
328  if ( scale.maxSizeMMEnabled )
329  convertedSize = std::min( convertedSize, scale.maxSizeMM * mScaleFactor );
330  }
331 
332  return convertedSize;
333 }
334 
335 double QgsRenderContext::convertToMapUnits( double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale ) const
336 {
337  double mup = mMapToPixel.mapUnitsPerPixel();
338 
339  switch ( unit )
340  {
342  {
343  size = convertMetersToMapUnits( size );
344  // Fall through to RenderMapUnits with values of meters converted to MapUnits
346  }
348  {
349  // check scale
350  double minSizeMU = std::numeric_limits<double>::lowest();
351  if ( scale.minSizeMMEnabled )
352  {
353  minSizeMU = scale.minSizeMM * mScaleFactor * mup;
354  }
355  if ( !qgsDoubleNear( scale.minScale, 0.0 ) )
356  {
357  minSizeMU = std::max( minSizeMU, size * ( mRendererScale / scale.minScale ) );
358  }
359  size = std::max( size, minSizeMU );
360 
361  double maxSizeMU = std::numeric_limits<double>::max();
362  if ( scale.maxSizeMMEnabled )
363  {
364  maxSizeMU = scale.maxSizeMM * mScaleFactor * mup;
365  }
366  if ( !qgsDoubleNear( scale.maxScale, 0.0 ) )
367  {
368  maxSizeMU = std::min( maxSizeMU, size * ( mRendererScale / scale.maxScale ) );
369  }
370  size = std::min( size, maxSizeMU );
371 
372  return size;
373  }
375  {
376  return size * mScaleFactor * mup;
377  }
379  {
380  return size * mScaleFactor * mup / POINTS_TO_MM;
381  }
383  {
384  return size * mScaleFactor * mup * INCH_TO_MM;
385  }
387  {
388  return size * mup;
389  }
390 
393  //no sensible value
394  return 0.0;
395  }
396  return 0.0;
397 }
398 
399 double QgsRenderContext::convertFromMapUnits( double sizeInMapUnits, QgsUnitTypes::RenderUnit outputUnit ) const
400 {
401  double mup = mMapToPixel.mapUnitsPerPixel();
402 
403  switch ( outputUnit )
404  {
406  {
407  return sizeInMapUnits / convertMetersToMapUnits( 1.0 );
408  }
410  {
411  return sizeInMapUnits;
412  }
414  {
415  return sizeInMapUnits / ( mScaleFactor * mup );
416  }
418  {
419  return sizeInMapUnits / ( mScaleFactor * mup / POINTS_TO_MM );
420  }
422  {
423  return sizeInMapUnits / ( mScaleFactor * mup * INCH_TO_MM );
424  }
426  {
427  return sizeInMapUnits / mup;
428  }
429 
432  //no sensible value
433  return 0.0;
434  }
435  return 0.0;
436 }
437 
438 double QgsRenderContext::convertMetersToMapUnits( double meters ) const
439 {
440  switch ( mDistanceArea.sourceCrs().mapUnits() )
441  {
443  return meters;
445  {
446  QgsPointXY pointCenter = mExtent.center();
447  // The Extent is in the sourceCrs(), when different from destinationCrs()
448  // - the point must be transformed, since DistanceArea uses the destinationCrs()
449  // Note: the default QgsCoordinateTransform() : authid() will return an empty String
450  if ( !mCoordTransform.isShortCircuited() )
451  {
452  pointCenter = mCoordTransform.transform( pointCenter );
453  }
454  return mDistanceArea.measureLineProjected( pointCenter, meters );
455  }
464  return ( meters * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::DistanceMeters, mDistanceArea.sourceCrs().mapUnits() ) );
465  }
466  return meters;
467 }
468 
469 QList<QgsRenderedFeatureHandlerInterface *> QgsRenderContext::renderedFeatureHandlers() const
470 {
471  return mRenderedFeatureHandlers;
472 }
473 
474 
void setForceVectorOutput(bool force)
Sets whether rendering operations should use vector operations instead of any faster raster shortcuts...
Meters value as Map units.
Definition: qgsunittypes.h:122
double convertToMapUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to map units.
Enable layer opacity and blending effects.
void setRenderingStopped(bool stopped)
Sets whether the rendering operation has been stopped and any ongoing rendering should be canceled im...
A rectangle specified with double values.
Definition: qgsrectangle.h:41
double minSizeMM
The minimum size in millimeters, or 0.0 if unset.
Enable vector simplification and other rendering optimizations.
virtual QgsFeatureFilterProvider * clone() const =0
Create a clone of the feature filter provider.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
const QgsExpressionContext & expressionContext() const
Gets the expression context.
QgsCoordinateTransformContext transformContext() const
Returns the context&#39;s coordinate transform context, which stores various information regarding which ...
void setFlags(QgsRenderContext::Flags flags)
Set combination of flags that will be used for rendering.
Use antialiasing while drawing.
double convertFromMapUnits(double sizeInMapUnits, QgsUnitTypes::RenderUnit outputUnit) const
Converts a size from map units to the specified units.
void setCoordinateTransform(const QgsCoordinateTransform &t)
Sets the current coordinate transform for the context.
QgsPointXY transform(const QgsPointXY &point, TransformDirection direction=ForwardTransform) const SIP_THROW(QgsCsException)
Transform the point from the source CRS to the destination CRS.
A class to represent a 2D point.
Definition: qgspointxy.h:43
QList< QgsRenderedFeatureHandlerInterface * > renderedFeatureHandlers() const
Returns the list of rendered feature handlers to use while rendering map layers.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:265
void setSimplifyHints(SimplifyHints simplifyHints)
Sets the simplification hints of the vector layer managed.
void setRendererScale(double scale)
Sets the renderer map scale.
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
void setPathResolver(const QgsPathResolver &resolver)
Sets the path resolver for conversion between relative and absolute paths during rendering operations...
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the context&#39;s coordinate transform context, which stores various information regarding which dat...
double computeMapUnitsPerPixel(const QgsRenderContext &c) const
Computes a map units per pixel scaling factor, respecting the minimum and maximum scales set for the ...
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Sets the simplification setting to use when rendering vector layers.
Mixed or unknown units.
Definition: qgsunittypes.h:121
Flags flags() const
Returns combination of flags used for rendering.
bool setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid by its acronym.
Percentage of another measurement (e.g., canvas size, feature size)
Definition: qgsunittypes.h:118
Enable layer opacity and blending effects.
void setTextRenderFormat(TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
Whether vector selections should be shown in the rendered map.
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes takes output image size into accou...
double maxScale
The maximum scale, or 0.0 if unset.
const QgsFeatureFilterProvider * featureFilterProvider() const
Gets the filter feature provider used for additional filtering of rendered features.
void setMapExtent(const QgsRectangle &extent)
Sets the original extent of the map being rendered.
bool minSizeMMEnabled
Whether the minimum size in mm should be respected.
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
Vector graphics should not be cached and drawn as raster images.
The QgsMapSettings class contains configuration for rendering of the map.
double convertMetersToMapUnits(double meters) const
Convert meter distances to active MapUnit values for QgsUnitTypes::RenderMetersInMapUnits.
void setSelectionColor(const QColor &color)
Sets the color to use when rendering selected features.
No simplification can be applied.
QString ellipsoidAcronym() const
Returns the ellipsoid acronym for the ellipsoid used by the CRS.
void setUseAdvancedEffects(bool enabled)
Used to enable or disable advanced effects such as blend modes.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings to use when rendering vector layers.
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
#define FALLTHROUGH
Definition: qgis.h:666
QgsRenderContext & operator=(const QgsRenderContext &rh)
#define INCH_TO_MM
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
void grow(double delta)
Grows the rectangle in place by the specified amount.
Definition: qgsrectangle.h:275
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
bool isShortCircuited() const
Returns true if the transform short circuits because the source and destination are equivalent...
Whether vector selections should be shown in the rendered map.
double scale() const
Returns the calculated map scale.
void setDrawEditingInformation(bool b)
Sets whether edit markers should be drawn during the render operation.
Enable anti-aliasing for map rendering.
static QgsRenderContext fromQPainter(QPainter *painter)
Creates a default render context given a pixel based QPainter destination.
QList< QgsRenderedFeatureHandlerInterface *> renderedFeatureHandlers() const
Returns the list of rendered feature handlers to use while rendering the map settings.
bool drawEditingInformation() const
Returns true if edit markers should be drawn during the render operation.
double extentBuffer() const
Returns the buffer in map units to use around the visible extent for rendering symbols whose correspo...
Draw bounds of symbols (for debugging/testing)
Degrees, for planar geographic CRS distance measurements.
Definition: qgsunittypes.h:62
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
Abstract interface for use by classes that filter the features of a layer.
void setSegmentationToleranceType(QgsAbstractGeometry::SegmentationToleranceType type)
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
Contains information about the context in which a coordinate transform is executed.
double mapUnitsPerPixel() const
Returns current map units per pixel.
const QgsMapToPixel & mapToPixel() const
Draw bounds of symbols (for debugging/testing)
Vector graphics should not be cached and drawn as raster images.
Enable drawing of vertex markers for layers in editing mode.
QgsAbstractGeometry::SegmentationToleranceType segmentationToleranceType() const
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
bool forceVectorOutput() const
Returns true if rendering operations should use vector operations instead of any faster raster shortc...
QgsCoordinateReferenceSystem sourceCrs() const
Returns the source spatial reference system.
void setSegmentationTolerance(double tolerance)
Sets the segmentation tolerance applied when rendering curved geometries.
bool useRenderingOptimization() const
Returns true if the rendering optimization (geometry simplification) can be executed.
Draw map such that there are no problems between adjacent tiles.
Unknown distance unit.
Definition: qgsunittypes.h:65
Render is a &#39;canvas preview&#39; render, and shortcuts should be taken to ensure fast rendering...
double outputDpi() const
Returns DPI used for conversion between real world units (e.g.
Render is a &#39;canvas preview&#39; render, and shortcuts should be taken to ensure fast rendering...
Contains information about the context of a rendering operation.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
#define POINTS_TO_MM
QString ellipsoid() const
Returns ellipsoid&#39;s acronym.
double segmentationTolerance() const
Gets the segmentation tolerance applied when rendering curved geometries.
QPainter * painter()
Returns the destination QPainter for the render operation.
double maxSizeMM
The maximum size in millimeters, or 0.0 if unset.
Points (e.g., for font sizes)
Definition: qgsunittypes.h:119
void setShowSelection(bool showSelection)
Sets whether vector selections should be shown in the rendered map.
Struct for storing maximum and minimum scales for measurements in map units.
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
double measureLineProjected(const QgsPointXY &p1, double distance=1, double azimuth=M_PI_2, QgsPointXY *projectedPoint=nullptr) const
Calculates the distance from one point with distance in meters and azimuth (direction) When the sourc...
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context&#39;s map to pixel transform, which transforms between map coordinates and device coordi...
Class for doing transforms between two map coordinate systems.
void setUseRenderingOptimization(bool enabled)
bool showSelection() const
Returns true if vector selections should be shown in the rendered map.
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
void setFeatureFilterProvider(const QgsFeatureFilterProvider *ffp)
Set a filter feature provider used for additional filtering of rendered features. ...
Enable vector simplification and other rendering optimizations.
void setSourceCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets source spatial reference system crs.
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
QgsRenderContext::TextRenderFormat textRenderFormat() const
Returns the text render format, which dictates how text is rendered (e.g.
QColor selectionColor() const
Gets color that is used for drawing of selected vector features.
QgsPointXY center() const
Returns the center point of the rectangle.
Definition: qgsrectangle.h:230
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
Terrestrial miles.
Definition: qgsunittypes.h:61
Draw map such that there are no problems between adjacent tiles.
Flag
Enumeration of flags that affect rendering operations.
static Q_INVOKABLE double fromUnitToUnitFactor(QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
Enable drawing of vertex markers for layers in editing mode.
double minScale
The minimum scale, or 0.0 if unset.
bool maxSizeMMEnabled
Whether the maximum size in mm should be respected.
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:113
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.