QGIS API Documentation
3.10.0-A Coruña (6c816b4204)
|
Contains information about the context of a rendering operation. More...
#include <qgsrendercontext.h>
Public Types | |
enum | Flag { DrawEditingInfo = 0x01, ForceVectorOutput = 0x02, UseAdvancedEffects = 0x04, UseRenderingOptimization = 0x08, DrawSelection = 0x10, DrawSymbolBounds = 0x20, RenderMapTile = 0x40, Antialiasing = 0x80, RenderPartialOutput = 0x100, RenderPreviewJob = 0x200, RenderBlocking = 0x400 } |
Enumeration of flags that affect rendering operations. More... | |
enum | TextRenderFormat { TextFormatAlwaysOutlines, TextFormatAlwaysText } |
Options for rendering text. More... | |
Public Member Functions | |
QgsRenderContext () | |
QgsRenderContext (const QgsRenderContext &rh) | |
double | convertFromMapUnits (double sizeInMapUnits, QgsUnitTypes::RenderUnit outputUnit) const |
Converts a size from map units to the specified units. More... | |
double | convertMetersToMapUnits (double meters) const |
Convert meter distances to active MapUnit values for QgsUnitTypes::RenderMetersInMapUnits. More... | |
double | convertToMapUnits (double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const |
Converts a size from the specified units to map units. More... | |
double | convertToPainterUnits (double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const |
Converts a size from the specified units to painter units (pixels). More... | |
QgsCoordinateTransform | coordinateTransform () const |
Returns the current coordinate transform for the context. More... | |
const QgsDistanceArea & | distanceArea () const |
A general purpose distance and area calculator, capable of performing ellipsoid based calculations. More... | |
bool | drawEditingInformation () const |
Returns true if edit markers should be drawn during the render operation. More... | |
QgsExpressionContext & | expressionContext () |
Gets the expression context. More... | |
const QgsExpressionContext & | expressionContext () const |
Gets the expression context (const version). More... | |
const QgsRectangle & | extent () const |
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the layer's CRS). More... | |
const QgsFeatureFilterProvider * | featureFilterProvider () const |
Gets the filter feature provider used for additional filtering of rendered features. More... | |
Flags | flags () const |
Returns combination of flags used for rendering. More... | |
bool | forceVectorOutput () const |
Returns true if rendering operations should use vector operations instead of any faster raster shortcuts. More... | |
const QgsAbstractGeometry * | geometry () const |
Returns pointer to the unsegmentized geometry. More... | |
bool | hasRenderedFeatureHandlers () const |
Returns true if the context has any rendered feature handlers. More... | |
QgsLabelingEngine * | labelingEngine () const |
Gets access to new labeling engine (may be nullptr ) More... | |
QgsRectangle | mapExtent () const |
Returns the original extent of the map being rendered. More... | |
const QgsMapToPixel & | mapToPixel () const |
Returns the context's map to pixel transform, which transforms between map coordinates and device coordinates. More... | |
QgsRenderContext & | operator= (const QgsRenderContext &rh) |
QPainter * | painter () |
Returns the destination QPainter for the render operation. More... | |
const QgsPathResolver & | pathResolver () const |
Returns the path resolver for conversion between relative and absolute paths during rendering operations, e.g. More... | |
QList< QgsRenderedFeatureHandlerInterface * > | renderedFeatureHandlers () const |
Returns the list of rendered feature handlers to use while rendering map layers. More... | |
double | rendererScale () const |
Returns the renderer map scale. More... | |
bool | renderingStopped () const |
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled immediately. More... | |
double | scaleFactor () const |
Returns the scaling factor for the render to convert painter units to physical sizes. More... | |
double | segmentationTolerance () const |
Gets the segmentation tolerance applied when rendering curved geometries. More... | |
QgsAbstractGeometry::SegmentationToleranceType | segmentationToleranceType () const |
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation) More... | |
QColor | selectionColor () const |
Returns the color to use when rendering selected features. More... | |
void | setCoordinateTransform (const QgsCoordinateTransform &t) |
Sets the current coordinate transform for the context. More... | |
void | setDistanceArea (const QgsDistanceArea &distanceArea) |
A general purpose distance and area calculator, capable of performing ellipsoid based calculations. More... | |
void | setDrawEditingInformation (bool b) |
Sets whether edit markers should be drawn during the render operation. More... | |
void | setExpressionContext (const QgsExpressionContext &context) |
Sets the expression context. More... | |
void | setExtent (const QgsRectangle &extent) |
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the layer's CRS). More... | |
void | setFeatureFilterProvider (const QgsFeatureFilterProvider *ffp) |
Set a filter feature provider used for additional filtering of rendered features. More... | |
void | setFlag (Flag flag, bool on=true) |
Enable or disable a particular flag (other flags are not affected) More... | |
void | setFlags (QgsRenderContext::Flags flags) |
Set combination of flags that will be used for rendering. More... | |
void | setForceVectorOutput (bool force) |
Sets whether rendering operations should use vector operations instead of any faster raster shortcuts. More... | |
void | setGeometry (const QgsAbstractGeometry *geometry) |
Sets pointer to original (unsegmentized) geometry. More... | |
void | setLabelingEngine (QgsLabelingEngine *engine2) |
Assign new labeling engine. More... | |
void | setMapExtent (const QgsRectangle &extent) |
Sets the original extent of the map being rendered. More... | |
void | setMapToPixel (const QgsMapToPixel &mtp) |
Sets the context's map to pixel transform, which transforms between map coordinates and device coordinates. More... | |
void | setPainter (QPainter *p) |
Sets the destination QPainter for the render operation. More... | |
void | setPathResolver (const QgsPathResolver &resolver) |
Sets the path resolver for conversion between relative and absolute paths during rendering operations, e.g. More... | |
void | setRendererScale (double scale) |
Sets the renderer map scale. More... | |
void | setRenderingStopped (bool stopped) |
Sets whether the rendering operation has been stopped and any ongoing rendering should be canceled immediately. More... | |
void | setScaleFactor (double factor) |
Sets the scaling factor for the render to convert painter units to physical sizes. More... | |
void | setSegmentationTolerance (double tolerance) |
Sets the segmentation tolerance applied when rendering curved geometries. More... | |
void | setSegmentationToleranceType (QgsAbstractGeometry::SegmentationToleranceType type) |
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation) More... | |
void | setSelectionColor (const QColor &color) |
Sets the color to use when rendering selected features. More... | |
void | setShowSelection (bool showSelection) |
Sets whether vector selections should be shown in the rendered map. More... | |
void | setTextRenderFormat (TextRenderFormat format) |
Sets the text render format, which dictates how text is rendered (e.g. More... | |
void | setTransformContext (const QgsCoordinateTransformContext &context) |
Sets the context's coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system. More... | |
void | setUseAdvancedEffects (bool enabled) |
Used to enable or disable advanced effects such as blend modes. More... | |
void | setUseRenderingOptimization (bool enabled) |
void | setVectorSimplifyMethod (const QgsVectorSimplifyMethod &simplifyMethod) |
Sets the simplification setting to use when rendering vector layers. More... | |
bool | showSelection () const |
Returns true if vector selections should be shown in the rendered map. More... | |
bool | testFlag (Flag flag) const |
Check whether a particular flag is enabled. More... | |
TextRenderFormat | textRenderFormat () const |
Returns the text render format, which dictates how text is rendered (e.g. More... | |
QgsCoordinateTransformContext | transformContext () const |
Returns the context's coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system. More... | |
bool | useAdvancedEffects () const |
Returns true if advanced effects such as blend modes such be used. More... | |
bool | useRenderingOptimization () const |
Returns true if the rendering optimization (geometry simplification) can be executed. More... | |
const QgsVectorSimplifyMethod & | vectorSimplifyMethod () const |
Returns the simplification settings to use when rendering vector layers. More... | |
Static Public Member Functions | |
static QgsRenderContext | fromMapSettings (const QgsMapSettings &mapSettings) |
create initialized QgsRenderContext instance from given QgsMapSettings More... | |
static QgsRenderContext | fromQPainter (QPainter *painter) |
Creates a default render context given a pixel based QPainter destination. More... | |
Contains information about the context of a rendering operation.
The context of a rendering operation defines properties such as the conversion ratio between screen and map units, the extents to be rendered etc.
Definition at line 51 of file qgsrendercontext.h.
Enumeration of flags that affect rendering operations.
Definition at line 63 of file qgsrendercontext.h.
Options for rendering text.
Enumerator | |
---|---|
TextFormatAlwaysOutlines | Always render text using path objects (AKA outlines/curves). This setting guarantees the best quality rendering, even when using a raster paint surface (where sub-pixel path based text rendering is superior to sub-pixel text-based rendering). The downside is that text is converted to paths only, so users cannot open created vector outputs for post-processing in other applications and retain text editability. This setting also guarantees complete compatibility with the full range of formatting options available through QgsTextRenderer and QgsTextFormat, some of which may not be possible to reproduce when using a vector-based paint surface and TextFormatAlwaysText mode. A final benefit to this setting is that vector exports created using text as outlines do not require all users to have the original fonts installed in order to display the text in its original style. |
TextFormatAlwaysText | Always render text as text objects. While this mode preserves text objects as text for post-processing in external vector editing applications, it can result in rendering artifacts or poor quality rendering, depending on the text format settings. Even with raster based paint devices, TextFormatAlwaysText can result in inferior rendering quality to TextFormatAlwaysOutlines. When rendering using TextFormatAlwaysText to a vector based device (e.g. PDF or SVG), care must be taken to ensure that the required fonts are available to users when opening the created files, or default fallback fonts will be used to display the output instead. (Although PDF exports MAY automatically embed some fonts when possible, depending on the user's platform). |
Definition at line 83 of file qgsrendercontext.h.
QgsRenderContext::QgsRenderContext | ( | ) |
Definition at line 31 of file qgsrendercontext.cpp.
QgsRenderContext::QgsRenderContext | ( | const QgsRenderContext & | rh | ) |
Definition at line 40 of file qgsrendercontext.cpp.
double QgsRenderContext::convertFromMapUnits | ( | double | sizeInMapUnits, |
QgsUnitTypes::RenderUnit | outputUnit | ||
) | const |
Converts a size from map units to the specified units.
Definition at line 400 of file qgsrendercontext.cpp.
double QgsRenderContext::convertMetersToMapUnits | ( | double | meters | ) | const |
Convert meter distances to active MapUnit values for QgsUnitTypes::RenderMetersInMapUnits.
Definition at line 439 of file qgsrendercontext.cpp.
double QgsRenderContext::convertToMapUnits | ( | double | size, |
QgsUnitTypes::RenderUnit | unit, | ||
const QgsMapUnitScale & | scale = QgsMapUnitScale() |
||
) | const |
Converts a size from the specified units to map units.
The conversion respects the limits specified by the optional scale parameter.
Definition at line 336 of file qgsrendercontext.cpp.
double QgsRenderContext::convertToPainterUnits | ( | double | size, |
QgsUnitTypes::RenderUnit | unit, | ||
const QgsMapUnitScale & | scale = QgsMapUnitScale() |
||
) | const |
Converts a size from the specified units to painter units (pixels).
The conversion respects the limits specified by the optional scale parameter.
Definition at line 274 of file qgsrendercontext.cpp.
|
inline |
Returns the current coordinate transform for the context.
This represents the coordinate transform required to transform a layer which is being rendered back to the CRS of the rendered map. If no coordinate transformation is required, or the render context is not associated with a map layer render, then an invalid coordinate transformation is returned.
Definition at line 179 of file qgsrendercontext.h.
|
inline |
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
Definition at line 185 of file qgsrendercontext.h.
bool QgsRenderContext::drawEditingInformation | ( | ) | const |
Returns true
if edit markers should be drawn during the render operation.
Definition at line 217 of file qgsrendercontext.cpp.
|
inline |
Gets the expression context.
This context should be used for all expression evaluation associated with this render context.
Definition at line 499 of file qgsrendercontext.h.
|
inline |
Gets the expression context (const version).
This context should be used for all expression evaluation associated with this render context.
Definition at line 508 of file qgsrendercontext.h.
|
inline |
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the layer's CRS).
This extent is a "worst-case" scenario, which is guaranteed to cover the complete visible portion of the layer when it is rendered to a map. It is often larger than the actual visible portion of that layer.
Definition at line 240 of file qgsrendercontext.h.
const QgsFeatureFilterProvider * QgsRenderContext::featureFilterProvider | ( | ) | const |
Gets the filter feature provider used for additional filtering of rendered features.
Definition at line 269 of file qgsrendercontext.cpp.
QgsRenderContext::Flags QgsRenderContext::flags | ( | ) | const |
Returns combination of flags used for rendering.
Definition at line 151 of file qgsrendercontext.cpp.
bool QgsRenderContext::forceVectorOutput | ( | ) | const |
Returns true
if rendering operations should use vector operations instead of any faster raster shortcuts.
Definition at line 202 of file qgsrendercontext.cpp.
|
static |
create initialized QgsRenderContext instance from given QgsMapSettings
Definition at line 161 of file qgsrendercontext.cpp.
|
static |
Creates a default render context given a pixel based QPainter destination.
If no painter is specified or the painter has no device, then a default DPI of 88 will be assumed.
Definition at line 102 of file qgsrendercontext.cpp.
|
inline |
Returns pointer to the unsegmentized geometry.
Definition at line 511 of file qgsrendercontext.h.
|
inline |
Returns true
if the context has any rendered feature handlers.
Definition at line 612 of file qgsrendercontext.h.
|
inline |
Gets access to new labeling engine (may be nullptr
)
Definition at line 313 of file qgsrendercontext.h.
|
inline |
Returns the original extent of the map being rendered.
Unlike extent(), this extent is always in the final destination CRS for the map render and represents the exact bounds of the map being rendered.
Definition at line 252 of file qgsrendercontext.h.
|
inline |
Returns the context's map to pixel transform, which transforms between map coordinates and device coordinates.
Definition at line 259 of file qgsrendercontext.h.
QgsRenderContext & QgsRenderContext::operator= | ( | const QgsRenderContext & | rh | ) |
Definition at line 70 of file qgsrendercontext.cpp.
|
inline |
Returns the destination QPainter for the render operation.
Definition at line 167 of file qgsrendercontext.h.
|
inline |
Returns the path resolver for conversion between relative and absolute paths during rendering operations, e.g.
for resolving relative symbol paths.
Definition at line 214 of file qgsrendercontext.h.
QList< QgsRenderedFeatureHandlerInterface * > QgsRenderContext::renderedFeatureHandlers | ( | ) | const |
Returns the list of rendered feature handlers to use while rendering map layers.
Definition at line 470 of file qgsrendercontext.cpp.
|
inline |
Returns the renderer map scale.
This will match the desired scale denominator for the rendered map, eg 1000.0 for a 1:1000 map render.
Definition at line 307 of file qgsrendercontext.h.
|
inline |
Returns true
if the rendering operation has been stopped and any ongoing rendering should be canceled immediately.
Definition at line 275 of file qgsrendercontext.h.
|
inline |
Returns the scaling factor for the render to convert painter units to physical sizes.
This is usually equal to the number of pixels per millimeter.
Definition at line 267 of file qgsrendercontext.h.
|
inline |
Gets the segmentation tolerance applied when rendering curved geometries.
Definition at line 536 of file qgsrendercontext.h.
|
inline |
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation)
Definition at line 543 of file qgsrendercontext.h.
|
inline |
Returns the color to use when rendering selected features.
Definition at line 320 of file qgsrendercontext.h.
void QgsRenderContext::setCoordinateTransform | ( | const QgsCoordinateTransform & | t | ) |
Sets the current coordinate transform for the context.
This represents the coordinate transform required to transform the layer which is being rendered back to the CRS of the rendered map.
Set to an invalid QgsCoordinateTransform to indicate that no transformation is required.
Definition at line 227 of file qgsrendercontext.cpp.
|
inline |
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
Will be used to convert meter distances to active MapUnit values for QgsUnitTypes::RenderMetersInMapUnits
Definition at line 398 of file qgsrendercontext.h.
void QgsRenderContext::setDrawEditingInformation | ( | bool | b | ) |
Sets whether edit markers should be drawn during the render operation.
Definition at line 232 of file qgsrendercontext.cpp.
|
inline |
Sets the expression context.
This context is used for all expression evaluation associated with this render context.
Definition at line 491 of file qgsrendercontext.h.
|
inline |
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the layer's CRS).
This extent should be a "worst-case" scenario, which is guaranteed to completely cover the entire visible portion of the layer when it is rendered to the map. It may be larger than the actual visible area, but MUST contain at least the entire visible area.
Definition at line 364 of file qgsrendercontext.h.
void QgsRenderContext::setFeatureFilterProvider | ( | const QgsFeatureFilterProvider * | ffp | ) |
Set a filter feature provider used for additional filtering of rendered features.
ffp | the filter feature provider |
Definition at line 257 of file qgsrendercontext.cpp.
void QgsRenderContext::setFlag | ( | QgsRenderContext::Flag | flag, |
bool | on = true |
||
) |
Enable or disable a particular flag (other flags are not affected)
Definition at line 143 of file qgsrendercontext.cpp.
void QgsRenderContext::setFlags | ( | QgsRenderContext::Flags | flags | ) |
Set combination of flags that will be used for rendering.
Definition at line 138 of file qgsrendercontext.cpp.
void QgsRenderContext::setForceVectorOutput | ( | bool | force | ) |
Sets whether rendering operations should use vector operations instead of any faster raster shortcuts.
Definition at line 237 of file qgsrendercontext.cpp.
|
inline |
Sets pointer to original (unsegmentized) geometry.
Definition at line 513 of file qgsrendercontext.h.
|
inline |
Assign new labeling engine.
Definition at line 435 of file qgsrendercontext.h.
|
inline |
Sets the original extent of the map being rendered.
Unlike setExtent(), this extent is always in the final destination CRS for the map render and represents the exact bounds of the map being rendered.
Definition at line 376 of file qgsrendercontext.h.
|
inline |
Sets the context's map to pixel transform, which transforms between map coordinates and device coordinates.
Definition at line 350 of file qgsrendercontext.h.
|
inline |
Sets the destination QPainter for the render operation.
Ownership of the painter is not transferred and the QPainter destination must stay alive for the duration of any rendering operations.
Definition at line 421 of file qgsrendercontext.h.
|
inline |
Sets the path resolver for conversion between relative and absolute paths during rendering operations, e.g.
for resolving relative symbol paths.
Definition at line 223 of file qgsrendercontext.h.
|
inline |
Sets the renderer map scale.
This should match the desired scale denominator for the rendered map, eg 1000.0 for a 1:1000 map render.
Definition at line 413 of file qgsrendercontext.h.
|
inline |
Sets whether the rendering operation has been stopped and any ongoing rendering should be canceled immediately.
Definition at line 391 of file qgsrendercontext.h.
|
inline |
Sets the scaling factor for the render to convert painter units to physical sizes.
This should usually be equal to the number of pixels per millimeter.
Definition at line 406 of file qgsrendercontext.h.
|
inline |
Sets the segmentation tolerance applied when rendering curved geometries.
tolerance | the segmentation tolerance |
Definition at line 534 of file qgsrendercontext.h.
|
inline |
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation)
type | the segmentation tolerance typename |
Definition at line 541 of file qgsrendercontext.h.
|
inline |
Sets the color to use when rendering selected features.
Definition at line 442 of file qgsrendercontext.h.
void QgsRenderContext::setShowSelection | ( | bool | showSelection | ) |
Sets whether vector selections should be shown in the rendered map.
showSelection | set to true if selections should be shown |
Definition at line 242 of file qgsrendercontext.cpp.
|
inline |
Sets the text render format, which dictates how text is rendered (e.g.
as paths or real text objects).
Definition at line 595 of file qgsrendercontext.h.
void QgsRenderContext::setTransformContext | ( | const QgsCoordinateTransformContext & | context | ) |
Sets the context's coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system.
Definition at line 130 of file qgsrendercontext.cpp.
void QgsRenderContext::setUseAdvancedEffects | ( | bool | enabled | ) |
Used to enable or disable advanced effects such as blend modes.
Definition at line 212 of file qgsrendercontext.cpp.
void QgsRenderContext::setUseRenderingOptimization | ( | bool | enabled | ) |
Definition at line 252 of file qgsrendercontext.cpp.
|
inline |
Sets the simplification setting to use when rendering vector layers.
This can be used to specify simplification methods to apply during map exports and renders, e.g. to allow vector layers to be simplified to an appropriate maximum level of detail during PDF exports or to speed up layer rendering
The default is to use no simplification.
Definition at line 483 of file qgsrendercontext.h.
bool QgsRenderContext::showSelection | ( | ) | const |
Returns true
if vector selections should be shown in the rendered map.
true
if selections should be shown Definition at line 222 of file qgsrendercontext.cpp.
bool QgsRenderContext::testFlag | ( | QgsRenderContext::Flag | flag | ) | const |
Check whether a particular flag is enabled.
Definition at line 156 of file qgsrendercontext.cpp.
|
inline |
Returns the text render format, which dictates how text is rendered (e.g.
as paths or real text objects).
Definition at line 584 of file qgsrendercontext.h.
QgsCoordinateTransformContext QgsRenderContext::transformContext | ( | ) | const |
Returns the context's coordinate transform context, which stores various information regarding which datum transforms should be used when transforming points from a source to destination coordinate reference system.
Definition at line 121 of file qgsrendercontext.cpp.
bool QgsRenderContext::useAdvancedEffects | ( | ) | const |
Returns true
if advanced effects such as blend modes such be used.
Definition at line 207 of file qgsrendercontext.cpp.
bool QgsRenderContext::useRenderingOptimization | ( | ) | const |
Returns true
if the rendering optimization (geometry simplification) can be executed.
Definition at line 247 of file qgsrendercontext.cpp.
|
inline |
Returns the simplification settings to use when rendering vector layers.
The default is to use no simplification.
Definition at line 468 of file qgsrendercontext.h.