QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
18 #ifndef QGSRENDERCONTEXT_H
19 #define QGSRENDERCONTEXT_H
21 #include "qgis_core.h"
71 DrawEditingInfo = 0x01,
72 ForceVectorOutput = 0x02,
73 UseAdvancedEffects = 0x04,
74 UseRenderingOptimization = 0x08,
76 DrawSymbolBounds = 0x20,
79 RenderPartialOutput = 0x100,
80 RenderPreviewJob = 0x200,
81 RenderBlocking = 0x400,
82 RenderSymbolPreview = 0x800,
84 Q_DECLARE_FLAGS( Flags, Flag )
134 void setFlags( QgsRenderContext::Flags flags );
140 void setFlag( Flag flag,
bool on =
true );
152 bool testFlag( Flag flag )
const;
183 const QPainter *
painter()
const {
return mPainter; }
195 QPainter *
maskPainter(
int id = 0 ) {
return mMaskPainter.value(
id,
nullptr ); }
333 bool forceVectorOutput()
const;
340 bool useAdvancedEffects()
const;
347 void setUseAdvancedEffects(
bool enabled );
354 bool drawEditingInformation()
const;
383 bool showSelection()
const;
437 void setDrawEditingInformation(
bool b );
503 void setForceVectorOutput(
bool force );
525 void setShowSelection(
bool showSelection );
532 bool useRenderingOptimization()
const;
539 void setUseRenderingOptimization(
bool enabled );
671 double convertMetersToMapUnits(
double meters )
const;
681 return mTextRenderFormat;
692 mTextRenderFormat = format;
700 QList<QgsRenderedFeatureHandlerInterface *> renderedFeatureHandlers()
const;
794 QPainter *mPainter =
nullptr;
802 QMap<int, QPainter *> mMaskPainter;
815 int mCurrentMaskId = -1;
821 bool mIsGuiPreview =
false;
839 bool mRenderingStopped =
false;
842 double mScaleFactor = 1.0;
845 double mRendererScale = 1.0;
851 QColor mSelectionColor;
863 std::unique_ptr< QgsFeatureFilterProvider > mFeatureFilterProvider;
865 double mSegmentationTolerance = M_PI_2 / 90;
873 TextRenderFormat mTextRenderFormat = TextFormatAlwaysOutlines;
874 QList< QgsRenderedFeatureHandlerInterface * > mRenderedFeatureHandlers;
875 bool mHasRenderedFeatureHandlers =
false;
876 QVariantMap mCustomRenderingFlags;
878 QSet<const QgsSymbolLayer *> mDisabledSymbolLayers;
881 bool mHasTransformContext =
false;
885 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsRenderContext::Flags )
911 : mContext( context )
912 , mPreviousPainter( context.painter() )
940 QPainter *mPreviousPainter =
nullptr;
941 bool mReleased =
false;
968 : mContext( context )
1012 : mContext( context )
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.
void setCustomRenderingFlag(const QString &flag, const QVariant &value)
Sets a custom rendering flag.
void setIsGuiPreview(bool preview)
Sets GUI preview mode.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
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.
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...
QgsScopedRenderContextPainterSwap(QgsRenderContext &context, QPainter *temporaryPainter)
Constructor for QgsScopedRenderContextPainterSwap.
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...
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.
const QPainter * painter() const
Returns the const destination QPainter for the render operation.
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. The input for the engine is a list o...
void setTextRenderFormat(TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
QColor selectionColor() const
Returns the color to use when rendering selected features.
QgsLabelingEngine * labelingEngine() const
Gets access to new labeling engine (may be nullptr)
QgsRectangle mapExtent() const
Returns the original extent of the map being rendered.
const QgsAbstractGeometry * geometry() const
Returns pointer to the unsegmentized geometry.
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...
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
~QgsScopedRenderContextScaleToMm()
Returns the destination painter back to pixel based units.
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).
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.
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.