QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
42  , mFlags( rh.mFlags )
43  , mPainter( rh.mPainter )
44  , mMaskPainter( rh.mMaskPainter )
45  , mCoordTransform( rh.mCoordTransform )
46  , mDistanceArea( rh.mDistanceArea )
47  , mExtent( rh.mExtent )
48  , mOriginalMapExtent( rh.mOriginalMapExtent )
49  , mMapToPixel( rh.mMapToPixel )
50  , mRenderingStopped( rh.mRenderingStopped )
51  , mScaleFactor( rh.mScaleFactor )
52  , mRendererScale( rh.mRendererScale )
53  , mLabelingEngine( rh.mLabelingEngine )
54  , mSelectionColor( rh.mSelectionColor )
55  , mVectorSimplifyMethod( rh.mVectorSimplifyMethod )
56  , mExpressionContext( rh.mExpressionContext )
57  , mGeometry( rh.mGeometry )
58  , mFeatureFilterProvider( rh.mFeatureFilterProvider ? rh.mFeatureFilterProvider->clone() : nullptr )
59  , mSegmentationTolerance( rh.mSegmentationTolerance )
60  , mSegmentationToleranceType( rh.mSegmentationToleranceType )
61  , mTransformContext( rh.mTransformContext )
62  , mPathResolver( rh.mPathResolver )
63  , mTextRenderFormat( rh.mTextRenderFormat )
64  , mRenderedFeatureHandlers( rh.mRenderedFeatureHandlers )
65  , mHasRenderedFeatureHandlers( rh.mHasRenderedFeatureHandlers )
66  , mCustomRenderingFlags( rh.mCustomRenderingFlags )
67  , mDisabledSymbolLayers()
68 #ifdef QGISDEBUG
69  , mHasTransformContext( rh.mHasTransformContext )
70 #endif
71 {
72 }
73 
75 {
76  mFlags = rh.mFlags;
77  mPainter = rh.mPainter;
78  mMaskPainter = rh.mMaskPainter;
79  mCoordTransform = rh.mCoordTransform;
80  mExtent = rh.mExtent;
81  mOriginalMapExtent = rh.mOriginalMapExtent;
82  mMapToPixel = rh.mMapToPixel;
83  mRenderingStopped = rh.mRenderingStopped;
84  mScaleFactor = rh.mScaleFactor;
85  mRendererScale = rh.mRendererScale;
86  mLabelingEngine = rh.mLabelingEngine;
87  mSelectionColor = rh.mSelectionColor;
88  mVectorSimplifyMethod = rh.mVectorSimplifyMethod;
89  mExpressionContext = rh.mExpressionContext;
90  mGeometry = rh.mGeometry;
91  mFeatureFilterProvider.reset( rh.mFeatureFilterProvider ? rh.mFeatureFilterProvider->clone() : nullptr );
92  mSegmentationTolerance = rh.mSegmentationTolerance;
93  mSegmentationToleranceType = rh.mSegmentationToleranceType;
94  mDistanceArea = rh.mDistanceArea;
95  mTransformContext = rh.mTransformContext;
96  mPathResolver = rh.mPathResolver;
97  mTextRenderFormat = rh.mTextRenderFormat;
98  mRenderedFeatureHandlers = rh.mRenderedFeatureHandlers;
99  mHasRenderedFeatureHandlers = rh.mHasRenderedFeatureHandlers;
100  mCustomRenderingFlags = rh.mCustomRenderingFlags;
101  setIsTemporal( rh.isTemporal() );
102  if ( isTemporal() )
104 #ifdef QGISDEBUG
105  mHasTransformContext = rh.mHasTransformContext;
106 #endif
107 
108  return *this;
109 }
110 
112 {
113  QgsRenderContext context;
114  context.setPainter( painter );
115  if ( painter && painter->device() )
116  {
117  context.setScaleFactor( painter->device()->logicalDpiX() / 25.4 );
118  }
119  else
120  {
121  context.setScaleFactor( 3.465 ); //assume 88 dpi as standard value
122  }
123  if ( painter && painter->renderHints() & QPainter::Antialiasing )
124  {
125  context.setFlag( QgsRenderContext::Antialiasing, true );
126  }
127  return context;
128 }
129 
131 {
132 #ifdef QGISDEBUG
133  if ( !mHasTransformContext )
134  QgsDebugMsgLevel( QStringLiteral( "No QgsCoordinateTransformContext context set for transform" ), 4 );
135 #endif
136  return mTransformContext;
137 }
138 
140 {
141  mTransformContext = context;
142 #ifdef QGISDEBUG
143  mHasTransformContext = true;
144 #endif
145 }
146 
147 void QgsRenderContext::setFlags( QgsRenderContext::Flags flags )
148 {
149  mFlags = flags;
150 }
151 
153 {
154  if ( on )
155  mFlags |= flag;
156  else
157  mFlags &= ~flag;
158 }
159 
160 QgsRenderContext::Flags QgsRenderContext::flags() const
161 {
162  return mFlags;
163 }
164 
166 {
167  return mFlags.testFlag( flag );
168 }
169 
171 {
172  QgsRenderContext ctx;
173  QgsRectangle extent = mapSettings.visibleExtent();
174  extent.grow( mapSettings.extentBuffer() );
175  ctx.setMapToPixel( mapSettings.mapToPixel() );
176  ctx.setExtent( extent );
177  ctx.setMapExtent( mapSettings.visibleExtent() );
183  ctx.setSelectionColor( mapSettings.selectionColor() );
191  ctx.setScaleFactor( mapSettings.outputDpi() / 25.4 ); // = pixels per mm
192  ctx.setRendererScale( mapSettings.scale() );
193  ctx.setExpressionContext( mapSettings.expressionContext() );
194  ctx.setSegmentationTolerance( mapSettings.segmentationTolerance() );
196  ctx.mDistanceArea.setSourceCrs( mapSettings.destinationCrs(), mapSettings.transformContext() );
197  ctx.mDistanceArea.setEllipsoid( mapSettings.ellipsoid() );
198  ctx.setTransformContext( mapSettings.transformContext() );
199  ctx.setPathResolver( mapSettings.pathResolver() );
200  ctx.setTextRenderFormat( mapSettings.textRenderFormat() );
201  ctx.setVectorSimplifyMethod( mapSettings.simplifyMethod() );
202  ctx.mRenderedFeatureHandlers = mapSettings.renderedFeatureHandlers();
203  ctx.mHasRenderedFeatureHandlers = !mapSettings.renderedFeatureHandlers().isEmpty();
204  //this flag is only for stopping during the current rendering progress,
205  //so must be false at every new render operation
206  ctx.setRenderingStopped( false );
207  ctx.mCustomRenderingFlags = mapSettings.customRenderingFlags();
208  ctx.setIsTemporal( mapSettings.isTemporal() );
209  if ( ctx.isTemporal() )
210  ctx.setTemporalRange( mapSettings.temporalRange() );
211 
212  return ctx;
213 }
214 
216 {
217  return mFlags.testFlag( ForceVectorOutput );
218 }
219 
221 {
222  return mFlags.testFlag( UseAdvancedEffects );
223 }
224 
226 {
227  setFlag( UseAdvancedEffects, enabled );
228 }
229 
231 {
232  return mFlags.testFlag( DrawEditingInfo );
233 }
234 
236 {
237  return mFlags.testFlag( DrawSelection );
238 }
239 
241 {
242  mCoordTransform = t;
243 }
244 
246 {
247  setFlag( DrawEditingInfo, b );
248 }
249 
251 {
252  setFlag( ForceVectorOutput, force );
253 }
254 
255 void QgsRenderContext::setShowSelection( const bool showSelection )
256 {
258 }
259 
261 {
262  return mFlags.testFlag( UseRenderingOptimization );
263 }
264 
266 {
267  setFlag( UseRenderingOptimization, enabled );
268 }
269 
271 {
272  if ( ffp )
273  {
274  mFeatureFilterProvider.reset( ffp->clone() );
275  }
276  else
277  {
278  mFeatureFilterProvider.reset( nullptr );
279  }
280 }
281 
283 {
284  return mFeatureFilterProvider.get();
285 }
286 
288 {
289  double conversionFactor = 1.0;
290  switch ( unit )
291  {
293  conversionFactor = mScaleFactor;
294  break;
295 
297  conversionFactor = mScaleFactor / POINTS_TO_MM;
298  break;
299 
301  conversionFactor = mScaleFactor * INCH_TO_MM;
302  break;
303 
305  {
306  size = convertMetersToMapUnits( size );
308  // Fall through to RenderMapUnits with size in meters converted to size in MapUnits
310  }
312  {
313  double mup = scale.computeMapUnitsPerPixel( *this );
314  if ( mup > 0 )
315  {
316  conversionFactor = 1.0 / mup;
317  }
318  else
319  {
320  conversionFactor = 1.0;
321  }
322  break;
323  }
325  conversionFactor = 1.0;
326  break;
327 
330  //no sensible value
331  conversionFactor = 1.0;
332  break;
333  }
334 
335  double convertedSize = size * conversionFactor;
336 
337  if ( unit == QgsUnitTypes::RenderMapUnits )
338  {
339  //check max/min size
340  if ( scale.minSizeMMEnabled )
341  convertedSize = std::max( convertedSize, scale.minSizeMM * mScaleFactor );
342  if ( scale.maxSizeMMEnabled )
343  convertedSize = std::min( convertedSize, scale.maxSizeMM * mScaleFactor );
344  }
345 
346  return convertedSize;
347 }
348 
349 double QgsRenderContext::convertToMapUnits( double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale ) const
350 {
351  double mup = mMapToPixel.mapUnitsPerPixel();
352 
353  switch ( unit )
354  {
356  {
357  size = convertMetersToMapUnits( size );
358  // Fall through to RenderMapUnits with values of meters converted to MapUnits
360  }
362  {
363  // check scale
364  double minSizeMU = std::numeric_limits<double>::lowest();
365  if ( scale.minSizeMMEnabled )
366  {
367  minSizeMU = scale.minSizeMM * mScaleFactor * mup;
368  }
369  if ( !qgsDoubleNear( scale.minScale, 0.0 ) )
370  {
371  minSizeMU = std::max( minSizeMU, size * ( mRendererScale / scale.minScale ) );
372  }
373  size = std::max( size, minSizeMU );
374 
375  double maxSizeMU = std::numeric_limits<double>::max();
376  if ( scale.maxSizeMMEnabled )
377  {
378  maxSizeMU = scale.maxSizeMM * mScaleFactor * mup;
379  }
380  if ( !qgsDoubleNear( scale.maxScale, 0.0 ) )
381  {
382  maxSizeMU = std::min( maxSizeMU, size * ( mRendererScale / scale.maxScale ) );
383  }
384  size = std::min( size, maxSizeMU );
385 
386  return size;
387  }
389  {
390  return size * mScaleFactor * mup;
391  }
393  {
394  return size * mScaleFactor * mup / POINTS_TO_MM;
395  }
397  {
398  return size * mScaleFactor * mup * INCH_TO_MM;
399  }
401  {
402  return size * mup;
403  }
404 
407  //no sensible value
408  return 0.0;
409  }
410  return 0.0;
411 }
412 
413 double QgsRenderContext::convertFromMapUnits( double sizeInMapUnits, QgsUnitTypes::RenderUnit outputUnit ) const
414 {
415  double mup = mMapToPixel.mapUnitsPerPixel();
416 
417  switch ( outputUnit )
418  {
420  {
421  return sizeInMapUnits / convertMetersToMapUnits( 1.0 );
422  }
424  {
425  return sizeInMapUnits;
426  }
428  {
429  return sizeInMapUnits / ( mScaleFactor * mup );
430  }
432  {
433  return sizeInMapUnits / ( mScaleFactor * mup / POINTS_TO_MM );
434  }
436  {
437  return sizeInMapUnits / ( mScaleFactor * mup * INCH_TO_MM );
438  }
440  {
441  return sizeInMapUnits / mup;
442  }
443 
446  //no sensible value
447  return 0.0;
448  }
449  return 0.0;
450 }
451 
452 double QgsRenderContext::convertMetersToMapUnits( double meters ) const
453 {
454  switch ( mDistanceArea.sourceCrs().mapUnits() )
455  {
457  return meters;
459  {
460  if ( mExtent.isNull() )
461  {
462  // we don't have an extent to calculate exactly -- so just use a very rough approximation
464  }
465 
466  QgsPointXY pointCenter = mExtent.center();
467  // The Extent is in the sourceCrs(), when different from destinationCrs()
468  // - the point must be transformed, since DistanceArea uses the destinationCrs()
469  // Note: the default QgsCoordinateTransform() : authid() will return an empty String
470  if ( !mCoordTransform.isShortCircuited() )
471  {
472  pointCenter = mCoordTransform.transform( pointCenter );
473  }
474  return mDistanceArea.measureLineProjected( pointCenter, meters );
475  }
484  return ( meters * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::DistanceMeters, mDistanceArea.sourceCrs().mapUnits() ) );
485  }
486  return meters;
487 }
488 
489 QList<QgsRenderedFeatureHandlerInterface *> QgsRenderContext::renderedFeatureHandlers() const
490 {
491  return mRenderedFeatureHandlers;
492 }
493 
494 
QgsRenderContext::renderedFeatureHandlers
QList< QgsRenderedFeatureHandlerInterface * > renderedFeatureHandlers() const
Returns the list of rendered feature handlers to use while rendering map layers.
Definition: qgsrendercontext.cpp:489
QgsVectorSimplifyMethod::NoSimplification
@ NoSimplification
No simplification can be applied.
Definition: qgsvectorsimplifymethod.h:52
QgsRenderContext::DrawEditingInfo
@ DrawEditingInfo
Enable drawing of vertex markers for layers in editing mode.
Definition: qgsrendercontext.h:71
QgsUnitTypes::RenderInches
@ RenderInches
Inches.
Definition: qgsunittypes.h:173
QgsRenderContext::testFlag
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
Definition: qgsrendercontext.cpp:165
QgsRenderContext::convertToPainterUnits
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
Definition: qgsrendercontext.cpp:287
QgsCoordinateTransformContext
Definition: qgscoordinatetransformcontext.h:57
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:166
QgsMapToPixel::mapUnitsPerPixel
double mapUnitsPerPixel() const
Returns current map units per pixel.
Definition: qgsmaptopixel.cpp:128
QgsMapSettings::textRenderFormat
QgsRenderContext::TextRenderFormat textRenderFormat() const
Returns the text render format, which dictates how text is rendered (e.g.
Definition: qgsmapsettings.h:333
QgsRenderContext::fromMapSettings
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
Definition: qgsrendercontext.cpp:170
QgsMapSettings::extentBuffer
double extentBuffer() const
Returns the buffer in map units to use around the visible extent for rendering symbols whose correspo...
Definition: qgsmapsettings.cpp:91
QgsUnitTypes::DistanceUnknownUnit
@ DistanceUnknownUnit
Unknown distance unit.
Definition: qgsunittypes.h:78
QgsRenderContext::UseRenderingOptimization
@ UseRenderingOptimization
Enable vector simplification and other rendering optimizations.
Definition: qgsrendercontext.h:74
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QgsRenderContext::setSegmentationTolerance
void setSegmentationTolerance(double tolerance)
Sets the segmentation tolerance applied when rendering curved geometries.
Definition: qgsrendercontext.h:618
qgsexpression.h
QgsRenderContext::drawEditingInformation
bool drawEditingInformation() const
Returns true if edit markers should be drawn during the render operation.
Definition: qgsrendercontext.cpp:230
QgsTemporalRangeObject::isTemporal
bool isTemporal() const
Returns true if the object's temporal range is enabled, and the object will be filtered when renderin...
Definition: qgstemporalrangeobject.cpp:30
QgsRenderContext::UseAdvancedEffects
@ UseAdvancedEffects
Enable layer opacity and blending effects.
Definition: qgsrendercontext.h:73
QgsRenderContext::showSelection
bool showSelection() const
Returns true if vector selections should be shown in the rendered map.
Definition: qgsrendercontext.cpp:235
QgsRenderContext::setFlag
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
Definition: qgsrendercontext.cpp:152
QgsTemporalRangeObject::setIsTemporal
void setIsTemporal(bool enabled)
Sets whether the temporal range is enabled (i.e.
Definition: qgstemporalrangeobject.cpp:25
QgsRenderContext::setPainter
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
Definition: qgsrendercontext.h:475
QgsUnitTypes::RenderPoints
@ RenderPoints
Points (e.g., for font sizes)
Definition: qgsunittypes.h:172
QgsRenderContext::setShowSelection
void setShowSelection(bool showSelection)
Sets whether vector selections should be shown in the rendered map.
Definition: qgsrendercontext.cpp:255
QgsMapSettings::ellipsoid
QString ellipsoid() const
Returns ellipsoid's acronym.
Definition: qgsmapsettings.h:287
qgsfeaturefilterprovider.h
QgsUnitTypes::RenderPercentage
@ RenderPercentage
Percentage of another measurement (e.g., canvas size, feature size)
Definition: qgsunittypes.h:171
QgsRenderContext::convertToMapUnits
double convertToMapUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to map units.
Definition: qgsrendercontext.cpp:349
QgsTemporalRangeObject::temporalRange
const QgsDateTimeRange & temporalRange() const
Returns the datetime range for the object.
Definition: qgstemporalrangeobject.cpp:43
QgsMapSettings::simplifyMethod
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings to use when rendering vector layers.
Definition: qgsmapsettings.h:610
QgsDistanceArea::sourceCrs
QgsCoordinateReferenceSystem sourceCrs() const
Returns the source spatial reference system.
Definition: qgsdistancearea.h:76
QgsRenderContext
Definition: qgsrendercontext.h:57
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
QgsMapUnitScale::minSizeMM
double minSizeMM
The minimum size in millimeters, or 0.0 if unset.
Definition: qgsmapunitscale.h:67
QgsMapSettings::customRenderingFlags
QVariantMap customRenderingFlags() const
Gets custom rendering flags.
Definition: qgsmapsettings.h:244
QgsVectorSimplifyMethod::setSimplifyHints
void setSimplifyHints(SimplifyHints simplifyHints)
Sets the simplification hints of the vector layer managed.
Definition: qgsvectorsimplifymethod.h:62
QgsMapSettings::RenderPartialOutput
@ RenderPartialOutput
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
Definition: qgsmapsettings.h:311
qgspoint.h
FALLTHROUGH
#define FALLTHROUGH
Definition: qgis.h:783
qgsmapsettings.h
QgsCoordinateTransform::transform
QgsPointXY transform(const QgsPointXY &point, TransformDirection direction=ForwardTransform) const SIP_THROW(QgsCsException)
Transform the point from the source CRS to the destination CRS.
Definition: qgscoordinatetransform.cpp:239
QgsRenderContext::extent
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
Definition: qgsrendercontext.h:290
QgsUnitTypes::DistanceKilometers
@ DistanceKilometers
Kilometers.
Definition: qgsunittypes.h:70
QgsRenderContext::setSegmentationToleranceType
void setSegmentationToleranceType(QgsAbstractGeometry::SegmentationToleranceType type)
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
Definition: qgsrendercontext.h:632
QgsRectangle
Definition: qgsrectangle.h:41
QgsDistanceArea::measureLineProjected
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...
Definition: qgsdistancearea.cpp:350
QgsMapSettings::UseAdvancedEffects
@ UseAdvancedEffects
Enable layer opacity and blending effects.
Definition: qgsmapsettings.h:305
QgsRenderContext::ForceVectorOutput
@ ForceVectorOutput
Vector graphics should not be cached and drawn as raster images.
Definition: qgsrendercontext.h:72
QgsMapSettings::ForceVectorOutput
@ ForceVectorOutput
Vector graphics should not be cached and drawn as raster images.
Definition: qgsmapsettings.h:304
QgsUnitTypes::fromUnitToUnitFactor
static Q_INVOKABLE double fromUnitToUnitFactor(QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
Definition: qgsunittypes.cpp:352
QgsRenderContext::setFlags
void setFlags(QgsRenderContext::Flags flags)
Set combination of flags that will be used for rendering.
Definition: qgsrendercontext.cpp:147
QgsDistanceArea::setEllipsoid
bool setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid by its acronym.
Definition: qgsdistancearea.cpp:66
QgsMapSettings::DrawSelection
@ DrawSelection
Whether vector selections should be shown in the rendered map.
Definition: qgsmapsettings.h:308
QgsRenderContext::useAdvancedEffects
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
Definition: qgsrendercontext.cpp:220
QgsRenderContext::forceVectorOutput
bool forceVectorOutput() const
Returns true if rendering operations should use vector operations instead of any faster raster shortc...
Definition: qgsrendercontext.cpp:215
QgsMapSettings::segmentationToleranceType
QgsAbstractGeometry::SegmentationToleranceType segmentationToleranceType() const
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
Definition: qgsmapsettings.h:510
QgsCoordinateTransform::isShortCircuited
bool isShortCircuited() const
Returns true if the transform short circuits because the source and destination are equivalent.
Definition: qgscoordinatetransform.cpp:881
QgsMapSettings::transformContext
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
Definition: qgsmapsettings.cpp:400
QgsUnitTypes::DistanceDegrees
@ DistanceDegrees
Degrees, for planar geographic CRS distance measurements.
Definition: qgsunittypes.h:75
QgsRenderContext::RenderBlocking
@ RenderBlocking
Render and load remote sources in the same thread to ensure rendering remote sources (svg and images)...
Definition: qgsrendercontext.h:81
qgsDoubleNear
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:315
QgsRenderContext::setPathResolver
void setPathResolver(const QgsPathResolver &resolver)
Sets the path resolver for conversion between relative and absolute paths during rendering operations...
Definition: qgsrendercontext.h:273
QgsRenderContext::featureFilterProvider
const QgsFeatureFilterProvider * featureFilterProvider() const
Gets the filter feature provider used for additional filtering of rendered features.
Definition: qgsrendercontext.cpp:282
QgsRenderContext::setExtent
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
Definition: qgsrendercontext.h:418
QgsRenderContext::setCoordinateTransform
void setCoordinateTransform(const QgsCoordinateTransform &t)
Sets the current coordinate transform for the context.
Definition: qgsrendercontext.cpp:240
QgsRenderContext::setVectorSimplifyMethod
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Sets the simplification setting to use when rendering vector layers.
Definition: qgsrendercontext.h:564
QgsRenderContext::setRenderingStopped
void setRenderingStopped(bool stopped)
Sets whether the rendering operation has been stopped and any ongoing rendering should be canceled im...
Definition: qgsrendercontext.h:445
QgsMapSettings::Antialiasing
@ Antialiasing
Enable anti-aliasing for map rendering.
Definition: qgsmapsettings.h:302
qgsrendercontext.h
QgsRenderContext::setMapToPixel
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context's map to pixel transform, which transforms between map coordinates and device coordi...
Definition: qgsrendercontext.h:404
QgsUnitTypes::DistanceFeet
@ DistanceFeet
Imperial feet.
Definition: qgsunittypes.h:71
QgsRenderContext::DrawSymbolBounds
@ DrawSymbolBounds
Draw bounds of symbols (for debugging/testing)
Definition: qgsrendercontext.h:76
QgsUnitTypes::DistanceMeters
@ DistanceMeters
Meters.
Definition: qgsunittypes.h:69
QgsMapSettings::DrawSymbolBounds
@ DrawSymbolBounds
Draw bounds of symbols (for debugging/testing)
Definition: qgsmapsettings.h:309
QgsRenderContext::setFeatureFilterProvider
void setFeatureFilterProvider(const QgsFeatureFilterProvider *ffp)
Set a filter feature provider used for additional filtering of rendered features.
Definition: qgsrendercontext.cpp:270
QgsRenderContext::RenderMapTile
@ RenderMapTile
Draw map such that there are no problems between adjacent tiles.
Definition: qgsrendercontext.h:77
QgsRenderContext::operator=
QgsRenderContext & operator=(const QgsRenderContext &rh)
Definition: qgsrendercontext.cpp:74
QgsMapSettings::scale
double scale() const
Returns the calculated map scale.
Definition: qgsmapsettings.cpp:395
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:37
QgsDistanceArea::setSourceCrs
void setSourceCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets source spatial reference system crs.
Definition: qgsdistancearea.cpp:60
QgsMapSettings::RenderMapTile
@ RenderMapTile
Draw map such that there are no problems between adjacent tiles.
Definition: qgsmapsettings.h:310
QgsMapSettings::expressionContext
const QgsExpressionContext & expressionContext() const
Gets the expression context.
Definition: qgsmapsettings.h:393
QgsRenderContext::Flag
Flag
Enumeration of flags that affect rendering operations.
Definition: qgsrendercontext.h:69
QgsMapSettings::selectionColor
QColor selectionColor() const
Gets color that is used for drawing of selected vector features.
Definition: qgsmapsettings.h:297
QgsRenderContext::setSelectionColor
void setSelectionColor(const QColor &color)
Sets the color to use when rendering selected features.
Definition: qgsrendercontext.h:516
QgsMapSettings::RenderPreviewJob
@ RenderPreviewJob
Render is a 'canvas preview' render, and shortcuts should be taken to ensure fast rendering.
Definition: qgsmapsettings.h:312
QgsMapSettings::segmentationTolerance
double segmentationTolerance() const
Gets the segmentation tolerance applied when rendering curved geometries.
Definition: qgsmapsettings.h:503
QgsUnitTypes::RenderPixels
@ RenderPixels
Pixels.
Definition: qgsunittypes.h:170
QgsRenderContext::setRendererScale
void setRendererScale(double scale)
Sets the renderer map scale.
Definition: qgsrendercontext.h:467
QgsRenderContext::setUseRenderingOptimization
void setUseRenderingOptimization(bool enabled)
Sets whether the rendering optimization (geometry simplification) should be executed.
Definition: qgsrendercontext.cpp:265
QgsRenderContext::setTextRenderFormat
void setTextRenderFormat(TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
Definition: qgsrendercontext.h:690
qgsvectorlayer.h
QgsPointXY
Definition: qgspointxy.h:43
QgsRenderContext::setForceVectorOutput
void setForceVectorOutput(bool force)
Sets whether rendering operations should use vector operations instead of any faster raster shortcuts...
Definition: qgsrendercontext.cpp:250
QgsMapSettings::destinationCrs
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
Definition: qgsmapsettings.cpp:317
QgsRenderContext::setTransformContext
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the context's coordinate transform context, which stores various information regarding which dat...
Definition: qgsrendercontext.cpp:139
QgsRenderContext::RenderPartialOutput
@ RenderPartialOutput
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
Definition: qgsrendercontext.h:79
POINTS_TO_MM
#define POINTS_TO_MM
Definition: qgsrendercontext.cpp:28
QgsMapSettings::UseRenderingOptimization
@ UseRenderingOptimization
Enable vector simplification and other rendering optimizations.
Definition: qgsmapsettings.h:307
QgsMapUnitScale::maxSizeMMEnabled
bool maxSizeMMEnabled
Whether the maximum size in mm should be respected.
Definition: qgsmapunitscale.h:69
QgsCoordinateReferenceSystem::mapUnits
QgsUnitTypes::DistanceUnit mapUnits
Definition: qgscoordinatereferencesystem.h:210
QgsRectangle::center
QgsPointXY center() const
Returns the center point of the rectangle.
Definition: qgsrectangle.h:230
QgsMapSettings::testFlag
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
Definition: qgsmapsettings.cpp:354
QgsRenderContext::setDrawEditingInformation
void setDrawEditingInformation(bool b)
Sets whether edit markers should be drawn during the render operation.
Definition: qgsrendercontext.cpp:245
QgsUnitTypes::DistanceMillimeters
@ DistanceMillimeters
Millimeters.
Definition: qgsunittypes.h:77
QgsMapUnitScale::maxSizeMM
double maxSizeMM
The maximum size in millimeters, or 0.0 if unset.
Definition: qgsmapunitscale.h:71
QgsUnitTypes::DistanceCentimeters
@ DistanceCentimeters
Centimeters.
Definition: qgsunittypes.h:76
QgsRenderContext::transformContext
QgsCoordinateTransformContext transformContext() const
Returns the context's coordinate transform context, which stores various information regarding which ...
Definition: qgsrendercontext.cpp:130
QgsMapSettings::DrawEditingInfo
@ DrawEditingInfo
Enable drawing of vertex markers for layers in editing mode.
Definition: qgsmapsettings.h:303
QgsFeatureFilterProvider::clone
virtual QgsFeatureFilterProvider * clone() const =0
Create a clone of the feature filter provider.
QgsRenderContext::fromQPainter
static QgsRenderContext fromQPainter(QPainter *painter)
Creates a default render context given a pixel based QPainter destination.
Definition: qgsrendercontext.cpp:111
QgsMapSettings::pathResolver
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
Definition: qgsmapsettings.h:422
QgsMapUnitScale::computeMapUnitsPerPixel
double computeMapUnitsPerPixel(const QgsRenderContext &c) const
Computes a map units per pixel scaling factor, respecting the minimum and maximum scales set for the ...
Definition: qgsmapunitscale.cpp:20
QgsUnitTypes::RenderMetersInMapUnits
@ RenderMetersInMapUnits
Meters value as Map units.
Definition: qgsunittypes.h:175
INCH_TO_MM
#define INCH_TO_MM
Definition: qgsrendercontext.cpp:29
QgsUnitTypes::RenderUnknownUnit
@ RenderUnknownUnit
Mixed or unknown units.
Definition: qgsunittypes.h:174
QgsUnitTypes::DistanceYards
@ DistanceYards
Imperial yards.
Definition: qgsunittypes.h:73
QgsMapSettings::renderedFeatureHandlers
QList< QgsRenderedFeatureHandlerInterface * > renderedFeatureHandlers() const
Returns the list of rendered feature handlers to use while rendering the map settings.
Definition: qgsmapsettings.cpp:690
QgsFeatureFilterProvider
Definition: qgsfeaturefilterprovider.h:40
QgsRenderContext::convertMetersToMapUnits
double convertMetersToMapUnits(double meters) const
Convert meter distances to active MapUnit values for QgsUnitTypes::RenderMetersInMapUnits.
Definition: qgsrendercontext.cpp:452
QgsRenderContext::Antialiasing
@ Antialiasing
Use antialiasing while drawing.
Definition: qgsrendercontext.h:78
QgsUnitTypes::DistanceMiles
@ DistanceMiles
Terrestrial miles.
Definition: qgsunittypes.h:74
QgsTemporalRangeObject::setTemporalRange
void setTemporalRange(const QgsDateTimeRange &range)
Sets the temporal range for the object.
Definition: qgstemporalrangeobject.cpp:35
QgsRenderContext::setExpressionContext
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
Definition: qgsrendercontext.h:572
QgsCoordinateReferenceSystem::ellipsoidAcronym
QString ellipsoidAcronym() const
Returns the ellipsoid acronym for the ellipsoid used by the CRS.
Definition: qgscoordinatereferencesystem.cpp:1351
QgsUnitTypes::DistanceNauticalMiles
@ DistanceNauticalMiles
Nautical miles.
Definition: qgsunittypes.h:72
QgsMapSettings::RenderBlocking
@ RenderBlocking
Render and load remote sources in the same thread to ensure rendering remote sources (svg and images)...
Definition: qgsmapsettings.h:313
QgsRenderContext::setUseAdvancedEffects
void setUseAdvancedEffects(bool enabled)
Used to enable or disable advanced effects such as blend modes.
Definition: qgsrendercontext.cpp:225
QgsRectangle::grow
void grow(double delta)
Grows the rectangle in place by the specified amount.
Definition: qgsrectangle.h:275
QgsMapUnitScale::minScale
double minScale
The minimum scale, or 0.0 if unset.
Definition: qgsmapunitscale.h:56
qgslogger.h
QgsMapSettings::outputDpi
double outputDpi() const
Returns DPI used for conversion between real world units (e.g.
Definition: qgsmapsettings.cpp:262
QgsRenderContext::painter
QPainter * painter()
Returns the destination QPainter for the render operation.
Definition: qgsrendercontext.h:174
QgsMapUnitScale::maxScale
double maxScale
The maximum scale, or 0.0 if unset.
Definition: qgsmapunitscale.h:62
QgsMapSettings
Definition: qgsmapsettings.h:86
QgsMapSettings::visibleExtent
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes takes output image size into accou...
Definition: qgsmapsettings.cpp:370
QgsCoordinateTransform
Definition: qgscoordinatetransform.h:52
QgsMapUnitScale::minSizeMMEnabled
bool minSizeMMEnabled
Whether the minimum size in mm should be respected.
Definition: qgsmapunitscale.h:65
QgsRenderContext::QgsRenderContext
QgsRenderContext()
Definition: qgsrendercontext.cpp:31
QgsRenderContext::RenderPreviewJob
@ RenderPreviewJob
Render is a 'canvas preview' render, and shortcuts should be taken to ensure fast rendering.
Definition: qgsrendercontext.h:80
QgsRenderContext::useRenderingOptimization
bool useRenderingOptimization() const
Returns true if the rendering optimization (geometry simplification) can be executed.
Definition: qgsrendercontext.cpp:260
QgsMapSettings::mapToPixel
const QgsMapToPixel & mapToPixel() const
Definition: qgsmapsettings.h:433
QgsUnitTypes::RenderMapUnits
@ RenderMapUnits
Map units.
Definition: qgsunittypes.h:169
QgsRectangle::isNull
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
Definition: qgsrectangle.h:447
QgsTemporalRangeObject
Definition: qgstemporalrangeobject.h:33
QgsRenderContext::setScaleFactor
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
Definition: qgsrendercontext.h:460
QgsRenderContext::DrawSelection
@ DrawSelection
Whether vector selections should be shown in the rendered map.
Definition: qgsrendercontext.h:75
QgsRenderContext::convertFromMapUnits
double convertFromMapUnits(double sizeInMapUnits, QgsUnitTypes::RenderUnit outputUnit) const
Converts a size from map units to the specified units.
Definition: qgsrendercontext.cpp:413
QgsRenderContext::setMapExtent
void setMapExtent(const QgsRectangle &extent)
Sets the original extent of the map being rendered.
Definition: qgsrendercontext.h:430
QgsRenderContext::flags
Flags flags() const
Returns combination of flags used for rendering.
Definition: qgsrendercontext.cpp:160