QGIS API Documentation 3.41.0-Master (3440c17df1d)
|
Object that keeps configuration of appearance of marker symbol's data-defined size in legend. More...
#include <qgsdatadefinedsizelegend.h>
Classes | |
struct | SizeClass |
Definition of one class for the legend. More... | |
Public Types | |
enum | LegendType { LegendSeparated , LegendCollapsed } |
Determines how to display data-defined size legend. More... | |
enum | VerticalAlignment { AlignCenter , AlignBottom } |
How to vertically align symbols when all classes go into one node. More... | |
Public Member Functions | |
QgsDataDefinedSizeLegend () | |
Constructor for QgsDataDefinedSizeLegend. | |
QgsDataDefinedSizeLegend (const QgsDataDefinedSizeLegend &other) | |
~QgsDataDefinedSizeLegend () | |
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. | |
QImage | collapsedLegendImage (QgsRenderContext &context, const QColor &backgroundColor=Qt::transparent, double paddingMM=1) const |
Returns output image that would be shown in the legend. Returns invalid image if legend is not configured as collapsed. | |
void | drawCollapsedLegend (QgsRenderContext &context, QSizeF *outputSize SIP_OUT=nullptr, double *labelXOffset SIP_OUT=nullptr) const |
Draw the legend if using LegendOneNodeForAll and optionally output size of the legend and x offset of labels (in painter units). | |
QFont | font () const |
Returns font used for rendering of labels - only valid for collapsed legend. | |
QgsLegendSymbolList | legendSymbolList () const |
Generates legend symbol items according to the configuration. | |
LegendType | legendType () const |
Returns how the legend should be rendered. | |
QgsLineSymbol * | lineSymbol () const |
Returns the line symbol that will be used to draw callout lines in legend. | |
QgsDataDefinedSizeLegend & | operator= (const QgsDataDefinedSizeLegend &other) |
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. | |
void | setFont (const QFont &font) |
Sets font used for rendering of labels - only valid for collapsed legend. | |
void | setLegendType (LegendType type) |
Sets how the legend should be rendered. | |
void | setLineSymbol (QgsLineSymbol *symbol SIP_TRANSFER) |
Sets the line symbol that will be used to draw callout lines in legend. | |
void | setSizeScaleTransformer (QgsSizeScaleTransformer *transformer SIP_TRANSFER) |
Sets transformer for scaling of symbol sizes. Takes ownership of the object. Accepts nullptr to set no transformer. | |
void | setSymbol (QgsMarkerSymbol *symbol SIP_TRANSFER) |
Sets marker symbol that will be used to draw markers in legend. | |
void | setTextAlignment (Qt::AlignmentFlag flag) |
Sets horizontal text alignment for rendering of labels - only valid for collapsed legend. | |
void | setTextColor (const QColor &color) |
Sets text color for rendering of labels - only valid for collapsed legend. | |
void | setTitle (const QString &title) |
Sets title label for data-defined size legend. | |
void | setVerticalAlignment (VerticalAlignment vAlign) |
Sets vertical alignment of symbols - only valid for collapsed legend. | |
QgsSizeScaleTransformer * | sizeScaleTransformer () const |
Returns transformer for scaling of symbol sizes. Returns nullptr if no transformer is defined. | |
QgsMarkerSymbol * | symbol () const |
Returns marker symbol that will be used to draw markers in legend. | |
Qt::AlignmentFlag | textAlignment () const |
Returns horizontal text alignment for rendering of labels - only valid for collapsed legend. | |
QColor | textColor () const |
Returns text color for rendering of labels - only valid for collapsed legend. | |
QString | title () const |
Returns title label for data-defined size legend. | |
void | updateFromSymbolAndProperty (const QgsMarkerSymbol *symbol, const QgsProperty &ddSize) |
Updates the list of classes, source symbol and title label from given symbol and property. | |
VerticalAlignment | verticalAlignment () const |
Returns vertical alignment of symbols - only valid for collapsed legend. | |
void | writeXml (QDomElement &elem, const QgsReadWriteContext &context) const |
Writes configuration to the given XML element. | |
Static Public Member Functions | |
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. | |
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.
Definition at line 41 of file qgsdatadefinedsizelegend.h.
Determines how to display data-defined size legend.
Enumerator | |
---|---|
LegendSeparated | Each class (size value) has a separate legend node. |
LegendCollapsed | All classes are rendered within one legend node. |
Definition at line 56 of file qgsdatadefinedsizelegend.h.
How to vertically align symbols when all classes go into one node.
Enumerator | |
---|---|
AlignCenter | Symbols are aligned to the center. |
AlignBottom | Symbols are aligned to the bottom. |
Definition at line 63 of file qgsdatadefinedsizelegend.h.
QgsDataDefinedSizeLegend::QgsDataDefinedSizeLegend | ( | ) |
Constructor for QgsDataDefinedSizeLegend.
Definition at line 31 of file qgsdatadefinedsizelegend.cpp.
|
default |
QgsDataDefinedSizeLegend::QgsDataDefinedSizeLegend | ( | const QgsDataDefinedSizeLegend & | other | ) |
Definition at line 39 of file qgsdatadefinedsizelegend.cpp.
|
inline |
Returns list of classes: each class is a pair of symbol size (in units used by the symbol) and label.
Definition at line 116 of file qgsdatadefinedsizelegend.h.
QImage QgsDataDefinedSizeLegend::collapsedLegendImage | ( | QgsRenderContext & | context, |
const QColor & | backgroundColor = Qt::transparent , |
||
double | paddingMM = 1 |
||
) | const |
Returns output image that would be shown in the legend. Returns invalid image if legend is not configured as collapsed.
Definition at line 339 of file qgsdatadefinedsizelegend.cpp.
void QgsDataDefinedSizeLegend::drawCollapsedLegend | ( | QgsRenderContext & | context, |
QSizeF *outputSize | SIP_OUT = nullptr , |
||
double *labelXOffset | SIP_OUT = nullptr |
||
) | const |
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 nullptr
, it only does size calculation without actual rendering. Does nothing if legend is not configured as collapsed.
Definition at line 171 of file qgsdatadefinedsizelegend.cpp.
|
inline |
Returns font used for rendering of labels - only valid for collapsed legend.
Definition at line 131 of file qgsdatadefinedsizelegend.h.
QgsLegendSymbolList QgsDataDefinedSizeLegend::legendSymbolList | ( | ) | const |
Generates legend symbol items according to the configuration.
Definition at line 125 of file qgsdatadefinedsizelegend.cpp.
|
inline |
Returns how the legend should be rendered.
Definition at line 84 of file qgsdatadefinedsizelegend.h.
QgsLineSymbol * QgsDataDefinedSizeLegend::lineSymbol | ( | ) | const |
Returns the line symbol that will be used to draw callout lines in legend.
Definition at line 86 of file qgsdatadefinedsizelegend.cpp.
QgsDataDefinedSizeLegend & QgsDataDefinedSizeLegend::operator= | ( | const QgsDataDefinedSizeLegend & | other | ) |
Definition at line 53 of file qgsdatadefinedsizelegend.cpp.
|
static |
Creates instance from given element and returns it (caller takes ownership). Returns nullptr
on error.
Definition at line 371 of file qgsdatadefinedsizelegend.cpp.
|
inline |
Sets list of classes: each class is a pair of symbol size (in units used by the symbol) and label.
Definition at line 114 of file qgsdatadefinedsizelegend.h.
|
inline |
Sets font used for rendering of labels - only valid for collapsed legend.
Definition at line 129 of file qgsdatadefinedsizelegend.h.
|
inline |
Sets how the legend should be rendered.
Definition at line 82 of file qgsdatadefinedsizelegend.h.
void QgsDataDefinedSizeLegend::setLineSymbol | ( | QgsLineSymbol *symbol | SIP_TRANSFER | ) |
Sets the line symbol that will be used to draw callout lines in legend.
Ownership of symbol is transferred.
Definition at line 81 of file qgsdatadefinedsizelegend.cpp.
void QgsDataDefinedSizeLegend::setSizeScaleTransformer | ( | QgsSizeScaleTransformer *transformer | SIP_TRANSFER | ) |
Sets transformer for scaling of symbol sizes. Takes ownership of the object. Accepts nullptr
to set no transformer.
Definition at line 91 of file qgsdatadefinedsizelegend.cpp.
void QgsDataDefinedSizeLegend::setSymbol | ( | QgsMarkerSymbol *symbol | SIP_TRANSFER | ) |
Sets marker symbol that will be used to draw markers in legend.
Definition at line 71 of file qgsdatadefinedsizelegend.cpp.
|
inline |
Sets horizontal text alignment for rendering of labels - only valid for collapsed legend.
Definition at line 139 of file qgsdatadefinedsizelegend.h.
|
inline |
Sets text color for rendering of labels - only valid for collapsed legend.
Definition at line 134 of file qgsdatadefinedsizelegend.h.
|
inline |
Sets title label for data-defined size legend.
Definition at line 119 of file qgsdatadefinedsizelegend.h.
|
inline |
Sets vertical alignment of symbols - only valid for collapsed legend.
Definition at line 124 of file qgsdatadefinedsizelegend.h.
QgsSizeScaleTransformer * QgsDataDefinedSizeLegend::sizeScaleTransformer | ( | ) | const |
Returns transformer for scaling of symbol sizes. Returns nullptr
if no transformer is defined.
Definition at line 96 of file qgsdatadefinedsizelegend.cpp.
QgsMarkerSymbol * QgsDataDefinedSizeLegend::symbol | ( | ) | const |
Returns marker symbol that will be used to draw markers in legend.
Definition at line 76 of file qgsdatadefinedsizelegend.cpp.
|
inline |
Returns horizontal text alignment for rendering of labels - only valid for collapsed legend.
Definition at line 141 of file qgsdatadefinedsizelegend.h.
|
inline |
Returns text color for rendering of labels - only valid for collapsed legend.
Definition at line 136 of file qgsdatadefinedsizelegend.h.
|
inline |
Returns title label for data-defined size legend.
Definition at line 121 of file qgsdatadefinedsizelegend.h.
void QgsDataDefinedSizeLegend::updateFromSymbolAndProperty | ( | const QgsMarkerSymbol * | symbol, |
const QgsProperty & | ddSize | ||
) |
Updates the list of classes, source symbol and title label from given symbol and property.
Definition at line 102 of file qgsdatadefinedsizelegend.cpp.
|
inline |
Returns vertical alignment of symbols - only valid for collapsed legend.
Definition at line 126 of file qgsdatadefinedsizelegend.h.
void QgsDataDefinedSizeLegend::writeXml | ( | QDomElement & | elem, |
const QgsReadWriteContext & | context | ||
) | const |
Writes configuration to the given XML element.
Definition at line 430 of file qgsdatadefinedsizelegend.cpp.