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;
487 if ( !size.isValid() )
493 size.rwidth() *= pixelToMap;
494 size.rheight() *= pixelToMap;
501 QPaintDevice *device = painter->device();
504 return device->logicalDpiX();
514 QString diagramType = elem.attribute( QStringLiteral(
"diagramType" ) );
515 if ( diagramType == QLatin1String(
"Pie" ) )
519 else if ( diagramType == QLatin1String(
"Text" ) )
523 else if ( diagramType == QLatin1String(
"Histogram" ) )
527 mShowAttributeLegend = ( elem.attribute( QStringLiteral(
"attributeLegend" ), QStringLiteral(
"1" ) ) != QLatin1String(
"0" ) );
537 rendererElem.setAttribute( QStringLiteral(
"diagramType" ),
mDiagram->diagramName() );
561 QList<QgsDiagramSettings> settingsList;
562 settingsList.push_back( mSettings );
568 QDomElement categoryElem = elem.firstChildElement( QStringLiteral(
"DiagramCategory" ) );
569 if ( categoryElem.isNull() )
574 mSettings.readXml( categoryElem );
580 QDomElement rendererElem = doc.createElement( QStringLiteral(
"SingleCategoryDiagramRenderer" ) );
581 mSettings.writeXml( rendererElem, doc );
583 layerElem.appendChild( rendererElem );
589 mInterpolationSettings.classificationAttributeIsExpression =
false;
594 , mSettings( other.mSettings )
595 , mInterpolationSettings( other.mInterpolationSettings )
596 , mDataDefinedSizeLegend( other.mDataDefinedSizeLegend ? new
QgsDataDefinedSizeLegend( *other.mDataDefinedSizeLegend ) : nullptr )
602 delete mDataDefinedSizeLegend;
612 QList<QgsDiagramSettings> settingsList;
613 settingsList.push_back( mSettings );
649 return mDiagram->diagramSize( feature, c, mSettings, mInterpolationSettings );
654 mInterpolationSettings.
lowerValue = elem.attribute( QStringLiteral(
"lowerValue" ) ).toDouble();
655 mInterpolationSettings.
upperValue = elem.attribute( QStringLiteral(
"upperValue" ) ).toDouble();
656 mInterpolationSettings.
lowerSize.setWidth( elem.attribute( QStringLiteral(
"lowerWidth" ) ).toDouble() );
657 mInterpolationSettings.
lowerSize.setHeight( elem.attribute( QStringLiteral(
"lowerHeight" ) ).toDouble() );
658 mInterpolationSettings.
upperSize.setWidth( elem.attribute( QStringLiteral(
"upperWidth" ) ).toDouble() );
659 mInterpolationSettings.
upperSize.setHeight( elem.attribute( QStringLiteral(
"upperHeight" ) ).toDouble() );
667 mInterpolationSettings.
classificationField = elem.attribute( QStringLiteral(
"classificationField" ) );
669 QDomElement settingsElem = elem.firstChildElement( QStringLiteral(
"DiagramCategory" ) );
670 if ( !settingsElem.isNull() )
672 mSettings.
readXml( settingsElem );
675 delete mDataDefinedSizeLegend;
677 QDomElement ddsLegendSizeElem = elem.firstChildElement( QStringLiteral(
"data-defined-size-legend" ) );
678 if ( !ddsLegendSizeElem.isNull() )
685 if ( elem.attribute( QStringLiteral(
"sizeLegend" ), QStringLiteral(
"0" ) ) != QLatin1String(
"0" ) )
688 QDomElement sizeLegendSymbolElem = elem.firstChildElement( QStringLiteral(
"symbol" ) );
689 if ( !sizeLegendSymbolElem.isNull() && sizeLegendSymbolElem.attribute( QStringLiteral(
"name" ) ) == QLatin1String(
"sizeSymbol" ) )
691 mDataDefinedSizeLegend->
setSymbol( QgsSymbolLayerUtils::loadSymbol<QgsMarkerSymbol>( sizeLegendSymbolElem, context ) );
696 mDataDefinedSizeLegend =
nullptr;
705 QDomElement rendererElem = doc.createElement( QStringLiteral(
"LinearlyInterpolatedDiagramRenderer" ) );
706 rendererElem.setAttribute( QStringLiteral(
"lowerValue" ), QString::number( mInterpolationSettings.
lowerValue ) );
707 rendererElem.setAttribute( QStringLiteral(
"upperValue" ), QString::number( mInterpolationSettings.
upperValue ) );
708 rendererElem.setAttribute( QStringLiteral(
"lowerWidth" ), QString::number( mInterpolationSettings.
lowerSize.width() ) );
709 rendererElem.setAttribute( QStringLiteral(
"lowerHeight" ), QString::number( mInterpolationSettings.
lowerSize.height() ) );
710 rendererElem.setAttribute( QStringLiteral(
"upperWidth" ), QString::number( mInterpolationSettings.
upperSize.width() ) );
711 rendererElem.setAttribute( QStringLiteral(
"upperHeight" ), QString::number( mInterpolationSettings.
upperSize.height() ) );
718 rendererElem.setAttribute( QStringLiteral(
"classificationField" ), mInterpolationSettings.
classificationField );
720 mSettings.
writeXml( rendererElem, doc );
722 if ( mDataDefinedSizeLegend )
724 QDomElement ddsLegendElem = doc.createElement( QStringLiteral(
"data-defined-size-legend" ) );
725 mDataDefinedSizeLegend->
writeXml( ddsLegendElem, context );
726 rendererElem.appendChild( ddsLegendElem );
730 layerElem.appendChild( rendererElem );
735 QList< QgsLayerTreeModelLegendNode * > list;
736 list.reserve( categoryLabels.size() );
737 for (
int i = 0; i < categoryLabels.size(); ++i )
739 QPixmap pix( 16, 16 );
740 pix.fill( categoryColors[i] );
741 list <<
new QgsSimpleLegendNode( nodeLayer, categoryLabels[i], QIcon( pix ),
nullptr, QStringLiteral(
"diagram_%1" ).arg( QString::number( i ) ) );
748 return QList< QgsLayerTreeModelLegendNode * >();
753 QList< QgsLayerTreeModelLegendNode * > nodes;
762 QList< QgsLayerTreeModelLegendNode * > nodes;
766 if ( mDataDefinedSizeLegend &&
mDiagram )
776 QList<QgsDataDefinedSizeLegend::SizeClass> sizeClasses;
777 if ( ddSizeLegend.
classes().isEmpty() )
782 double size =
mDiagram->legendSize( v, mSettings, mInterpolationSettings );
791 double size =
mDiagram->legendSize( sc.
size, mSettings, mInterpolationSettings );
811 delete mDataDefinedSizeLegend;
812 mDataDefinedSizeLegend = settings;
817 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.
y-coordinate data defined diagram position
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.
QString label
Label to be shown with the particular symbol size.
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...
Whether the diagram should always be shown, even if it overlaps other diagrams/labels.
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.
Z-index for diagram ordering.
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)
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.
Diagram priority (between 0 and 10)
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.
double size
Marker size in units used by the symbol (usually millimeters). May be further scaled before rendering...
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.
x-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 diagram features act as obstacles for other diagrams/labels.
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.
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
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.
Distance to diagram from feature.
void setSymbol(QgsMarkerSymbol *symbol SIP_TRANSFER)
Sets marker symbol that will be used to draw markers in legend.
QgsDataDefinedSizeLegend * dataDefinedSizeLegendSettings() const
Returns extra information for data-defined size legend rendering.
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 to show the diagram.
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 null 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
Gets 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.