Class: QgsDataDefinedSizeLegend¶
-
class
qgis.core.
QgsDataDefinedSizeLegend
¶ Bases:
sip.wrapper
Constructor for QgsDataDefinedSizeLegend.
QgsDataDefinedSizeLegend(other: QgsDataDefinedSizeLegend) Copy constructor
Object that keeps configuration of appearance of marker symbol’s data-defined size in legend. For example: the list of classes (size values), whether the classes should appear in separate legend nodes or whether to collapse them into one legend node.
New in version 3.0: Enums
Methods
Returns list of classes: each class is a pair of symbol size (in units used by the symbol) and label
Returns output image that would be shown in the legend.
Draw the legend if using LegendOneNodeForAll and optionally output size of the legend and x offset of labels (in painter units).
Returns font used for rendering of labels - only valid for collapsed legend
Generates legend symbol items according to the configuration
Returns how the legend should be rendered
Creates instance from given element and returns it (caller takes ownership).
Sets list of classes: each class is a pair of symbol size (in units used by the symbol) and label
Sets font used for rendering of labels - only valid for collapsed legend
Sets how the legend should be rendered
Sets transformer for scaling of symbol sizes.
Sets marker symbol that will be used to draw markers in legend
Sets horizontal text alignment for rendering of labels - only valid for collapsed legend
Sets text color for rendering of labels - only valid for collapsed legend
Sets title label for data-defined size legend
Sets vertical alignment of symbols - only valid for collapsed legend
Returns transformer for scaling of symbol sizes.
Returns marker symbol that will be used to draw markers in legend
Returns horizontal text alignment for rendering of labels - only valid for collapsed legend
Returns text color for rendering of labels - only valid for collapsed legend
Returns title label for data-defined size legend
Updates the list of classes, source symbol and title label from given symbol and property
Returns vertical alignment of symbols - only valid for collapsed legend
Writes configuration to the given XML element.
Signals
Attributes
-
AlignBottom
= 1¶
-
AlignCenter
= 0¶
-
LegendCollapsed
= 1¶
-
LegendSeparated
= 0¶
-
class
LegendType
¶ Bases:
int
-
class
SizeClass
(size: float, label: str)¶ Bases:
sip.wrapper
QgsDataDefinedSizeLegend.SizeClass(QgsDataDefinedSizeLegend.SizeClass)
-
label
¶
-
size
¶
-
-
class
VerticalAlignment
¶ Bases:
int
-
classes
(self) → List[QgsDataDefinedSizeLegend.SizeClass]¶ Returns list of classes: each class is a pair of symbol size (in units used by the symbol) and label
-
collapsedLegendImage
(self, context: QgsRenderContext, backgroundColor: Union[QColor, Qt.GlobalColor, QGradient] = Qt.transparent, paddingMM: float = 1) → QImage¶ Returns output image that would be shown in the legend. Returns invalid image if legend is not configured as collapsed.
-
drawCollapsedLegend
(self, context: QgsRenderContext) → Tuple[QSize, int]¶ Draw the legend if using LegendOneNodeForAll and optionally output size of the legend and x offset of labels (in painter units). If the painter in context is null, it only does size calculation without actual rendering. Does nothing if legend is not configured as collapsed.
-
font
(self) → QFont¶ Returns font used for rendering of labels - only valid for collapsed legend
-
legendSymbolList
(self) → object¶ Generates legend symbol items according to the configuration
-
legendType
(self) → QgsDataDefinedSizeLegend.LegendType¶ Returns how the legend should be rendered
-
readXml
(elem: QDomElement, context: QgsReadWriteContext) → QgsDataDefinedSizeLegend¶ Creates instance from given element and returns it (caller takes ownership). Returns null on error.
-
setClasses
(self, classes: object)¶ Sets list of classes: each class is a pair of symbol size (in units used by the symbol) and label
-
setFont
(self, font: QFont)¶ Sets font used for rendering of labels - only valid for collapsed legend
-
setLegendType
(self, type: QgsDataDefinedSizeLegend.LegendType)¶ Sets how the legend should be rendered
-
setSizeScaleTransformer
(self, transformer: QgsSizeScaleTransformer)¶ Sets transformer for scaling of symbol sizes. Takes ownership of the object. Accepts null pointer to set no transformer.
-
setSymbol
(self, symbol: QgsMarkerSymbol)¶ Sets marker symbol that will be used to draw markers in legend
-
setTextAlignment
(self, flag: Qt.AlignmentFlag)¶ Sets horizontal text alignment for rendering of labels - only valid for collapsed legend
-
setTextColor
(self, color: Union[QColor, Qt.GlobalColor, QGradient])¶ Sets text color for rendering of labels - only valid for collapsed legend
-
setTitle
(self, title: str)¶ Sets title label for data-defined size legend
-
setVerticalAlignment
(self, vAlign: QgsDataDefinedSizeLegend.VerticalAlignment)¶ Sets vertical alignment of symbols - only valid for collapsed legend
-
sizeScaleTransformer
(self) → QgsSizeScaleTransformer¶ Returns transformer for scaling of symbol sizes. Returns null if no transformer is defined.
-
symbol
(self) → QgsMarkerSymbol¶ Returns marker symbol that will be used to draw markers in legend
-
textAlignment
(self) → Qt.AlignmentFlag¶ Returns horizontal text alignment for rendering of labels - only valid for collapsed legend
-
textColor
(self) → QColor¶ Returns text color for rendering of labels - only valid for collapsed legend
-
title
(self) → str¶ Returns title label for data-defined size legend
-
updateFromSymbolAndProperty
(self, symbol: QgsMarkerSymbol, ddSize: QgsProperty)¶ Updates the list of classes, source symbol and title label from given symbol and property
-
verticalAlignment
(self) → QgsDataDefinedSizeLegend.VerticalAlignment¶ Returns vertical alignment of symbols - only valid for collapsed legend
-
writeXml
(self, elem: QDomElement, context: QgsReadWriteContext)¶ Writes configuration to the given XML element.
-