QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
QgsColorRampLegendNode Class Reference

A legend node which renders a color ramp. More...

#include <qgscolorramplegendnode.h>

Inheritance diagram for QgsColorRampLegendNode:

Public Member Functions

 QgsColorRampLegendNode (QgsLayerTreeLayer *nodeLayer, QgsColorRamp *ramp, const QgsColorRampLegendNodeSettings &settings, double minimumValue, double maximumValue, QObject *parent=nullptr, const QString &key=QString(), const QString &parentKey=QString())
 Constructor for QgsColorRampLegendNode.
 QgsColorRampLegendNode (QgsLayerTreeLayer *nodeLayer, QgsColorRamp *ramp, const QString &minimumLabel, const QString &maximumLabel, QObject *parent=nullptr, const QString &key=QString(), const QString &parentKey=QString())
 Constructor for QgsColorRampLegendNode.
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.
QSizeF drawSymbolText (const QgsLegendSettings &settings, ItemContext *ctx, QSizeF symbolSize) const override
 Draws label on the right 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".
QSize iconSize () const
 Returns the icon size, which is how large the ramp will render in a layer tree widget.
const QgsColorRampramp () const
 Returns the color ramp used by the node.
void setIconSize (QSize size)
 Set the icon size, which controls how large the ramp will render in a layer tree widget.
void setSettings (const QgsColorRampLegendNodeSettings &settings)
 Sets the node's settings.
QgsColorRampLegendNodeSettings settings () const
 Returns the node's settings.
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.
QJsonObject exportToJson (const QgsLegendSettings &settings, const QgsRenderContext &context)
 Entry point called from QgsLegendRenderer to do the rendering in a JSON object.
virtual Qt::ItemFlags flags () const
 Returns item flags associated with the item. Default implementation returns Qt::ItemIsEnabled.
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 bool setData (const QVariant &value, int role)
 Sets some data associated with the item. Default implementation does nothing and returns false.
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 = false
QgsLayerTreeLayermLayerNode = nullptr
QgsLegendPatchShape mPatchShape
QString mUserLabel
QSizeF mUserSize

Detailed Description

A legend node which renders a color ramp.

Since
QGIS 3.18

Definition at line 32 of file qgscolorramplegendnode.h.

Constructor & Destructor Documentation

◆ QgsColorRampLegendNode() [1/2]

QgsColorRampLegendNode::QgsColorRampLegendNode ( QgsLayerTreeLayer * nodeLayer,
QgsColorRamp * ramp,
const QString & minimumLabel,
const QString & maximumLabel,
QObject * parent = nullptr,
const QString & key = QString(),
const QString & parentKey = QString() )

Constructor for QgsColorRampLegendNode.

Parameters
nodeLayerlayer node
rampcolor ramp to render in node. Ownership is transferred to the node.
minimumLabellabel text to render for the minimum value in the ramp
maximumLabellabel text to render for the maximum value in the ramp
parentattach a parent QObject to the legend node.
keyrule key. optional identifier to allow a unique ID to be assigned to the node by a renderer (since QGIS 3.40)
parentKeyrule key of parent (since QGIS 3.40)

Definition at line 33 of file qgscolorramplegendnode.cpp.

◆ QgsColorRampLegendNode() [2/2]

QgsColorRampLegendNode::QgsColorRampLegendNode ( QgsLayerTreeLayer * nodeLayer,
QgsColorRamp * ramp,
const QgsColorRampLegendNodeSettings & settings,
double minimumValue,
double maximumValue,
QObject * parent = nullptr,
const QString & key = QString(),
const QString & parentKey = QString() )

Constructor for QgsColorRampLegendNode.

Parameters
nodeLayerlayer node
rampcolor ramp to render in node. Ownership is transferred to the node.
settingsnode settings
minimumValuevalue associated with minimum of ramp
maximumValuevalue associated with maximum of ramp
parentattach a parent QObject to the legend node.
keyrule key. optional identifier to allow a unique ID to be assigned to the node by a renderer (since QGIS 3.40)
parentKeyrule key of parent (since QGIS 3.40)

Definition at line 45 of file qgscolorramplegendnode.cpp.

Member Function Documentation

◆ data()

QVariant QgsColorRampLegendNode::data ( int role) const
overridevirtual

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

Implements QgsLayerTreeModelLegendNode.

Definition at line 98 of file qgscolorramplegendnode.cpp.

◆ drawSymbol()

QSizeF QgsColorRampLegendNode::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 195 of file qgscolorramplegendnode.cpp.

◆ drawSymbolText()

QSizeF QgsColorRampLegendNode::drawSymbolText ( const QgsLegendSettings & settings,
QgsLayerTreeModelLegendNode::ItemContext * ctx,
QSizeF symbolSize ) const
overridevirtual

Draws label on the right side of the item.

Parameters
settingsLegend layout configuration
ctxContext for rendering - may be nullptr if only doing layout without actual rendering
symbolSizeReal size of the associated symbol - used for correct positioning when rendering
Returns
Size of the label (may span multiple lines)

Reimplemented from QgsLayerTreeModelLegendNode.

Definition at line 395 of file qgscolorramplegendnode.cpp.

◆ exportSymbolToJson()

QJsonObject QgsColorRampLegendNode::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 491 of file qgscolorramplegendnode.cpp.

◆ iconSize()

QSize QgsColorRampLegendNode::iconSize ( ) const
inline

Returns the icon size, which is how large the ramp will render in a layer tree widget.

See also
setIconSize()

Definition at line 87 of file qgscolorramplegendnode.h.

◆ ramp()

const QgsColorRamp * QgsColorRampLegendNode::ramp ( ) const

Returns the color ramp used by the node.

Definition at line 65 of file qgscolorramplegendnode.cpp.

◆ setIconSize()

void QgsColorRampLegendNode::setIconSize ( QSize size)
inline

Set the icon size, which controls how large the ramp will render in a layer tree widget.

See also
iconSize()

Definition at line 80 of file qgscolorramplegendnode.h.

◆ setSettings()

void QgsColorRampLegendNode::setSettings ( const QgsColorRampLegendNodeSettings & settings)

Sets the node's settings.

See also
settings()

Definition at line 75 of file qgscolorramplegendnode.cpp.

◆ settings()

QgsColorRampLegendNodeSettings QgsColorRampLegendNode::settings ( ) const

Returns the node's settings.

See also
setSettings()

Definition at line 70 of file qgscolorramplegendnode.cpp.


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