QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
18 #ifndef QGSRENDERCONTEXT_H
19 #define QGSRENDERCONTEXT_H
21 #include "qgis_core.h"
72 DrawEditingInfo = 0x01,
73 ForceVectorOutput = 0x02,
74 UseAdvancedEffects = 0x04,
75 UseRenderingOptimization = 0x08,
77 DrawSymbolBounds = 0x20,
80 RenderPartialOutput = 0x100,
81 RenderPreviewJob = 0x200,
82 RenderBlocking = 0x400,
83 RenderSymbolPreview = 0x800,
84 LosslessImageRendering = 0x1000,
85 ApplyScalingWorkaroundForTextRendering = 0x2000,
87 ApplyClipAfterReprojection = 0x8000,
89 Q_DECLARE_FLAGS( Flags, Flag )
139 void setFlags( QgsRenderContext::Flags flags );
145 void setFlag( Flag flag,
bool on =
true );
157 bool testFlag( Flag flag )
const;
188 const QPainter *
painter()
const {
return mPainter; }
200 void setPainterFlagsUsingContext( QPainter *painter =
nullptr )
const;
211 QPainter *
maskPainter(
int id = 0 ) {
return mMaskPainter.value(
id,
nullptr ); }
349 bool forceVectorOutput()
const;
356 bool useAdvancedEffects()
const;
363 void setUseAdvancedEffects(
bool enabled );
370 bool drawEditingInformation()
const;
399 bool showSelection()
const;
453 void setDrawEditingInformation(
bool b );
519 void setForceVectorOutput(
bool force );
541 void setShowSelection(
bool showSelection );
548 bool useRenderingOptimization()
const;
555 void setUseRenderingOptimization(
bool enabled );
687 double convertMetersToMapUnits(
double meters )
const;
697 return mTextRenderFormat;
708 mTextRenderFormat = format;
716 QList<QgsRenderedFeatureHandlerInterface *> renderedFeatureHandlers()
const;
812 QList< QgsMapClippingRegion > clippingRegions()
const;
839 void setFeatureClipGeometry(
const QgsGeometry &geometry );
848 QPointF textureOrigin()
const;
857 void setTextureOrigin(
const QPointF &origin );
864 QPainter *mPainter =
nullptr;
872 QMap<int, QPainter *> mMaskPainter;
885 int mCurrentMaskId = -1;
891 bool mIsGuiPreview =
false;
909 bool mRenderingStopped =
false;
912 double mScaleFactor = 1.0;
915 double mRendererScale = 1.0;
921 QColor mSelectionColor;
933 std::unique_ptr< QgsFeatureFilterProvider > mFeatureFilterProvider;
935 double mSegmentationTolerance = M_PI_2 / 90;
943 TextRenderFormat mTextRenderFormat = TextFormatAlwaysOutlines;
944 QList< QgsRenderedFeatureHandlerInterface * > mRenderedFeatureHandlers;
945 bool mHasRenderedFeatureHandlers =
false;
946 QVariantMap mCustomRenderingFlags;
948 QSet<const QgsSymbolLayer *> mDisabledSymbolLayers;
950 QList< QgsMapClippingRegion > mClippingRegions;
953 QPointF mTextureOrigin;
956 bool mHasTransformContext =
false;
986 : mContext( context )
987 , mPreviousPainter( context.painter() )
1015 QPainter *mPreviousPainter =
nullptr;
1016 bool mReleased =
false;
1043 : mContext( context )
1087 : mContext( context )
1129 : mPainter( painter )
1139 mPainter->restore();
1144 QPainter *mPainter =
nullptr;
TextRenderFormat textRenderFormat() const
Returns the text render format, which dictates how text is rendered (e.g.
@ 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.
This class contains information how to simplify geometries fetched from a vector layer.
void setCustomRenderingFlag(const QString &flag, const QVariant &value)
Sets a custom rendering flag.
void setIsGuiPreview(bool preview)
Sets GUI preview mode.
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).
RenderUnit
Rendering size units.
QgsExpressionContext & expressionContext()
Gets the expression context.
const QgsExpressionContext & expressionContext() const
Gets the expression context (const version).
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 setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
bool hasRenderedFeatureHandlers() const
Returns true if the context has any rendered feature handlers.
Contains information about the context of a rendering operation.
TextRenderFormat
Options for rendering text.
void setLabelingEngine(QgsLabelingEngine *engine)
Assign new labeling engine.
QgsScopedRenderContextScaleToPixels(QgsRenderContext &context)
Constructor for QgsScopedRenderContextScaleToPixels.
~QgsScopedRenderContextPainterSwap()
Returns the destination painter for the context back to the original QPainter object.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle.
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...
const QgsDistanceArea & distanceArea() const
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
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...
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.
@ TextFormatAlwaysText
Always render text as text objects.
void setRenderingStopped(bool stopped)
Sets whether the rendering operation has been stopped and any ongoing rendering should be canceled im...
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
~QgsRenderContext() override
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.
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.
Flag
Enumeration of flags that affect rendering operations.
Abstract base class for all geometries.
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.
void setTextRenderFormat(TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
~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)
Some rendering operations may need multiple mask images.
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.
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 of a layer.
QgsScopedQPainterState(QPainter *painter)
Constructor for QgsScopedQPainterState.
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.
Scoped object for temporary scaling of a QgsRenderContext for pixel based rendering.
QPainter * painter()
Returns the destination QPainter for the render operation.
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...
@ TextFormatAlwaysOutlines
Always render text using path objects (AKA outlines/curves).
The QgsMapSettings class contains configuration for rendering of the map.
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.
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.