QGIS API Documentation
3.20.0-Odense (decaadbb31)
|
A legend node which renders a color ramp. More...
#include <qgscolorramplegendnode.h>
Public Member Functions | |
QgsColorRampLegendNode (QgsLayerTreeLayer *nodeLayer, QgsColorRamp *ramp, const QgsColorRampLegendNodeSettings &settings, double minimumValue, double maximumValue, QObject *parent=nullptr) | |
Constructor for QgsColorRampLegendNode. More... | |
QgsColorRampLegendNode (QgsLayerTreeLayer *nodeLayer, QgsColorRamp *ramp, const QString &minimumLabel, const QString &maximumLabel, QObject *parent=nullptr) | |
Constructor for QgsColorRampLegendNode. More... | |
QVariant | data (int role) const override |
Returns data associated with the item. Must be implemented in derived class. More... | |
QSizeF | drawSymbol (const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const override |
Draws symbol on the left side of the item. More... | |
QSizeF | drawSymbolText (const QgsLegendSettings &settings, ItemContext *ctx, QSizeF symbolSize) const override |
Draws label on the right side of the item. More... | |
QSize | iconSize () const |
Returns the icon size, which is how large the ramp will render in a layer tree widget. More... | |
const QgsColorRamp * | ramp () const |
Returns the color ramp used by the node. More... | |
void | setIconSize (QSize size) |
Set the icon size, which controls how large the ramp will render in a layer tree widget. More... | |
void | setSettings (const QgsColorRampLegendNodeSettings &settings) |
Sets the node's settings. More... | |
QgsColorRampLegendNodeSettings | settings () const |
Returns the node's settings. More... | |
Public Member Functions inherited from QgsLayerTreeModelLegendNode | |
virtual bool | columnBreak () const |
Returns whether a forced column break should occur before the node. More... | |
virtual ItemMetrics | draw (const QgsLegendSettings &settings, ItemContext *ctx) |
Entry point called from QgsLegendRenderer to do the rendering. More... | |
virtual QJsonObject | exportSymbolToJson (const QgsLegendSettings &settings, const QgsRenderContext &context) const |
Adds a symbol in base64 string within a JSON object with the key "icon". More... | |
QJsonObject | exportToJson (const QgsLegendSettings &settings, const QgsRenderContext &context) |
Entry point called from QgsLegendRenderer to do the rendering in a JSON object. More... | |
virtual Qt::ItemFlags | flags () const |
Returns item flags associated with the item. Default implementation returns Qt::ItemIsEnabled. More... | |
virtual void | invalidateMapBasedData () |
Notification from model that information from associated map view has changed. More... | |
virtual bool | isEmbeddedInParent () const |
virtual bool | isScaleOK (double scale) const |
QgsLayerTreeLayer * | layerNode () const |
Returns pointer to the parent layer node. More... | |
QgsLayerTreeModel * | model () const |
Returns pointer to model owning this legend node. More... | |
virtual void | setColumnBreak (bool breakBeforeNode) |
Sets whether a forced column break should occur before the node. More... | |
virtual bool | setData (const QVariant &value, int role) |
Sets some data associated with the item. Default implementation does nothing and returns false . More... | |
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. More... | |
virtual QString | userLabel () const |
virtual QSizeF | userPatchSize () const |
Returns the user (overridden) size for the legend node. More... | |
Additional Inherited Members | |
Public Types inherited from QgsLayerTreeModelLegendNode | |
enum | LegendNodeRoles { RuleKeyRole = Qt::UserRole , ParentRuleKeyRole , NodeTypeRole } |
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. More... | |
void | toggleAllItems () |
Toggle all checkable items belonging to the same layer as this node. More... | |
void | uncheckAllItems () |
Unchecks all checkable items belonging to the same layer as this node. More... | |
Signals inherited from QgsLayerTreeModelLegendNode | |
void | dataChanged () |
Emitted on internal data change so the layer tree model can forward the signal to views. More... | |
void | sizeChanged () |
Emitted when the size of this node changes. More... | |
Protected Member Functions inherited from QgsLayerTreeModelLegendNode | |
QgsLayerTreeModelLegendNode (QgsLayerTreeLayer *nodeL, QObject *parent=nullptr) | |
Construct the node with pointer to its parent layer node. More... | |
QgsRenderContext * | createTemporaryRenderContext () const |
Returns a temporary context or nullptr if legendMapViewData are not valid. More... | |
Protected Attributes inherited from QgsLayerTreeModelLegendNode | |
bool | mColumnBreakBeforeNode = false |
bool | mEmbeddedInParent |
QgsLayerTreeLayer * | mLayerNode = nullptr |
QgsLegendPatchShape | mPatchShape |
QString | mUserLabel |
QSizeF | mUserSize |
A legend node which renders a color ramp.
Definition at line 34 of file qgscolorramplegendnode.h.
QgsColorRampLegendNode::QgsColorRampLegendNode | ( | QgsLayerTreeLayer * | nodeLayer, |
QgsColorRamp * | ramp, | ||
const QString & | minimumLabel, | ||
const QString & | maximumLabel, | ||
QObject * | parent = nullptr |
||
) |
Constructor for QgsColorRampLegendNode.
nodeLayer | layer node |
ramp | color ramp to render in node. Ownership is transferred to the node. |
minimumLabel | label text to render for the minimum value in the ramp |
maximumLabel | label text to render for the maximum value in the ramp |
parent | attach a parent QObject to the legend node. |
Definition at line 25 of file qgscolorramplegendnode.cpp.
QgsColorRampLegendNode::QgsColorRampLegendNode | ( | QgsLayerTreeLayer * | nodeLayer, |
QgsColorRamp * | ramp, | ||
const QgsColorRampLegendNodeSettings & | settings, | ||
double | minimumValue, | ||
double | maximumValue, | ||
QObject * | parent = nullptr |
||
) |
Constructor for QgsColorRampLegendNode.
nodeLayer | layer node |
ramp | color ramp to render in node. Ownership is transferred to the node. |
settings | node settings |
minimumValue | value associated with minimum of ramp |
maximumValue | value associated with maximum of ramp |
parent | attach a parent QObject to the legend node. |
Definition at line 35 of file qgscolorramplegendnode.cpp.
|
overridevirtual |
Returns data associated with the item. Must be implemented in derived class.
Implements QgsLayerTreeModelLegendNode.
Definition at line 86 of file qgscolorramplegendnode.cpp.
|
overridevirtual |
Draws symbol on the left side of the item.
settings | Legend layout configuration |
ctx | Context for rendering - may be nullptr if only doing layout without actual rendering |
itemHeight | Minimal height of the legend item - used for correct positioning when rendering |
Reimplemented from QgsLayerTreeModelLegendNode.
Definition at line 179 of file qgscolorramplegendnode.cpp.
|
overridevirtual |
Draws label on the right side of the item.
settings | Legend layout configuration |
ctx | Context for rendering - may be nullptr if only doing layout without actual rendering |
symbolSize | Real size of the associated symbol - used for correct positioning when rendering |
Reimplemented from QgsLayerTreeModelLegendNode.
Definition at line 383 of file qgscolorramplegendnode.cpp.
|
inline |
Returns the icon size, which is how large the ramp will render in a layer tree widget.
Definition at line 82 of file qgscolorramplegendnode.h.
const QgsColorRamp * QgsColorRampLegendNode::ramp | ( | ) | const |
Returns the color ramp used by the node.
Definition at line 53 of file qgscolorramplegendnode.cpp.
|
inline |
Set the icon size, which controls how large the ramp will render in a layer tree widget.
Definition at line 75 of file qgscolorramplegendnode.h.
void QgsColorRampLegendNode::setSettings | ( | const QgsColorRampLegendNodeSettings & | settings | ) |
Sets the node's settings.
Definition at line 63 of file qgscolorramplegendnode.cpp.
QgsColorRampLegendNodeSettings QgsColorRampLegendNode::settings | ( | ) | const |
Returns the node's settings.
Definition at line 58 of file qgscolorramplegendnode.cpp.