18#ifndef QGSRENDERCONTEXT_H
19#define QGSRENDERCONTEXT_H
41#include <QPainterPath>
120 const QPainter *
painter()
const {
return mPainter; }
155 void setPainterFlagsUsingContext( QPainter *painter =
nullptr )
const;
166 QPainter *
maskPainter(
int id = 0 ) {
return mMaskPainter.value(
id,
nullptr ); }
180 Q_DECL_DEPRECATED
void setDisabledSymbolLayers(
const QSet<const QgsSymbolLayer *> &symbolLayers )
SIP_DEPRECATED;
191 void setDisabledSymbolLayersV2(
const QSet<QString> &symbolLayers );
203 Q_DECL_DEPRECATED QSet<const QgsSymbolLayer *> disabledSymbolLayers() const
SIP_DEPRECATED;
214 QSet<QString> disabledSymbolLayersV2() const;
387 Q_DECL_DEPRECATED
void setUseAdvancedEffects(
bool enabled )
SIP_DEPRECATED;
394 bool drawEditingInformation() const;
448 bool showSelection()
const;
502 void setDrawEditingInformation(
bool b );
598 Q_DECL_DEPRECATED
void setForceVectorOutput(
bool force )
SIP_DEPRECATED;
628 void setShowSelection(
bool showSelection );
635 bool useRenderingOptimization()
const;
642 void setUseRenderingOptimization(
bool enabled );
780 double convertFromMapUnits(
double sizeInMapUnits,
Qgis::RenderUnit outputUnit )
const;
786 double convertMetersToMapUnits(
double meters )
const;
796 return mTextRenderFormat;
807 mTextRenderFormat = format;
815 QList<QgsRenderedFeatureHandlerInterface *> renderedFeatureHandlers()
const;
914 void setCustomProperty(
const QString &property,
const QVariant &value ) { mCustomProperties[property] = value; }
939 QList< QgsMapClippingRegion > clippingRegions()
const;
966 void setFeatureClipGeometry(
const QgsGeometry &geometry );
975 QPointF textureOrigin()
const;
984 void setTextureOrigin(
const QPointF &origin );
1019 Q_DECL_DEPRECATED
void addSymbolLayerClipPath(
const QString &symbolLayerId, QPainterPath path )
SIP_DEPRECATED;
1027 Q_DECL_DEPRECATED QList<QPainterPath> symbolLayerClipPaths(
const QString &symbolLayerId )
const SIP_DEPRECATED;
1035 void addSymbolLayerClipGeometry(
const QString &symbolLayerId,
const QgsGeometry &geometry );
1043 bool symbolLayerHasClipGeometries(
const QString &symbolLayerId )
const;
1052 QVector<QgsGeometry> symbolLayerClipGeometries(
const QString &symbolLayerId )
const;
1078 QSize outputSize()
const;
1086 void setOutputSize( QSize size );
1096 float devicePixelRatio()
const;
1106 void setDevicePixelRatio(
float ratio );
1119 QSize deviceOutputSize()
const;
1182 double frameRate()
const;
1192 void setFrameRate(
double rate );
1202 long long currentFrame()
const;
1212 void setCurrentFrame(
long long frame );
1235 void matchRasterizedRenderingPolicyToFlags();
1241 QPainter *mPainter =
nullptr;
1244 QPainter *mPreviewRenderPainter =
nullptr;
1252 QMap<int, QPainter *> mMaskPainter;
1265 int mCurrentMaskId = -1;
1271 bool mIsGuiPreview =
false;
1288 bool mRenderingStopped =
false;
1294 double mScaleFactor = 1.0;
1297 double mDpiTarget = -1.0;
1300 double mRendererScale = 1.0;
1302 double mSymbologyReferenceScale = -1;
1311 QColor mSelectionColor;
1323 std::unique_ptr< QgsFeatureFilterProvider > mFeatureFilterProvider;
1325 double mSegmentationTolerance = M_PI_2 / 90;
1334 QList< QgsRenderedFeatureHandlerInterface * > mRenderedFeatureHandlers;
1335 bool mHasRenderedFeatureHandlers =
false;
1336 QVariantMap mCustomProperties;
1338 QSet<QString> mDisabledSymbolLayers;
1340 QList< QgsMapClippingRegion > mClippingRegions;
1343 QPointF mTextureOrigin;
1348 float mDevicePixelRatio = 1.0;
1349 QImage::Format mImageFormat = QImage::Format_ARGB32_Premultiplied;
1353 double mFrameRate = -1;
1354 long long mCurrentFrame = -1;
1357 QMap< QString, QVector<QgsGeometry> > mSymbolLayerClippingGeometries;
1362 bool mHasTransformContext =
false;
1392 : mContext( context )
1393 , mPreviousPainter( context.painter() )
1395 mContext.setPainter( temporaryPainter );
1405 mContext.setPainter( mPreviousPainter );
1421 QPainter *mPreviousPainter =
nullptr;
1422 bool mReleased =
false;
1449 : mContext( context )
1451 if ( mContext.painter() )
1452 mContext.painter()->scale( mContext.scaleFactor(), mContext.scaleFactor() );
1460 if ( mContext.painter() )
1461 mContext.painter()->scale( 1.0 / mContext.scaleFactor(), 1.0 / mContext.scaleFactor() );
1493 : mContext( context )
1495 if ( mContext.painter() )
1496 mContext.painter()->scale( 1.0 / mContext.scaleFactor(), 1.0 / mContext.scaleFactor() );
1504 if ( mContext.painter() )
1505 mContext.painter()->scale( mContext.scaleFactor(), mContext.scaleFactor() );
1535 : mPainter( painter )
1545 mPainter->restore();
1550 QPainter *mPainter =
nullptr;
1574 : mContext( &context )
1575 , mOriginalScale( context.symbologyReferenceScale() )
1577 mContext->setSymbologyReferenceScale( scale );
1584 : mContext( o.mContext )
1585 , mOriginalScale( o.mOriginalScale )
1587 o.mContext =
nullptr;
1596 mContext->setSymbologyReferenceScale( mOriginalScale );
1602 double mOriginalScale = 0;
RasterizedRenderingPolicy
Policies controlling when rasterisation of content during renders is permitted.
@ Default
Allow raster-based rendering in situations where it is required for correct rendering or where it wil...
RenderSubcomponentProperty
Rendering subcomponent properties.
@ Generic
Generic subcomponent property.
QFlags< RenderContextFlag > RenderContextFlags
Render context flags.
TextRenderFormat
Options for rendering text.
@ AlwaysOutlines
Always render text using path objects (AKA outlines/curves). This setting guarantees the best quality...
RenderUnit
Rendering size units.
RenderContextFlag
Flags which affect rendering operations.
RendererUsage
Usage of the renderer.
@ Unknown
Renderer used for unknown usage.
Abstract base class for all geometries.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle.
@ MaximumAngle
Maximum angle between generating radii (lines from arc center to output vertices).
Contains information about the context in which a coordinate transform is executed.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
QgsRange which stores a range of double values.
Stores a digital elevation model in a raster image which may get updated as a part of the map layer r...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Abstract interface for use by classes that filter the features or attributes of a layer.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
A geometry is the spatial representation of a feature.
Abstract base class that can be used to intercept rendered labels from a labeling / rendering job.
Provides map labeling functionality.
A map clipping region (in map coordinates and CRS).
Contains configuration for rendering maps.
Perform transforms between map coordinates and device coordinates.
Struct for storing maximum and minimum scales for measurements in map units.
Allows the creation of mask ids based on the different label layers and to give a mask id from a labe...
Contains settings regarding how masks are calculated and handled during a map render.
Resolves relative paths into absolute paths and vice versa.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
const QgsMaskIdProvider * maskIdProvider() const
Returns the mask id provider attached to the context.
QgsMaskRenderSettings & maskSettings()
Returns a reference to the mask render settings, which control how masks are drawn and behave during ...
void setMapExtent(const QgsRectangle &extent)
Sets the original extent of the map being rendered.
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
void setRenderingStopped(bool stopped)
Sets whether the rendering operation has been stopped and any ongoing rendering should be canceled im...
Q_DECL_DEPRECATED QVariantMap customRenderingFlags() const
Gets custom rendering flags.
void setDistanceArea(const QgsDistanceArea &distanceArea)
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
Qgis::RendererUsage rendererUsage() const
Returns the renderer usage.
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
bool hasRenderedFeatureHandlers() const
Returns true if the context has any rendered feature handlers.
void setImageFormat(QImage::Format format)
Sets QImage format which should be used for QImages created during rendering.
QgsVectorSimplifyMethod & vectorSimplifyMethod()
Returns the simplification settings to use when rendering vector layers.
void setSegmentationToleranceType(QgsAbstractGeometry::SegmentationToleranceType type)
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
double symbologyReferenceScale() const
Returns the symbology reference scale.
double segmentationTolerance() const
Gets the segmentation tolerance applied when rendering curved geometries.
const QPainter * painter() const
Returns the const destination QPainter for the render operation.
const QgsDistanceArea & distanceArea() const
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
Q_DECL_DEPRECATED void clearCustomRenderingFlag(const QString &flag)
Clears the specified custom rendering flag.
const QPainter * previewRenderPainter() const
Returns the const destination QPainter for temporary in-progress preview renders.
QPainter * painter()
Returns the destination QPainter for the render operation.
double rendererScale() const
Returns the renderer map scale.
QgsExpressionContext & expressionContext()
Gets the expression context.
void setTextRenderFormat(Qgis::TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
void setGeometry(const QgsAbstractGeometry *geometry)
Sets pointer to original (unsegmentized) geometry.
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Sets the simplification setting to use when rendering vector layers.
QgsLabelSink * labelSink() const
Returns the associated label sink, or nullptr if not set.
bool isGuiPreview() const
Returns the Gui preview mode.
void setPreviewRenderPainter(QPainter *painter)
Sets the destination painter for temporary in-progress preview renders.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
bool testFlag(Qgis::RenderContextFlag flag) const
Check whether a particular flag is enabled.
void setCurrentMaskId(int id)
Stores a mask id as the "current" one.
void clearCustomProperty(const QString &property)
Clears the specified custom rendering property.
void setDpiTarget(double dpi)
Sets the targeted dpi for rendering.
~QgsRenderContext() override
void setPathResolver(const QgsPathResolver &resolver)
Sets the path resolver for conversion between relative and absolute paths during rendering operations...
void setIsGuiPreview(bool preview)
Sets GUI preview mode.
QVariantMap customProperties() const
Returns custom rendering properties.
void setLabelSink(QgsLabelSink *sink)
Assigns the label sink which will take over responsibility for handling labels.
const QgsExpressionContext & expressionContext() const
Gets the expression context (const version).
Qgis::TextRenderFormat textRenderFormat() const
Returns the text render format, which dictates how text is rendered (e.g.
QgsRectangle mapExtent() const
Returns the original extent of the map being rendered.
void setFlag(Qgis::RenderContextFlag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected).
void setSymbologyReferenceScale(double scale)
Sets the symbology reference scale.
double dpiTarget() const
Returns the targeted DPI for rendering.
const QgsVectorSimplifyMethod & vectorSimplifyMethod() const
Returns the simplification settings to use when rendering vector layers.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
void setFlags(Qgis::RenderContextFlags flags)
Set combination of flags that will be used for rendering.
void setMaskIdProvider(QgsMaskIdProvider *provider)
Attaches a mask id provider to the context.
QColor selectionColor() const
Returns the color to use when rendering selected features.
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
QPainter * maskPainter(int id=0)
Returns a mask QPainter for the render operation.
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context's map to pixel transform, which transforms between map coordinates and device coordi...
int currentMaskId() const
Returns the current mask id, which can be used with maskPainter().
void setCustomProperty(const QString &property, const QVariant &value)
Sets a custom rendering property.
Q_DECL_DEPRECATED void setCustomRenderingFlag(const QString &flag, const QVariant &value)
Sets a custom rendering flag.
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
void setMaskPainter(QPainter *p, int id=0)
Sets a mask QPainter for the render operation.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
void setLabelingEngine(QgsLabelingEngine *engine)
Assigns the labeling engine.
bool renderingStopped() const
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled...
static QgsRenderContext fromQPainter(QPainter *painter)
Creates a default render context given a pixel based QPainter destination.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
void setRendererScale(double scale)
Sets the renderer map scale.
QgsLabelingEngine * labelingEngine() const
Gets access to new labeling engine (may be nullptr).
QPainter * previewRenderPainter()
Returns the const destination QPainter for temporary in-progress preview renders.
void setRendererUsage(Qgis::RendererUsage usage)
Sets the renderer usage.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
Qgis::RenderContextFlags flags() const
Returns combination of flags used for rendering.
QgsAbstractGeometry::SegmentationToleranceType segmentationToleranceType() const
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
const QgsAbstractGeometry * geometry() const
Returns pointer to the unsegmentized geometry.
QImage::Format imageFormat() const
Returns the QImage format which should be used for QImages created during rendering.
QgsRenderContext & operator=(const QgsRenderContext &rh)
const QgsMaskRenderSettings & maskSettings() const
Returns a reference to the mask render settings, which control how masks are drawn and behave during ...
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
void setSelectionColor(const QColor &color)
Sets the color to use when rendering selected features.
void setSegmentationTolerance(double tolerance)
Sets the segmentation tolerance applied when rendering curved geometries.
An interface for classes which provide custom handlers for features rendered as part of a map render ...
QgsScopedQPainterState(QPainter *painter)
Constructor for QgsScopedQPainterState.
~QgsScopedQPainterState()
Restores the painter back to its original state.
QgsScopedRenderContextPainterSwap(QgsRenderContext &context, QPainter *temporaryPainter)
Constructor for QgsScopedRenderContextPainterSwap.
~QgsScopedRenderContextPainterSwap()
Returns the destination painter for the context back to the original QPainter object.
void reset()
Resets the destination painter for the context back to the original QPainter object.
QgsScopedRenderContextReferenceScaleOverride(QgsScopedRenderContextReferenceScaleOverride &&o) noexcept
Move constructor.
~QgsScopedRenderContextReferenceScaleOverride()
Returns the render context back to the original reference scale.
QgsScopedRenderContextReferenceScaleOverride(QgsRenderContext &context, double scale)
Constructor for QgsScopedRenderContextReferenceScaleOverride.
~QgsScopedRenderContextScaleToMm()
Returns the destination painter back to pixel based units.
QgsScopedRenderContextScaleToMm(QgsRenderContext &context)
Constructor for QgsScopedRenderContextScaleToMm.
QgsScopedRenderContextScaleToPixels(QgsRenderContext &context)
Constructor for QgsScopedRenderContextScaleToPixels.
~QgsScopedRenderContextScaleToPixels()
Returns the destination painter back to millimeter based units.
Abstract base class for symbol layers.
QgsTemporalRangeObject(bool enabled=false)
Constructor QgsTemporalRangeObject.
Contains settings for simplifying geometries fetched from a vector layer.