15#ifndef QGSDIAGRAMRENDERER_H
16#define QGSDIAGRAMRENDERER_H
28#include <QDomDocument>
181 double zIndex()
const {
return mZIndex; }
268 void readXml(
const QDomElement &elem );
274 void writeXml( QDomElement &layerElem, QDomDocument &doc )
const;
317 Placement mPlacement = AroundPoint;
320 LinePlacementFlags mPlacementFlags = OnLine;
330 double mZIndex = 0.0;
333 bool mObstacle =
false;
336 double mDistance = 0.0;
339 std::unique_ptr<QgsDiagramRenderer> mRenderer;
342 bool mShowAll =
true;
347 static void initPropertyDefinitions();
619 void setDirection(
Direction direction );
662 bool showAxis()
const;
672 void setShowAxis(
bool showAxis );
700 double mStackedDiagramSpacing = 0;
706 bool mShowAxis =
false;
707 std::unique_ptr< QgsLineSymbol > mAxisLineSymbol;
708 std::unique_ptr< QgsPaintEffect > mPaintEffect;
744 if ( sipCpp->rendererName() == QLatin1String(
"SingleCategory" ) )
745 sipType = sipType_QgsSingleCategoryDiagramRenderer;
746 else if ( sipCpp->rendererName() == QLatin1String(
"LinearlyInterpolated" ) )
747 sipType = sipType_QgsLinearlyInterpolatedDiagramRenderer;
748 else if ( sipCpp->rendererName() == QLatin1String(
"Stacked" ) )
749 sipType = sipType_QgsStackedDiagramRenderer;
890 QList<QgsDiagramSettings> diagramSettings()
const override;
893 void writeXml( QDomElement &layerElem, QDomDocument &doc,
const QgsReadWriteContext &context )
const override;
929 QList<QString> diagramAttributes()
const override;
935 void setLowerValue(
double val ) { mInterpolationSettings.lowerValue = val; }
936 double lowerValue()
const {
return mInterpolationSettings.lowerValue; }
938 void setUpperValue(
double val ) { mInterpolationSettings.upperValue = val; }
939 double upperValue()
const {
return mInterpolationSettings.upperValue; }
941 void setLowerSize( QSizeF s ) { mInterpolationSettings.lowerSize = s; }
942 QSizeF
lowerSize()
const {
return mInterpolationSettings.lowerSize; }
944 void setUpperSize( QSizeF s ) { mInterpolationSettings.upperSize = s; }
945 QSizeF
upperSize()
const {
return mInterpolationSettings.upperSize; }
966 void writeXml( QDomElement &layerElem, QDomDocument &doc,
const QgsReadWriteContext &context )
const override;
990 std::unique_ptr<QgsDataDefinedSizeLegend> mDataDefinedSizeLegend;
1031 QList<QString> diagramAttributes()
const override;
1036 void writeXml( QDomElement &layerElem, QDomDocument &doc,
const QgsReadWriteContext &context )
const override;
1048 void _writeXmlSubRenderers( QDomElement &rendererElem, QDomDocument &doc,
const QgsReadWriteContext &context )
const;
1058 QList< QgsDiagramRenderer * > renderers(
bool sortByDiagramMode =
false )
const;
1078 int rendererCount()
const;
1086 QList< QgsDiagramRenderer * > mDiagramRenderers;
RenderUnit
Rendering size units.
@ Millimeters
Millimeters.
Object that keeps configuration of appearance of marker symbol's data-defined size in legend.
Additional diagram settings for interpolated size rendering.
bool classificationAttributeIsExpression
QString classificationField
Name of the field for classification.
QString classificationAttributeExpression
Stores the settings for rendering of all diagrams for a layer.
LinePlacementFlag
Line placement flags for controlling line based placements.
void setZIndex(double index)
Sets the diagram z-index.
Placement placement() const
Returns the diagram placement.
QgsCoordinateTransform coordinateTransform() const
Returns the coordinate transform associated with the layer, or an invalid transform if no transformat...
QFlags< LinePlacementFlag > LinePlacementFlags
bool showAllDiagrams() const
Returns whether the layer should show all diagrams, including overlapping diagrams.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the diagram's property collection, used for data defined overrides.
LinePlacementFlags linePlacementFlags() const
Returns the diagram placement flags.
Property
Data definable properties.
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the diagram's property collection, used for data defined overrides.
void setShowAllDiagrams(bool showAllDiagrams)
Sets whether the layer should show all diagrams, including overlapping diagrams.
void setDistance(double distance)
Sets the distance between the diagram and the feature.
QgsDiagramLayerSettings()
void setPriority(int value)
Sets the diagram priority.
int priority() const
Returns the diagram priority.
const QgsDiagramRenderer * renderer() const
Returns the diagram renderer associated with the layer.
void setIsObstacle(bool isObstacle)
Sets whether the feature associated with a diagram acts as an obstacle for other labels or diagrams.
QgsDiagramRenderer * renderer()
Returns the diagram renderer associated with the layer.
bool isObstacle() const
Returns whether the feature associated with a diagram acts as an obstacle for other labels or diagram...
void setPlacement(Placement value)
Sets the diagram placement.
void setLinePlacementFlags(LinePlacementFlags flags)
Sets the the diagram placement flags.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the diagram's property collection, used for data defined overrides.
double zIndex() const
Returns the diagram z-index.
double distance() const
Returns the distance between the diagram and the feature (in mm).
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
virtual QString rendererName() const =0
virtual QList< QgsLayerTreeModelLegendNode * > legendItems(QgsLayerTreeLayer *nodeLayer) const
Returns list of legend nodes for the diagram.
QgsDiagram * diagram() const
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.
void _writeXml(QDomElement &rendererElem, QDomDocument &doc, const QgsReadWriteContext &context) const
Writes internal QgsDiagramRenderer diagram state to a DOM element.
void setAttributeLegend(bool enabled)
Sets whether the renderer will show legend items for diagram attributes.
virtual QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext()) const
Returns the set of any fields required for diagram rendering.
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 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 void writeXml(QDomElement &layerElem, QDomDocument &doc, const QgsReadWriteContext &context) const =0
Writes diagram state to a DOM element.
void _readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads internal QgsDiagramRenderer state from a DOM element.
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 QList< QString > diagramAttributes() const =0
Returns attribute indices needed for diagram rendering.
std::unique_ptr< QgsDiagram > mDiagram
Reference to the object that does the real diagram rendering.
void convertSizeToMapUnits(QSizeF &size, const QgsRenderContext &context) const
Converts size from mm to map units.
virtual ~QgsDiagramRenderer()=default
friend class QgsStackedDiagramRenderer
virtual QList< QgsDiagramSettings > diagramSettings() const =0
Returns list with all diagram settings in the renderer.
bool mShowAttributeLegend
Whether to show an attribute legend for the diagrams.
QgsDiagramRenderer()=default
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)=0
Reads diagram state from a DOM element.
bool attributeLegend() const
Returns true if renderer will show legend items for diagram attributes.
void setDiagram(QgsDiagram *d)
virtual QgsDiagramRenderer * clone() const =0
Returns new instance that is equivalent to this one.
static int dpiPaintDevice(const QPainter *)
Returns the paint device dpi (or -1 in case of error.
Stores the settings for rendering a single diagram.
void setStackedDiagramSpacing(double spacing)
Sets the spacing between subdiagrams in a stacked diagram.
StackedDiagramMode stackedDiagramMode
DiagramOrientation
Orientation of histogram.
LabelPlacementMethod labelPlacementMethod
void setStackedDiagramSpacingUnit(Qgis::RenderUnit unit)
Sets the unit for the spacing between subdiagrams in a stacked diagram.
double opacity
Opacity, from 0 (transparent) to 1.0 (opaque).
QgsDiagramSettings & operator=(const QgsDiagramSettings &other)
Qgis::RenderUnit sizeType
Diagram size unit.
void setSpacingUnit(Qgis::RenderUnit unit)
Sets the unit for the content spacing.
QList< QString > categoryAttributes
QList< QString > categoryLabels
Qgis::RenderUnit stackedDiagramSpacingUnit() const
Returns the units for the spacing between subdiagrams in a stacked diagram.
DiagramOrientation diagramOrientation
QgsMapUnitScale lineSizeScale
Line unit scale.
StackedDiagramMode
Orientation of the stacked diagrams.
double spacing() const
Returns the spacing between diagram contents.
QList< QColor > categoryColors
double rotationOffset
Rotation offset, in degrees clockwise from horizontal.
QgsMapUnitScale sizeScale
Diagram size unit scale.
double minimumScale
The minimum map scale (i.e.
const QgsMapUnitScale & stackedDiagramSpacingMapUnitScale() const
Returns the map unit scale for the spacing between subdiagrams in a stacked diagram.
void setSpacing(double spacing)
Sets the spacing between diagram contents.
bool scaleBasedVisibility
double maximumScale
The maximum map scale (i.e.
void setSpacingMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the content spacing.
Qgis::RenderUnit lineSizeUnit
Line unit index.
const QgsMapUnitScale & spacingMapUnitScale() const
Returns the map unit scale for the content spacing.
double minimumSize
Scale diagrams smaller than mMinimumSize to mMinimumSize.
Direction
Angular directions.
@ Counterclockwise
Counter-clockwise orientation.
@ Clockwise
Clockwise orientation.
double stackedDiagramSpacing() const
Returns the spacing between subdiagrams in a stacked diagram.
void setStackedDiagramSpacingMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the spacing between subdiagrams in a stacked diagram.
Qgis::RenderUnit spacingUnit() const
Returns the units for the content spacing.
Base class for all diagram types.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Layer tree node points to a map layer.
An abstract interface for legend items returned from QgsMapLayerLegend implementation.
A line symbol type, for rendering LineString and MultiLineString geometries.
void setLowerValue(double val)
double upperValue() const
QString classificationAttributeExpression() const
void setDiagramSettings(const QgsDiagramSettings &s)
double lowerValue() const
QgsLinearlyInterpolatedDiagramRenderer()
void setLowerSize(QSizeF s)
QString classificationField() const
Returns the field name used for interpolating the diagram size.
QList< QgsDiagramSettings > diagramSettings() const override
Returns list with all diagram settings in the renderer.
void setClassificationAttributeExpression(const QString &expression)
QgsLinearlyInterpolatedDiagramRenderer * clone() const override
Returns new instance that is equivalent to this one.
bool classificationAttributeIsExpression() const
QString rendererName() const override
void setClassificationField(const QString &field)
Sets the field name used for interpolating the diagram size.
void setClassificationAttributeIsExpression(bool isExpression)
void setUpperSize(QSizeF s)
QgsLinearlyInterpolatedDiagramRenderer & operator=(const QgsLinearlyInterpolatedDiagramRenderer &other)
void setUpperValue(double val)
static const QString DIAGRAM_RENDERER_NAME_LINEARLY_INTERPOLATED
Perform transforms between map coordinates and device coordinates.
Struct for storing maximum and minimum scales for measurements in map units.
Base class for visual effects which can be applied to QPicture drawings.
A grouped map of multiple QgsProperty objects, each referenced by an integer key value.
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
QgsSingleCategoryDiagramRenderer * clone() const override
Returns new instance that is equivalent to this one.
void setDiagramSettings(const QgsDiagramSettings &s)
QgsSingleCategoryDiagramRenderer()=default
static const QString DIAGRAM_RENDERER_NAME_SINGLE_CATEGORY
QString rendererName() const override
QList< QString > diagramAttributes() const override
Returns attribute indices needed for diagram rendering.
QgsStackedDiagramRenderer * clone() const override
Returns new instance that is equivalent to this one.
QList< QgsDiagramSettings > diagramSettings() const override
Returns list with all diagram settings in the renderer.
void renderDiagram(const QgsFeature &feature, QgsRenderContext &c, QPointF pos, const QgsPropertyCollection &properties=QgsPropertyCollection()) const override
Renders the diagram for a specified feature at a specific position in the passed render context,...
void setDiagramSettings(const QgsDiagramSettings &s)
static const QString DIAGRAM_RENDERER_NAME_STACKED
QgsStackedDiagramRenderer & operator=(const QgsStackedDiagramRenderer &other)
QString rendererName() const override
QgsStackedDiagramRenderer()=default
QSizeF sizeMapUnits(const QgsFeature &feature, const QgsRenderContext &c) const override
Returns size of the diagram for a feature in map units. Returns an invalid QSizeF in case of error.
Represents a vector layer which manages a vector based dataset.
A set of features which influence the labeling process.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
#define SIP_ENUM_BASETYPE(type)
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.