QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
18 #ifndef QGSRENDERCONTEXT_H
19 #define QGSRENDERCONTEXT_H
21 #include "qgis_core.h"
25 #include <QPainterPath>
72 void setFlags( Qgis::RenderContextFlags flags );
84 Qgis::RenderContextFlags flags()
const;
121 const QPainter *
painter()
const {
return mPainter; }
133 void setPainterFlagsUsingContext( QPainter *painter =
nullptr )
const;
144 QPainter *
maskPainter(
int id = 0 ) {
return mMaskPainter.value(
id,
nullptr ); }
316 bool forceVectorOutput()
const;
323 bool useAdvancedEffects()
const;
330 void setUseAdvancedEffects(
bool enabled );
337 bool drawEditingInformation()
const;
391 bool showSelection()
const;
445 void setDrawEditingInformation(
bool b );
540 void setForceVectorOutput(
bool force );
570 void setShowSelection(
bool showSelection );
577 bool useRenderingOptimization()
const;
584 void setUseRenderingOptimization(
bool enabled );
721 double convertMetersToMapUnits(
double meters )
const;
731 return mTextRenderFormat;
742 mTextRenderFormat = format;
750 QList<QgsRenderedFeatureHandlerInterface *> renderedFeatureHandlers()
const;
846 QList< QgsMapClippingRegion > clippingRegions()
const;
873 void setFeatureClipGeometry(
const QgsGeometry &geometry );
882 QPointF textureOrigin()
const;
891 void setTextureOrigin(
const QPointF &origin );
899 void addSymbolLayerClipPath(
const QgsSymbolLayer *symbolLayer, QPainterPath path );
905 QList<QPainterPath> symbolLayerClipPaths(
const QgsSymbolLayer *symbolLayer )
const;
933 QSize outputSize()
const;
941 void setOutputSize( QSize size );
951 float devicePixelRatio()
const;
961 void setDevicePixelRatio(
float ratio );
974 QSize deviceOutputSize()
const;
1021 double frameRate()
const;
1031 void setFrameRate(
double rate );
1041 long long currentFrame()
const;
1051 void setCurrentFrame(
long long frame );
1055 Qgis::RenderContextFlags mFlags;
1058 QPainter *mPainter =
nullptr;
1066 QMap<int, QPainter *> mMaskPainter;
1079 int mCurrentMaskId = -1;
1085 bool mIsGuiPreview =
false;
1103 bool mRenderingStopped =
false;
1109 double mScaleFactor = 1.0;
1112 double mDpiTarget = -1.0;
1115 double mRendererScale = 1.0;
1117 double mSymbologyReferenceScale = -1;
1126 QColor mSelectionColor;
1138 std::unique_ptr< QgsFeatureFilterProvider > mFeatureFilterProvider;
1140 double mSegmentationTolerance = M_PI_2 / 90;
1149 QList< QgsRenderedFeatureHandlerInterface * > mRenderedFeatureHandlers;
1150 bool mHasRenderedFeatureHandlers =
false;
1151 QVariantMap mCustomRenderingFlags;
1153 QSet<const QgsSymbolLayer *> mDisabledSymbolLayers;
1155 QList< QgsMapClippingRegion > mClippingRegions;
1158 QPointF mTextureOrigin;
1163 float mDevicePixelRatio = 1.0;
1164 QImage::Format mImageFormat = QImage::Format_ARGB32_Premultiplied;
1168 double mFrameRate = -1;
1169 long long mCurrentFrame = -1;
1172 QMap< const QgsSymbolLayer *, QList<QPainterPath> > mSymbolLayerClipPaths;
1175 bool mHasTransformContext =
false;
1203 : mContext( context )
1204 , mPreviousPainter( context.painter() )
1232 QPainter *mPreviousPainter =
nullptr;
1233 bool mReleased =
false;
1260 : mContext( context )
1304 : mContext( context )
1346 : mPainter( painter )
1356 mPainter->restore();
1361 QPainter *mPainter =
nullptr;
1385 : mContext( &context )
1386 , mOriginalScale( context.symbologyReferenceScale() )
1395 : mContext( o.mContext )
1396 , mOriginalScale( o.mOriginalScale )
1398 o.mContext =
nullptr;
1413 double mOriginalScale = 0;
@ MaximumAngle
Maximum angle between generating radii (lines from arc center to output vertices)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QPainter * maskPainter(int id=0)
Returns a mask QPainter for the render operation.
void setImageFormat(QImage::Format format)
Sets QImage format which should be used for QImages created during rendering.
This class contains information how to simplify geometries fetched from a vector layer.
QgsLabelSink * labelSink() const
Returns the associated label sink, or nullptr if not set.
Scoped object for temporary override of the symbologyReferenceScale property of a QgsRenderContext.
void setCustomRenderingFlag(const QString &flag, const QVariant &value)
Sets a custom rendering flag.
void setIsGuiPreview(bool preview)
Sets GUI preview mode.
void setDpiTarget(double dpi)
Sets the targeted dpi for rendering.
Contains information about the context in which a coordinate transform is executed.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
A map clipping region (in map coordinates and CRS).
TextRenderFormat
Options for rendering text.
RenderUnit
Rendering size units.
QgsExpressionContext & expressionContext()
Gets the expression context.
const QgsExpressionContext & expressionContext() const
Gets the expression context (const version).
QImage::Format imageFormat() const
Returns the QImage format which should be used for QImages created during rendering.
void clearCustomRenderingFlag(const QString &flag)
Clears the specified custom rendering flag.
void setSegmentationTolerance(double tolerance)
Sets the segmentation tolerance applied when rendering curved geometries.
void setLabelSink(QgsLabelSink *sink)
Assigns the label sink which will take over responsibility for handling labels.
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
Abstract base class that can be used to intercept rendered labels from a labeling / rendering job.
Qgis::RendererUsage rendererUsage() const
Returns the renderer usage.
bool hasRenderedFeatureHandlers() const
Returns true if the context has any rendered feature handlers.
Contains information about the context of a rendering operation.
void setLabelingEngine(QgsLabelingEngine *engine)
Assigns the labeling engine.
QgsScopedRenderContextScaleToPixels(QgsRenderContext &context)
Constructor for QgsScopedRenderContextScaleToPixels.
~QgsScopedRenderContextPainterSwap()
Returns the destination painter for the context back to the original QPainter object.
RenderSubcomponentProperty
Rendering subcomponent properties.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle.
QgsScopedRenderContextReferenceScaleOverride(QgsScopedRenderContextReferenceScaleOverride &&o) noexcept
Move constructor.
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
QgsScopedRenderContextReferenceScaleOverride(QgsRenderContext &context, double scale)
Constructor for QgsScopedRenderContextReferenceScaleOverride.
Qgis::TextRenderFormat textRenderFormat() const
Returns the text render format, which dictates how text is rendered (e.g.
const QgsDistanceArea & distanceArea() const
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
double dpiTarget() const
Returns the targeted DPI for rendering.
void setSegmentationToleranceType(QgsAbstractGeometry::SegmentationToleranceType type)
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
A rectangle specified with double values.
QgsScopedRenderContextPainterSwap(QgsRenderContext &context, QPainter *temporaryPainter)
Constructor for QgsScopedRenderContextPainterSwap.
An interface for classes which provider custom handlers for features rendered as part of a map render...
bool isSymbolLayerEnabled(const QgsSymbolLayer *layer) const
When rendering a map layer in a second pass (for selective masking), some symbol layers may be disabl...
int currentMaskId() const
Returns the current mask id, which can be used with maskPainter()
bool renderingStopped() const
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled...
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
const QgsMaskIdProvider * maskIdProvider() const
Returns the mask id provider attached to the context.
QgsScopedRenderContextScaleToMm(QgsRenderContext &context)
Constructor for QgsScopedRenderContextScaleToMm.
void setMaskIdProvider(QgsMaskIdProvider *provider)
Attaches a mask id provider to the context.
QVariantMap customRenderingFlags() const
Gets custom rendering flags.
void setPathResolver(const QgsPathResolver &resolver)
Sets the path resolver for conversion between relative and absolute paths during rendering operations...
Base class for feedback objects to be used for cancellation of something running in a worker thread.
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
~QgsScopedRenderContextScaleToPixels()
Returns the destination painter back to millimeter based units.
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...
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context's map to pixel transform, which transforms between map coordinates and device coordi...
double segmentationTolerance() const
Gets the segmentation tolerance applied when rendering curved geometries.
QgsAbstractGeometry::SegmentationToleranceType segmentationToleranceType() const
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
void setDistanceArea(const QgsDistanceArea &distanceArea)
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
Struct for storing maximum and minimum scales for measurements in map units.
Scoped object for saving and restoring a QPainter object's state.
RenderContextFlag
Flags which affect rendering operations.
const QPainter * painter() const
Returns the const destination QPainter for the render operation.
Scoped object for temporary scaling of a QgsRenderContext for millimeter based rendering.
Abstract base class for all geometries.
@ Unknown
Renderer used for unknown usage.
void reset()
Resets the destination painter for the context back to the original QPainter object.
void setSelectionColor(const QColor &color)
Sets the color to use when rendering selected features.
const QgsVectorSimplifyMethod & vectorSimplifyMethod() const
Returns the simplification settings to use when rendering vector layers.
void setRendererScale(double scale)
Sets the renderer map scale.
The QgsLabelingEngine class provides map labeling functionality. The input for the engine is a list o...
~QgsScopedQPainterState()
Restores the painter back to its original state.
Scoped object for temporary replacement of a QgsRenderContext destination painter.
QColor selectionColor() const
Returns the color to use when rendering selected features.
QgsLabelingEngine * labelingEngine() const
Gets access to new labeling engine (may be nullptr).
This class allows the creation of mask ids based on the different label layers and to give a mask id ...
QgsRange which stores a range of double values.
QgsRectangle mapExtent() const
Returns the original extent of the map being rendered.
const QgsAbstractGeometry * geometry() const
Returns pointer to the unsegmentized geometry.
A geometry is the spatial representation of a feature.
Perform transforms between map coordinates and device coordinates.
~QgsScopedRenderContextReferenceScaleOverride()
Returns the render context back to the original reference scale.
double symbologyReferenceScale() const
Returns the symbology reference scale.
bool isGuiPreview() const
Returns the Gui preview mode.
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
Abstract interface for use by classes that filter the features or attributes of a layer.
QgsScopedQPainterState(QPainter *painter)
Constructor for QgsScopedQPainterState.
RendererUsage
Usage of the renderer.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
~QgsScopedRenderContextScaleToMm()
Returns the destination painter back to pixel based units.
void setSymbologyReferenceScale(double scale)
Sets the symbology reference scale.
Scoped object for temporary scaling of a QgsRenderContext for pixel based rendering.
void setTextRenderFormat(Qgis::TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
QPainter * painter()
Returns the destination QPainter for the render operation.
void setRendererUsage(Qgis::RendererUsage usage)
Sets the renderer usage.
void setGeometry(const QgsAbstractGeometry *geometry)
Sets pointer to original (unsegmentized) geometry.
double rendererScale() const
Returns the renderer map scale.
void setDisabledSymbolLayers(const QSet< const QgsSymbolLayer * > &symbolLayers)
When rendering a map layer in a second pass (for selective masking), some symbol layers may be disabl...
The QgsMapSettings class contains configuration for rendering of the map. The rendering itself is don...
QSet< const QgsSymbolLayer * > disabledSymbolLayers() const
When rendering a map layer in a second pass (for selective masking), some symbol layers may be disabl...
void setCurrentMaskId(int id)
Stores a mask id as the "current" one.
Resolves relative paths into absolute paths and vice versa. Used for writing.
Base class for objects with an associated (optional) temporal range.
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
void setMapExtent(const QgsRectangle &extent)
Sets the original extent of the map being rendered.
void setMaskPainter(QPainter *p, int id=0)
Sets a mask QPainter for the render operation.
@ Generic
Generic subcomponent property.