QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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:
38
48 const QString &minimumLabel, const QString &maximumLabel, QObject *parent SIP_TRANSFERTHIS = nullptr );
49
60 const QgsColorRampLegendNodeSettings &settings, double minimumValue,
61 double maximumValue, QObject *parent SIP_TRANSFERTHIS = nullptr );
62
63
64 QVariant data( int role ) const override;
65 QSizeF drawSymbol( const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight ) const override;
66 QSizeF drawSymbolText( const QgsLegendSettings &settings, ItemContext *ctx, QSizeF symbolSize ) const override;
67
73 void setIconSize( QSize size ) { mIconSize = size; }
74
80 QSize iconSize() const { return mIconSize; }
81
85 const QgsColorRamp *ramp() const;
86
92 QgsColorRampLegendNodeSettings settings() const;
93
99 void setSettings( const QgsColorRampLegendNodeSettings &settings );
100
101 private:
102 void init( QgsLayerTreeLayer *nodeLayer );
103
104 QString labelForMinimum() const;
105 QString labelForMaximum() const;
106
107 std::unique_ptr< QgsColorRamp > mRamp;
108
109 mutable QPixmap mPixmap; // cached symbol preview
110 QSize mIconSize;
111
113 double mMinimumValue = 0;
114 double mMaximumValue = 0;
115
116};
117
118
119
120#endif // QGSCOLORRAMPLEGENDNODE_H
Settings for a color ramp legend node.
A legend node which renders a color ramp.
QSize iconSize() const
Returns the icon size, which is how large the ramp will render in a layer tree widget.
void setIconSize(QSize size)
Set the icon size, which controls how large the ramp will render in a layer tree widget.
Abstract base class for color ramps.
Definition: qgscolorramp.h:30
Layer tree node points to a map layer.
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
virtual QVariant data(int role) const =0
Returns data associated with the item. Must be implemented in derived class.
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.
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_TRANSFER
Definition: qgis_sip.h:36