27 #include <QDomElement> 32 void QgsDiagramLayerSettings::initPropertyDefinitions()
34 if ( !sPropertyDefinitions.isEmpty() )
37 const QString origin = QStringLiteral(
"diagram" );
58 initPropertyDefinitions();
59 return sPropertyDefinitions;
64 initPropertyDefinitions();
69 , mPlacement( rh.mPlacement )
70 , mPlacementFlags( rh.mPlacementFlags )
71 , mPriority( rh.mPriority )
72 , mZIndex( rh.mZIndex )
73 , mObstacle( rh.mObstacle )
74 , mDistance( rh.mDistance )
75 , mRenderer( rh.mRenderer ? rh.mRenderer->clone() : nullptr )
76 , mShowAll( rh.mShowAll )
77 , mDataDefinedProperties( rh.mDataDefinedProperties )
79 initPropertyDefinitions();
84 mPlacement = rh.mPlacement;
85 mPlacementFlags = rh.mPlacementFlags;
86 mPriority = rh.mPriority;
88 mObstacle = rh.mObstacle;
89 mDistance = rh.mDistance;
90 mRenderer = rh.mRenderer ? rh.mRenderer->
clone() :
nullptr;
92 mShowAll = rh.mShowAll;
93 mDataDefinedProperties = rh.mDataDefinedProperties;
104 if ( diagramRenderer == mRenderer )
108 mRenderer = diagramRenderer;
118 QDomNodeList propertyElems = elem.elementsByTagName( QStringLiteral(
"properties" ) );
119 if ( !propertyElems.isEmpty() )
121 ( void )mDataDefinedProperties.
readXml( propertyElems.at( 0 ).toElement(), sPropertyDefinitions );
125 mDataDefinedProperties.
clear();
128 mPlacement =
static_cast< Placement >( elem.attribute( QStringLiteral(
"placement" ) ).toInt() );
129 mPlacementFlags =
static_cast< LinePlacementFlag >( elem.attribute( QStringLiteral(
"linePlacementFlags" ) ).toInt() );
130 mPriority = elem.attribute( QStringLiteral(
"priority" ) ).toInt();
131 mZIndex = elem.attribute( QStringLiteral(
"zIndex" ) ).toDouble();
132 mObstacle = elem.attribute( QStringLiteral(
"obstacle" ) ).toInt();
133 mDistance = elem.attribute( QStringLiteral(
"dist" ) ).toDouble();
134 mShowAll = ( elem.attribute( QStringLiteral(
"showAll" ), QStringLiteral(
"0" ) ) != QLatin1String(
"0" ) );
139 QDomElement diagramLayerElem = doc.createElement( QStringLiteral(
"DiagramLayerSettings" ) );
140 QDomElement propertiesElem = doc.createElement( QStringLiteral(
"properties" ) );
141 ( void )mDataDefinedProperties.
writeXml( propertiesElem, sPropertyDefinitions );
142 diagramLayerElem.appendChild( propertiesElem );
143 diagramLayerElem.setAttribute( QStringLiteral(
"placement" ), mPlacement );
144 diagramLayerElem.setAttribute( QStringLiteral(
"linePlacementFlags" ), mPlacementFlags );
145 diagramLayerElem.setAttribute( QStringLiteral(
"priority" ), mPriority );
146 diagramLayerElem.setAttribute( QStringLiteral(
"zIndex" ), mZIndex );
147 diagramLayerElem.setAttribute( QStringLiteral(
"obstacle" ), mObstacle );
148 diagramLayerElem.setAttribute( QStringLiteral(
"dist" ), QString::number( mDistance ) );
149 diagramLayerElem.setAttribute( QStringLiteral(
"showAll" ), mShowAll );
150 layerElem.appendChild( diagramLayerElem );
155 return mDataDefinedProperties.
prepare( context );
160 QSet< QString > referenced;
172 enabled = ( elem.attribute( QStringLiteral(
"enabled" ), QStringLiteral(
"1" ) ) != QLatin1String(
"0" ) );
175 font.fromString( elem.attribute( QStringLiteral(
"font" ) ) );
177 backgroundColor.setNamedColor( elem.attribute( QStringLiteral(
"backgroundColor" ) ) );
178 backgroundColor.setAlpha( elem.attribute( QStringLiteral(
"backgroundAlpha" ) ).toInt() );
179 size.setWidth( elem.attribute( QStringLiteral(
"width" ) ).toDouble() );
180 size.setHeight( elem.attribute( QStringLiteral(
"height" ) ).toDouble() );
181 if ( elem.hasAttribute( QStringLiteral(
"transparency" ) ) )
183 opacity = 1 - elem.attribute( QStringLiteral(
"transparency" ), QStringLiteral(
"0" ) ).toInt() / 255.0;
187 opacity = elem.attribute( QStringLiteral(
"opacity" ), QStringLiteral(
"1.00" ) ).toDouble();
190 penColor.setNamedColor( elem.attribute( QStringLiteral(
"penColor" ) ) );
191 int penAlpha = elem.attribute( QStringLiteral(
"penAlpha" ), QStringLiteral(
"255" ) ).toInt();
192 penColor.setAlpha( penAlpha );
193 penWidth = elem.attribute( QStringLiteral(
"penWidth" ) ).toDouble();
195 maximumScale = elem.attribute( QStringLiteral(
"minScaleDenominator" ), QStringLiteral(
"-1" ) ).toDouble();
196 minimumScale = elem.attribute( QStringLiteral(
"maxScaleDenominator" ), QStringLiteral(
"-1" ) ).toDouble();
197 if ( elem.hasAttribute( QStringLiteral(
"scaleBasedVisibility" ) ) )
199 scaleBasedVisibility = ( elem.attribute( QStringLiteral(
"scaleBasedVisibility" ), QStringLiteral(
"1" ) ) != QLatin1String(
"0" ) );
203 scaleBasedVisibility = maximumScale >= 0 && minimumScale >= 0;
207 if ( elem.attribute( QStringLiteral(
"sizeType" ) ) == QLatin1String(
"MapUnits" ) )
223 if ( elem.attribute( QStringLiteral(
"labelPlacementMethod" ) ) == QLatin1String(
"Height" ) )
225 labelPlacementMethod = Height;
229 labelPlacementMethod = XHeight;
233 if ( elem.attribute( QStringLiteral(
"diagramOrientation" ) ) == QLatin1String(
"Left" ) )
235 diagramOrientation = Left;
237 else if ( elem.attribute( QStringLiteral(
"diagramOrientation" ) ) == QLatin1String(
"Right" ) )
239 diagramOrientation = Right;
241 else if ( elem.attribute( QStringLiteral(
"diagramOrientation" ) ) == QLatin1String(
"Down" ) )
243 diagramOrientation = Down;
247 diagramOrientation = Up;
251 if ( elem.attribute( QStringLiteral(
"scaleDependency" ) ) == QLatin1String(
"Diameter" ) )
260 barWidth = elem.attribute( QStringLiteral(
"barWidth" ) ).toDouble();
262 if ( elem.hasAttribute( QStringLiteral(
"angleOffset" ) ) )
263 rotationOffset = std::fmod( 360.0 - elem.attribute( QStringLiteral(
"angleOffset" ) ).toInt() / 16.0, 360.0 );
265 rotationOffset = elem.attribute( QStringLiteral(
"rotationOffset" ) ).toDouble();
267 minimumSize = elem.attribute( QStringLiteral(
"minimumSize" ) ).toDouble();
270 categoryColors.clear();
271 QDomNodeList attributes = elem.elementsByTagName( QStringLiteral(
"attribute" ) );
273 if ( attributes.length() > 0 )
275 for (
int i = 0; i < attributes.size(); i++ )
277 QDomElement attrElem = attributes.at( i ).toElement();
278 QColor newColor( attrElem.attribute( QStringLiteral(
"color" ) ) );
279 newColor.setAlphaF( opacity );
280 categoryColors.append( newColor );
281 categoryAttributes.append( attrElem.attribute( QStringLiteral(
"field" ) ) );
282 categoryLabels.append( attrElem.attribute( QStringLiteral(
"label" ) ) );
283 if ( categoryLabels.back().isEmpty() )
285 categoryLabels.back() = categoryAttributes.back();
293 QStringList colorList = elem.attribute( QStringLiteral(
"colors" ) ).split(
'/' );
294 QStringList::const_iterator colorIt = colorList.constBegin();
295 for ( ; colorIt != colorList.constEnd(); ++colorIt )
297 QColor newColor( *colorIt );
298 newColor.setAlphaF( opacity );
299 categoryColors.append( QColor( newColor ) );
303 categoryAttributes.clear();
304 QStringList catList = elem.attribute( QStringLiteral(
"categories" ) ).split(
'/' );
305 QStringList::const_iterator catIt = catList.constBegin();
306 for ( ; catIt != catList.constEnd(); ++catIt )
308 categoryAttributes.append( *catIt );
309 categoryLabels.append( *catIt );
316 QDomElement categoryElem = doc.createElement( QStringLiteral(
"DiagramCategory" ) );
317 categoryElem.setAttribute( QStringLiteral(
"enabled" ), enabled );
319 categoryElem.setAttribute( QStringLiteral(
"backgroundColor" ), backgroundColor.name() );
320 categoryElem.setAttribute( QStringLiteral(
"backgroundAlpha" ), backgroundColor.alpha() );
321 categoryElem.setAttribute( QStringLiteral(
"width" ), QString::number( size.width() ) );
322 categoryElem.setAttribute( QStringLiteral(
"height" ), QString::number( size.height() ) );
323 categoryElem.setAttribute( QStringLiteral(
"penColor" ), penColor.name() );
324 categoryElem.setAttribute( QStringLiteral(
"penAlpha" ), penColor.alpha() );
325 categoryElem.setAttribute( QStringLiteral(
"penWidth" ), QString::number( penWidth ) );
326 categoryElem.setAttribute( QStringLiteral(
"scaleBasedVisibility" ), scaleBasedVisibility );
327 categoryElem.setAttribute( QStringLiteral(
"minScaleDenominator" ), QString::number( maximumScale ) );
328 categoryElem.setAttribute( QStringLiteral(
"maxScaleDenominator" ), QString::number( minimumScale ) );
329 categoryElem.setAttribute( QStringLiteral(
"opacity" ), QString::number( opacity ) );
340 if ( labelPlacementMethod == Height )
342 categoryElem.setAttribute( QStringLiteral(
"labelPlacementMethod" ), QStringLiteral(
"Height" ) );
346 categoryElem.setAttribute( QStringLiteral(
"labelPlacementMethod" ), QStringLiteral(
"XHeight" ) );
351 categoryElem.setAttribute( QStringLiteral(
"scaleDependency" ), QStringLiteral(
"Area" ) );
355 categoryElem.setAttribute( QStringLiteral(
"scaleDependency" ), QStringLiteral(
"Diameter" ) );
359 switch ( diagramOrientation )
362 categoryElem.setAttribute( QStringLiteral(
"diagramOrientation" ), QStringLiteral(
"Left" ) );
366 categoryElem.setAttribute( QStringLiteral(
"diagramOrientation" ), QStringLiteral(
"Right" ) );
370 categoryElem.setAttribute( QStringLiteral(
"diagramOrientation" ), QStringLiteral(
"Down" ) );
374 categoryElem.setAttribute( QStringLiteral(
"diagramOrientation" ), QStringLiteral(
"Up" ) );
378 categoryElem.setAttribute( QStringLiteral(
"diagramOrientation" ), QStringLiteral(
"Up" ) );
382 categoryElem.setAttribute( QStringLiteral(
"barWidth" ), QString::number( barWidth ) );
383 categoryElem.setAttribute( QStringLiteral(
"minimumSize" ), QString::number( minimumSize ) );
384 categoryElem.setAttribute( QStringLiteral(
"rotationOffset" ), QString::number( rotationOffset ) );
386 int nCats = std::min( categoryColors.size(), categoryAttributes.size() );
387 for (
int i = 0; i < nCats; ++i )
389 QDomElement attributeElem = doc.createElement( QStringLiteral(
"attribute" ) );
391 attributeElem.setAttribute( QStringLiteral(
"field" ), categoryAttributes.at( i ) );
392 attributeElem.setAttribute( QStringLiteral(
"color" ), categoryColors.at( i ).name() );
393 attributeElem.setAttribute( QStringLiteral(
"label" ), categoryLabels.at( i ) );
394 categoryElem.appendChild( attributeElem );
397 rendererElem.appendChild( categoryElem );
402 if ( mDiagram.get() == d )
409 : mDiagram( other.mDiagram ? other.mDiagram->clone() : nullptr )
410 , mShowAttributeLegend( other.mShowAttributeLegend )
446 mDiagram->renderDiagram( feature, c, s, pos );
458 if ( size.isValid() )
461 size.rheight() *= width / size.width();
462 size.setWidth( width );
469 QSet< QString > referenced;
475 for (
const QString &att : constDiagramAttributes )
479 for (
const QString &field : constReferencedColumns )
489 if ( !size.isValid() )
495 size.rwidth() *= pixelToMap;
496 size.rheight() *= pixelToMap;
503 QPaintDevice *device = painter->device();
506 return device->logicalDpiX();
516 QString diagramType = elem.attribute( QStringLiteral(
"diagramType" ) );
517 if ( diagramType == QLatin1String(
"Pie" ) )
521 else if ( diagramType == QLatin1String(
"Text" ) )
525 else if ( diagramType == QLatin1String(
"Histogram" ) )
529 mShowAttributeLegend = ( elem.attribute( QStringLiteral(
"attributeLegend" ), QStringLiteral(
"1" ) ) != QLatin1String(
"0" ) );
539 rendererElem.setAttribute( QStringLiteral(
"diagramType" ),
mDiagram->diagramName() );
563 QList<QgsDiagramSettings> settingsList;
564 settingsList.push_back( mSettings );
570 QDomElement categoryElem = elem.firstChildElement( QStringLiteral(
"DiagramCategory" ) );
571 if ( categoryElem.isNull() )
576 mSettings.readXml( categoryElem );
582 QDomElement rendererElem = doc.createElement( QStringLiteral(
"SingleCategoryDiagramRenderer" ) );
583 mSettings.writeXml( rendererElem, doc );
585 layerElem.appendChild( rendererElem );
591 mInterpolationSettings.classificationAttributeIsExpression =
false;
596 , mSettings( other.mSettings )
597 , mInterpolationSettings( other.mInterpolationSettings )
598 , mDataDefinedSizeLegend( other.mDataDefinedSizeLegend ? new
QgsDataDefinedSizeLegend( *other.mDataDefinedSizeLegend ) : nullptr )
604 delete mDataDefinedSizeLegend;
614 QList<QgsDiagramSettings> settingsList;
615 settingsList.push_back( mSettings );
638 for (
const QString &field : constReferencedColumns )
652 return mDiagram->diagramSize( feature, c, mSettings, mInterpolationSettings );
657 mInterpolationSettings.
lowerValue = elem.attribute( QStringLiteral(
"lowerValue" ) ).toDouble();
658 mInterpolationSettings.
upperValue = elem.attribute( QStringLiteral(
"upperValue" ) ).toDouble();
659 mInterpolationSettings.
lowerSize.setWidth( elem.attribute( QStringLiteral(
"lowerWidth" ) ).toDouble() );
660 mInterpolationSettings.
lowerSize.setHeight( elem.attribute( QStringLiteral(
"lowerHeight" ) ).toDouble() );
661 mInterpolationSettings.
upperSize.setWidth( elem.attribute( QStringLiteral(
"upperWidth" ) ).toDouble() );
662 mInterpolationSettings.
upperSize.setHeight( elem.attribute( QStringLiteral(
"upperHeight" ) ).toDouble() );
670 mInterpolationSettings.
classificationField = elem.attribute( QStringLiteral(
"classificationField" ) );
672 QDomElement settingsElem = elem.firstChildElement( QStringLiteral(
"DiagramCategory" ) );
673 if ( !settingsElem.isNull() )
675 mSettings.
readXml( settingsElem );
678 delete mDataDefinedSizeLegend;
680 QDomElement ddsLegendSizeElem = elem.firstChildElement( QStringLiteral(
"data-defined-size-legend" ) );
681 if ( !ddsLegendSizeElem.isNull() )
688 if ( elem.attribute( QStringLiteral(
"sizeLegend" ), QStringLiteral(
"0" ) ) != QLatin1String(
"0" ) )
691 QDomElement sizeLegendSymbolElem = elem.firstChildElement( QStringLiteral(
"symbol" ) );
692 if ( !sizeLegendSymbolElem.isNull() && sizeLegendSymbolElem.attribute( QStringLiteral(
"name" ) ) == QLatin1String(
"sizeSymbol" ) )
694 mDataDefinedSizeLegend->
setSymbol( QgsSymbolLayerUtils::loadSymbol<QgsMarkerSymbol>( sizeLegendSymbolElem, context ) );
699 mDataDefinedSizeLegend =
nullptr;
708 QDomElement rendererElem = doc.createElement( QStringLiteral(
"LinearlyInterpolatedDiagramRenderer" ) );
709 rendererElem.setAttribute( QStringLiteral(
"lowerValue" ), QString::number( mInterpolationSettings.
lowerValue ) );
710 rendererElem.setAttribute( QStringLiteral(
"upperValue" ), QString::number( mInterpolationSettings.
upperValue ) );
711 rendererElem.setAttribute( QStringLiteral(
"lowerWidth" ), QString::number( mInterpolationSettings.
lowerSize.width() ) );
712 rendererElem.setAttribute( QStringLiteral(
"lowerHeight" ), QString::number( mInterpolationSettings.
lowerSize.height() ) );
713 rendererElem.setAttribute( QStringLiteral(
"upperWidth" ), QString::number( mInterpolationSettings.
upperSize.width() ) );
714 rendererElem.setAttribute( QStringLiteral(
"upperHeight" ), QString::number( mInterpolationSettings.
upperSize.height() ) );
721 rendererElem.setAttribute( QStringLiteral(
"classificationField" ), mInterpolationSettings.
classificationField );
723 mSettings.
writeXml( rendererElem, doc );
725 if ( mDataDefinedSizeLegend )
727 QDomElement ddsLegendElem = doc.createElement( QStringLiteral(
"data-defined-size-legend" ) );
728 mDataDefinedSizeLegend->
writeXml( ddsLegendElem, context );
729 rendererElem.appendChild( ddsLegendElem );
733 layerElem.appendChild( rendererElem );
738 QList< QgsLayerTreeModelLegendNode * > list;
739 list.reserve( categoryLabels.size() );
740 for (
int i = 0; i < categoryLabels.size(); ++i )
742 QPixmap pix( 16, 16 );
743 pix.fill( categoryColors[i] );
744 list <<
new QgsSimpleLegendNode( nodeLayer, categoryLabels[i], QIcon( pix ),
nullptr, QStringLiteral(
"diagram_%1" ).arg( QString::number( i ) ) );
751 return QList< QgsLayerTreeModelLegendNode * >();
756 QList< QgsLayerTreeModelLegendNode * > nodes;
765 QList< QgsLayerTreeModelLegendNode * > nodes;
769 if ( mDataDefinedSizeLegend &&
mDiagram )
779 QList<QgsDataDefinedSizeLegend::SizeClass> sizeClasses;
780 if ( ddSizeLegend.
classes().isEmpty() )
784 for (
double v : prettyBreaks )
786 double size =
mDiagram->legendSize( v, mSettings, mInterpolationSettings );
793 const auto constClasses = ddSizeLegend.
classes();
796 double size =
mDiagram->legendSize( sc.size, mSettings, mInterpolationSettings );
805 if ( si.dataDefinedSizeLegendSettings() )
817 delete mDataDefinedSizeLegend;
818 mDataDefinedSizeLegend = settings;
823 return mDataDefinedSizeLegend;
void _writeXml(QDomElement &rendererElem, QDomDocument &doc, const QgsReadWriteContext &context) const
Writes internal QgsDiagramRenderer diagram state to a DOM element.
Class for parsing and evaluation of expressions (formerly called "search strings").
static int dpiPaintDevice(const QPainter *)
Returns the paint device dpi (or -1 in case of error.
The class is used as a container of context for various read/write operations on other objects...
QColor valueAsColor(int key, const QgsExpressionContext &context, const QColor &defaultColor=QColor(), bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a color...
void setCoordinateTransform(const QgsCoordinateTransform &transform)
Sets the coordinate transform associated with the layer.
double convertToMapUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to map units.
Distance to diagram from feature.
void writeXml(QDomElement &layerElem, QDomDocument &doc, const QgsReadWriteContext &context) const override
Writes diagram state to a DOM element.
QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext()) const override
Returns the set of any fields required for diagram rendering.
QgsSingleCategoryDiagramRenderer * clone() const override
Returns new instance that is equivalent to this one.
double valueAsDouble(int key, const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a double...
Diagram background color.
Definition of one class for the legend.
virtual bool readXml(const QDomElement &collectionElem, const QgsPropertiesDefinition &definitions)
Reads property collection state from an XML element.
Renders the diagrams for all features with the same settings.
~QgsDiagramLayerSettings()
QList< QString > categoryAttributes
QgsDiagramRenderer()=default
Constructor for QgsDiagramRenderer.
~QgsLinearlyInterpolatedDiagramRenderer() override
bool classificationAttributeIsExpression
virtual QList< QgsLayerTreeModelLegendNode *> legendItems(QgsLayerTreeLayer *nodeLayer) const
Returns list of legend nodes for the diagram.
Produces legend node with a marker symbol.
virtual QList< QString > diagramAttributes() const =0
Returns attribute indices needed for diagram rendering.
void writeXml(QDomElement &layerElem, QDomDocument &doc) const
Writes the diagram settings to a DOM element.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the size map unit scale for the whole symbol (including all symbol layers).
Implementation of legend node interface for displaying preview of vector symbols and their labels and...
Angle offset for pie diagram.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
Color with alpha channel.
QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext()) const
Returns the set of any fields referenced by the layer's diagrams.
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Positive double value (including 0)
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...
QgsLegendSymbolList legendSymbolList() const
Generates legend symbol items according to the configuration.
Whether diagram features act as obstacles for other diagrams/labels.
QSizeF diagramSize(const QgsFeature &, const QgsRenderContext &c) const override
Returns size of the diagram (in painter units) or an invalid size in case of error.
bool mShowAttributeLegend
Whether to show an attribute legend for the diagrams.
QMap< QString, QString > QgsStringMap
double rotationOffset
Rotation offset, in degrees clockwise from horizontal.
QgsMarkerSymbol * symbol() const
Returns marker symbol that will be used to draw markers in legend.
Rotation (value between 0-360 degrees)
A marker symbol type, for rendering Point and MultiPoint geometries.
void setDiagram(QgsDiagram *d)
QList< QgsDiagramSettings > diagramSettings() const override
Returns list with all diagram settings in the renderer.
static QString encodeColor(const QColor &color)
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
bool prepare(const QgsExpressionContext &context=QgsExpressionContext()) const override
Prepares the collection against a specified expression context.
Z-index for diagram ordering.
QList< QgsDataDefinedSizeLegend::SizeClass > classes() const
Returns list of classes: each class is a pair of symbol size (in units used by the symbol) and label...
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
QString classificationAttributeExpression
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
bool prepare(const QgsExpressionContext &context=QgsExpressionContext()) const
Prepares the diagrams for a specified expression context.
void readXml(const QDomElement &elem)
Reads the diagram settings from a DOM element.
void convertSizeToMapUnits(QSizeF &size, const QgsRenderContext &context) const
Converts size from mm to map units.
QgsDiagramLayerSettings()
Constructor for QgsDiagramLayerSettings.
QgsMapUnitScale sizeScale
Diagram size unit scale.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads diagram state from a DOM element.
static bool setFromXmlChildNode(QFont &font, const QDomElement &element, const QString &childNode)
Sets the properties of a font to match the properties stored in an XML child node.
Y-coordinate data defined diagram position.
Implementation of legend node interface for displaying arbitrary label with icon. ...
void clear() override
Removes all properties from the collection.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
double mapUnitsPerPixel() const
Returns current map units per pixel.
Whether to show the diagram.
Double value (including negative values)
QList< QgsLayerTreeModelLegendNode *> legendItems(QgsLayerTreeLayer *nodeLayer) const
Returns list of legend nodes for the diagram.
std::unique_ptr< QgsDiagram > mDiagram
Reference to the object that does the real diagram rendering.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the size units for the whole symbol (including all symbol layers).
QgsLinearlyInterpolatedDiagramRenderer()
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const
Writes configuration to the given XML element.
void writeXml(QDomElement &layerElem, QDomDocument &doc, const QgsReadWriteContext &context) const override
Writes diagram state to a DOM element.
Definition for a property.
Base class for all diagram types.
QgsLinearlyInterpolatedDiagramRenderer * clone() const override
Returns new instance that is equivalent to this one.
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
QgsUnitTypes::RenderUnit sizeType
Diagram size unit.
void setRenderer(QgsDiagramRenderer *diagramRenderer)
Sets the diagram renderer associated with the layer.
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
QgsExpressionContext & expressionContext()
Gets the expression context.
void readXml(const QDomElement &elem)
Reads diagram settings from XML.
Stores the settings for rendering of all diagrams for a layer.
static QList< double > prettyBreaks(double minimum, double maximum, int classes)
Computes a sequence of about 'classes' equally spaced round values which cover the range of values fr...
QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext()) const override
Returns the set of any fields referenced by the active properties from the collection.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
Contains information about the context of a rendering operation.
X-coordinate data defined diagram position.
QgsDataDefinedSizeLegend * dataDefinedSizeLegend() const
Returns configuration of appearance of legend.
virtual QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext()) const
Returns the set of any fields required for diagram rendering.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QList< QgsLayerTreeModelLegendNode *> legendItems(QgsLayerTreeLayer *nodeLayer) const override
Returns list of legend nodes for the diagram.
virtual QSizeF diagramSize(const QgsFeature &features, const QgsRenderContext &c) const =0
Returns size of the diagram (in painter units) or an invalid size in case of error.
Diagram priority (between 0 and 10)
void setSymbol(QgsMarkerSymbol *symbol SIP_TRANSFER)
Sets marker symbol that will be used to draw markers in legend.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the diagram property definitions.
QList< QString > diagramAttributes() const override
Returns attribute indices needed for diagram rendering.
QgsDiagramRenderer & operator=(const QgsDiagramRenderer &other)
virtual QList< QgsDiagramSettings > diagramSettings() const =0
Returns list with all diagram settings in the renderer.
QString classificationField
Name of the field for classification.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
Whether the diagram should always be shown, even if it overlaps other diagrams/labels.
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...
bool hasActiveProperties() const override
Returns true if the collection has any active properties, or false if all properties within the colle...
void writeXml(QDomElement &rendererElem, QDomDocument &doc) const
Writes diagram settings to XML.
static QgsMarkerSymbol * createSimple(const QgsStringMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
static QDomElement toXmlElement(const QFont &font, QDomDocument &document, const QString &elementName)
Returns a DOM element containing the properties of the font.
LinePlacementFlag
Line placement flags for controlling line based placements.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads diagram state from a DOM element.
QList< QgsLayerTreeModelLegendNode *> legendItems(QgsLayerTreeLayer *nodeLayer) const override
Returns list of legend nodes for the diagram.
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
Object that keeps configuration of appearance of marker symbol's data-defined size in legend...
virtual bool writeXml(QDomElement &collectionElem, const QgsPropertiesDefinition &definitions) const
Writes the current state of the property collection into an XML element.
void setDataDefinedSizeLegend(QgsDataDefinedSizeLegend *settings)
Configures appearance of legend.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
static QgsDataDefinedSizeLegend * readXml(const QDomElement &elem, const QgsReadWriteContext &context) SIP_FACTORY
Creates instance from given element and returns it (caller takes ownership). Returns nullptr on error...
QList< QgsDiagramSettings > diagramSettings() const override
Returns list with all diagram settings in the renderer.
QgsDiagramLayerSettings & operator=(const QgsDiagramLayerSettings &rh)
void _readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads internal QgsDiagramRenderer state from a DOM element.
Stores the settings for rendering a single diagram.
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
virtual QgsDiagramRenderer * clone() const =0
Returns new instance that is equivalent to this one.
void setClasses(const QList< QgsDataDefinedSizeLegend::SizeClass > &classes)
Sets list of classes: each class is a pair of symbol size (in units used by the symbol) and label...
Layer tree node points to a map layer.
QSizeF diagramSize(const QgsFeature &, const QgsRenderContext &c) const override
Returns size of the diagram (in painter units) or an invalid size in case of error.