QGIS API Documentation 3.41.0-Master (25ec5511245)
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
QgsDiagramRenderer Class Referenceabstract

Evaluates and returns the diagram settings relating to a diagram for a specific feature. More...

#include <qgsdiagramrenderer.h>

Inheritance diagram for QgsDiagramRenderer:
Inheritance graph
[legend]

Public Member Functions

 QgsDiagramRenderer ()=default
 
virtual ~QgsDiagramRenderer ()=default
 
bool attributeLegend () const
 Returns true if renderer will show legend items for diagram attributes.
 
virtual QgsDiagramRendererclone () const =0
 Returns new instance that is equivalent to this one.
 
QgsDiagramdiagram () const
 
virtual QList< QString > diagramAttributes () const =0
 Returns attribute indices needed for diagram rendering.
 
virtual QList< QgsDiagramSettingsdiagramSettings () const =0
 Returns list with all diagram settings in the renderer.
 
virtual QList< QgsLayerTreeModelLegendNode * > legendItems (QgsLayerTreeLayer *nodeLayer) const
 Returns list of legend nodes for the diagram.
 
virtual void readXml (const QDomElement &elem, const QgsReadWriteContext &context)=0
 Reads diagram state from a DOM element.
 
virtual QSet< QString > referencedFields (const QgsExpressionContext &context=QgsExpressionContext()) const
 Returns the set of any fields required for diagram rendering.
 
virtual void renderDiagram (const QgsFeature &feature, QgsRenderContext &c, QPointF pos, const QgsPropertyCollection &properties=QgsPropertyCollection()) const
 Renders the diagram for a specified feature at a specific position in the passed render context.
 
virtual QString rendererName () const =0
 
void setAttributeLegend (bool enabled)
 Sets whether the renderer will show legend items for diagram attributes.
 
void setDiagram (QgsDiagram *d)
 
virtual QSizeF sizeMapUnits (const QgsFeature &feature, const QgsRenderContext &c) const
 Returns size of the diagram for a feature in map units. Returns an invalid QSizeF in case of error.
 
virtual void writeXml (QDomElement &layerElem, QDomDocument &doc, const QgsReadWriteContext &context) const =0
 Writes diagram state to a DOM element.
 

Protected Member Functions

 QgsDiagramRenderer (const QgsDiagramRenderer &other)
 
void _readXml (const QDomElement &elem, const QgsReadWriteContext &context)
 Reads internal QgsDiagramRenderer state from a DOM element.
 
void _writeXml (QDomElement &rendererElem, QDomDocument &doc, const QgsReadWriteContext &context) const
 Writes internal QgsDiagramRenderer diagram state to a DOM element.
 
void convertSizeToMapUnits (QSizeF &size, const QgsRenderContext &context) const
 Converts size from mm to map units.
 
virtual bool diagramSettings (const QgsFeature &feature, const QgsRenderContext &c, QgsDiagramSettings &s) const =0
 Returns diagram settings for a feature (or false if the diagram for the feature is not to be rendered).
 
virtual QSizeF diagramSize (const QgsFeature &feature, const QgsRenderContext &c) const =0
 Returns size of the diagram (in painter units) or an invalid size in case of error.
 
QgsDiagramRendereroperator= (const QgsDiagramRenderer &other)
 

Static Protected Member Functions

