QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgscolorramplegendnode.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscolorramplegendnode.h
3 --------------------------------------
4 Date : December 2020
5 Copyright : (C) 2020 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSCOLORRAMPLEGENDNODE_H
17#define QGSCOLORRAMPLEGENDNODE_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
23
24class QgsColorRamp;
25
33{
34 Q_OBJECT
35
36
37 public:
49 QgsLayerTreeLayer *nodeLayer,
51 const QString &minimumLabel,
52 const QString &maximumLabel,
53 QObject *parent SIP_TRANSFERTHIS = nullptr,
54 const QString &key = QString(),
55 const QString &parentKey = QString()
56 );
57
70 QgsLayerTreeLayer *nodeLayer,
73 double minimumValue,
74 double maximumValue,
75 QObject *parent SIP_TRANSFERTHIS = nullptr,
76 const QString &key = QString(),
77 const QString &parentKey = QString()
78 );
79
80
81 QVariant data( int role ) const override;
82 QSizeF drawSymbol( const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight ) const override;
83 QSizeF drawSymbolText( const QgsLegendSettings &settings, ItemContext *ctx, QSizeF symbolSize ) const override;
84 QJsonObject exportSymbolToJson( const QgsLegendSettings &settings, const QgsRenderContext &context ) const override;
85
91 void setIconSize( QSize size ) { mIconSize = size; }
92
98 QSize iconSize() const { return mIconSize; }
99
103 const QgsColorRamp *ramp() const;
104
110 QgsColorRampLegendNodeSettings settings() const;
111
117 void setSettings( const QgsColorRampLegendNodeSettings &settings );
118
124 void setMinimum( double minimum ) { mMinimumValue = minimum; };
125
131 void setMaximum( double maximum ) { mMaximumValue = maximum; };
132
138 double minimum() const { return mMinimumValue; };
139
145 double maximum() const { return mMaximumValue; };
146
147 private:
148 void init( QgsLayerTreeLayer *nodeLayer );
149
150 QString labelForMinimum() const;
151 QString labelForMaximum() const;
152
153 std::unique_ptr< QgsColorRamp > mRamp;
154
155 mutable QPixmap mPixmap; // cached symbol preview
156 QSize mIconSize;
157
159 double mMinimumValue = 0;
160 double mMaximumValue = 0;
161 QString mKey;
162 QString mParentKey;
163};
164
165
166#endif // QGSCOLORRAMPLEGENDNODE_H
Settings for a color ramp legend node.
const QgsColorRamp * ramp() const
Returns the color ramp used by the node.
QSize iconSize() const
Returns the icon size, which is how large the ramp will render in a layer tree widget.
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.
double maximum() const
Returns the node's maximum value.
double minimum() const
Returns the node's minimum value.
QgsColorRampLegendNodeSettings settings() const
Returns the node's settings.
void setIconSize(QSize size)
Set the icon size, which controls how large the ramp will render in a layer tree widget.
void setMinimum(double minimum)
Sets the node's minimum value.
void setMaximum(double maximum)
Sets the node's maximum value.
Abstract base class for color ramps.
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.
QgsLayerTreeModelLegendNode(QgsLayerTreeLayer *nodeL, QObject *parent=nullptr)
Construct the node with pointer to its parent layer node.
virtual QJsonObject exportSymbolToJson(const QgsLegendSettings &settings, const QgsRenderContext &context) const
Adds a symbol in base64 string within a JSON object with the key "icon".
virtual QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const
Draws symbol on the left side of the item.
virtual QSizeF drawSymbolText(const QgsLegendSettings &settings, ItemContext *ctx, QSizeF symbolSize) const
Draws label on the right side of the item.
Stores the appearance and layout settings for legend drawing with QgsLegendRenderer.
Contains information about the context of a rendering operation.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_TRANSFER
Definition qgis_sip.h:35