QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
QgsFeatureRenderer Class Referenceabstract

Abstract base class for all 2D vector feature renderers. More...

#include <qgsrenderer.h>

Inheritance diagram for QgsFeatureRenderer:
Inheritance graph
[legend]

Public Types

typedef QFlags< CapabilityCapabilities
 
enum  Capability { SymbolLevels = 1 , MoreSymbolsPerFeature = 1 << 2 , Filter = 1 << 3 , ScaleDependent = 1 << 4 }
 Used to specify details about a renderer. More...
 
enum class  Property : int { HeatmapRadius , HeatmapMaximum }
 Data definable properties for renderers. More...
 

Public Member Functions

virtual ~QgsFeatureRenderer ()
 
virtual bool accept (QgsStyleEntityVisitorInterface *visitor) const
 Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer.
 
virtual bool canSkipRender ()
 Returns true if the renderer can be entirely skipped, i.e.
 
virtual QgsFeatureRenderer::Capabilities capabilities ()
 Returns details about internals of this renderer.
 
virtual void checkLegendSymbolItem (const QString &key, bool state=true)
 Sets whether the legend symbology item with the specified ley should be checked.
 
virtual QgsFeatureRendererclone () const =0
 Create a deep copy of this renderer.
 
void copyRendererData (QgsFeatureRenderer *destRenderer) const
 Clones generic renderer data to another renderer.
 
virtual QList< QgsLayerTreeModelLegendNode * > createLegendNodes (QgsLayerTreeLayer *nodeLayer) const
 Returns a list of legend nodes to be used for the legend for the renderer.
 
QgsPropertyCollectiondataDefinedProperties ()
 Returns a reference to the renderer's property collection, used for data defined overrides.
 
const QgsPropertyCollectiondataDefinedProperties () const
 Returns a reference to the renderer's property collection, used for data defined overrides.
 
virtual QString dump () const
 Returns debug information about this renderer.
 
virtual const QgsFeatureRendererembeddedRenderer () const
 Returns the current embedded renderer (subrenderer) for this feature renderer.
 
virtual QString filter (const QgsFields &fields=QgsFields())
 If a renderer does not require all the features this method may be overridden and return an expression used as where clause.
 
virtual bool filterNeedsGeometry () const
 Returns true if this renderer requires the geometry to apply the filter.
 
virtual Qgis::FeatureRendererFlags flags () const
 Returns flags associated with the renderer.
 
bool forceRasterRender () const
 Returns whether the renderer must render as a raster.
 
virtual QString legendClassificationAttribute () const
 If supported by the renderer, return classification attribute for the use in legend.
 
QSet< QString > legendKeys () const
 Returns the set of all legend keys used by the renderer.
 
virtual QSet< QString > legendKeysForFeature (const QgsFeature &feature, QgsRenderContext &context) const
 Returns legend keys matching a specified feature.
 
virtual QString legendKeyToExpression (const QString &key, QgsVectorLayer *layer, bool &ok) const
 Attempts to convert the specified legend rule key to a QGIS expression matching the features displayed using that key.
 
virtual bool legendSymbolItemChecked (const QString &key)
 Returns true if the legend symbology item with the specified key is checked.
 
virtual QgsLegendSymbolList legendSymbolItems () const
 Returns a list of symbology items for the legend.
 
virtual bool legendSymbolItemsCheckable () const
 Returns true if symbology items in legend are checkable.
 
virtual void modifyRequestExtent (QgsRectangle &extent, QgsRenderContext &context)
 Allows for a renderer to modify the extent of a feature request prior to rendering.
 
QgsFeatureRequest::OrderBy orderBy () const
 Gets the order in which features shall be processed by this renderer.
 
bool orderByEnabled () const
 Returns whether custom ordering will be applied before features are processed by this renderer.
 
virtual QgsSymboloriginalSymbolForFeature (const QgsFeature &feature, QgsRenderContext &context) const
 Returns symbol for feature.
 
virtual QgsSymbolList originalSymbolsForFeature (const QgsFeature &feature, QgsRenderContext &context) const
 Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbols per feature - similar to symbolsForFeature()
 
QgsPaintEffectpaintEffect () const
 Returns the current paint effect for the renderer.
 
double referenceScale () const
 Returns the symbology reference scale.
 