static int dpiPaintDevice (const QPainter *)
 Returns the paint device dpi (or -1 in case of error.
 

Protected Attributes

std::unique_ptr< QgsDiagrammDiagram
 Reference to the object that does the real diagram rendering.
 
bool mShowAttributeLegend = true
 Whether to show an attribute legend for the diagrams.
 

Friends

class QgsStackedDiagramRenderer
 

Detailed Description

Evaluates and returns the diagram settings relating to a diagram for a specific feature.

Definition at line 738 of file qgsdiagramrenderer.h.

Constructor & Destructor Documentation

◆ QgsDiagramRenderer() [1/2]

QgsDiagramRenderer::QgsDiagramRenderer ( )
default

◆ ~QgsDiagramRenderer()

virtual QgsDiagramRenderer::~QgsDiagramRenderer ( )
virtualdefault

◆ QgsDiagramRenderer() [2/2]

QgsDiagramRenderer::QgsDiagramRenderer ( const QgsDiagramRenderer other)
protected

Definition at line 481 of file qgsdiagramrenderer.cpp.

Member Function Documentation

◆ _readXml()

void QgsDiagramRenderer::_readXml ( const QDomElement &  elem,
const QgsReadWriteContext context 
)
protected

Reads internal QgsDiagramRenderer state from a DOM element.

See also
_writeXml()

Definition at line 612 of file qgsdiagramrenderer.cpp.

◆ _writeXml()

void QgsDiagramRenderer::_writeXml ( QDomElement &  rendererElem,
QDomDocument &  doc,
const QgsReadWriteContext context 
) const
protected

Writes internal QgsDiagramRenderer diagram state to a DOM element.

See also
_readXml()

Definition at line 645 of file qgsdiagramrenderer.cpp.

◆ attributeLegend()

bool QgsDiagramRenderer::attributeLegend ( ) const
inline

Returns true if renderer will show legend items for diagram attributes.

See also
setAttributeLegend()

Definition at line 813 of file qgsdiagramrenderer.h.

◆ clone()

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

Returns new instance that is equivalent to this one.

Implemented in QgsSingleCategoryDiagramRenderer, QgsLinearlyInterpolatedDiagramRenderer, and QgsStackedDiagramRenderer.

◆ convertSizeToMapUnits()

void QgsDiagramRenderer::convertSizeToMapUnits ( QSizeF &  size,
const QgsRenderContext context 
) const
protected

Converts size from mm to map units.

Definition at line 587 of file qgsdiagramrenderer.cpp.

◆ diagram()

QgsDiagram * QgsDiagramRenderer::diagram ( ) const
inline

Definition at line 784 of file qgsdiagramrenderer.h.

◆ diagramAttributes()

virtual QList< QString > QgsDiagramRenderer::diagramAttributes ( ) const
pure virtual

Returns attribute indices needed for diagram rendering.

Implemented in QgsSingleCategoryDiagramRenderer, QgsLinearlyInterpolatedDiagramRenderer, and QgsStackedDiagramRenderer.

◆ diagramSettings() [1/2]

virtual QList< QgsDiagramSettings > QgsDiagramRenderer::diagramSettings ( ) const
pure virtual

Returns list with all diagram settings in the renderer.

Implemented in QgsSingleCategoryDiagramRenderer, QgsLinearlyInterpolatedDiagramRenderer, and QgsStackedDiagramRenderer.

◆ diagramSettings() [2/2]

virtual bool QgsDiagramRenderer::diagramSettings ( const QgsFeature feature,
const QgsRenderContext c,
QgsDiagramSettings s 
) const
protectedpure virtual

Returns diagram settings for a feature (or false if the diagram for the feature is not to be rendered).

Used internally within renderDiagram()

Parameters
featurethe feature
crender context
sout: diagram settings for the feature

Implemented in QgsSingleCategoryDiagramRenderer, QgsLinearlyInterpolatedDiagramRenderer, and QgsStackedDiagramRenderer.

◆ diagramSize()

virtual QSizeF QgsDiagramRenderer::diagramSize ( const QgsFeature feature,
const QgsRenderContext c 
) const
protectedpure virtual

Returns size of the diagram (in painter units) or an invalid size in case of error.

Parameters
featurethe feature
crender context

Implemented in QgsSingleCategoryDiagramRenderer, QgsLinearlyInterpolatedDiagramRenderer, and QgsStackedDiagramRenderer.

◆ dpiPaintDevice()

int QgsDiagramRenderer::dpiPaintDevice ( const QPainter *  painter)
staticprotected

Returns the paint device dpi (or -1 in case of error.

Definition at line 599 of file qgsdiagramrenderer.cpp.

◆ legendItems()

QList< QgsLayerTreeModelLegendNode * > QgsDiagramRenderer::legendItems ( QgsLayerTreeLayer nodeLayer) const
virtual

Returns list of legend nodes for the diagram.

Note
caller is responsible for deletion of QgsLayerTreeModelLegendNodes

Reimplemented in QgsSingleCategoryDiagramRenderer, QgsLinearlyInterpolatedDiagramRenderer, and QgsStackedDiagramRenderer.

Definition at line 1308 of file qgsdiagramrenderer.cpp.

◆ operator=()

QgsDiagramRenderer & QgsDiagramRenderer::operator= ( const QgsDiagramRenderer other)
protected

Definition at line 487 of file qgsdiagramrenderer.cpp.

◆ readXml()

virtual void QgsDiagramRenderer::readXml ( const QDomElement &  elem,
const QgsReadWriteContext context 
)
pure virtual

Reads diagram state from a DOM element.

Subclasses should ensure that _readXml() is called by their readXml implementation to restore the general QgsDiagramRenderer settings.

See also
writeXml()

Implemented in QgsSingleCategoryDiagramRenderer, QgsLinearlyInterpolatedDiagramRenderer, and QgsStackedDiagramRenderer.

◆ referencedFields()

QSet< QString > QgsDiagramRenderer::referencedFields ( const QgsExpressionContext context = QgsExpressionContext()) const
virtual

Returns the set of any fields required for diagram rendering.

Parameters
contextexpression context the diagrams will be drawn using

Reimplemented in QgsLinearlyInterpolatedDiagramRenderer.

Definition at line 567 of file qgsdiagramrenderer.cpp.

◆ renderDiagram()

void QgsDiagramRenderer::renderDiagram ( const QgsFeature feature,
QgsRenderContext c,
QPointF  pos,
const QgsPropertyCollection properties = QgsPropertyCollection() 
) const
virtual

Renders the diagram for a specified feature at a specific position in the passed render context.

Reimplemented in QgsStackedDiagramRenderer.

Definition at line 494 of file qgsdiagramrenderer.cpp.

◆ rendererName()

virtual QString QgsDiagramRenderer::rendererName ( ) const
pure virtual

◆ setAttributeLegend()

void QgsDiagramRenderer::setAttributeLegend ( bool  enabled)
inline

Sets whether the renderer will show legend items for diagram attributes.

Parameters
enabledset to true to show diagram attribute legend
See also
attributeLegend()

Definition at line 820 of file qgsdiagramrenderer.h.

◆ setDiagram()

void QgsDiagramRenderer::setDiagram ( QgsDiagram d)

Definition at line 473 of file qgsdiagramrenderer.cpp.

◆ sizeMapUnits()

QSizeF QgsDiagramRenderer::sizeMapUnits ( const QgsFeature feature,
const QgsRenderContext c 
) const
virtual

Returns size of the diagram for a feature in map units. Returns an invalid QSizeF in case of error.

Reimplemented in QgsStackedDiagramRenderer.

Definition at line 529 of file qgsdiagramrenderer.cpp.

◆ writeXml()

virtual void QgsDiagramRenderer::writeXml ( QDomElement &  layerElem,
QDomDocument &  doc,
const QgsReadWriteContext context 
) const
pure virtual

Writes diagram state to a DOM element.

Subclasses should ensure that _writeXml() is called by their writeXml implementation to save the general QgsDiagramRenderer settings.

See also
readXml()

Implemented in QgsSingleCategoryDiagramRenderer, QgsLinearlyInterpolatedDiagramRenderer, and QgsStackedDiagramRenderer.

Friends And Related Symbol Documentation

◆ QgsStackedDiagramRenderer

friend class QgsStackedDiagramRenderer
friend

Definition at line 867 of file qgsdiagramrenderer.h.

Member Data Documentation

◆ mDiagram

std::unique_ptr< QgsDiagram > QgsDiagramRenderer::mDiagram
protected

Reference to the object that does the real diagram rendering.

Definition at line 862 of file qgsdiagramrenderer.h.

◆ mShowAttributeLegend

bool QgsDiagramRenderer::mShowAttributeLegend = true
protected

Whether to show an attribute legend for the diagrams.

Definition at line 865 of file qgsdiagramrenderer.h.


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