33 #include <QDomElement>
38 void QgsDiagramLayerSettings::initPropertyDefinitions()
40 if ( !sPropertyDefinitions.isEmpty() )
43 const QString origin = QStringLiteral(
"diagram" );
64 initPropertyDefinitions();
65 return sPropertyDefinitions;
70 initPropertyDefinitions();
75 , mPlacement( rh.mPlacement )
76 , mPlacementFlags( rh.mPlacementFlags )
77 , mPriority( rh.mPriority )
78 , mZIndex( rh.mZIndex )
79 , mObstacle( rh.mObstacle )
80 , mDistance( rh.mDistance )
81 , mRenderer( rh.mRenderer ? rh.mRenderer->clone() : nullptr )
82 , mShowAll( rh.mShowAll )
83 , mDataDefinedProperties( rh.mDataDefinedProperties )
85 initPropertyDefinitions();
90 mPlacement = rh.mPlacement;
91 mPlacementFlags = rh.mPlacementFlags;
92 mPriority = rh.mPriority;
94 mObstacle = rh.mObstacle;
95 mDistance = rh.mDistance;
96 mRenderer = rh.mRenderer ? rh.mRenderer->
clone() :
nullptr;
98 mShowAll = rh.mShowAll;
99 mDataDefinedProperties = rh.mDataDefinedProperties;
110 if ( diagramRenderer == mRenderer )
114 mRenderer = diagramRenderer;
124 const QDomNodeList propertyElems = elem.elementsByTagName( QStringLiteral(
"properties" ) );
125 if ( !propertyElems.isEmpty() )
127 ( void )mDataDefinedProperties.
readXml( propertyElems.at( 0 ).toElement(), sPropertyDefinitions );
131 mDataDefinedProperties.
clear();
134 mPlacement =
static_cast< Placement >( elem.attribute( QStringLiteral(
"placement" ) ).toInt() );
135 mPlacementFlags =
static_cast< LinePlacementFlag >( elem.attribute( QStringLiteral(
"linePlacementFlags" ) ).toInt() );
136 mPriority = elem.attribute( QStringLiteral(
"priority" ) ).toInt();
137 mZIndex = elem.attribute( QStringLiteral(
"zIndex" ) ).toDouble();
138 mObstacle = elem.attribute( QStringLiteral(
"obstacle" ) ).toInt();
139 mDistance = elem.attribute( QStringLiteral(
"dist" ) ).toDouble();
140 mShowAll = ( elem.attribute( QStringLiteral(
"showAll" ), QStringLiteral(
"0" ) ) != QLatin1String(
"0" ) );
145 QDomElement diagramLayerElem = doc.createElement( QStringLiteral(
"DiagramLayerSettings" ) );
146 QDomElement propertiesElem = doc.createElement( QStringLiteral(
"properties" ) );
147 ( void )mDataDefinedProperties.
writeXml( propertiesElem, sPropertyDefinitions );
148 diagramLayerElem.appendChild( propertiesElem );
149 diagramLayerElem.setAttribute( QStringLiteral(
"placement" ), mPlacement );
150 diagramLayerElem.setAttribute( QStringLiteral(
"linePlacementFlags" ), mPlacementFlags );
151 diagramLayerElem.setAttribute( QStringLiteral(
"priority" ), mPriority );
152 diagramLayerElem.setAttribute( QStringLiteral(
"zIndex" ), mZIndex );
153 diagramLayerElem.setAttribute( QStringLiteral(
"obstacle" ), mObstacle );
154 diagramLayerElem.setAttribute( QStringLiteral(
"dist" ), QString::number( mDistance ) );
155 diagramLayerElem.setAttribute( QStringLiteral(
"showAll" ), mShowAll );
156 layerElem.appendChild( diagramLayerElem );
161 return mDataDefinedProperties.
prepare( context );
166 QSet< QString > referenced;
178 enabled = ( elem.attribute( QStringLiteral(
"enabled" ), QStringLiteral(
"1" ) ) != QLatin1String(
"0" ) );
181 font.fromString( elem.attribute( QStringLiteral(
"font" ) ) );
183 backgroundColor.setNamedColor( elem.attribute( QStringLiteral(
"backgroundColor" ) ) );
184 backgroundColor.setAlpha( elem.attribute( QStringLiteral(
"backgroundAlpha" ) ).toInt() );
185 size.setWidth( elem.attribute( QStringLiteral(
"width" ) ).toDouble() );
186 size.setHeight( elem.attribute( QStringLiteral(
"height" ) ).toDouble() );
187 if ( elem.hasAttribute( QStringLiteral(
"transparency" ) ) )
189 opacity = 1 - elem.attribute( QStringLiteral(
"transparency" ), QStringLiteral(
"0" ) ).toInt() / 255.0;
193 opacity = elem.attribute( QStringLiteral(
"opacity" ), QStringLiteral(
"1.00" ) ).toDouble();
196 penColor.setNamedColor( elem.attribute( QStringLiteral(
"penColor" ) ) );
197 const int penAlpha = elem.attribute( QStringLiteral(
"penAlpha" ), QStringLiteral(
"255" ) ).toInt();
199 penWidth = elem.attribute( QStringLiteral(
"penWidth" ) ).toDouble();
201 mDirection =
static_cast< Direction >( elem.attribute( QStringLiteral(
"direction" ), QStringLiteral(
"1" ) ).toInt() );
203 maximumScale = elem.attribute( QStringLiteral(
"minScaleDenominator" ), QStringLiteral(
"-1" ) ).toDouble();
204 minimumScale = elem.attribute( QStringLiteral(
"maxScaleDenominator" ), QStringLiteral(
"-1" ) ).toDouble();
205 if ( elem.hasAttribute( QStringLiteral(
"scaleBasedVisibility" ) ) )
207 scaleBasedVisibility = ( elem.attribute( QStringLiteral(
"scaleBasedVisibility" ), QStringLiteral(
"1" ) ) != QLatin1String(
"0" ) );
215 if ( elem.attribute( QStringLiteral(
"sizeType" ) ) == QLatin1String(
"MapUnits" ) )
230 mSpacing = elem.attribute( QStringLiteral(
"spacing" ) ).toDouble();
235 if ( elem.attribute( QStringLiteral(
"labelPlacementMethod" ) ) == QLatin1String(
"Height" ) )
245 if ( elem.attribute( QStringLiteral(
"diagramOrientation" ) ) == QLatin1String(
"Left" ) )
249 else if ( elem.attribute( QStringLiteral(
"diagramOrientation" ) ) == QLatin1String(
"Right" ) )
253 else if ( elem.attribute( QStringLiteral(
"diagramOrientation" ) ) == QLatin1String(
"Down" ) )
263 if ( elem.attribute( QStringLiteral(
"scaleDependency" ) ) == QLatin1String(
"Diameter" ) )
272 barWidth = elem.attribute( QStringLiteral(
"barWidth" ) ).toDouble();
274 if ( elem.hasAttribute( QStringLiteral(
"angleOffset" ) ) )
275 rotationOffset = std::fmod( 360.0 - elem.attribute( QStringLiteral(
"angleOffset" ) ).toInt() / 16.0, 360.0 );
277 rotationOffset = elem.attribute( QStringLiteral(
"rotationOffset" ) ).toDouble();
279 minimumSize = elem.attribute( QStringLiteral(
"minimumSize" ) ).toDouble();
281 const QDomNodeList axisSymbolNodes = elem.elementsByTagName( QStringLiteral(
"axisSymbol" ) );
282 if ( axisSymbolNodes.count() > 0 )
284 const QDomElement axisSymbolElem = axisSymbolNodes.at( 0 ).toElement().firstChildElement();
285 mAxisLineSymbol.reset( QgsSymbolLayerUtils::loadSymbol<QgsLineSymbol>( axisSymbolElem, context ) );
289 mAxisLineSymbol = std::make_unique< QgsLineSymbol >();
292 mShowAxis = elem.attribute( QStringLiteral(
"showAxis" ), QStringLiteral(
"0" ) ).toInt();
296 const QDomNodeList attributes = elem.elementsByTagName( QStringLiteral(
"attribute" ) );
299 if ( attributes.length() > 0 )
301 for (
int i = 0; i < attributes.size(); i++ )
303 const QDomElement attrElem = attributes.at( i ).toElement();
304 QColor newColor( attrElem.attribute( QStringLiteral(
"color" ) ) );
308 categoryLabels.append( attrElem.attribute( QStringLiteral(
"label" ) ) );
319 const QStringList colorList = elem.attribute( QStringLiteral(
"colors" ) ).split(
'/' );
320 QStringList::const_iterator colorIt = colorList.constBegin();
321 for ( ; colorIt != colorList.constEnd(); ++colorIt )
323 QColor newColor( *colorIt );
330 const QStringList catList = elem.attribute( QStringLiteral(
"categories" ) ).split(
'/' );
331 QStringList::const_iterator catIt = catList.constBegin();
332 for ( ; catIt != catList.constEnd(); ++catIt )
339 const QDomElement effectElem = elem.firstChildElement( QStringLiteral(
"effect" ) );
340 if ( !effectElem.isNull() )
348 QDomElement categoryElem = doc.createElement( QStringLiteral(
"DiagramCategory" ) );
349 categoryElem.setAttribute( QStringLiteral(
"enabled" ),
enabled );
351 categoryElem.setAttribute( QStringLiteral(
"backgroundColor" ),
backgroundColor.name() );
352 categoryElem.setAttribute( QStringLiteral(
"backgroundAlpha" ),
backgroundColor.alpha() );
353 categoryElem.setAttribute( QStringLiteral(
"width" ), QString::number(
size.width() ) );
354 categoryElem.setAttribute( QStringLiteral(
"height" ), QString::number(
size.height() ) );
355 categoryElem.setAttribute( QStringLiteral(
"penColor" ),
penColor.name() );
356 categoryElem.setAttribute( QStringLiteral(
"penAlpha" ),
penColor.alpha() );
357 categoryElem.setAttribute( QStringLiteral(
"penWidth" ), QString::number(
penWidth ) );
359 categoryElem.setAttribute( QStringLiteral(
"minScaleDenominator" ), QString::number(
maximumScale ) );
360 categoryElem.setAttribute( QStringLiteral(
"maxScaleDenominator" ), QString::number(
minimumScale ) );
361 categoryElem.setAttribute( QStringLiteral(
"opacity" ), QString::number(
opacity ) );
362 categoryElem.setAttribute( QStringLiteral(
"spacing" ), QString::number( mSpacing ) );
365 categoryElem.setAttribute( QStringLiteral(
"direction" ), QString::number( mDirection ) );
378 categoryElem.setAttribute( QStringLiteral(
"labelPlacementMethod" ), QStringLiteral(
"Height" ) );
382 categoryElem.setAttribute( QStringLiteral(
"labelPlacementMethod" ), QStringLiteral(
"XHeight" ) );
387 categoryElem.setAttribute( QStringLiteral(
"scaleDependency" ), QStringLiteral(
"Area" ) );
391 categoryElem.setAttribute( QStringLiteral(
"scaleDependency" ), QStringLiteral(
"Diameter" ) );
398 categoryElem.setAttribute( QStringLiteral(
"diagramOrientation" ), QStringLiteral(
"Left" ) );
402 categoryElem.setAttribute( QStringLiteral(
"diagramOrientation" ), QStringLiteral(
"Right" ) );
406 categoryElem.setAttribute( QStringLiteral(
"diagramOrientation" ), QStringLiteral(
"Down" ) );
410 categoryElem.setAttribute( QStringLiteral(
"diagramOrientation" ), QStringLiteral(
"Up" ) );
414 categoryElem.setAttribute( QStringLiteral(
"barWidth" ), QString::number(
barWidth ) );
415 categoryElem.setAttribute( QStringLiteral(
"minimumSize" ), QString::number(
minimumSize ) );
416 categoryElem.setAttribute( QStringLiteral(
"rotationOffset" ), QString::number(
rotationOffset ) );
419 for (
int i = 0; i < nCats; ++i )
421 QDomElement attributeElem = doc.createElement( QStringLiteral(
"attribute" ) );
424 attributeElem.setAttribute( QStringLiteral(
"color" ),
categoryColors.at( i ).name() );
425 attributeElem.setAttribute( QStringLiteral(
"label" ),
categoryLabels.at( i ) );
426 categoryElem.appendChild( attributeElem );
429 categoryElem.setAttribute( QStringLiteral(
"showAxis" ), mShowAxis ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
430 QDomElement axisSymbolElem = doc.createElement( QStringLiteral(
"axisSymbol" ) );
432 axisSymbolElem.appendChild( symbolElem );
433 categoryElem.appendChild( axisSymbolElem );
436 mPaintEffect->saveProperties( doc, categoryElem );
438 rendererElem.appendChild( categoryElem );
450 : mDiagram( other.mDiagram ? other.mDiagram->clone() : nullptr )
451 , mShowAttributeLegend( other.mShowAttributeLegend )
481 c.expressionContext().setOriginalValueVariable( s.
penWidth );
488 std::unique_ptr< QgsEffectPainter > effectPainter;
489 if ( effect && effect->
enabled() )
491 effectPainter = std::make_unique< QgsEffectPainter >(
c, effect );
494 mDiagram->renderDiagram( feature,
c, s, pos );
506 if ( size.isValid() )
509 size.rheight() *= width / size.width();
510 size.setWidth( width );
517 QSet< QString > referenced;
523 for (
const QString &att : constDiagramAttributes )
527 for (
const QString &
field : constReferencedColumns )
537 if ( !size.isValid() )
543 size.rwidth() *= pixelToMap;
544 size.rheight() *= pixelToMap;
551 QPaintDevice *device = painter->device();
554 return device->logicalDpiX();
564 const QString diagramType = elem.attribute( QStringLiteral(
"diagramType" ) );
565 if ( diagramType == QLatin1String(
"Pie" ) )
569 else if ( diagramType == QLatin1String(
"Text" ) )
573 else if ( diagramType == QLatin1String(
"Histogram" ) )
577 else if ( diagramType == QLatin1String(
"Stacked" ) )
586 mShowAttributeLegend = ( elem.attribute( QStringLiteral(
"attributeLegend" ), QStringLiteral(
"1" ) ) != QLatin1String(
"0" ) );
596 rendererElem.setAttribute( QStringLiteral(
"diagramType" ),
mDiagram->diagramName() );
620 QList<QgsDiagramSettings> settingsList;
621 settingsList.push_back( mSettings );
627 const QDomElement categoryElem = elem.firstChildElement( QStringLiteral(
"DiagramCategory" ) );
628 if ( categoryElem.isNull() )
633 mSettings.
readXml( categoryElem, context );
639 QDomElement rendererElem = doc.createElement( QStringLiteral(
"SingleCategoryDiagramRenderer" ) );
640 mSettings.
writeXml( rendererElem, doc, context );
642 layerElem.appendChild( rendererElem );
653 , mSettings( other.mSettings )
654 , mInterpolationSettings( other.mInterpolationSettings )
655 , mDataDefinedSizeLegend( other.mDataDefinedSizeLegend ? new
QgsDataDefinedSizeLegend( *other.mDataDefinedSizeLegend ) : nullptr )
661 delete mDataDefinedSizeLegend;
666 if ( &other ==
this )
670 mSettings = other.mSettings;
671 mInterpolationSettings = other.mInterpolationSettings;
672 delete mDataDefinedSizeLegend;
684 QList<QgsDiagramSettings> settingsList;
685 settingsList.push_back( mSettings );
708 for (
const QString &
field : constReferencedColumns )
722 return mDiagram->diagramSize( feature,
c, mSettings, mInterpolationSettings );
727 mInterpolationSettings.
lowerValue = elem.attribute( QStringLiteral(
"lowerValue" ) ).toDouble();
728 mInterpolationSettings.
upperValue = elem.attribute( QStringLiteral(
"upperValue" ) ).toDouble();
729 mInterpolationSettings.
lowerSize.setWidth( elem.attribute( QStringLiteral(
"lowerWidth" ) ).toDouble() );
730 mInterpolationSettings.
lowerSize.setHeight( elem.attribute( QStringLiteral(
"lowerHeight" ) ).toDouble() );
731 mInterpolationSettings.
upperSize.setWidth( elem.attribute( QStringLiteral(
"upperWidth" ) ).toDouble() );
732 mInterpolationSettings.
upperSize.setHeight( elem.attribute( QStringLiteral(
"upperHeight" ) ).toDouble() );
740 mInterpolationSettings.
classificationField = elem.attribute( QStringLiteral(
"classificationField" ) );
742 const QDomElement settingsElem = elem.firstChildElement( QStringLiteral(
"DiagramCategory" ) );
743 if ( !settingsElem.isNull() )
745 mSettings.
readXml( settingsElem );
748 delete mDataDefinedSizeLegend;
750 const QDomElement ddsLegendSizeElem = elem.firstChildElement( QStringLiteral(
"data-defined-size-legend" ) );
751 if ( !ddsLegendSizeElem.isNull() )
758 if ( elem.attribute( QStringLiteral(
"sizeLegend" ), QStringLiteral(
"0" ) ) != QLatin1String(
"0" ) )
761 const QDomElement sizeLegendSymbolElem = elem.firstChildElement( QStringLiteral(
"symbol" ) );
762 if ( !sizeLegendSymbolElem.isNull() && sizeLegendSymbolElem.attribute( QStringLiteral(
"name" ) ) == QLatin1String(
"sizeSymbol" ) )
764 mDataDefinedSizeLegend->
setSymbol( QgsSymbolLayerUtils::loadSymbol<QgsMarkerSymbol>( sizeLegendSymbolElem, context ) );
769 mDataDefinedSizeLegend =
nullptr;
778 QDomElement rendererElem = doc.createElement( QStringLiteral(
"LinearlyInterpolatedDiagramRenderer" ) );
779 rendererElem.setAttribute( QStringLiteral(
"lowerValue" ), QString::number( mInterpolationSettings.
lowerValue ) );
780 rendererElem.setAttribute( QStringLiteral(
"upperValue" ), QString::number( mInterpolationSettings.
upperValue ) );
781 rendererElem.setAttribute( QStringLiteral(
"lowerWidth" ), QString::number( mInterpolationSettings.
lowerSize.width() ) );
782 rendererElem.setAttribute( QStringLiteral(
"lowerHeight" ), QString::number( mInterpolationSettings.
lowerSize.height() ) );
783 rendererElem.setAttribute( QStringLiteral(
"upperWidth" ), QString::number( mInterpolationSettings.
upperSize.width() ) );
784 rendererElem.setAttribute( QStringLiteral(
"upperHeight" ), QString::number( mInterpolationSettings.
upperSize.height() ) );
791 rendererElem.setAttribute( QStringLiteral(
"classificationField" ), mInterpolationSettings.
classificationField );
793 mSettings.
writeXml( rendererElem, doc );
795 if ( mDataDefinedSizeLegend )
797 QDomElement ddsLegendElem = doc.createElement( QStringLiteral(
"data-defined-size-legend" ) );
798 mDataDefinedSizeLegend->
writeXml( ddsLegendElem, context );
799 rendererElem.appendChild( ddsLegendElem );
803 layerElem.appendChild( rendererElem );
808 QList< QgsLayerTreeModelLegendNode * > list;
812 QPixmap pix( 16, 16 );
821 return mAxisLineSymbol.get();
842 return mPaintEffect.get();
847 if ( effect != mPaintEffect.get() )
848 mPaintEffect.reset( effect );
859 : enabled( other.enabled )
861 , categoryColors( other.categoryColors )
862 , categoryAttributes( other.categoryAttributes )
863 , categoryLabels( other.categoryLabels )
865 , sizeType( other.sizeType )
866 , sizeScale( other.sizeScale )
867 , lineSizeUnit( other.lineSizeUnit )
868 , lineSizeScale( other.lineSizeScale )
869 , backgroundColor( other.backgroundColor )
870 , penColor( other.penColor )
871 , penWidth( other.penWidth )
872 , labelPlacementMethod( other.labelPlacementMethod )
873 , diagramOrientation( other.diagramOrientation )
874 , barWidth( other.barWidth )
875 , opacity( other.opacity )
876 , scaleByArea( other.scaleByArea )
877 , rotationOffset( other.rotationOffset )
878 , scaleBasedVisibility( other.scaleBasedVisibility )
879 , maximumScale( other.maximumScale )
880 , minimumScale( other.minimumScale )
881 , minimumSize( other.minimumSize )
882 , mSpacing( other.mSpacing )
883 , mSpacingUnit( other.mSpacingUnit )
884 , mSpacingMapUnitScale( other.mSpacingMapUnitScale )
885 , mDirection( other.mDirection )
886 , mShowAxis( other.mShowAxis )
887 , mAxisLineSymbol( other.mAxisLineSymbol ? other.mAxisLineSymbol->clone() : nullptr )
888 , mPaintEffect( other.mPaintEffect ? other.mPaintEffect->clone() : nullptr )
918 mSpacing = other.mSpacing;
919 mSpacingUnit = other.mSpacingUnit;
920 mSpacingMapUnitScale = other.mSpacingMapUnitScale;
921 mDirection = other.mDirection;
922 mAxisLineSymbol.reset( other.mAxisLineSymbol ? other.mAxisLineSymbol->clone() :
nullptr );
923 mShowAxis = other.mShowAxis;
924 mPaintEffect.reset( other.mPaintEffect ? other.mPaintEffect->clone() :
nullptr );
940 return QList< QgsLayerTreeModelLegendNode * >();
945 QList< QgsLayerTreeModelLegendNode * > nodes;
954 QList< QgsLayerTreeModelLegendNode * > nodes;
958 if ( mDataDefinedSizeLegend &&
mDiagram )
968 QList<QgsDataDefinedSizeLegend::SizeClass> sizeClasses;
969 if ( ddSizeLegend.
classes().isEmpty() )
973 for (
const double v : prettyBreaks )
975 const double size =
mDiagram->legendSize( v, mSettings, mInterpolationSettings );
982 const auto constClasses = ddSizeLegend.
classes();
985 const double size =
mDiagram->legendSize( sc.size, mSettings, mInterpolationSettings );
994 if (
auto *lDataDefinedSizeLegendSettings = si.dataDefinedSizeLegendSettings() )
1006 delete mDataDefinedSizeLegend;
1007 mDataDefinedSizeLegend = settings;
1012 return mDataDefinedSizeLegend;
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.
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.
virtual bool readXml(const QDomElement &collectionElem, const QgsPropertiesDefinition &definitions)
Reads property collection state from an XML element.
virtual bool writeXml(QDomElement &collectionElem, const QgsPropertiesDefinition &definitions) const
Writes the current state of the property collection into an XML element.
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application's paint effect registry, used for managing paint effects.
Produces legend node with a marker symbol.
Object that keeps configuration of appearance of marker symbol's data-defined size in legend.
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.
void setSymbol(QgsMarkerSymbol *symbol SIP_TRANSFER)
Sets marker symbol that will be used to draw markers in legend.
QgsMarkerSymbol * symbol() const
Returns marker symbol that will be used to draw markers in legend.
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.
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...
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const
Writes configuration to the given XML element.
QgsLegendSymbolList legendSymbolList() const
Generates legend symbol items according to the configuration.
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.
QgsDiagramLayerSettings & operator=(const QgsDiagramLayerSettings &rh)
@ StartAngle
Angle offset for pie diagram.
@ Distance
Distance to diagram from feature.
@ IsObstacle
Whether diagram features act as obstacles for other diagrams/labels.
@ PositionX
X-coordinate data defined diagram position.
@ Priority
Diagram priority (between 0 and 10)
@ AlwaysShow
Whether the diagram should always be shown, even if it overlaps other diagrams/labels.
@ Show
Whether to show the diagram.
@ StrokeColor
Stroke color.
@ StrokeWidth
Stroke width.
@ ZIndex
Z-index for diagram ordering.
@ BackgroundColor
Diagram background color.
@ PositionY
Y-coordinate data defined diagram position.
void setRenderer(QgsDiagramRenderer *diagramRenderer)
Sets the diagram renderer associated with the layer.
~QgsDiagramLayerSettings()
void readXml(const QDomElement &elem)
Reads the diagram settings from a DOM element.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the diagram property definitions.
QgsDiagramLayerSettings()
Constructor for QgsDiagramLayerSettings.
QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext()) const
Returns the set of any fields referenced by the layer's diagrams.
void writeXml(QDomElement &layerElem, QDomDocument &doc) const
Writes the diagram settings to a DOM element.
bool prepare(const QgsExpressionContext &context=QgsExpressionContext()) const
Prepares the diagrams for a specified expression context.
void setCoordinateTransform(const QgsCoordinateTransform &transform)
Sets the coordinate transform associated with the layer.
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
virtual QList< QgsLayerTreeModelLegendNode * > legendItems(QgsLayerTreeLayer *nodeLayer) const
Returns list of legend nodes for the diagram.
virtual QgsDiagramRenderer * clone() const =0
Returns new instance that is equivalent to this one.
virtual QList< QString > diagramAttributes() const =0
Returns attribute indices needed for diagram rendering.
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.
void _writeXml(QDomElement &rendererElem, QDomDocument &doc, const QgsReadWriteContext &context) const
Writes internal QgsDiagramRenderer diagram state to a DOM element.
virtual QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext()) const
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 _readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads internal QgsDiagramRenderer state from a DOM element.
QgsDiagramRenderer & operator=(const QgsDiagramRenderer &other)
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.
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 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
Constructor for QgsDiagramRenderer.
void setDiagram(QgsDiagram *d)
static int dpiPaintDevice(const QPainter *)
Returns the paint device dpi (or -1 in case of error.
Stores the settings for rendering a single diagram.
QgsUnitTypes::RenderUnit sizeType
Diagram size unit.
Direction direction() const
Returns the chart's angular direction.
void setDirection(Direction direction)
Sets the chart's angular direction.
bool showAxis() const
Returns true if the diagram axis should be shown.
LabelPlacementMethod labelPlacementMethod
void readXml(const QDomElement &elem, const QgsReadWriteContext &context=QgsReadWriteContext())
Reads diagram settings from XML.
double opacity
Opacity, from 0 (transparent) to 1.0 (opaque)
QgsDiagramSettings & operator=(const QgsDiagramSettings &other)
QgsLineSymbol * axisLineSymbol() const
Returns the line symbol to use for rendering axis in diagrams.
QList< QString > categoryAttributes
QList< QString > categoryLabels
QgsDiagramSettings()
Constructor for QgsDiagramSettings.
DiagramOrientation diagramOrientation
QList< QgsLayerTreeModelLegendNode * > legendItems(QgsLayerTreeLayer *nodeLayer) const
Returns list of legend nodes for the diagram.
QgsMapUnitScale lineSizeScale
Line unit scale.
void writeXml(QDomElement &rendererElem, QDomDocument &doc, const QgsReadWriteContext &context=QgsReadWriteContext()) const
Writes diagram settings to XML.
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.
bool scaleBasedVisibility
double maximumScale
The maximum map scale (i.e.
void setAxisLineSymbol(QgsLineSymbol *symbol)
Sets the line symbol to use for rendering axis in diagrams.
QgsUnitTypes::RenderUnit lineSizeUnit
Line unit index.
double minimumSize
Scale diagrams smaller than mMinimumSize to mMinimumSize.
Direction
Angular directions.
void setShowAxis(bool showAxis)
Sets whether the diagram axis should be shown.
void setPaintEffect(QgsPaintEffect *effect)
Sets the paint effect to use while rendering diagrams.
QgsPaintEffect * paintEffect() const
Returns the paint effect to use while rendering diagrams.
Base class for all diagram types.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Class for parsing and evaluation of expressions (formerly called "search strings").
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
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.
static QDomElement toXmlElement(const QFont &font, QDomDocument &document, const QString &elementName)
Returns a DOM element containing the properties of the font.
A histogram style diagram.
Layer tree node points to a map layer.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
A line symbol type, for rendering LineString and MultiLineString geometries.
QgsLinearlyInterpolatedDiagramRenderer()
void setDataDefinedSizeLegend(QgsDataDefinedSizeLegend *settings)
Configures appearance of legend.
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.
QList< QString > diagramAttributes() const override
Returns attribute indices needed for diagram rendering.
QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext()) const override
Returns the set of any fields required for diagram rendering.
QList< QgsDiagramSettings > diagramSettings() const override
Returns list with all diagram settings in the renderer.
void writeXml(QDomElement &layerElem, QDomDocument &doc, const QgsReadWriteContext &context) const override
Writes diagram state to a DOM element.
QgsLinearlyInterpolatedDiagramRenderer * clone() const override
Returns new instance that is equivalent to this one.
QList< QgsLayerTreeModelLegendNode * > legendItems(QgsLayerTreeLayer *nodeLayer) const override
Returns list of legend nodes for the diagram.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads diagram state from a DOM element.
QgsDataDefinedSizeLegend * dataDefinedSizeLegend() const
Returns configuration of appearance of legend.
~QgsLinearlyInterpolatedDiagramRenderer() override
QgsLinearlyInterpolatedDiagramRenderer & operator=(const QgsLinearlyInterpolatedDiagramRenderer &other)
double mapUnitsPerPixel() const
Returns the current map units per pixel.
A marker symbol type, for rendering Point and MultiPoint geometries.
static QgsMarkerSymbol * createSimple(const QVariantMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the size units for the whole symbol (including all symbol layers).
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the size map unit scale for the whole symbol (including all symbol layers).
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
Base class for visual effects which can be applied to QPicture drawings.
bool enabled() const
Returns whether the effect is enabled.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext(), bool ignoreContext=false) const override
Returns the set of any fields referenced by the active properties from the collection.
void clear() override
Removes all properties from the collection.
bool hasActiveProperties() const override
Returns true if the collection has any active properties, or false if all properties within the colle...
bool prepare(const QgsExpressionContext &context=QgsExpressionContext()) const override
Prepares the collection against a specified expression context.
Definition for a property.
@ Double
Double value (including negative values)
@ StrokeWidth
Line stroke width.
@ Rotation
Rotation (value between 0-360 degrees)
@ ColorWithAlpha
Color with alpha channel.
@ DoublePositive
Positive double value (including 0)
The class is used as a container of context for various read/write operations on other objects.
Contains information about the context of a rendering operation.
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
Implementation of legend node interface for displaying arbitrary label with icon.
Renders the diagrams for all features with the same settings.
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.
void writeXml(QDomElement &layerElem, QDomDocument &doc, const QgsReadWriteContext &context) const override
Writes diagram state to a DOM element.
QgsSingleCategoryDiagramRenderer * clone() const override
Returns new instance that is equivalent to this one.
QgsSingleCategoryDiagramRenderer()=default
Constructor for QgsSingleCategoryDiagramRenderer.
QList< QgsLayerTreeModelLegendNode * > legendItems(QgsLayerTreeLayer *nodeLayer) const override
Returns list of legend nodes for the diagram.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads diagram state from a DOM element.
QList< QgsDiagramSettings > diagramSettings() const override
Returns list with all diagram settings in the renderer.
A stacked bar chart diagram.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
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...
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
static QString encodeColor(const QColor &color)
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
Implementation of legend node interface for displaying preview of vector symbols and their labels and...
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
@ RenderMapUnits
Map units.
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
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
Definition of one class for the legend.