QGIS API Documentation  3.20.0-Odense (decaadbb31)
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
QgsDataDefinedSizeLegend Class Reference

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. More...
 
 QgsDataDefinedSizeLegend (const QgsDataDefinedSizeLegend &other)
 Copy constructor. More...
 
 ~QgsDataDefinedSizeLegend ()
 
QList< QgsDataDefinedSizeLegend::SizeClassclasses () const
 Returns list of classes: each class is a pair of symbol size (in units used by the symbol) and label. More...
 
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. More...
 
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). More...
 
QFont font () const
 Returns font used for rendering of labels - only valid for collapsed legend. More...
 
QgsLegendSymbolList legendSymbolList () const
 Generates legend symbol items according to the configuration. More...
 
LegendType legendType () const
 Returns how the legend should be rendered. More...
 
QgsLineSymbollineSymbol () const
 Returns the line symbol that will be used to draw callout lines in legend. More...
 
QgsDataDefinedSizeLegendoperator= (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. More...
 
void setFont (const QFont &font)
 Sets font used for rendering of labels - only valid for collapsed legend. More...
 
void setLegendType (LegendType type)
 Sets how the legend should be rendered. More...
 
void setLineSymbol (QgsLineSymbol *symbol SIP_TRANSFER)
 Sets the line symbol that will be used to draw callout lines in legend. More...
 
void setSizeScaleTransformer (QgsSizeScaleTransformer *transformer SIP_TRANSFER)
 Sets transformer for scaling of symbol sizes. Takes ownership of the object. Accepts nullptr to set no transformer. More...
 
void setSymbol (QgsMarkerSymbol *symbol SIP_TRANSFER)
 Sets marker symbol that will be used to draw markers in legend. More...
 
void setTextAlignment (Qt::AlignmentFlag flag)
 Sets horizontal text alignment for rendering of labels - only valid for collapsed legend. More...
 
void setTextColor (const QColor &color)
 Sets text color for rendering of labels - only valid for collapsed legend. More...
 
void setTitle (const QString &title)
 Sets title label for data-defined size legend. More...
 
void setVerticalAlignment (VerticalAlignment vAlign)
 Sets vertical alignment of symbols - only valid for collapsed legend. More...
 
QgsSizeScaleTransformersizeScaleTransformer () const
 Returns transformer for scaling of symbol sizes. Returns nullptr if no transformer is defined. More...
 
QgsMarkerSymbolsymbol () const
 Returns marker symbol that will be used to draw markers in legend. More...
 
Qt::AlignmentFlag textAlignment () const
 Returns horizontal text alignment for rendering of labels - only valid for collapsed legend. More...
 
QColor textColor () const
 Returns text color for rendering of labels - only valid for collapsed legend. More...
 
QString title () const
 Returns title label for data-defined size legend. More...
 
void updateFromSymbolAndProperty (const QgsMarkerSymbol *symbol, const QgsProperty &ddSize)
 Updates the list of classes, source symbol and title label from given symbol and property. More...
 
VerticalAlignment verticalAlignment () const
 Returns vertical alignment of symbols - only valid for collapsed legend. More...
 
void writeXml (QDomElement &elem, const QgsReadWriteContext &context) const
 Writes configuration to the given XML element. More...
 

Static Public Member Functions

static QgsDataDefinedSizeLegendreadXml (const QDomElement &elem, const QgsReadWriteContext &context) SIP_FACTORY
 Creates instance from given element and returns it (caller takes ownership). Returns nullptr on error. More...
 

Detailed Description

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.

Since
QGIS 3.0

Definition at line 42 of file qgsdatadefinedsizelegend.h.

Member Enumeration Documentation

◆ LegendType

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 58 of file qgsdatadefinedsizelegend.h.

◆ VerticalAlignment

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 65 of file qgsdatadefinedsizelegend.h.

Constructor & Destructor Documentation

◆ QgsDataDefinedSizeLegend() [1/2]

QgsDataDefinedSizeLegend::QgsDataDefinedSizeLegend ( )

Constructor for QgsDataDefinedSizeLegend.

Definition at line 28 of file qgsdatadefinedsizelegend.cpp.

◆ ~QgsDataDefinedSizeLegend()

QgsDataDefinedSizeLegend::~QgsDataDefinedSizeLegend ( )
default

◆ QgsDataDefinedSizeLegend() [2/2]

QgsDataDefinedSizeLegend::QgsDataDefinedSizeLegend ( const QgsDataDefinedSizeLegend other)

Copy constructor.

Definition at line 36 of file qgsdatadefinedsizelegend.cpp.

Member Function Documentation

◆ classes()

QList< QgsDataDefinedSizeLegend::SizeClass > QgsDataDefinedSizeLegend::classes ( ) const
inline

Returns list of classes: each class is a pair of symbol size (in units used by the symbol) and label.

Definition at line 115 of file qgsdatadefinedsizelegend.h.

◆ collapsedLegendImage()

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 332 of file qgsdatadefinedsizelegend.cpp.

◆ drawCollapsedLegend()

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 164 of file qgsdatadefinedsizelegend.cpp.

◆ font()

QFont QgsDataDefinedSizeLegend::font ( ) const
inline

Returns font used for rendering of labels - only valid for collapsed legend.

Definition at line 130 of file qgsdatadefinedsizelegend.h.

◆ legendSymbolList()

QgsLegendSymbolList QgsDataDefinedSizeLegend::legendSymbolList ( ) const

Generates legend symbol items according to the configuration.

Definition at line 122 of file qgsdatadefinedsizelegend.cpp.

◆ legendType()

LegendType QgsDataDefinedSizeLegend::legendType ( ) const
inline

Returns how the legend should be rendered.

Definition at line 83 of file qgsdatadefinedsizelegend.h.

◆ lineSymbol()

QgsLineSymbol * QgsDataDefinedSizeLegend::lineSymbol ( ) const

Returns the line symbol that will be used to draw callout lines in legend.

See also
setLineSymbol()
Since
QGIS 3.14

Definition at line 83 of file qgsdatadefinedsizelegend.cpp.

◆ operator=()

QgsDataDefinedSizeLegend & QgsDataDefinedSizeLegend::operator= ( const QgsDataDefinedSizeLegend other)

Definition at line 50 of file qgsdatadefinedsizelegend.cpp.

◆ readXml()

QgsDataDefinedSizeLegend * QgsDataDefinedSizeLegend::readXml ( const QDomElement &  elem,
const QgsReadWriteContext context 
)
static

Creates instance from given element and returns it (caller takes ownership). Returns nullptr on error.

Definition at line 364 of file qgsdatadefinedsizelegend.cpp.

◆ setClasses()

void QgsDataDefinedSizeLegend::setClasses ( const QList< QgsDataDefinedSizeLegend::SizeClass > &  classes)
inline

Sets list of classes: each class is a pair of symbol size (in units used by the symbol) and label.

Definition at line 113 of file qgsdatadefinedsizelegend.h.

◆ setFont()

void QgsDataDefinedSizeLegend::setFont ( const QFont &  font)
inline

Sets font used for rendering of labels - only valid for collapsed legend.

Definition at line 128 of file qgsdatadefinedsizelegend.h.

◆ setLegendType()

void QgsDataDefinedSizeLegend::setLegendType ( LegendType  type)
inline

Sets how the legend should be rendered.

Definition at line 81 of file qgsdatadefinedsizelegend.h.

◆ setLineSymbol()

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.

See also
lineSymbol()
Since
QGIS 3.14

Definition at line 78 of file qgsdatadefinedsizelegend.cpp.

◆ setSizeScaleTransformer()

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 88 of file qgsdatadefinedsizelegend.cpp.

◆ setSymbol()

void QgsDataDefinedSizeLegend::setSymbol ( QgsMarkerSymbol *symbol  SIP_TRANSFER)

Sets marker symbol that will be used to draw markers in legend.

Definition at line 68 of file qgsdatadefinedsizelegend.cpp.

◆ setTextAlignment()

void QgsDataDefinedSizeLegend::setTextAlignment ( Qt::AlignmentFlag  flag)
inline

Sets horizontal text alignment for rendering of labels - only valid for collapsed legend.

Definition at line 138 of file qgsdatadefinedsizelegend.h.

◆ setTextColor()

void QgsDataDefinedSizeLegend::setTextColor ( const QColor &  color)
inline

Sets text color for rendering of labels - only valid for collapsed legend.

Definition at line 133 of file qgsdatadefinedsizelegend.h.

◆ setTitle()

void QgsDataDefinedSizeLegend::setTitle ( const QString &  title)
inline

Sets title label for data-defined size legend.

Definition at line 118 of file qgsdatadefinedsizelegend.h.

◆ setVerticalAlignment()

void QgsDataDefinedSizeLegend::setVerticalAlignment ( VerticalAlignment  vAlign)
inline

Sets vertical alignment of symbols - only valid for collapsed legend.

Definition at line 123 of file qgsdatadefinedsizelegend.h.

◆ sizeScaleTransformer()

QgsSizeScaleTransformer * QgsDataDefinedSizeLegend::sizeScaleTransformer ( ) const

Returns transformer for scaling of symbol sizes. Returns nullptr if no transformer is defined.

Definition at line 93 of file qgsdatadefinedsizelegend.cpp.

◆ symbol()

QgsMarkerSymbol * QgsDataDefinedSizeLegend::symbol ( ) const

Returns marker symbol that will be used to draw markers in legend.

Definition at line 73 of file qgsdatadefinedsizelegend.cpp.

◆ textAlignment()

Qt::AlignmentFlag QgsDataDefinedSizeLegend::textAlignment ( ) const
inline

Returns horizontal text alignment for rendering of labels - only valid for collapsed legend.

Definition at line 140 of file qgsdatadefinedsizelegend.h.

◆ textColor()

QColor QgsDataDefinedSizeLegend::textColor ( ) const
inline

Returns text color for rendering of labels - only valid for collapsed legend.

Definition at line 135 of file qgsdatadefinedsizelegend.h.

◆ title()

QString QgsDataDefinedSizeLegend::title ( ) const
inline

Returns title label for data-defined size legend.

Definition at line 120 of file qgsdatadefinedsizelegend.h.

◆ updateFromSymbolAndProperty()

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 99 of file qgsdatadefinedsizelegend.cpp.

◆ verticalAlignment()

VerticalAlignment QgsDataDefinedSizeLegend::verticalAlignment ( ) const
inline

Returns vertical alignment of symbols - only valid for collapsed legend.

Definition at line 125 of file qgsdatadefinedsizelegend.h.

◆ writeXml()

void QgsDataDefinedSizeLegend::writeXml ( QDomElement &  elem,
const QgsReadWriteContext context 
) const

Writes configuration to the given XML element.

Definition at line 423 of file qgsdatadefinedsizelegend.cpp.


The documentation for this class was generated from the following files: