QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
28 #define POINTS_TO_MM 2.83464567
29 #define INCH_TO_MM 25.4
32 : mFlags( DrawEditingInfo | UseAdvancedEffects | DrawSelection | UseRenderingOptimization )
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()
69 , mHasTransformContext( rh.mHasTransformContext )
77 mPainter = rh.mPainter;
78 mMaskPainter = rh.mMaskPainter;
79 mCoordTransform = rh.mCoordTransform;
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;
105 mHasTransformContext = rh.mHasTransformContext;
133 if ( !mHasTransformContext )
134 QgsDebugMsgLevel( QStringLiteral(
"No QgsCoordinateTransformContext context set for transform" ), 4 );
136 return mTransformContext;
141 mTransformContext = context;
143 mHasTransformContext =
true;
167 return mFlags.testFlag( flag );
274 mFeatureFilterProvider.reset( ffp->
clone() );
278 mFeatureFilterProvider.reset(
nullptr );
284 return mFeatureFilterProvider.get();
289 double conversionFactor = 1.0;
293 conversionFactor = mScaleFactor;
316 conversionFactor = 1.0 / mup;
320 conversionFactor = 1.0;
325 conversionFactor = 1.0;
331 conversionFactor = 1.0;
335 double convertedSize = size * conversionFactor;
341 convertedSize = std::max( convertedSize, scale.
minSizeMM * mScaleFactor );
343 convertedSize = std::min( convertedSize, scale.
maxSizeMM * mScaleFactor );
346 return convertedSize;
364 double minSizeMU = std::numeric_limits<double>::lowest();
367 minSizeMU = scale.
minSizeMM * mScaleFactor * mup;
371 minSizeMU = std::max( minSizeMU, size * ( mRendererScale / scale.
minScale ) );
373 size = std::max( size, minSizeMU );
375 double maxSizeMU = std::numeric_limits<double>::max();
378 maxSizeMU = scale.
maxSizeMM * mScaleFactor * mup;
382 maxSizeMU = std::min( maxSizeMU, size * ( mRendererScale / scale.
maxScale ) );
384 size = std::min( size, maxSizeMU );
390 return size * mScaleFactor * mup;
398 return size * mScaleFactor * mup *
INCH_TO_MM;
417 switch ( outputUnit )
425 return sizeInMapUnits;
429 return sizeInMapUnits / ( mScaleFactor * mup );
433 return sizeInMapUnits / ( mScaleFactor * mup /
POINTS_TO_MM );
437 return sizeInMapUnits / ( mScaleFactor * mup *
INCH_TO_MM );
441 return sizeInMapUnits / mup;
472 pointCenter = mCoordTransform.
transform( pointCenter );
491 return mRenderedFeatureHandlers;
QList< QgsRenderedFeatureHandlerInterface * > renderedFeatureHandlers() const
Returns the list of rendered feature handlers to use while rendering map layers.
@ NoSimplification
No simplification can be applied.
@ DrawEditingInfo
Enable drawing of vertex markers for layers in editing mode.
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
RenderUnit
Rendering size units.
double mapUnitsPerPixel() const
Returns current map units per pixel.
QgsRenderContext::TextRenderFormat textRenderFormat() const
Returns the text render format, which dictates how text is rendered (e.g.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
double extentBuffer() const
Returns the buffer in map units to use around the visible extent for rendering symbols whose correspo...
@ DistanceUnknownUnit
Unknown distance unit.
@ UseRenderingOptimization
Enable vector simplification and other rendering optimizations.
#define QgsDebugMsgLevel(str, level)
void setSegmentationTolerance(double tolerance)
Sets the segmentation tolerance applied when rendering curved geometries.
bool drawEditingInformation() const
Returns true if edit markers should be drawn during the render operation.
bool isTemporal() const
Returns true if the object's temporal range is enabled, and the object will be filtered when renderin...
@ UseAdvancedEffects
Enable layer opacity and blending effects.
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 setIsTemporal(bool enabled)
Sets whether the temporal range is enabled (i.e.
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
@ RenderPoints
Points (e.g., for font sizes)
void setShowSelection(bool showSelection)
Sets whether vector selections should be shown in the rendered map.
QString ellipsoid() const
Returns ellipsoid's acronym.
@ RenderPercentage
Percentage of another measurement (e.g., canvas size, feature size)
double convertToMapUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to map units.
const QgsDateTimeRange & temporalRange() const
Returns the datetime range for the object.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings to use when rendering vector layers.
QgsCoordinateReferenceSystem sourceCrs() const
Returns the source spatial reference system.
@ RenderMillimeters
Millimeters.
double minSizeMM
The minimum size in millimeters, or 0.0 if unset.
QVariantMap customRenderingFlags() const
Gets custom rendering flags.
void setSimplifyHints(SimplifyHints simplifyHints)
Sets the simplification hints of the vector layer managed.
@ RenderPartialOutput
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
@ DistanceKilometers
Kilometers.
void setSegmentationToleranceType(QgsAbstractGeometry::SegmentationToleranceType type)
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
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...
@ UseAdvancedEffects
Enable layer opacity and blending effects.
@ ForceVectorOutput
Vector graphics should not be cached and drawn as raster images.
@ ForceVectorOutput
Vector graphics should not be cached and drawn as raster images.
static Q_INVOKABLE double fromUnitToUnitFactor(QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
void setFlags(QgsRenderContext::Flags flags)
Set combination of flags that will be used for rendering.
bool setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid by its acronym.
@ DrawSelection
Whether vector selections should be shown in the rendered map.
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
bool forceVectorOutput() const
Returns true if rendering operations should use vector operations instead of any faster raster shortc...
QgsAbstractGeometry::SegmentationToleranceType segmentationToleranceType() const
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
@ DistanceDegrees
Degrees, for planar geographic CRS distance measurements.
@ RenderBlocking
Render and load remote sources in the same thread to ensure rendering remote sources (svg and images)...
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
void setPathResolver(const QgsPathResolver &resolver)
Sets the path resolver for conversion between relative and absolute paths during rendering operations...
const QgsFeatureFilterProvider * featureFilterProvider() const
Gets the filter feature provider used for additional filtering of rendered features.
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
void setCoordinateTransform(const QgsCoordinateTransform &t)
Sets the current coordinate transform for the context.
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Sets the simplification setting to use when rendering vector layers.
void setRenderingStopped(bool stopped)
Sets whether the rendering operation has been stopped and any ongoing rendering should be canceled im...
@ Antialiasing
Enable anti-aliasing for map rendering.
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context's map to pixel transform, which transforms between map coordinates and device coordi...
@ DistanceFeet
Imperial feet.
@ DrawSymbolBounds
Draw bounds of symbols (for debugging/testing)
@ DrawSymbolBounds
Draw bounds of symbols (for debugging/testing)
void setFeatureFilterProvider(const QgsFeatureFilterProvider *ffp)
Set a filter feature provider used for additional filtering of rendered features.
@ RenderMapTile
Draw map such that there are no problems between adjacent tiles.
QgsRenderContext & operator=(const QgsRenderContext &rh)
double scale() const
Returns the calculated map scale.
Struct for storing maximum and minimum scales for measurements in map units.
void setSourceCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets source spatial reference system crs.
@ RenderMapTile
Draw map such that there are no problems between adjacent tiles.
const QgsExpressionContext & expressionContext() const
Gets the expression context.
Flag
Enumeration of flags that affect rendering operations.
QColor selectionColor() const
Gets color that is used for drawing of selected vector features.
void setSelectionColor(const QColor &color)
Sets the color to use when rendering selected features.
@ RenderPreviewJob
Render is a 'canvas preview' render, and shortcuts should be taken to ensure fast rendering.
double segmentationTolerance() const
Gets the segmentation tolerance applied when rendering curved geometries.
void setRendererScale(double scale)
Sets the renderer map scale.
void setUseRenderingOptimization(bool enabled)
Sets whether the rendering optimization (geometry simplification) should be executed.
void setTextRenderFormat(TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
void setForceVectorOutput(bool force)
Sets whether rendering operations should use vector operations instead of any faster raster shortcuts...
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the context's coordinate transform context, which stores various information regarding which dat...
@ RenderPartialOutput
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
@ UseRenderingOptimization
Enable vector simplification and other rendering optimizations.
bool maxSizeMMEnabled
Whether the maximum size in mm should be respected.
QgsUnitTypes::DistanceUnit mapUnits
QgsPointXY center() const
Returns the center point of the rectangle.
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
void setDrawEditingInformation(bool b)
Sets whether edit markers should be drawn during the render operation.
@ DistanceMillimeters
Millimeters.
double maxSizeMM
The maximum size in millimeters, or 0.0 if unset.
@ DistanceCentimeters
Centimeters.
QgsCoordinateTransformContext transformContext() const
Returns the context's coordinate transform context, which stores various information regarding which ...
@ DrawEditingInfo
Enable drawing of vertex markers for layers in editing mode.
virtual QgsFeatureFilterProvider * clone() const =0
Create a clone of the feature filter provider.
static QgsRenderContext fromQPainter(QPainter *painter)
Creates a default render context given a pixel based QPainter destination.
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
double computeMapUnitsPerPixel(const QgsRenderContext &c) const
Computes a map units per pixel scaling factor, respecting the minimum and maximum scales set for the ...
@ RenderMetersInMapUnits
Meters value as Map units.
@ RenderUnknownUnit
Mixed or unknown units.
@ DistanceYards
Imperial yards.
QList< QgsRenderedFeatureHandlerInterface * > renderedFeatureHandlers() const
Returns the list of rendered feature handlers to use while rendering the map settings.
double convertMetersToMapUnits(double meters) const
Convert meter distances to active MapUnit values for QgsUnitTypes::RenderMetersInMapUnits.
@ Antialiasing
Use antialiasing while drawing.
@ DistanceMiles
Terrestrial miles.
void setTemporalRange(const QgsDateTimeRange &range)
Sets the temporal range for the object.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
QString ellipsoidAcronym() const
Returns the ellipsoid acronym for the ellipsoid used by the CRS.
@ DistanceNauticalMiles
Nautical miles.
@ RenderBlocking
Render and load remote sources in the same thread to ensure rendering remote sources (svg and images)...
void setUseAdvancedEffects(bool enabled)
Used to enable or disable advanced effects such as blend modes.
void grow(double delta)
Grows the rectangle in place by the specified amount.
double minScale
The minimum scale, or 0.0 if unset.
double outputDpi() const
Returns DPI used for conversion between real world units (e.g.
QPainter * painter()
Returns the destination QPainter for the render operation.
double maxScale
The maximum scale, or 0.0 if unset.
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes takes output image size into accou...
bool minSizeMMEnabled
Whether the minimum size in mm should be respected.
@ RenderPreviewJob
Render is a 'canvas preview' render, and shortcuts should be taken to ensure fast rendering.
bool useRenderingOptimization() const
Returns true if the rendering optimization (geometry simplification) can be executed.
const QgsMapToPixel & mapToPixel() const
@ RenderMapUnits
Map units.
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
@ DrawSelection
Whether vector selections should be shown in the rendered map.
double convertFromMapUnits(double sizeInMapUnits, QgsUnitTypes::RenderUnit outputUnit) const
Converts a size from map units to the specified units.
void setMapExtent(const QgsRectangle &extent)
Sets the original extent of the map being rendered.
Flags flags() const
Returns combination of flags used for rendering.