QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsRasterSymbolLegendNode Class Reference

Implementation of legend node interface for displaying raster legend entries. More...

#include <qgslayertreemodellegendnode.h>

Inheritance diagram for QgsRasterSymbolLegendNode:
Inheritance graph
[legend]

Public Member Functions

 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.
 
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".
 
Qt::ItemFlags flags () const override
 Returns item flags associated with the item. Default implementation returns Qt::ItemIsEnabled.
 
bool isCheckable () const
 Returns whether the item is user-checkable - whether renderer supports enabling/disabling it.
 
QString ruleKey () const
 Returns the unique identifier of node for identification of the item within renderer.
 
bool setData (const QVariant &value, int role) override
 Sets some data associated with the item. Default implementation does nothing and returns false.
 
- Public Member Functions inherited from QgsLayerTreeModelLegendNode
virtual bool columnBreak () const
 Returns whether a forced column break should occur before the node.
 
virtual ItemMetrics draw (const QgsLegendSettings &settings, ItemContext *ctx)
 Entry point called from QgsLegendRenderer to do the rendering.
 
virtual QSizeF drawSymbolText (const QgsLegendSettings &settings, ItemContext *ctx, QSizeF symbolSize) const
 Draws label on the right side of the item.
 
QJsonObject exportToJson (const QgsLegendSettings &settings, const QgsRenderContext &context)
 Entry point called from QgsLegendRenderer to do the rendering in a JSON object.
 
virtual void invalidateMapBasedData ()
 Notification from model that information from associated map view has changed.
 
virtual bool isEmbeddedInParent () const
 
virtual bool isScaleOK (double scale) const
 
QgsLayerTreeLayerlayerNode () const
 Returns pointer to the parent layer node.
 
QgsLayerTreeModelmodel () const
 Returns pointer to model owning this legend node.
 
virtual void setColumnBreak (bool breakBeforeNode)
 Sets whether a forced column break should occur before the node.
 
virtual void setEmbeddedInParent (bool embedded)
 
virtual void setUserLabel (const QString &userLabel)
 
virtual void setUserPatchSize (QSizeF size)
 Sets the user (overridden) size for the legend node.
 
virtual QString userLabel () const
 
virtual QSizeF userPatchSize () const
 Returns the user (overridden) size for the legend node.
 

Additional Inherited Members

- Public Types inherited from QgsLayerTreeModelLegendNode
enum class  CustomRole : int { RuleKey = Qt::UserRole , ParentRuleKey , NodeType , IsDataDefinedSize }
 Legend node data roles. More...
 
enum  NodeTypes {
  SimpleLegend , SymbolLegend , RasterSymbolLegend , ImageLegend ,
  WmsLegend , DataDefinedSizeLegend , EmbeddedWidget , ColorRampLegend
}
 Types of legend nodes. More...
 
- Public Slots inherited from QgsLayerTreeModelLegendNode
void checkAllItems ()
 Checks all checkable items belonging to the same layer as this node.
 
void toggleAllItems ()
 Toggle all checkable items belonging to the same layer as this node.
 
void uncheckAllItems ()
 Unchecks all checkable items belonging to the same layer as this node.
 
- Signals inherited from QgsLayerTreeModelLegendNode
void dataChanged ()
 Emitted on internal data change so the layer tree model can forward the signal to views.
 
void sizeChanged ()
 Emitted when the size of this node changes.
 
- Protected Member Functions inherited from QgsLayerTreeModelLegendNode
 QgsLayerTreeModelLegendNode (QgsLayerTreeLayer *nodeL, QObject *parent=nullptr)
 Construct the node with pointer to its parent layer node.
 
QgsRenderContextcreateTemporaryRenderContext () const
 Returns a temporary context or nullptr if legendMapViewData are not valid.
 
- Protected Attributes inherited from QgsLayerTreeModelLegendNode
bool mColumnBreakBeforeNode = false
 
bool mEmbeddedInParent
 
QgsLayerTreeLayermLayerNode = nullptr
 
QgsLegendPatchShape mPatchShape
 
QString mUserLabel
 
QSizeF mUserSize
 

Detailed Description

Implementation of legend node interface for displaying raster legend entries.

Definition at line 666 of file qgslayertreemodellegendnode.h.

Constructor & Destructor Documentation

◆ QgsRasterSymbolLegendNode()

QgsRasterSymbolLegendNode::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.

Parameters
nodeLayerlayer node
colorcolor
labellabel
parentattach a parent QObject to the legend node.
isCheckableset to true to enable the checkbox for the node (since QGIS 3.18)
ruleKeyoptional identifier to allow a unique ID to be assigned to the node by a renderer (since QGIS 3.18)
parentRuleKeyrule key of parent (since QGIS 3.40)

Definition at line 1082 of file qgslayertreemodellegendnode.cpp.

Member Function Documentation

◆ data()

QVariant QgsRasterSymbolLegendNode::data ( int  role) const
overridevirtual

Returns data associated with the item. Must be implemented in derived class.

Implements QgsLayerTreeModelLegendNode.

Definition at line 1100 of file qgslayertreemodellegendnode.cpp.

◆ drawSymbol()

QSizeF QgsRasterSymbolLegendNode::drawSymbol ( const QgsLegendSettings settings,
ItemContext ctx,
double  itemHeight 
) const
overridevirtual

Draws symbol on the left side of the item.

Parameters
settingsLegend layout configuration
ctxContext for rendering - may be nullptr if only doing layout without actual rendering
itemHeightMinimal height of the legend item - used for correct positioning when rendering
Returns
Real size of the symbol (may be bigger than "normal" symbol size from settings)

Reimplemented from QgsLayerTreeModelLegendNode.

Definition at line 1177 of file qgslayertreemodellegendnode.cpp.

◆ exportSymbolToJson()

QJsonObject QgsRasterSymbolLegendNode::exportSymbolToJson ( const QgsLegendSettings settings,
const QgsRenderContext context 
) const
overridevirtual

Adds a symbol in base64 string within a JSON object with the key "icon".

Parameters
settingsLegend layout configuration
contextRendering context
Since
QGIS 3.8

Reimplemented from QgsLayerTreeModelLegendNode.

Definition at line 1235 of file qgslayertreemodellegendnode.cpp.

◆ flags()

Qt::ItemFlags QgsRasterSymbolLegendNode::flags ( ) const
overridevirtual

Returns item flags associated with the item. Default implementation returns Qt::ItemIsEnabled.

Reimplemented from QgsLayerTreeModelLegendNode.

Definition at line 1092 of file qgslayertreemodellegendnode.cpp.

◆ isCheckable()

bool QgsRasterSymbolLegendNode::isCheckable ( ) const
inline

Returns whether the item is user-checkable - whether renderer supports enabling/disabling it.

Since
QGIS 3.18

Definition at line 703 of file qgslayertreemodellegendnode.h.

◆ ruleKey()

QString QgsRasterSymbolLegendNode::ruleKey ( ) const
inline

Returns the unique identifier of node for identification of the item within renderer.

Since
QGIS 3.18

Definition at line 696 of file qgslayertreemodellegendnode.h.

◆ setData()

bool QgsRasterSymbolLegendNode::setData ( const QVariant &  value,
int  role 
)
overridevirtual

Sets some data associated with the item. Default implementation does nothing and returns false.

Reimplemented from QgsLayerTreeModelLegendNode.

Definition at line 1146 of file qgslayertreemodellegendnode.cpp.


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