19#ifndef QGSLAYERTREEMODELLEGENDNODE_H
20#define QGSLAYERTREEMODELLEGENDNODE_H
32using namespace Qt::StringLiterals;
59 if ( qobject_cast<QgsSymbolLegendNode *>( sipCpp ) )
60 sipType = sipType_QgsSymbolLegendNode;
61 else if ( qobject_cast<QgsDataDefinedSizeLegendNode *>( sipCpp ) )
62 sipType = sipType_QgsDataDefinedSizeLegendNode;
63 else if ( qobject_cast<QgsImageLegendNode *>( sipCpp ) )
64 sipType = sipType_QgsImageLegendNode;
65 else if ( qobject_cast<QgsRasterSymbolLegendNode *>( sipCpp ) )
66 sipType = sipType_QgsRasterSymbolLegendNode;
67 else if ( qobject_cast<QgsSimpleLegendNode *>( sipCpp ) )
68 sipType = sipType_QgsSimpleLegendNode;
69 else if ( qobject_cast<QgsWmsLegendNode *>( sipCpp ) )
70 sipType = sipType_QgsWmsLegendNode;
71 else if ( qobject_cast<QgsColorRampLegendNode *>( sipCpp ) )
72 sipType = sipType_QgsColorRampLegendNode;
122 virtual Qt::ItemFlags flags()
const;
125 virtual QVariant
data(
int role )
const = 0;
128 virtual bool setData(
const QVariant &value,
int role );
145 virtual QSizeF userPatchSize()
const;
156 virtual void setUserPatchSize( QSizeF size );
335 SIP_PYOBJECT __repr__();
337 QString str = u
"<QgsLayerTreeModelLegendNode: \"%1\">"_s.arg( sipCpp->data( Qt::DisplayRole ).toString() );
338 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
400 void checkAll(
bool state );
404#include "qgslegendsymbolitem.h"
435 Qt::ItemFlags
flags()
const override;
436 QVariant
data(
int role )
const override;
437 bool setData(
const QVariant &value,
int role )
override;
451 bool isScaleOK(
double scale )
const override {
return mItem.isScaleOK( scale ); }
453 void invalidateMapBasedData()
override;
458 void setIconSize( QSize sz );
467 QSize minimumIconSize()
const;
518 QString symbolLabel()
const;
579 SIP_PYOBJECT __repr__();
581 QString str = u
"<QgsSymbolLegendNode: %1 \"%2\""_s.arg(
583 sipCpp->data( Qt::DisplayRole ).toString() );
584 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
596 mutable QPixmap mPixmap;
598 bool mSymbolUsesMapUnits =
false;
602 QString mTextOnSymbolLabel;
605 std::unique_ptr< QgsSymbol > mCustomSymbol;
608 static const int INDENT_SIZE = 20;
632 QVariant
data(
int role )
const override;
636 SIP_PYOBJECT __repr__();
638 QString str = u
"<QgsSimpleLegendNode: \"%1\">"_s.arg( sipCpp->data( Qt::DisplayRole ).toString() );
639 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
671 QVariant
data(
int role )
const override;
679 SIP_PYOBJECT __repr__();
681 QString str = u
"<QgsImageLegendNode: \"%1\">"_s.arg( sipCpp->data( Qt::DisplayRole ).toString() );
682 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
716 const QString &label,
719 const QString &
ruleKey = QString(),
720 const QString &parentRuleKey = QString()
723 Qt::ItemFlags
flags()
const override;
724 QVariant
data(
int role )
const override;
725 bool setData(
const QVariant &value,
int role )
override;
745 SIP_PYOBJECT __repr__();
747 QString str = u
"<QgsRasterSymbolLegendNode: \"%1\">"_s.arg( sipCpp->data( Qt::DisplayRole ).toString() );
748 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
758 bool mCheckable =
false;
760 QString mParentRuleKey;
763class QgsImageFetcher;
784 QVariant
data(
int role )
const override;
801 SIP_PYOBJECT __repr__();
803 QString str = u
"<QgsWmsLegendNode: \"%1\">"_s.arg( sipCpp->data( Qt::DisplayRole ).toString() );
804 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
813 void getLegendGraphicFinished(
const QImage & );
814 void getLegendGraphicErrored(
const QString & );
815 void getLegendGraphicProgress( qint64, qint64 );
819 QImage getLegendGraphic(
bool synchronous =
false )
const;
821 QImage renderMessage(
const QString &msg )
const;
827 mutable std::unique_ptr<QgsImageFetcher> mFetcher;
844 QVariant
data(
int role )
const override;
850 SIP_PYOBJECT __repr__();
852 QString str = u
"<QgsDataDefinedSizeLegendNode: \"%1\">"_s.arg( sipCpp->data( Qt::DisplayRole ).toString() );
853 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
861 void cacheImage()
const;
862 std::unique_ptr<QgsDataDefinedSizeLegend> mSettings;
863 mutable QImage mImage;
889 QVariant
data(
int role )
const override;
910 SIP_PYOBJECT __repr__();
912 QString str = u
"<QgsVectorLabelLegendNode: \"%1\">"_s.arg( sipCpp->data( Qt::DisplayRole ).toString() );
913 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
923 void textWidthHeight(
double &width,
double &height,
QgsRenderContext &ctx,
const QgsTextFormat &textFormat,
const QStringList &textLines )
const;
QgsDataDefinedSizeLegendNode(QgsLayerTreeLayer *nodeLayer, const QgsDataDefinedSizeLegend &settings, QObject *parent=nullptr)
Construct the node using QgsDataDefinedSizeLegend as definition of the node's appearance.
ItemMetrics draw(const QgsLegendSettings &settings, ItemContext &ctx) override
Entry point called from QgsLegendRenderer to do the rendering.
QVariant data(int role) const override
Returns data associated with the item. Must be implemented in derived class.
void invalidateDisplayData() override
Invalidates cached display data for the node.
Object that keeps configuration of appearance of marker symbol's data-defined size in legend.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QVariant data(int role) const override
Returns data associated with the item. Must be implemented in derived class.
QgsImageLegendNode(QgsLayerTreeLayer *nodeLayer, const QImage &img, QObject *parent=nullptr)
Constructor for QgsImageLegendNode.
QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const override
Draws symbol on the left side of the item.
QJsonObject exportSymbolToJson(const QgsLegendSettings &settings, const QgsRenderContext &context) const override
Adds a symbol in base64 string within a JSON object with the key "icon".
Layer tree node points to a map layer.
virtual QVariant data(int role) const =0
Returns data associated with the item. Must be implemented in derived class.
QJsonObject exportToJson(const QgsLegendSettings &settings, const QgsRenderContext &context)
Entry point called from QgsLegendRenderer to do the rendering in a JSON object.
virtual bool columnBreak() const
Returns whether a forced column break should occur before the node.
NodeTypes
Types of legend nodes.
@ SimpleLegend
Simple label with icon legend node type.
@ RasterSymbolLegend
Raster symbol legend node type.
@ ImageLegend
Raster image legend node type.
@ DataDefinedSizeLegend
Marker symbol legend node type.
@ WmsLegend
WMS legend node type.
@ EmbeddedWidget
Embedded widget placeholder node type.
@ ColorRampLegend
Color ramp legend.
@ SymbolLegend
Vector symbol legend node type.
void checkAllItems()
Checks all checkable items belonging to the same layer as this node.
CustomRole
Legend node data roles.
@ RuleKey
Rule key of the node (QString).
void uncheckAllItems()
Unchecks all checkable items belonging to the same layer as this node.
virtual QString userLabel() const
virtual bool isScaleOK(double scale) const
virtual void setColumnBreak(bool breakBeforeNode)
Sets whether a forced column break should occur before the node.
QgsLayerTreeLayer * mLayerNode
QgsLayerTreeModelLegendNode(QgsLayerTreeLayer *nodeL, QObject *parent=nullptr)
Construct the node with pointer to its parent layer node.
virtual void invalidateMapBasedData()
Notification from model that information from associated map view has changed.
void sizeChanged()
Emitted when the size of this node changes.
virtual ItemMetrics draw(const QgsLegendSettings &settings, ItemContext &ctx)
Entry point called from QgsLegendRenderer to do the rendering.
void dataChanged()
Emitted on internal data change so the layer tree model can forward the signal to views.
virtual bool isEmbeddedInParent() const
QgsRenderContext * createTemporaryRenderContext() const
Returns a temporary context or nullptr if legendMapViewData are not valid.
virtual QJsonObject exportSymbolToJson(const QgsLegendSettings &settings, const QgsRenderContext &context) const
Adds a symbol in base64 string within a JSON object with the key "icon".
bool mColumnBreakBeforeNode
void toggleAllItems()
Toggle all checkable items belonging to the same layer as this node.
QgsLegendPatchShape mPatchShape
QgsLayerTreeLayer * layerNode() const
Returns pointer to the parent layer node.
virtual void invalidateDisplayData()
Invalidates cached display data for the node.
virtual QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const
Draws symbol on the left side of the item.
virtual void setEmbeddedInParent(bool embedded)
virtual void setUserLabel(const QString &userLabel)
virtual bool setData(const QVariant &value, int role)
Sets some data associated with the item. Default implementation does nothing and returns false.
virtual QSizeF drawSymbolText(const QgsLegendSettings &settings, ItemContext *ctx, QSizeF symbolSize) const
Draws label on the right side of the item.
A model representing the layer tree, including layers and groups of layers.
Represents a patch shape for use in map legends.
Stores the appearance and layout settings for legend drawing with QgsLegendRenderer.
Stores information about one class/rule of a vector layer renderer in a unified way that can be used ...
Contains configuration for rendering maps.
Contains settings for how a map layer will be labeled.
Qt::ItemFlags flags() const override
Returns item flags associated with the item. Default implementation returns Qt::ItemIsEnabled.
bool setData(const QVariant &value, int role) override
Sets some data associated with the item. Default implementation does nothing and returns false.
QString ruleKey() const
Returns the unique identifier of node for identification of the item within renderer.
QJsonObject exportSymbolToJson(const QgsLegendSettings &settings, const QgsRenderContext &context) const override
Adds a symbol in base64 string within a JSON object with the key "icon".
QgsRasterSymbolLegendNode(QgsLayerTreeLayer *nodeLayer, const QColor &color, const QString &label, QObject *parent=nullptr, bool isCheckable=false, const QString &ruleKey=QString(), const QString &parentRuleKey=QString())
Constructor for QgsRasterSymbolLegendNode.
QVariant data(int role) const override
Returns data associated with the item. Must be implemented in derived class.
bool isCheckable() const
Returns whether the item is user-checkable - whether renderer supports enabling/disabling it.
QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const override
Draws symbol on the left side of the item.
Contains information about the context of a rendering operation.
Stores properties relating to a screen.
QVariant data(int role) const override
Returns data associated with the item. Must be implemented in derived class.
QgsSimpleLegendNode(QgsLayerTreeLayer *nodeLayer, const QString &label, const QIcon &icon=QIcon(), QObject *parent=nullptr, const QString &key=QString())
Constructor for QgsSimpleLegendNode.
static double MAXIMUM_SIZE
QString textOnSymbolLabel() const
Returns label of text to be shown on top of the symbol.
QgsSymbolLegendNode(QgsLayerTreeLayer *nodeLayer, const QgsLegendSymbolItem &item, QObject *parent=nullptr)
Constructor for QgsSymbolLegendNode.
void setUserLabel(const QString &userLabel) override
static const QgsSettingsEntryDouble * settingsLegendSymbolMaximumSize
void setTextOnSymbolTextFormat(const QgsTextFormat &format)
Sets format of text to be shown on top of the symbol.
void setTextOnSymbolLabel(const QString &label)
Sets label of text to be shown on top of the symbol.
~QgsSymbolLegendNode() override
QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const override
Draws symbol on the left side of the item.
bool setData(const QVariant &value, int role) override
Sets some data associated with the item. Default implementation does nothing and returns false.
Qt::ItemFlags flags() const override
Returns item flags associated with the item. Default implementation returns Qt::ItemIsEnabled.
bool isScaleOK(double scale) const override
void invalidateDisplayData() override
Invalidates cached display data for the node.
void setEmbeddedInParent(bool embedded) override
static double MINIMUM_SIZE
QVariant data(int role) const override
Returns data associated with the item. Must be implemented in derived class.
static const QgsSettingsEntryDouble * settingsLegendSymbolMinimumSize
QJsonObject exportSymbolToJson(const QgsLegendSettings &settings, const QgsRenderContext &context) const override
Adds a symbol in base64 string within a JSON object with the key "icon".
QgsTextFormat textOnSymbolTextFormat() const
Returns text format of the label to be shown on top of the symbol.
Abstract base class for all rendered symbols.
Contains pre-calculated metrics of a QgsTextDocument.
Represents a document consisting of one or more QgsTextBlock objects.
Container for all settings relating to text rendering.
QgsVectorLabelLegendNode(QgsLayerTreeLayer *nodeLayer, const QgsPalLayerSettings &labelSettings, QObject *parent=nullptr)
QgsVectorLabelLegendNode.
QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const override
drawSymbol
QJsonObject exportSymbolToJson(const QgsLegendSettings &settings, const QgsRenderContext &context) const override
exportSymbolToJson
QVariant data(int role) const override
data Returns data associated with the item
QImage getLegendGraphicBlocking() const
Fetches the image from the server and returns it.
QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const override
Draws symbol on the left side of the item.
void invalidateMapBasedData() override
Notification from model that information from associated map view has changed.
QVariant data(int role) const override
Returns data associated with the item. Must be implemented in derived class.
~QgsWmsLegendNode() override
QgsWmsLegendNode(QgsLayerTreeLayer *nodeLayer, QObject *parent=nullptr)
Constructor for QgsWmsLegendNode.
QJsonObject exportSymbolToJson(const QgsLegendSettings &settings, const QgsRenderContext &context) const override
Adds a symbol in base64 string within a JSON object with the key "icon".
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
Q_NOWARN_DEPRECATED_PUSH ItemContext()=default
QPainter * painter
Painter.
double top
Top y-position of legend item.
Q_DECL_DEPRECATED double labelXOffset
Offset from the left side where label should start.
QgsLegendPatchShape patchShape
The patch shape to render for the node.
QgsScreenProperties screenProperties
Destination screen properties.
double maxSiblingSymbolWidth
Largest symbol width, considering all other sibling legend components associated with the current com...
QSizeF patchSize
Symbol patch size to render for the node.
const QgsTextDocument * textDocument
Optional text document.
double columnLeft
Left side of current legend column.
const QgsTextDocumentMetrics * textDocumentMetrics
Optional text document metrics.
double columnRight
Right side of current legend column.
Q_DECL_DEPRECATED QPointF point
Top-left corner of the legend item.
Q_NOWARN_DEPRECATED_POP QgsRenderContext * context
Render context, if available.