QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
44  , mFlags( rh.mFlags )
45  , mPainter( rh.mPainter )
46  , mMaskPainter( rh.mMaskPainter )
47  , mCoordTransform( rh.mCoordTransform )
48  , mDistanceArea( rh.mDistanceArea )
49  , mExtent( rh.mExtent )
50  , mOriginalMapExtent( rh.mOriginalMapExtent )
51  , mMapToPixel( rh.mMapToPixel )
52  , mRenderingStopped( rh.mRenderingStopped )
53  , mScaleFactor( rh.mScaleFactor )
54  , mRendererScale( rh.mRendererScale )
55  , mLabelingEngine( rh.mLabelingEngine )
56  , mSelectionColor( rh.mSelectionColor )
57  , mVectorSimplifyMethod( rh.mVectorSimplifyMethod )
58  , mExpressionContext( rh.mExpressionContext )
59  , mGeometry( rh.mGeometry )
60  , mFeatureFilterProvider( rh.mFeatureFilterProvider ? rh.mFeatureFilterProvider->clone() : nullptr )
61  , mSegmentationTolerance( rh.mSegmentationTolerance )
62  , mSegmentationToleranceType( rh.mSegmentationToleranceType )
63  , mTransformContext( rh.mTransformContext )
64  , mPathResolver( rh.mPathResolver )
65  , mTextRenderFormat( rh.mTextRenderFormat )
66  , mRenderedFeatureHandlers( rh.mRenderedFeatureHandlers )
67  , mHasRenderedFeatureHandlers( rh.mHasRenderedFeatureHandlers )
68  , mCustomRenderingFlags( rh.mCustomRenderingFlags )
69  , mDisabledSymbolLayers()
70  , mClippingRegions( rh.mClippingRegions )
71  , mFeatureClipGeometry( rh.mFeatureClipGeometry )
72  , mTextureOrigin( rh.mTextureOrigin )
73 #ifdef QGISDEBUG
74  , mHasTransformContext( rh.mHasTransformContext )
75 #endif
76 {
77 }
78 
80 {
81  mFlags = rh.mFlags;
82  mPainter = rh.mPainter;
83  mMaskPainter = rh.mMaskPainter;
84  mCoordTransform = rh.mCoordTransform;
85  mExtent = rh.mExtent;
86  mOriginalMapExtent = rh.mOriginalMapExtent;
87  mMapToPixel = rh.mMapToPixel;
88  mRenderingStopped = rh.mRenderingStopped;
89  mScaleFactor = rh.mScaleFactor;
90  mRendererScale = rh.mRendererScale;
91  mLabelingEngine = rh.mLabelingEngine;
92  mSelectionColor = rh.mSelectionColor;
93  mVectorSimplifyMethod = rh.mVectorSimplifyMethod;
94  mExpressionContext = rh.mExpressionContext;
95  mGeometry = rh.mGeometry;
96  mFeatureFilterProvider.reset( rh.mFeatureFilterProvider ? rh.mFeatureFilterProvider->clone() : nullptr );
97  mSegmentationTolerance = rh.mSegmentationTolerance;
98  mSegmentationToleranceType = rh.mSegmentationToleranceType;
99  mDistanceArea = rh.mDistanceArea;
100  mTransformContext = rh.mTransformContext;
101  mPathResolver = rh.mPathResolver;
102  mTextRenderFormat = rh.mTextRenderFormat;
103  mRenderedFeatureHandlers = rh.mRenderedFeatureHandlers;
104  mHasRenderedFeatureHandlers = rh.mHasRenderedFeatureHandlers;
105  mCustomRenderingFlags = rh.mCustomRenderingFlags;
106  mClippingRegions = rh.mClippingRegions;
107  mFeatureClipGeometry = rh.mFeatureClipGeometry;
108  mTextureOrigin = rh.mTextureOrigin;
109  setIsTemporal( rh.isTemporal() );
110  if ( isTemporal() )
112 #ifdef QGISDEBUG
113  mHasTransformContext = rh.mHasTransformContext;
114 #endif
115 
116  return *this;
117 }
118 
120 {
121  QgsRenderContext context;
122  context.setPainter( painter );
123  if ( painter && painter->device() )
124  {
125  context.setScaleFactor( painter->device()->logicalDpiX() / 25.4 );
126  }
127  else
128  {
129  context.setScaleFactor( 3.465 ); //assume 88 dpi as standard value
130  }
131 
132  if ( painter && painter->renderHints() & QPainter::Antialiasing )
133  context.setFlag( QgsRenderContext::Antialiasing, true );
134 
135 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
136  if ( painter && painter->renderHints() & QPainter::LosslessImageRendering )
138 #endif
139 
140  return context;
141 }
142 
143 void QgsRenderContext::setPainterFlagsUsingContext( QPainter *painter ) const
144 {
145  if ( !painter )
146  painter = mPainter;
147 
148  if ( !painter )
149  return;
150 
151  painter->setRenderHint( QPainter::Antialiasing, mFlags & QgsRenderContext::Antialiasing );
152 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
153  painter->setRenderHint( QPainter::LosslessImageRendering, mFlags & QgsRenderContext::LosslessImageRendering );
154 #endif
155 }
156 
158 {
159 #ifdef QGISDEBUG
160  if ( !mHasTransformContext )
161  QgsDebugMsgLevel( QStringLiteral( "No QgsCoordinateTransformContext context set for transform" ), 4 );
162 #endif
163  return mTransformContext;
164 }
165 
167 {
168  mTransformContext = context;
169 #ifdef QGISDEBUG
170  mHasTransformContext = true;
171 #endif
172 }
173 
174 void QgsRenderContext::setFlags( QgsRenderContext::Flags flags )
175 {
176  mFlags = flags;
177 }
178 
180 {
181  if ( on )
182  mFlags |= flag;
183  else
184  mFlags &= ~flag;
185 }
186 
187 QgsRenderContext::Flags QgsRenderContext::flags() const
188 {
189  return mFlags;
190 }
191 
193 {
194  return mFlags.testFlag( flag );
195 }
196 
198 {
199  QgsRenderContext ctx;
200  QgsRectangle extent = mapSettings.visibleExtent();
201  extent.grow( mapSettings.extentBuffer() );
202  ctx.setMapToPixel( mapSettings.mapToPixel() );
203  ctx.setExtent( extent );
204  ctx.setMapExtent( mapSettings.visibleExtent() );
210  ctx.setSelectionColor( mapSettings.selectionColor() );
220  ctx.setScaleFactor( mapSettings.outputDpi() / 25.4 ); // = pixels per mm
221  ctx.setRendererScale( mapSettings.scale() );
222  ctx.setExpressionContext( mapSettings.expressionContext() );
223  ctx.setSegmentationTolerance( mapSettings.segmentationTolerance() );
225  ctx.mDistanceArea.setSourceCrs( mapSettings.destinationCrs(), mapSettings.transformContext() );
226  ctx.mDistanceArea.setEllipsoid( mapSettings.ellipsoid() );
227  ctx.setTransformContext( mapSettings.transformContext() );
228  ctx.setPathResolver( mapSettings.pathResolver() );
229  ctx.setTextRenderFormat( mapSettings.textRenderFormat() );
230  ctx.setVectorSimplifyMethod( mapSettings.simplifyMethod() );
231  ctx.mRenderedFeatureHandlers = mapSettings.renderedFeatureHandlers();
232  ctx.mHasRenderedFeatureHandlers = !mapSettings.renderedFeatureHandlers().isEmpty();
233  //this flag is only for stopping during the current rendering progress,
234  //so must be false at every new render operation
235  ctx.setRenderingStopped( false );
236  ctx.mCustomRenderingFlags = mapSettings.customRenderingFlags();
237  ctx.setIsTemporal( mapSettings.isTemporal() );
238  if ( ctx.isTemporal() )
239  ctx.setTemporalRange( mapSettings.temporalRange() );
240 
241  ctx.mClippingRegions = mapSettings.clippingRegions();
242 
243  return ctx;
244 }
245 
247 {
248  return mFlags.testFlag( ForceVectorOutput );
249 }
250 
252 {
253  return mFlags.testFlag( UseAdvancedEffects );
254 }
255 
257 {
258  setFlag( UseAdvancedEffects, enabled );
259 }
260 
262 {
263  return mFlags.testFlag( DrawEditingInfo );
264 }
265 
267 {
268  return mFlags.testFlag( DrawSelection );
269 }
270 
272 {
273  mCoordTransform = t;
274 }
275 
277 {
278  setFlag( DrawEditingInfo, b );
279 }
280 
282 {
283  setFlag( ForceVectorOutput, force );
284 }
285 
286 void QgsRenderContext::setShowSelection( const bool showSelection )
287 {
289 }
290 
292 {
293  return mFlags.testFlag( UseRenderingOptimization );
294 }
295 
297 {
298  setFlag( UseRenderingOptimization, enabled );
299 }
300 
302 {
303  if ( ffp )
304  {
305  mFeatureFilterProvider.reset( ffp->clone() );
306  }
307  else
308  {
309  mFeatureFilterProvider.reset( nullptr );
310  }
311 }
312 
314 {
315  return mFeatureFilterProvider.get();
316 }
317 
319 {
320  double conversionFactor = 1.0;
321  switch ( unit )
322  {
324  conversionFactor = mScaleFactor;
325  break;
326 
328  conversionFactor = mScaleFactor / POINTS_TO_MM;
329  break;
330 
332  conversionFactor = mScaleFactor * INCH_TO_MM;
333  break;
334 
336  {
337  size = convertMetersToMapUnits( size );
339  // Fall through to RenderMapUnits with size in meters converted to size in MapUnits
341  }
343  {
344  double mup = scale.computeMapUnitsPerPixel( *this );
345  if ( mup > 0 )
346  {
347  conversionFactor = 1.0 / mup;
348  }
349  else
350  {
351  conversionFactor = 1.0;
352  }
353  break;
354  }
356  conversionFactor = 1.0;
357  break;
358 
361  //no sensible value
362  conversionFactor = 1.0;
363  break;
364  }
365 
366  double convertedSize = size * conversionFactor;
367 
368  if ( unit == QgsUnitTypes::RenderMapUnits )
369  {
370  //check max/min size
371  if ( scale.minSizeMMEnabled )
372  convertedSize = std::max( convertedSize, scale.minSizeMM * mScaleFactor );
373  if ( scale.maxSizeMMEnabled )
374  convertedSize = std::min( convertedSize, scale.maxSizeMM * mScaleFactor );
375  }
376 
377  return convertedSize;
378 }
379 
380 double QgsRenderContext::convertToMapUnits( double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale ) const
381 {
382  double mup = mMapToPixel.mapUnitsPerPixel();
383 
384  switch ( unit )
385  {
387  {
388  size = convertMetersToMapUnits( size );
389  // Fall through to RenderMapUnits with values of meters converted to MapUnits
391  }
393  {
394  // check scale
395  double minSizeMU = std::numeric_limits<double>::lowest();
396  if ( scale.minSizeMMEnabled )
397  {
398  minSizeMU = scale.minSizeMM * mScaleFactor * mup;
399  }
400  if ( !qgsDoubleNear( scale.minScale, 0.0 ) )
401  {
402  minSizeMU = std::max( minSizeMU, size * ( mRendererScale / scale.minScale ) );
403  }
404  size = std::max( size, minSizeMU );
405 
406  double maxSizeMU = std::numeric_limits<double>::max();
407  if ( scale.maxSizeMMEnabled )
408  {
409  maxSizeMU = scale.maxSizeMM * mScaleFactor * mup;
410  }
411  if ( !qgsDoubleNear( scale.maxScale, 0.0 ) )
412  {
413  maxSizeMU = std::min( maxSizeMU, size * ( mRendererScale / scale.maxScale ) );
414  }
415  size = std::min( size, maxSizeMU );
416 
417  return size;
418  }
420  {
421  return size * mScaleFactor * mup;
422  }
424  {
425  return size * mScaleFactor * mup / POINTS_TO_MM;
426  }
428  {
429  return size * mScaleFactor * mup * INCH_TO_MM;
430  }
432  {
433  return size * mup;
434  }
435 
438  //no sensible value
439  return 0.0;
440  }
441  return 0.0;
442 }
443 
444 double QgsRenderContext::convertFromMapUnits( double sizeInMapUnits, QgsUnitTypes::RenderUnit outputUnit ) const
445 {
446  double mup = mMapToPixel.mapUnitsPerPixel();
447 
448  switch ( outputUnit )
449  {
451  {
452  return sizeInMapUnits / convertMetersToMapUnits( 1.0 );
453  }
455  {
456  return sizeInMapUnits;
457  }
459  {
460  return sizeInMapUnits / ( mScaleFactor * mup );
461  }
463  {
464  return sizeInMapUnits / ( mScaleFactor * mup / POINTS_TO_MM );
465  }
467  {
468  return sizeInMapUnits / ( mScaleFactor * mup * INCH_TO_MM );
469  }
471  {
472  return sizeInMapUnits / mup;
473  }
474 
477  //no sensible value
478  return 0.0;
479  }
480  return 0.0;
481 }
482 
483 double QgsRenderContext::convertMetersToMapUnits( double meters ) const
484 {
485  switch ( mDistanceArea.sourceCrs().mapUnits() )
486  {
488  return meters;
490  {
491  if ( mExtent.isNull() )
492  {
493  // we don't have an extent to calculate exactly -- so just use a very rough approximation
495  }
496 
497  QgsPointXY pointCenter = mExtent.center();
498  // The Extent is in the sourceCrs(), when different from destinationCrs()
499  // - the point must be transformed, since DistanceArea uses the destinationCrs()
500  // Note: the default QgsCoordinateTransform() : authid() will return an empty String
501  if ( !mCoordTransform.isShortCircuited() )
502  {
503  pointCenter = mCoordTransform.transform( pointCenter );
504  }
505  return mDistanceArea.measureLineProjected( pointCenter, meters );
506  }
515  return ( meters * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::DistanceMeters, mDistanceArea.sourceCrs().mapUnits() ) );
516  }
517  return meters;
518 }
519 
520 QList<QgsRenderedFeatureHandlerInterface *> QgsRenderContext::renderedFeatureHandlers() const
521 {
522  return mRenderedFeatureHandlers;
523 }
524 
525 QList<QgsMapClippingRegion> QgsRenderContext::clippingRegions() const
526 {
527  return mClippingRegions;
528 }
529 
531 {
532  return mFeatureClipGeometry;
533 }
534 
536 {
537  mFeatureClipGeometry = geometry;
538 }
539 
541 {
542  return mTextureOrigin;
543 }
544 
545 void QgsRenderContext::setTextureOrigin( const QPointF &origin )
546 {
547  mTextureOrigin = origin;
548 }
549 
550 
QgsRenderContext::renderedFeatureHandlers
QList< QgsRenderedFeatureHandlerInterface * > renderedFeatureHandlers() const
Returns the list of rendered feature handlers to use while rendering map layers.
Definition: qgsrendercontext.cpp:520
QgsVectorSimplifyMethod::NoSimplification
@ NoSimplification
No simplification can be applied.
Definition: qgsvectorsimplifymethod.h:39
QgsRenderContext::DrawEditingInfo
@ DrawEditingInfo
Enable drawing of vertex markers for layers in editing mode.
Definition: qgsrendercontext.h:72
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:192
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:318
QgsRenderContext::setPainterFlagsUsingContext
void setPainterFlagsUsingContext(QPainter *painter=nullptr) const
Sets relevant flags on a destination painter, using the flags and settings currently defined for the ...
Definition: qgsrendercontext.cpp:143
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:58
QgsCoordinateReferenceSystem::mapUnits
Q_GADGET QgsUnitTypes::DistanceUnit mapUnits
Definition: qgscoordinatereferencesystem.h:209
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
QgsRenderContext::featureClipGeometry
QgsGeometry featureClipGeometry() const
Returns the geometry to use to clip features at render time.
Definition: qgsrendercontext.cpp:530
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:336
QgsRenderContext::Render3DMap
@ Render3DMap
Render is for a 3D map.
Definition: qgsrendercontext.h:86
QgsRenderContext::fromMapSettings
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
Definition: qgsrendercontext.cpp:197
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
QgsRenderContext::setFeatureClipGeometry
void setFeatureClipGeometry(const QgsGeometry &geometry)
Sets a geometry to use to clip features at render time.
Definition: qgsrendercontext.cpp:535
QgsUnitTypes::DistanceUnknownUnit
@ DistanceUnknownUnit
Unknown distance unit.
Definition: qgsunittypes.h:78
QgsRenderContext::UseRenderingOptimization
@ UseRenderingOptimization
Enable vector simplification and other rendering optimizations.
Definition: qgsrendercontext.h:75
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:634
qgsexpression.h
QgsRenderContext::drawEditingInformation
bool drawEditingInformation() const
Returns true if edit markers should be drawn during the render operation.
Definition: qgsrendercontext.cpp:261
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
QgsRectangle::center
QgsPointXY center() const SIP_HOLDGIL
Returns the center point of the rectangle.
Definition: qgsrectangle.h:230
QgsRenderContext::UseAdvancedEffects
@ UseAdvancedEffects
Enable layer opacity and blending effects.
Definition: qgsrendercontext.h:74
QgsRenderContext::showSelection
bool showSelection() const
Returns true if vector selections should be shown in the rendered map.
Definition: qgsrendercontext.cpp:266
QgsRenderContext::setFlag
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
Definition: qgsrendercontext.cpp:179
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:491
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:286
QgsMapSettings::ellipsoid
QString ellipsoid() const
Returns ellipsoid's acronym.
Definition: qgsmapsettings.h:288
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:380
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:659
QgsDistanceArea::sourceCrs
QgsCoordinateReferenceSystem sourceCrs() const
Returns the source spatial reference system.
Definition: qgsdistancearea.h:76
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:58
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:245
QgsVectorSimplifyMethod::setSimplifyHints
void setSimplifyHints(SimplifyHints simplifyHints)
Sets the simplification hints of the vector layer managed.
Definition: qgsvectorsimplifymethod.h:49
QgsMapSettings::RenderPartialOutput
@ RenderPartialOutput
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
Definition: qgsmapsettings.h:312
qgspoint.h
FALLTHROUGH
#define FALLTHROUGH
Definition: qgis.h:828
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:306
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:648
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
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:306
QgsRenderContext::ForceVectorOutput
@ ForceVectorOutput
Vector graphics should not be cached and drawn as raster images.
Definition: qgsrendercontext.h:73
QgsMapSettings::ForceVectorOutput
@ ForceVectorOutput
Vector graphics should not be cached and drawn as raster images.
Definition: qgsmapsettings.h:305
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:174
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:309
QgsRenderContext::useAdvancedEffects
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
Definition: qgsrendercontext.cpp:251
QgsRenderContext::forceVectorOutput
bool forceVectorOutput() const
Returns true if rendering operations should use vector operations instead of any faster raster shortc...
Definition: qgsrendercontext.cpp:246
QgsMapSettings::segmentationToleranceType
QgsAbstractGeometry::SegmentationToleranceType segmentationToleranceType() const
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
Definition: qgsmapsettings.h:529
QgsCoordinateTransform::isShortCircuited
bool isShortCircuited() const
Returns true if the transform short circuits because the source and destination are equivalent.
Definition: qgscoordinatetransform.cpp:897
QgsMapSettings::transformContext
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
Definition: qgsmapsettings.cpp:401
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:82
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:289
QgsRenderContext::featureFilterProvider
const QgsFeatureFilterProvider * featureFilterProvider() const
Gets the filter feature provider used for additional filtering of rendered features.
Definition: qgsrendercontext.cpp:313
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:434
QgsRenderContext::setCoordinateTransform
void setCoordinateTransform(const QgsCoordinateTransform &t)
Sets the current coordinate transform for the context.
Definition: qgsrendercontext.cpp:271
QgsRenderContext::setVectorSimplifyMethod
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Sets the simplification setting to use when rendering vector layers.
Definition: qgsrendercontext.h:580
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:461
QgsMapSettings::Antialiasing
@ Antialiasing
Enable anti-aliasing for map rendering.
Definition: qgsmapsettings.h:303
qgsrendercontext.h
QgsMapSettings::LosslessImageRendering
@ LosslessImageRendering
Render images losslessly whenever possible, instead of the default lossy jpeg rendering used for some...
Definition: qgsmapsettings.h:315
QgsRenderContext::~QgsRenderContext
~QgsRenderContext() override
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:420
QgsUnitTypes::DistanceFeet
@ DistanceFeet
Imperial feet.
Definition: qgsunittypes.h:71
QgsRenderContext::DrawSymbolBounds
@ DrawSymbolBounds
Draw bounds of symbols (for debugging/testing)
Definition: qgsrendercontext.h:77
QgsUnitTypes::DistanceMeters
@ DistanceMeters
Meters.
Definition: qgsunittypes.h:69
QgsMapSettings::DrawSymbolBounds
@ DrawSymbolBounds
Draw bounds of symbols (for debugging/testing)
Definition: qgsmapsettings.h:310
QgsRenderContext::setFeatureFilterProvider
void setFeatureFilterProvider(const QgsFeatureFilterProvider *ffp)
Set a filter feature provider used for additional filtering of rendered features.
Definition: qgsrendercontext.cpp:301
QgsRenderContext::RenderMapTile
@ RenderMapTile
Draw map such that there are no problems between adjacent tiles.
Definition: qgsrendercontext.h:78
QgsRenderContext::operator=
QgsRenderContext & operator=(const QgsRenderContext &rh)
Definition: qgsrendercontext.cpp:79
QgsMapSettings::scale
double scale() const
Returns the calculated map scale.
Definition: qgsmapsettings.cpp:396
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:38
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:311
QgsMapSettings::expressionContext
const QgsExpressionContext & expressionContext() const
Gets the expression context.
Definition: qgsmapsettings.h:396
QgsRenderContext::Flag
Flag
Enumeration of flags that affect rendering operations.
Definition: qgsrendercontext.h:71
QgsMapSettings::selectionColor
QColor selectionColor() const
Gets color that is used for drawing of selected vector features.
Definition: qgsmapsettings.h:298
QgsRenderContext::setSelectionColor
void setSelectionColor(const QColor &color)
Sets the color to use when rendering selected features.
Definition: qgsrendercontext.h:532
QgsMapSettings::RenderPreviewJob
@ RenderPreviewJob
Render is a 'canvas preview' render, and shortcuts should be taken to ensure fast rendering.
Definition: qgsmapsettings.h:313
QgsMapSettings::segmentationTolerance
double segmentationTolerance() const
Gets the segmentation tolerance applied when rendering curved geometries.
Definition: qgsmapsettings.h:521
QgsUnitTypes::RenderPixels
@ RenderPixels
Pixels.
Definition: qgsunittypes.h:170
QgsRenderContext::setRendererScale
void setRendererScale(double scale)
Sets the renderer map scale.
Definition: qgsrendercontext.h:483
QgsRenderContext::setUseRenderingOptimization
void setUseRenderingOptimization(bool enabled)
Sets whether the rendering optimization (geometry simplification) should be executed.
Definition: qgsrendercontext.cpp:296
QgsRenderContext::setTextRenderFormat
void setTextRenderFormat(TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
Definition: qgsrendercontext.h:706
qgsvectorlayer.h
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:44
QgsRenderContext::setForceVectorOutput
void setForceVectorOutput(bool force)
Sets whether rendering operations should use vector operations instead of any faster raster shortcuts...
Definition: qgsrendercontext.cpp:281
QgsMapSettings::destinationCrs
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
Definition: qgsmapsettings.cpp:318
QgsRenderContext::setTransformContext
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the context's coordinate transform context, which stores various information regarding which dat...
Definition: qgsrendercontext.cpp:166
QgsRenderContext::LosslessImageRendering
@ LosslessImageRendering
Render images losslessly whenever possible, instead of the default lossy jpeg rendering used for some...
Definition: qgsrendercontext.h:84
QgsRenderContext::RenderPartialOutput
@ RenderPartialOutput
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
Definition: qgsrendercontext.h:80
POINTS_TO_MM
#define POINTS_TO_MM
Definition: qgsrendercontext.cpp:28
QgsMapSettings::UseRenderingOptimization
@ UseRenderingOptimization
Enable vector simplification and other rendering optimizations.
Definition: qgsmapsettings.h:308
QgsRenderContext::textureOrigin
QPointF textureOrigin() const
Returns the texture origin, which should be used as a brush transform when rendering using QBrush obj...
Definition: qgsrendercontext.cpp:540
QgsMapUnitScale::maxSizeMMEnabled
bool maxSizeMMEnabled
Whether the maximum size in mm should be respected.
Definition: qgsmapunitscale.h:69
QgsMapSettings::testFlag
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
Definition: qgsmapsettings.cpp:355
QgsRenderContext::geometry
const QgsAbstractGeometry * geometry() const
Returns pointer to the unsegmentized geometry.
Definition: qgsrendercontext.h:608
QgsRenderContext::setDrawEditingInformation
void setDrawEditingInformation(bool b)
Sets whether edit markers should be drawn during the render operation.
Definition: qgsrendercontext.cpp:276
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
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:157
QgsMapSettings::DrawEditingInfo
@ DrawEditingInfo
Enable drawing of vertex markers for layers in editing mode.
Definition: qgsmapsettings.h:304
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:119
QgsMapSettings::pathResolver
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
Definition: qgsmapsettings.h:425
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:746
QgsMapSettings::Render3DMap
@ Render3DMap
Render is for a 3D map.
Definition: qgsmapsettings.h:316
QgsFeatureFilterProvider
Abstract interface for use by classes that filter the features of a layer.
Definition: qgsfeaturefilterprovider.h:41
QgsRenderContext::clippingRegions
QList< QgsMapClippingRegion > clippingRegions() const
Returns the list of clipping regions to apply during the render.
Definition: qgsrendercontext.cpp:525
QgsRenderContext::convertMetersToMapUnits
double convertMetersToMapUnits(double meters) const
Convert meter distances to active MapUnit values for QgsUnitTypes::RenderMetersInMapUnits.
Definition: qgsrendercontext.cpp:483
QgsRenderContext::Antialiasing
@ Antialiasing
Use antialiasing while drawing.
Definition: qgsrendercontext.h:79
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:588
QgsCoordinateReferenceSystem::ellipsoidAcronym
QString ellipsoidAcronym() const
Returns the ellipsoid acronym for the ellipsoid used by the CRS.
Definition: qgscoordinatereferencesystem.cpp:1373
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:314
QgsMapSettings::clippingRegions
QList< QgsMapClippingRegion > clippingRegions() const
Returns the list of clipping regions to apply to the map.
Definition: qgsmapsettings.cpp:736
QgsRenderContext::setUseAdvancedEffects
void setUseAdvancedEffects(bool enabled)
Used to enable or disable advanced effects such as blend modes.
Definition: qgsrendercontext.cpp:256
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:263
QgsRenderContext::painter
QPainter * painter()
Returns the destination QPainter for the render operation.
Definition: qgsrendercontext.h:179
QgsMapUnitScale::maxScale
double maxScale
The maximum scale, or 0.0 if unset.
Definition: qgsmapunitscale.h:62
QgsMapSettings
The QgsMapSettings class contains configuration for rendering of the map.
Definition: qgsmapsettings.h:88
QgsMapSettings::visibleExtent
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes takes output image size into accou...
Definition: qgsmapsettings.cpp:371
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:53
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::setTextureOrigin
void setTextureOrigin(const QPointF &origin)
Sets the texture origin, which should be used as a brush transform when rendering using QBrush object...
Definition: qgsrendercontext.cpp:545
QgsRenderContext::RenderPreviewJob
@ RenderPreviewJob
Render is a 'canvas preview' render, and shortcuts should be taken to ensure fast rendering.
Definition: qgsrendercontext.h:81
QgsRenderContext::useRenderingOptimization
bool useRenderingOptimization() const
Returns true if the rendering optimization (geometry simplification) can be executed.
Definition: qgsrendercontext.cpp:291
QgsMapSettings::mapToPixel
const QgsMapToPixel & mapToPixel() const
Definition: qgsmapsettings.h:436
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
Base class for objects with an associated (optional) temporal range.
Definition: qgstemporalrangeobject.h:34
QgsRenderContext::setScaleFactor
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
Definition: qgsrendercontext.h:476
QgsRenderContext::DrawSelection
@ DrawSelection
Whether vector selections should be shown in the rendered map.
Definition: qgsrendercontext.h:76
QgsRenderContext::convertFromMapUnits
double convertFromMapUnits(double sizeInMapUnits, QgsUnitTypes::RenderUnit outputUnit) const
Converts a size from map units to the specified units.
Definition: qgsrendercontext.cpp:444
QgsRenderContext::setMapExtent
void setMapExtent(const QgsRectangle &extent)
Sets the original extent of the map being rendered.
Definition: qgsrendercontext.h:446
QgsRenderContext::flags
Flags flags() const
Returns combination of flags used for rendering.
Definition: qgsrendercontext.cpp:187