virtual bool renderFeature (const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
 Render a feature using this renderer in the given context.
 
virtual QDomElement save (QDomDocument &doc, const QgsReadWriteContext &context)
 Stores renderer properties to an XML element.
 
void setDataDefinedProperties (const QgsPropertyCollection &collection)
 Sets the renderer's property collection, used for data defined overrides.
 
void setDataDefinedProperty (Property key, const QgsProperty &property)
 Sets a data defined property for the renderer.
 
virtual void setEmbeddedRenderer (QgsFeatureRenderer *subRenderer)
 Sets an embedded renderer (subrenderer) for this feature renderer.
 
void setForceRasterRender (bool forceRaster)
 Sets whether the renderer should be rendered to a raster destination.
 
virtual void setLegendSymbolItem (const QString &key, QgsSymbol *symbol)
 Sets the symbol to be used for a legend symbol item.
 
void setOrderBy (const QgsFeatureRequest::OrderBy &orderBy)
 Define the order in which features shall be processed by this renderer.
 
void setOrderByEnabled (bool enabled)
 Sets whether custom ordering should be applied before features are processed by this renderer.
 
void setPaintEffect (QgsPaintEffect *effect)
 Sets the current paint effect for the renderer.
 
void setReferenceScale (double scale)
 Sets the symbology reference scale.
 
void setUsingSymbolLevels (bool usingSymbolLevels)
 
void setVertexMarkerAppearance (Qgis::VertexMarkerType type, double size)
 Sets type and size of editing vertex markers for subsequent rendering.
 
virtual void startRender (QgsRenderContext &context, const QgsFields &fields)
 Must be called when a new render cycle is started.
 
virtual void stopRender (QgsRenderContext &context)
 Must be called when a render cycle has finished, to allow the renderer to clean up.
 
virtual QgsSymbolsymbolForFeature (const QgsFeature &feature, QgsRenderContext &context) const =0
 To be overridden.
 
virtual QgsSymbolList symbols (QgsRenderContext &context) const
 Returns list of symbols used by the renderer.
 
virtual QgsSymbolList symbolsForFeature (const QgsFeature &feature, QgsRenderContext &context) const
 Returns list of symbols used for rendering the feature.
 
virtual void toSld (QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const
 used from subclasses to create SLD Rule elements following SLD v1.1 specs
 
QString type () const
 
virtual QSet< QString > usedAttributes (const QgsRenderContext &context) const =0
 Returns a list of attributes required by this renderer.
 
virtual bool usesEmbeddedSymbols () const
 Returns true if the renderer uses embedded symbols for features.
 
bool usingSymbolLevels () const
 
virtual bool willRenderFeature (const QgsFeature &feature, QgsRenderContext &context) const
 Returns whether the renderer will render a feature or not.
 
virtual QDomElement writeSld (QDomDocument &doc, const QString &styleName, const QVariantMap &props=QVariantMap()) const
 create the SLD UserStyle element following the SLD v1.1 specs with the given name
 

Static Public Member Functions

static QgsFeatureRendererdefaultRenderer (Qgis::GeometryType geomType)
 Returns a new renderer - used by default in vector layers.
 
static QgsFeatureRendererload (QDomElement &symbologyElem, const QgsReadWriteContext &context)
 create a renderer from XML element
 
static QgsFeatureRendererloadSld (const QDomNode &node, Qgis::GeometryType geomType, QString &errorMessage)
 Create a new renderer according to the information contained in the UserStyle element of a SLD style document.
 
static const QgsPropertiesDefinitionpropertyDefinitions ()
 Returns the symbol property definitions.
 

Protected Member Functions

 QgsFeatureRenderer (const QString &type)
 
void renderFeatureWithSymbol (const QgsFeature &feature, QgsSymbol *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker)
 Render the feature with the symbol using context.
 
void renderVertexMarker (QPointF pt, QgsRenderContext &context)
 render editing vertex marker at specified point
 
void renderVertexMarkerPolygon (QPolygonF &pts, QList< QPolygonF > *rings, QgsRenderContext &context)
 render editing vertex marker for a polygon
 
void renderVertexMarkerPolyline (QPolygonF &pts, QgsRenderContext &context)
 render editing vertex marker for a polyline
 
void saveRendererData (QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context)
 Saves generic renderer data into the specified element.
 

Static Protected Member Functions

static QPointF _getPoint (QgsRenderContext &context, const QgsPoint &point)
 Creates a point in screen coordinates from a wkb string in map coordinates.
 
static void convertSymbolRotation (QgsSymbol *symbol, const QString &field)
 
static void convertSymbolSizeScale (QgsSymbol *symbol, Qgis::ScaleMethod method, const QString &field)
 

Protected Attributes

double mCurrentVertexMarkerSize = 2
 The current size of editing marker.
 
Qgis::VertexMarkerType mCurrentVertexMarkerType = Qgis::VertexMarkerType::Cross
 The current type of editing marker.
 
bool mForceRaster = false
 
QgsFeatureRequest::OrderBy mOrderBy
 
bool mOrderByEnabled = false
 
QgsPaintEffectmPaintEffect = nullptr
 
double mReferenceScale = -1.0
 
QString mType
 
bool mUsingSymbolLevels = false
 

Detailed Description

Abstract base class for all 2D vector feature renderers.

Definition at line 105 of file qgsrenderer.h.

Member Typedef Documentation

◆ Capabilities

Definition at line 298 of file qgsrenderer.h.

Member Enumeration Documentation

◆ Capability

Used to specify details about a renderer.

Is returned from the capabilities() method.

Enumerator
SymbolLevels 

Rendering with symbol levels (i.e. implements symbols(), symbolForFeature())

MoreSymbolsPerFeature 

May use more than one symbol to render a feature: symbolsForFeature() will return them.

Filter 

Features may be filtered, i.e. some features may not be rendered (categorized, rule based ...)

ScaleDependent 

Depends on scale if feature will be rendered (rule based )

Definition at line 290 of file qgsrenderer.h.

◆ Property

enum class QgsFeatureRenderer::Property : int
strong

Data definable properties for renderers.

Since
QGIS 3.38
Enumerator
HeatmapRadius 

Heatmap renderer radius.

HeatmapMaximum 

Heatmap maximum value.

Definition at line 147 of file qgsrenderer.h.

Constructor & Destructor Documentation

◆ ~QgsFeatureRenderer()

QgsFeatureRenderer::~QgsFeatureRenderer ( )
virtual

Definition at line 72 of file qgsrenderer.cpp.

◆ QgsFeatureRenderer()

QgsFeatureRenderer::QgsFeatureRenderer ( const QString &  type)
protected

Definition at line 65 of file qgsrenderer.cpp.

Member Function Documentation

◆ _getPoint()

QPointF QgsFeatureRenderer::_getPoint ( QgsRenderContext context,
const QgsPoint point 
)
staticprotected

Creates a point in screen coordinates from a wkb string in map coordinates.

Definition at line 44 of file qgsrenderer.cpp.

◆ accept()

bool QgsFeatureRenderer::accept ( QgsStyleEntityVisitorInterface visitor) const
virtual

Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer.

Returns true if the visitor should continue visiting other objects, or false if visiting should be canceled.

Since
QGIS 3.10

Reimplemented in Qgs25DRenderer, QgsCategorizedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsHeatmapRenderer, QgsMergedFeatureRenderer, QgsPointClusterRenderer, QgsPointDisplacementRenderer, QgsPointDistanceRenderer, QgsRuleBasedRenderer, and QgsSingleSymbolRenderer.

Definition at line 553 of file qgsrenderer.cpp.

◆ canSkipRender()

bool QgsFeatureRenderer::canSkipRender ( )
virtual

Returns true if the renderer can be entirely skipped, i.e.

if it is known in advance that no features will be rendered.

Warning
Must be called between startRender() and stopRender() calls.
Since
QGIS 3.30

Reimplemented in QgsRuleBasedRenderer.

Definition at line 116 of file qgsrenderer.cpp.

◆ capabilities()

virtual QgsFeatureRenderer::Capabilities QgsFeatureRenderer::capabilities ( )
inlinevirtual

Returns details about internals of this renderer.

E.g. if you only want to deal with visible features:

if not renderer.capabilities().testFlag(QgsFeatureRenderer.Filter) or renderer.willRenderFeature(feature, context):
deal_with_my_feature()
else:
skip_the_curren_feature()

Reimplemented in QgsCategorizedSymbolRenderer, QgsEmbeddedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsMergedFeatureRenderer, QgsPointDistanceRenderer, QgsRuleBasedRenderer, and QgsSingleSymbolRenderer.

Definition at line 312 of file qgsrenderer.h.

◆ checkLegendSymbolItem()

void QgsFeatureRenderer::checkLegendSymbolItem ( const QString &  key,
bool  state = true 
)
virtual

Sets whether the legend symbology item with the specified ley should be checked.

See also
legendSymbolItemChecked()
legendKeys()

Reimplemented in QgsPointDistanceRenderer, QgsCategorizedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsMergedFeatureRenderer, and QgsRuleBasedRenderer.

Definition at line 397 of file qgsrenderer.cpp.

◆ clone()

virtual QgsFeatureRenderer * QgsFeatureRenderer::clone ( ) const
pure virtual

Create a deep copy of this renderer.

Should be implemented by all subclasses and generate a proper subclass.

Returns
A copy of this renderer

Implemented in Qgs25DRenderer, QgsCategorizedSymbolRenderer, QgsEmbeddedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsHeatmapRenderer, QgsInvertedPolygonRenderer, QgsMergedFeatureRenderer, QgsNullSymbolRenderer, QgsPointClusterRenderer, QgsPointDisplacementRenderer, QgsRuleBasedRenderer, and QgsSingleSymbolRenderer.

◆ convertSymbolRotation()

void QgsFeatureRenderer::convertSymbolRotation ( QgsSymbol symbol,
const QString &  field 
)
staticprotected
Note
this function is used to convert old rotations expressions to symbol level DataDefined angle

Definition at line 580 of file qgsrenderer.cpp.

◆ convertSymbolSizeScale()

void QgsFeatureRenderer::convertSymbolSizeScale ( QgsSymbol symbol,
Qgis::ScaleMethod  method,
const QString &  field 
)
staticprotected
Note
this function is used to convert old sizeScale expressions to symbol level DataDefined size

Definition at line 558 of file qgsrenderer.cpp.

◆ copyRendererData()

void QgsFeatureRenderer::copyRendererData ( QgsFeatureRenderer destRenderer) const

Clones generic renderer data to another renderer.

Currently clones

  • Order by
  • Paint effect
  • Reference scale
  • Symbol levels enabled/disabled
  • Force raster render enabled/disabled
  • Data defined properties
Parameters
destRendererdestination renderer for copied effect
Since
QGIS 3.22

Definition at line 49 of file qgsrenderer.cpp.

◆ createLegendNodes()

QList< QgsLayerTreeModelLegendNode * > QgsFeatureRenderer::createLegendNodes ( QgsLayerTreeLayer nodeLayer) const
virtual

Returns a list of legend nodes to be used for the legend for the renderer.

Ownership is transferred to the caller.

The default implementation creates a legend node for each symbol item returned by legendSymbolItems()

See also
legendSymbolItems()
Since
QGIS 3.38

Reimplemented in QgsHeatmapRenderer.

Definition at line 420 of file qgsrenderer.cpp.

◆ dataDefinedProperties() [1/2]

QgsPropertyCollection & QgsFeatureRenderer::dataDefinedProperties ( )
inline

Returns a reference to the renderer's property collection, used for data defined overrides.

See also
setDataDefinedProperties()
Property
Since
QGIS 3.38

Definition at line 530 of file qgsrenderer.h.

◆ dataDefinedProperties() [2/2]

const QgsPropertyCollection & QgsFeatureRenderer::dataDefinedProperties ( ) const
inline

Returns a reference to the renderer's property collection, used for data defined overrides.

See also
setDataDefinedProperties()
Since
QGIS 3.38

Definition at line 539 of file qgsrenderer.h.

◆ defaultRenderer()

QgsFeatureRenderer * QgsFeatureRenderer::defaultRenderer ( Qgis::GeometryType  geomType)
static

Returns a new renderer - used by default in vector layers.

Definition at line 83 of file qgsrenderer.cpp.

◆ dump()

QString QgsFeatureRenderer::dump ( ) const
virtual

◆ embeddedRenderer()

const QgsFeatureRenderer * QgsFeatureRenderer::embeddedRenderer ( ) const
virtual

Returns the current embedded renderer (subrenderer) for this feature renderer.

The base class implementation does not use subrenderers and will always return nullptr.

See also
setEmbeddedRenderer()

Reimplemented in QgsMergedFeatureRenderer, and QgsPointDistanceRenderer.

Definition at line 548 of file qgsrenderer.cpp.

◆ filter()

virtual QString QgsFeatureRenderer::filter ( const QgsFields fields = QgsFields())
inlinevirtual

If a renderer does not require all the features this method may be overridden and return an expression used as where clause.

This will be called once after startRender() and before the first call to renderFeature(). By default this returns a null string and all features will be requested. You do not need to specify the extent in here, this is taken care of separately and will be combined with a filter returned from this method.

Returns
An expression used as where clause

Reimplemented in QgsCategorizedSymbolRenderer, QgsPointDistanceRenderer, and QgsRuleBasedRenderer.

Definition at line 235 of file qgsrenderer.h.

◆ filterNeedsGeometry()

bool QgsFeatureRenderer::filterNeedsGeometry ( ) const
virtual

Returns true if this renderer requires the geometry to apply the filter.

Reimplemented in QgsCategorizedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsMergedFeatureRenderer, QgsPointDistanceRenderer, and QgsRuleBasedRenderer.

Definition at line 133 of file qgsrenderer.cpp.

◆ flags()

Qgis::FeatureRendererFlags QgsFeatureRenderer::flags ( ) const
virtual

◆ forceRasterRender()

bool QgsFeatureRenderer::forceRasterRender ( ) const
inline

Returns whether the renderer must render as a raster.

See also
setForceRasterRender

Definition at line 500 of file qgsrenderer.h.

◆ legendClassificationAttribute()

virtual QString QgsFeatureRenderer::legendClassificationAttribute ( ) const
inlinevirtual

If supported by the renderer, return classification attribute for the use in legend.

Reimplemented in QgsCategorizedSymbolRenderer, and QgsGraduatedSymbolRenderer.

Definition at line 449 of file qgsrenderer.h.

◆ legendKeys()

QSet< QString > QgsFeatureRenderer::legendKeys ( ) const

Returns the set of all legend keys used by the renderer.

See also
legendSymbolItems()
Since
QGIS 3.32

Definition at line 358 of file qgsrenderer.cpp.

◆ legendKeysForFeature()

QSet< QString > QgsFeatureRenderer::legendKeysForFeature ( const QgsFeature feature,
QgsRenderContext context 
) const
virtual

Returns legend keys matching a specified feature.

Reimplemented in QgsCategorizedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsMergedFeatureRenderer, QgsPointDistanceRenderer, QgsRuleBasedRenderer, and QgsSingleSymbolRenderer.

Definition at line 93 of file qgsrenderer.cpp.

◆ legendKeyToExpression()

QString QgsFeatureRenderer::legendKeyToExpression ( const QString &  key,
QgsVectorLayer layer,
bool &  ok 
) const
virtual

Attempts to convert the specified legend rule key to a QGIS expression matching the features displayed using that key.

Parameters
keylegend key
layerassociated vector layer
okwill be set to true if legend key was successfully converted to a filter expression
Returns
QGIS expression string for matching features with the specified key
See also
legendKeys()
Since
QGIS 3.26

Reimplemented in QgsCategorizedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsMergedFeatureRenderer, QgsPointDistanceRenderer, QgsRuleBasedRenderer, and QgsSingleSymbolRenderer.

Definition at line 409 of file qgsrenderer.cpp.

◆ legendSymbolItemChecked()

bool QgsFeatureRenderer::legendSymbolItemChecked ( const QString &  key)
virtual

Returns true if the legend symbology item with the specified key is checked.

See also
checkLegendSymbolItem()
legendKeys()

Reimplemented in QgsCategorizedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsMergedFeatureRenderer, QgsPointDistanceRenderer, and QgsRuleBasedRenderer.

Definition at line 391 of file qgsrenderer.cpp.

◆ legendSymbolItems()

QgsLegendSymbolList QgsFeatureRenderer::legendSymbolItems ( ) const
virtual

◆ legendSymbolItemsCheckable()

bool QgsFeatureRenderer::legendSymbolItemsCheckable ( ) const
virtual

Returns true if symbology items in legend are checkable.

Reimplemented in QgsCategorizedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsMergedFeatureRenderer, QgsPointDistanceRenderer, and QgsRuleBasedRenderer.

Definition at line 386 of file qgsrenderer.cpp.

◆ load()

QgsFeatureRenderer * QgsFeatureRenderer::load ( QDomElement &  symbologyElem,
const QgsReadWriteContext context 
)
static

create a renderer from XML element

Definition at line 173 of file qgsrenderer.cpp.

◆ loadSld()

QgsFeatureRenderer * QgsFeatureRenderer::loadSld ( const QDomNode &  node,
Qgis::GeometryType  geomType,
QString &  errorMessage 
)
static

Create a new renderer according to the information contained in the UserStyle element of a SLD style document.

Parameters
nodethe node in the SLD document whose the UserStyle element is a child
geomTypethe geometry type of the features, used to convert Symbolizer elements
errorMessageit will contain the error message if something went wrong
Returns
the renderer

Definition at line 246 of file qgsrenderer.cpp.

◆ modifyRequestExtent()

void QgsFeatureRenderer::modifyRequestExtent ( QgsRectangle extent,
QgsRenderContext context 
)
virtual

Allows for a renderer to modify the extent of a feature request prior to rendering.

Parameters
extentreference to request's filter extent. Modify extent to change the extent of feature request
contextrender context

Reimplemented in QgsHeatmapRenderer.

Definition at line 493 of file qgsrenderer.cpp.

◆ orderBy()

QgsFeatureRequest::OrderBy QgsFeatureRenderer::orderBy ( ) const

Gets the order in which features shall be processed by this renderer.

Note
this property has no effect if orderByEnabled() is false
See also
orderByEnabled()

Definition at line 523 of file qgsrenderer.cpp.

◆ orderByEnabled()

bool QgsFeatureRenderer::orderByEnabled ( ) const

Returns whether custom ordering will be applied before features are processed by this renderer.

See also
orderBy()
setOrderByEnabled()

Definition at line 533 of file qgsrenderer.cpp.

◆ originalSymbolForFeature()

QgsSymbol * QgsFeatureRenderer::originalSymbolForFeature ( const QgsFeature feature,
QgsRenderContext context 
) const
virtual

Returns symbol for feature.

The difference compared to symbolForFeature() is that it returns original symbol which can be used as an identifier for renderer's rule - the former may return a temporary replacement of a symbol for use in rendering.

Reimplemented in QgsCategorizedSymbolRenderer, QgsEmbeddedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsMergedFeatureRenderer, QgsNullSymbolRenderer, QgsPointDistanceRenderer, and QgsSingleSymbolRenderer.

Definition at line 88 of file qgsrenderer.cpp.

◆ originalSymbolsForFeature()

QgsSymbolList QgsFeatureRenderer::originalSymbolsForFeature ( const QgsFeature feature,
QgsRenderContext context 
) const
virtual

Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbols per feature - similar to symbolsForFeature()

Reimplemented in QgsMergedFeatureRenderer, QgsPointDistanceRenderer, and QgsRuleBasedRenderer.

Definition at line 499 of file qgsrenderer.cpp.

◆ paintEffect()

QgsPaintEffect * QgsFeatureRenderer::paintEffect ( ) const

Returns the current paint effect for the renderer.

Returns
paint effect
See also
setPaintEffect

Definition at line 507 of file qgsrenderer.cpp.

◆ propertyDefinitions()

const QgsPropertiesDefinition & QgsFeatureRenderer::propertyDefinitions ( )
static

Returns the symbol property definitions.

Since
QGIS 3.18

Definition at line 77 of file qgsrenderer.cpp.

◆ referenceScale()

double QgsFeatureRenderer::referenceScale ( ) const
inline

Returns the symbology reference scale.

This represents the desired scale denominator for the rendered map, eg 1000.0 for a 1:1000 map render. A value of -1 indicates that symbology scaling by reference scale is disabled.

The symbology reference scale is an optional property which specifies the reference scale at which symbology in paper units (such a millimeters or points) is fixed to. For instance, if the scale is 1000 then a 2mm thick line will be rendered at exactly 2mm thick when a map is rendered at 1:1000, or 1mm thick when rendered at 1:2000, or 4mm thick at 1:500.

See also
setReferenceScale()
Since
QGIS 3.22

Definition at line 566 of file qgsrenderer.h.

◆ renderFeature()

bool QgsFeatureRenderer::renderFeature ( const QgsFeature feature,
QgsRenderContext context,
int  layer = -1,
bool  selected = false,
bool  drawVertexMarker = false 
)
virtual

Render a feature using this renderer in the given context.

Must be called between startRender() and stopRender() calls. Default implementation renders a symbol as determined by symbolForFeature() call. Returns true if the feature has been returned (this is used for example to determine whether the feature may be labelled).

If layer is not -1, the renderer should draw only a particular layer from symbols (in order to support symbol level rendering).

See also
startRender()
stopRender()

Reimplemented in QgsEmbeddedSymbolRenderer, QgsHeatmapRenderer, QgsMergedFeatureRenderer, QgsNullSymbolRenderer, QgsPointDistanceRenderer, and QgsRuleBasedRenderer.

Definition at line 138 of file qgsrenderer.cpp.

◆ renderFeatureWithSymbol()

void QgsFeatureRenderer::renderFeatureWithSymbol ( const QgsFeature feature,
QgsSymbol symbol,
QgsRenderContext context,
int  layer,
bool  selected,
bool  drawVertexMarker 
)
protected

Render the feature with the symbol using context.

Use layer to specify the symbol layer, selected to specify if it should be rendered as selected and drawVertexMarker to specify if vertex markers should be rendered.

Definition at line 152 of file qgsrenderer.cpp.

◆ renderVertexMarker()

void QgsFeatureRenderer::renderVertexMarker ( QPointF  pt,
QgsRenderContext context 
)
protected

render editing vertex marker at specified point

Definition at line 452 of file qgsrenderer.cpp.

◆ renderVertexMarkerPolygon()

void QgsFeatureRenderer::renderVertexMarkerPolygon ( QPolygonF &  pts,
QList< QPolygonF > *  rings,
QgsRenderContext context 
)
protected

render editing vertex marker for a polygon

Definition at line 467 of file qgsrenderer.cpp.

◆ renderVertexMarkerPolyline()

void QgsFeatureRenderer::renderVertexMarkerPolyline ( QPolygonF &  pts,
QgsRenderContext context 
)
protected

render editing vertex marker for a polyline

Definition at line 460 of file qgsrenderer.cpp.

◆ save()

QDomElement QgsFeatureRenderer::save ( QDomDocument &  doc,
const QgsReadWriteContext context 
)
virtual

Stores renderer properties to an XML element.

Subclasses which override this method should call saveRendererData() as part of their implementation in order to store all common base class properties in the returned DOM element.

Reimplemented in Qgs25DRenderer, QgsCategorizedSymbolRenderer, QgsEmbeddedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsHeatmapRenderer, QgsInvertedPolygonRenderer, QgsMergedFeatureRenderer, QgsNullSymbolRenderer, QgsPointClusterRenderer, QgsPointDisplacementRenderer, QgsRuleBasedRenderer, and QgsSingleSymbolRenderer.

Definition at line 213 of file qgsrenderer.cpp.

◆ saveRendererData()

void QgsFeatureRenderer::saveRendererData ( QDomDocument &  doc,
QDomElement &  element,
const QgsReadWriteContext context 
)
protected

Saves generic renderer data into the specified element.

This method should be called in a subclass' save() implementation in order to store all common base class properties in the DOM element.

Since
QGIS 3.22

Definition at line 224 of file qgsrenderer.cpp.

◆ setDataDefinedProperties()

void QgsFeatureRenderer::setDataDefinedProperties ( const QgsPropertyCollection collection)
inline

Sets the renderer's property collection, used for data defined overrides.

Parameters
collectionproperty collection. Existing properties will be replaced.
See also
dataDefinedProperties()
Since
QGIS 3.38

Definition at line 550 of file qgsrenderer.h.

◆ setDataDefinedProperty()

void QgsFeatureRenderer::setDataDefinedProperty ( Property  key,
const QgsProperty property 
)

Sets a data defined property for the renderer.

Any existing property with the same key will be overwritten.

See also
dataDefinedProperties()
Property
Since
QGIS 3.38

Definition at line 518 of file qgsrenderer.cpp.

◆ setEmbeddedRenderer()

void QgsFeatureRenderer::setEmbeddedRenderer ( QgsFeatureRenderer subRenderer)
virtual

Sets an embedded renderer (subrenderer) for this feature renderer.

The base class implementation does nothing with subrenderers, but individual derived classes can use these to modify their behavior.

Parameters
subRendererthe embedded renderer. Ownership will be transferred.
See also
embeddedRenderer()

Reimplemented in QgsPointDistanceRenderer, and QgsMergedFeatureRenderer.

Definition at line 543 of file qgsrenderer.cpp.

◆ setForceRasterRender()

void QgsFeatureRenderer::setForceRasterRender ( bool  forceRaster)
inline

Sets whether the renderer should be rendered to a raster destination.

Parameters
forceRasterset to true if renderer must be drawn on a raster surface. This may be desirable for highly detailed layers where rendering as a vector would result in a large, complex vector output.
See also
forceRasterRender

Definition at line 509 of file qgsrenderer.h.

◆ setLegendSymbolItem()

void QgsFeatureRenderer::setLegendSymbolItem ( const QString &  key,
QgsSymbol symbol 
)
virtual

Sets the symbol to be used for a legend symbol item.

Parameters
keyrule key for legend symbol
symbolnew symbol for legend item. Ownership is transferred to renderer.
See also
legendKeys()

Reimplemented in QgsCategorizedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsMergedFeatureRenderer, QgsPointDistanceRenderer, QgsRuleBasedRenderer, and QgsSingleSymbolRenderer.

Definition at line 403 of file qgsrenderer.cpp.

◆ setOrderBy()

void QgsFeatureRenderer::setOrderBy ( const QgsFeatureRequest::OrderBy orderBy)

Define the order in which features shall be processed by this renderer.

Note
this property has no effect if orderByEnabled() is false
See also
setOrderByEnabled()

Definition at line 528 of file qgsrenderer.cpp.

◆ setOrderByEnabled()

void QgsFeatureRenderer::setOrderByEnabled ( bool  enabled)

Sets whether custom ordering should be applied before features are processed by this renderer.

Parameters
enabledset to true to enable custom feature ordering
See also
setOrderBy()
orderByEnabled()

Definition at line 538 of file qgsrenderer.cpp.

◆ setPaintEffect()

void QgsFeatureRenderer::setPaintEffect ( QgsPaintEffect effect)

Sets the current paint effect for the renderer.

Parameters
effectpaint effect. Ownership is transferred to the renderer.
See also
paintEffect

Definition at line 512 of file qgsrenderer.cpp.

◆ setReferenceScale()

void QgsFeatureRenderer::setReferenceScale ( double  scale)
inline

Sets the symbology reference scale.

This should match the desired scale denominator for the rendered map, eg 1000.0 for a 1:1000 map render. Set to -1 to disable symbology scaling by reference scale.

The symbology reference scale is an optional property which specifies the reference scale at which symbology in paper units (such a millimeters or points) is fixed to. For instance, if scale is set to 1000 then a 2mm thick line will be rendered at exactly 2mm thick when a map is rendered at 1:1000, or 1mm thick when rendered at 1:2000, or 4mm thick at 1:500.

See also
referenceScale()
Since
QGIS 3.22

Definition at line 582 of file qgsrenderer.h.

◆ setUsingSymbolLevels()

void QgsFeatureRenderer::setUsingSymbolLevels ( bool  usingSymbolLevels)
inline

Definition at line 328 of file qgsrenderer.h.

◆ setVertexMarkerAppearance()

void QgsFeatureRenderer::setVertexMarkerAppearance ( Qgis::VertexMarkerType  type,
double  size 
)

Sets type and size of editing vertex markers for subsequent rendering.

Definition at line 441 of file qgsrenderer.cpp.

◆ startRender()

void QgsFeatureRenderer::startRender ( QgsRenderContext context,
const QgsFields fields 
)
virtual

Must be called when a new render cycle is started.

A call to startRender() must always be followed by a corresponding call to stopRender() after all features have been rendered.

Parameters
contextAdditional information passed to the renderer about the job which will be rendered
fieldsThe fields available for rendering
See also
stopRender()
Warning
This method is not thread safe. Before calling startRender() in a non-main thread, the renderer should instead be cloned and startRender()/stopRender() called on the clone.

Reimplemented in Qgs25DRenderer, QgsCategorizedSymbolRenderer, QgsEmbeddedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsHeatmapRenderer, QgsMergedFeatureRenderer, QgsPointClusterRenderer, QgsPointDisplacementRenderer, QgsPointDistanceRenderer, QgsRuleBasedRenderer, and QgsSingleSymbolRenderer.

Definition at line 100 of file qgsrenderer.cpp.

◆ stopRender()

void QgsFeatureRenderer::stopRender ( QgsRenderContext context)
virtual

Must be called when a render cycle has finished, to allow the renderer to clean up.

Calls to stopRender() must always be preceded by a call to startRender().

Warning
This method is not thread safe. Before calling startRender() in a non-main thread, the renderer should instead be cloned and startRender()/stopRender() called on the clone.
See also
startRender()

Reimplemented in Qgs25DRenderer, QgsCategorizedSymbolRenderer, QgsEmbeddedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsHeatmapRenderer, QgsMergedFeatureRenderer, QgsNullSymbolRenderer, QgsPointClusterRenderer, QgsPointDisplacementRenderer, QgsPointDistanceRenderer, QgsRuleBasedRenderer, and QgsSingleSymbolRenderer.

Definition at line 121 of file qgsrenderer.cpp.

◆ symbolForFeature()

virtual QgsSymbol * QgsFeatureRenderer::symbolForFeature ( const QgsFeature feature,
QgsRenderContext context 
) const
pure virtual

To be overridden.

Must be called between startRender() and stopRender() calls.

Parameters
featurefeature
contextrender context
Returns
returns pointer to symbol or 0 if symbol was not found

Implemented in Qgs25DRenderer, QgsCategorizedSymbolRenderer, QgsEmbeddedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsHeatmapRenderer, QgsMergedFeatureRenderer, QgsNullSymbolRenderer, QgsPointDistanceRenderer, QgsRuleBasedRenderer, and QgsSingleSymbolRenderer.

◆ symbols()

QgsSymbolList QgsFeatureRenderer::symbols ( QgsRenderContext context) const
virtual

◆ symbolsForFeature()

QgsSymbolList QgsFeatureRenderer::symbolsForFeature ( const QgsFeature feature,
QgsRenderContext context 
) const
virtual

Returns list of symbols used for rendering the feature.

For renderers that do not support MoreSymbolsPerFeature it is more efficient to use symbolForFeature()

Reimplemented in QgsMergedFeatureRenderer, QgsPointDistanceRenderer, and QgsRuleBasedRenderer.

Definition at line 485 of file qgsrenderer.cpp.

◆ toSld()

virtual void QgsFeatureRenderer::toSld ( QDomDocument &  doc,
QDomElement &  element,
const QVariantMap &  props = QVariantMap() 
) const
inlinevirtual

used from subclasses to create SLD Rule elements following SLD v1.1 specs

Reimplemented in QgsCategorizedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsPointDistanceRenderer, QgsRuleBasedRenderer, and QgsSingleSymbolRenderer.

Definition at line 360 of file qgsrenderer.h.

◆ type()

QString QgsFeatureRenderer::type ( ) const
inline

Definition at line 164 of file qgsrenderer.h.

◆ usedAttributes()

virtual QSet< QString > QgsFeatureRenderer::usedAttributes ( const QgsRenderContext context) const
pure virtual

Returns a list of attributes required by this renderer.

Attributes not listed in here may not have been requested from the provider at rendering time.

Returns
A set of attributes

Implemented in Qgs25DRenderer, QgsCategorizedSymbolRenderer, QgsEmbeddedSymbolRenderer, QgsGraduatedSymbolRenderer, QgsHeatmapRenderer, QgsMergedFeatureRenderer, QgsNullSymbolRenderer, QgsPointClusterRenderer, QgsPointDisplacementRenderer, QgsPointDistanceRenderer, QgsRuleBasedRenderer, and QgsSingleSymbolRenderer.

◆ usesEmbeddedSymbols()

bool QgsFeatureRenderer::usesEmbeddedSymbols ( ) const
virtual

Returns true if the renderer uses embedded symbols for features.

The default implementation returns false.

Since
QGIS 3.20

Reimplemented in QgsEmbeddedSymbolRenderer.

Definition at line 128 of file qgsrenderer.cpp.

◆ usingSymbolLevels()

bool QgsFeatureRenderer::usingSymbolLevels ( ) const
inline

Definition at line 327 of file qgsrenderer.h.

◆ willRenderFeature()

bool QgsFeatureRenderer::willRenderFeature ( const QgsFeature feature,
QgsRenderContext context 
) const
virtual

Returns whether the renderer will render a feature or not.

Must be called between startRender() and stopRender() calls. Default implementation uses symbolForFeature().

Reimplemented in QgsMergedFeatureRenderer, QgsNullSymbolRenderer, QgsPointDistanceRenderer, and QgsRuleBasedRenderer.

Definition at line 447 of file qgsrenderer.cpp.

◆ writeSld()

QDomElement QgsFeatureRenderer::writeSld ( QDomDocument &  doc,
const QString &  styleName,
const QVariantMap &  props = QVariantMap() 
) const
virtual

create the SLD UserStyle element following the SLD v1.1 specs with the given name

Definition at line 371 of file qgsrenderer.cpp.

Member Data Documentation

◆ mCurrentVertexMarkerSize

double QgsFeatureRenderer::mCurrentVertexMarkerSize = 2
protected

The current size of editing marker.

Definition at line 698 of file qgsrenderer.h.

◆ mCurrentVertexMarkerType

Qgis::VertexMarkerType QgsFeatureRenderer::mCurrentVertexMarkerType = Qgis::VertexMarkerType::Cross
protected

The current type of editing marker.

Definition at line 695 of file qgsrenderer.h.

◆ mForceRaster

bool QgsFeatureRenderer::mForceRaster = false
protected

Definition at line 702 of file qgsrenderer.h.

◆ mOrderBy

QgsFeatureRequest::OrderBy QgsFeatureRenderer::mOrderBy
protected

Definition at line 718 of file qgsrenderer.h.

◆ mOrderByEnabled

bool QgsFeatureRenderer::mOrderByEnabled = false
protected

Definition at line 720 of file qgsrenderer.h.

◆ mPaintEffect

QgsPaintEffect* QgsFeatureRenderer::mPaintEffect = nullptr
protected

Definition at line 700 of file qgsrenderer.h.

◆ mReferenceScale

double QgsFeatureRenderer::mReferenceScale = -1.0
protected

Definition at line 704 of file qgsrenderer.h.

◆ mType

QString QgsFeatureRenderer::mType
protected

Definition at line 690 of file qgsrenderer.h.

◆ mUsingSymbolLevels

bool QgsFeatureRenderer::mUsingSymbolLevels = false
protected

Definition at line 692 of file qgsrenderer.h.


The documentation for this class was generated from the following files: