18 #ifndef QGSRENDERCONTEXT_H
19 #define QGSRENDERCONTEXT_H
21 #include "qgis_core.h"
73 DrawEditingInfo = 0x01,
74 ForceVectorOutput = 0x02,
75 UseAdvancedEffects = 0x04,
76 UseRenderingOptimization = 0x08,
78 DrawSymbolBounds = 0x20,
81 RenderPartialOutput = 0x100,
82 RenderPreviewJob = 0x200,
83 RenderBlocking = 0x400,
84 RenderSymbolPreview = 0x800,
85 LosslessImageRendering = 0x1000,
86 ApplyScalingWorkaroundForTextRendering = 0x2000,
88 ApplyClipAfterReprojection = 0x8000,
90 Q_DECLARE_FLAGS( Flags, Flag )
140 void setFlags( QgsRenderContext::Flags flags );
146 void setFlag( Flag flag,
bool on =
true );
158 bool testFlag( Flag flag )
const;
189 const QPainter *
painter()
const {
return mPainter; }
201 void setPainterFlagsUsingContext( QPainter *painter =
nullptr )
const;
212 QPainter *
maskPainter(
int id = 0 ) {
return mMaskPainter.value(
id,
nullptr ); }
350 bool forceVectorOutput()
const;
357 bool useAdvancedEffects()
const;
364 void setUseAdvancedEffects(
bool enabled );
371 bool drawEditingInformation()
const;
400 bool showSelection()
const;
454 void setDrawEditingInformation(
bool b );
520 void setForceVectorOutput(
bool force );
542 void setShowSelection(
bool showSelection );
549 bool useRenderingOptimization()
const;
556 void setUseRenderingOptimization(
bool enabled );
688 double convertMetersToMapUnits(
double meters )
const;
698 return mTextRenderFormat;
709 mTextRenderFormat = format;
717 QList<QgsRenderedFeatureHandlerInterface *> renderedFeatureHandlers()
const;
813 QList< QgsMapClippingRegion > clippingRegions()
const;
840 void setFeatureClipGeometry(
const QgsGeometry &geometry );
849 QPointF textureOrigin()
const;
858 void setTextureOrigin(
const QPointF &origin );
881 QPainter *mPainter =
nullptr;
889 QMap<int, QPainter *> mMaskPainter;
902 int mCurrentMaskId = -1;
908 bool mIsGuiPreview =
false;
926 bool mRenderingStopped =
false;
929 double mScaleFactor = 1.0;
932 double mRendererScale = 1.0;
938 QColor mSelectionColor;
950 std::unique_ptr< QgsFeatureFilterProvider > mFeatureFilterProvider;
952 double mSegmentationTolerance = M_PI_2 / 90;
960 TextRenderFormat mTextRenderFormat = TextFormatAlwaysOutlines;
961 QList< QgsRenderedFeatureHandlerInterface * > mRenderedFeatureHandlers;
962 bool mHasRenderedFeatureHandlers =
false;
963 QVariantMap mCustomRenderingFlags;
965 QSet<const QgsSymbolLayer *> mDisabledSymbolLayers;
967 QList< QgsMapClippingRegion > mClippingRegions;
970 QPointF mTextureOrigin;
975 bool mHasTransformContext =
false;
1005 : mContext( context )
1006 , mPreviousPainter( context.painter() )
1034 QPainter *mPreviousPainter =
nullptr;
1035 bool mReleased =
false;
1062 : mContext( context )
1106 : mContext( context )
1148 : mPainter( painter )
1158 mPainter->restore();
1163 QPainter *mPainter =
nullptr;
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.
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.
A geometry is the spatial representation of a feature.
The QgsLabelingEngine class provides map labeling functionality.
A map clipping region (in map coordinates and CRS).
The QgsMapSettings class contains configuration for rendering of the map.
Perform transforms between map coordinates and device coordinates.
Struct for storing maximum and minimum scales for measurements in map units.
This class allows the creation of mask ids based on the different label layers and to give a mask id ...
Resolves relative paths into absolute paths and vice versa.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
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...
void setDistanceArea(const QgsDistanceArea &distanceArea)
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
QPainter * maskPainter(int id=0)
Returns a mask QPainter for the render operation.
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.
TextRenderFormat
Options for rendering text.
@ TextFormatAlwaysText
Always render text as text objects.
@ TextFormatAlwaysOutlines
Always render text using path objects (AKA outlines/curves).
void setSegmentationToleranceType(QgsAbstractGeometry::SegmentationToleranceType type)
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
void setTextRenderFormat(TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
double segmentationTolerance() const
Gets the segmentation tolerance applied when rendering curved geometries.
const QgsAbstractGeometry * geometry() const
Returns pointer to the unsegmentized geometry.
void clearCustomRenderingFlag(const QString &flag)
Clears the specified custom rendering flag.
QPainter * painter()
Returns the destination QPainter for the render operation.
double rendererScale() const
Returns the renderer map scale.
QgsExpressionContext & expressionContext()
Gets the expression context.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
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.
QVariantMap customRenderingFlags() const
Gets custom rendering flags.
bool isGuiPreview() const
Returns the Gui preview mode.
void setCurrentMaskId(int id)
Stores a mask id as the "current" one.
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...
~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.
QgsRectangle mapExtent() const
Returns the original extent of the map being rendered.
QSet< const QgsSymbolLayer * > disabledSymbolLayers() const
When rendering a map layer in a second pass (for selective masking), some symbol layers may be disabl...
void setMaskIdProvider(QgsMaskIdProvider *provider)
Attaches a mask id provider to the context.
const QPainter * painter() const
Returns the const destination QPainter for the render operation.
QColor selectionColor() const
Returns the color to use when rendering selected features.
const QgsExpressionContext & expressionContext() const
Gets the expression context (const version).
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
QgsLabelingEngine * labelingEngine() const
Gets access to new labeling engine (may be nullptr)
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context's map to pixel transform, which transforms between map coordinates and device coordi...
Flag
Enumeration of flags that affect rendering operations.
int currentMaskId() const
Returns the current mask id, which can be used with maskPainter()
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.
bool isSymbolLayerEnabled(const QgsSymbolLayer *layer) const
When rendering a map layer in a second pass (for selective masking), some symbol layers may be disabl...
void setMaskPainter(QPainter *p, int id=0)
Sets a mask QPainter for the render operation.
const QgsDistanceArea & distanceArea() const
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
void setLabelingEngine(QgsLabelingEngine *engine)
Assign new labeling engine.
bool renderingStopped() const
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled...
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
void setRendererScale(double scale)
Sets the renderer map scale.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
QgsAbstractGeometry::SegmentationToleranceType segmentationToleranceType() const
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
const QgsVectorSimplifyMethod & vectorSimplifyMethod() const
Returns the simplification settings to use when rendering vector layers.
TextRenderFormat textRenderFormat() const
Returns the text render format, which dictates how text is rendered (e.g.
const QgsMaskIdProvider * maskIdProvider() const
Returns the mask id provider attached to the context.
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 provider custom handlers for features rendered as part of a map render...
Scoped object for saving and restoring a QPainter object's state.
QgsScopedQPainterState(QPainter *painter)
Constructor for QgsScopedQPainterState.
~QgsScopedQPainterState()
Restores the painter back to its original state.
Scoped object for temporary replacement of a QgsRenderContext destination painter.
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.
Scoped object for temporary scaling of a QgsRenderContext for millimeter based rendering.
~QgsScopedRenderContextScaleToMm()
Returns the destination painter back to pixel based units.
QgsScopedRenderContextScaleToMm(QgsRenderContext &context)
Constructor for QgsScopedRenderContextScaleToMm.
Scoped object for temporary scaling of a QgsRenderContext for pixel based rendering.
QgsScopedRenderContextScaleToPixels(QgsRenderContext &context)
Constructor for QgsScopedRenderContextScaleToPixels.
~QgsScopedRenderContextScaleToPixels()
Returns the destination painter back to millimeter based units.
Base class for objects with an associated (optional) temporal range.
RenderUnit
Rendering size units.
This class contains information how to simplify geometries fetched from a vector layer.
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.