QgsDiagramRenderer class
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
Contents
Derived classes
- class QgsSingleCategoryDiagramRenderer
- Renders the diagrams for all features with the same settings.
Constructors, destructors, conversion operators
- QgsDiagramRenderer() defaulted
- Constructor for QgsDiagramRenderer.
Public functions
- auto attributeLegend() const -> bool
- Returns true if renderer will show legend items for diagram attributes.
- auto clone() const -> QgsDiagramRenderer* pure virtual
- Returns new instance that is equivalent to this one.
- auto diagramAttributes() const -> QList<QString> pure virtual
- Returns attribute indices needed for diagram rendering.
- auto diagramSettings() const -> QList<QgsDiagramSettings> pure virtual
- Returns list with all diagram settings in the renderer.
- auto legendItems(QgsLayerTreeLayer* nodeLayer) const -> QList<QgsLayerTreeModelLegendNode*> virtual
- Returns list of legend nodes for the diagram.
- void readXml(const QDomElement& elem, const QgsReadWriteContext& context) pure virtual
- Reads diagram state from a DOM element.
- auto referencedFields(const QgsExpressionContext& context = QgsExpressionContext()) const -> QSet<QString> virtual
- Returns the set of any fields required for diagram rendering.
- 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.
- void setAttributeLegend(bool enabled)
- Sets whether the renderer will show legend items for diagram attributes.
- auto sizeMapUnits(const QgsFeature& feature, const QgsRenderContext& c) const -> QSizeF virtual
- Returns size of the diagram for a feature in map units. Returns an invalid QSizeF in case of error.
- void writeXml(QDomElement& layerElem, QDomDocument& doc, const QgsReadWriteContext& context) const pure virtual
- Writes diagram state to a DOM element.
Protected static functions
- static auto dpiPaintDevice(const QPainter*) -> int
- Returns the paint device dpi (or -1 in case of error.
Protected functions
- 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.
- auto diagramSettings(const QgsFeature& feature, const QgsRenderContext& c, QgsDiagramSettings& s) const -> bool pure virtual
- Returns diagram settings for a feature (or false if the diagram for the feature is not to be rendered).
- auto diagramSize(const QgsFeature& features, const QgsRenderContext& c) const -> QSizeF pure virtual
- Returns size of the diagram (in painter units) or an invalid size in case of error.
Protected variables
- std::unique_ptr<QgsDiagram> mDiagram
- Reference to the object that does the real diagram rendering.
- bool mShowAttributeLegend
- Whether to show an attribute legend for the diagrams.
Function documentation
bool QgsDiagramRenderer:: attributeLegend() const
Returns true if renderer will show legend items for diagram attributes.
QgsDiagramRenderer* QgsDiagramRenderer:: clone() const pure virtual
Returns new instance that is equivalent to this one.
QList<QgsLayerTreeModelLegendNode*> QgsDiagramRenderer:: legendItems(QgsLayerTreeLayer* nodeLayer) const virtual
Returns list of legend nodes for the diagram.
void QgsDiagramRenderer:: readXml(const QDomElement& elem,
const QgsReadWriteContext& context) pure virtual
Reads diagram state from a DOM element.
Subclasses should ensure that _
QSet<QString> QgsDiagramRenderer:: referencedFields(const QgsExpressionContext& context = QgsExpressionContext()) const virtual
Returns the set of any fields required for diagram rendering.
| Parameters | |
|---|---|
| context | expression context the diagrams will be drawn using |
void QgsDiagramRenderer:: setAttributeLegend(bool enabled)
Sets whether the renderer will show legend items for diagram attributes.
| Parameters | |
|---|---|
| enabled | set to true to show diagram attribute legend |
void QgsDiagramRenderer:: writeXml(QDomElement& layerElem,
QDomDocument& doc,
const QgsReadWriteContext& context) const pure virtual
Writes diagram state to a DOM element.
Subclasses should ensure that _
void QgsDiagramRenderer:: _readXml(const QDomElement& elem,
const QgsReadWriteContext& context) protected
Reads internal QgsDiagramRenderer state from a DOM element.
void QgsDiagramRenderer:: _writeXml(QDomElement& rendererElem,
QDomDocument& doc,
const QgsReadWriteContext& context) const protected
Writes internal QgsDiagramRenderer diagram state to a DOM element.
bool QgsDiagramRenderer:: diagramSettings(const QgsFeature& feature,
const QgsRenderContext& c,
QgsDiagramSettings& s) const pure virtual protected
Returns diagram settings for a feature (or false if the diagram for the feature is not to be rendered).
| Parameters | |
|---|---|
| feature | the feature |
| c | render context |
| s | out: diagram settings for the feature |
Used internally within renderDiagram()