QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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"
22 #include "qgslegendsymbolitem.h"
23 #include "qgstextformat.h"
25 
26 class QgsColorRamp;
27 
35 {
36  Q_OBJECT
37 
38 
39  public:
40 
50  const QString &minimumLabel, const QString &maximumLabel, QObject *parent SIP_TRANSFERTHIS = nullptr );
51 
62  const QgsColorRampLegendNodeSettings &settings, double minimumValue,
63  double maximumValue, QObject *parent SIP_TRANSFERTHIS = nullptr );
64 
65 
66  QVariant data( int role ) const override;
67  QSizeF drawSymbol( const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight ) const override;
68  QSizeF drawSymbolText( const QgsLegendSettings &settings, ItemContext *ctx, QSizeF symbolSize ) const override;
69 
75  void setIconSize( QSize size ) { mIconSize = size; }
76 
82  QSize iconSize() const { return mIconSize; }
83 
87  const QgsColorRamp *ramp() const;
88 
94  QgsColorRampLegendNodeSettings settings() const;
95 
101  void setSettings( const QgsColorRampLegendNodeSettings &settings );
102 
103  private:
104  void init( QgsLayerTreeLayer *nodeLayer );
105 
106  QString labelForMinimum() const;
107  QString labelForMaximum() const;
108 
109  std::unique_ptr< QgsColorRamp > mRamp;
110 
111  mutable QPixmap mPixmap; // cached symbol preview
112  QSize mIconSize;
113 
115  double mMinimumValue = 0;
116  double mMaximumValue = 0;
117 
118 };
119 
120 
121 
122 #endif // QGSCOLORRAMPLEGENDNODE_H
QgsColorRamp
Abstract base class for color ramps.
Definition: qgscolorramp.h:29
qgslayertreemodellegendnode.h
QgsLayerTreeModelLegendNode::data
virtual QVariant data(int role) const =0
Returns data associated with the item. Must be implemented in derived class.
QgsLayerTreeModelLegendNode::drawSymbolText
virtual QSizeF drawSymbolText(const QgsLegendSettings &settings, ItemContext *ctx, QSizeF symbolSize) const
Draws label on the right side of the item.
Definition: qgslayertreemodellegendnode.cpp:167
QgsColorRampLegendNode
A legend node which renders a color ramp.
Definition: qgscolorramplegendnode.h:34
QgsLayerTreeLayer
Layer tree node points to a map layer.
Definition: qgslayertreelayer.h:43
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
qgslegendsymbolitem.h
QgsLegendSettings
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
Definition: qgslegendsettings.h:38
QgsColorRampLegendNode::setIconSize
void setIconSize(QSize size)
Set the icon size, which controls how large the ramp will render in a layer tree widget.
Definition: qgscolorramplegendnode.h:75
QgsLayerTreeModelLegendNode::ItemContext
Definition: qgslayertreemodellegendnode.h:168
qgscolorramplegendnodesettings.h
qgstextformat.h
QgsLayerTreeModelLegendNode::drawSymbol
virtual QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const
Draws symbol on the left side of the item.
Definition: qgslayertreemodellegendnode.cpp:110
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsColorRampLegendNodeSettings
Settings for a color ramp legend node.
Definition: qgscolorramplegendnodesettings.h:37
QgsColorRampLegendNode::iconSize
QSize iconSize() const
Returns the icon size, which is how large the ramp will render in a layer tree widget.
Definition: qgscolorramplegendnode.h:82
QgsLayerTreeModelLegendNode
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
Definition: qgslayertreemodellegendnode.h:49