QGIS API Documentation 3.43.0-Master (c67cf405802)
qgscolorrampshaderwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscolorrampshaderwidget.h
3 --------------------------
4 begin : Jun 2018
5 copyright : (C) 2018 by Peter Petrik
6 email : zilolv at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSCOLORRAMPSHADERWIDGET_H
19#define QGSCOLORRAMPSHADERWIDGET_H
20
21#include <QStyledItemDelegate>
22#include <QPointer>
23
24#include "qgis_sip.h"
25#include "qgis_gui.h"
27#include "qgsrectangle.h"
28#include "qgscolorrampshader.h"
29#include "ui_qgscolorrampshaderwidgetbase.h"
30
32class QgsLocaleAwareNumericLineEditDelegate;
33
47class GUI_EXPORT QgsColorRampShaderWidget : public QWidget, protected Ui::QgsColorRampShaderWidgetBase
48{
49 Q_OBJECT
50
51 public:
53 QgsColorRampShaderWidget( QWidget *parent = nullptr );
55
57 void initializeForUseWithRasterLayer();
58
60 void setRasterDataProvider( QgsRasterDataProvider *dp );
61
63 void setRasterBand( int band );
64
66 void setExtent( const QgsRectangle &extent );
67
69 void setMinimumMaximumAndClassify( double minimum, double maximum );
70
72 void setMinimumMaximum( double minimum, double maximum );
73
75 double minimum() const;
76
78 double maximum() const;
79
81 QgsColorRampShader shader() const;
82
84 void setFromShader( const QgsColorRampShader &colorRampShader );
85
86 signals:
88 void minimumMaximumChangedFromTree( double minimum, double maximum );
89
92
95
96 public slots:
97
101 void classify();
102
104 void loadMinimumMaximumFromTree();
105
106 protected:
108 void populateColormapTreeWidget( const QList<QgsColorRampShader::ColorRampItem> &colorRampItems );
109
110 private:
111 enum Column
112 {
113 ValueColumn = 0,
114 ColorColumn = 1,
115 LabelColumn = 2,
116 };
117
123 void autoLabel();
124
126 bool colormapMinMax( double &min, double &max ) const;
127
129 void setUnitFromLabels();
130
131 QMenu *contextMenu = nullptr;
132
133 private slots:
134
135 void applyColorRamp();
136 void updateColorRamp();
137 void mAddEntryButton_clicked();
138 void mDeleteEntryButton_clicked();
139 void mLoadFromBandButton_clicked();
140 void mLoadFromFileButton_clicked();
141 void mExportToFileButton_clicked();
142 void mUnitLineEdit_textEdited( const QString &text );
143 void mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
144 void mColormapTreeWidget_itemEdited( QTreeWidgetItem *item, int column );
145 void mColorInterpolationComboBox_currentIndexChanged( int index );
146 void mClassificationModeComboBox_currentIndexChanged( int index );
147 void changeColor();
148 void changeOpacity();
149 void showLegendSettings();
150
151 private:
152 void setLineEditValue( QLineEdit *lineEdit, double value );
153 double lineEditValue( const QLineEdit *lineEdit ) const;
154 void resetClassifyButton();
155
156 QString createLabel( QTreeWidgetItem *item, int row, const QString unit );
157
158#ifdef QGISDEBUG
160 void dumpClasses();
161#endif
162
163 double mMin = std::numeric_limits<double>::quiet_NaN();
164 double mMax = std::numeric_limits<double>::quiet_NaN();
165
166 // For mode with raster layer
167 QPointer<QgsRasterDataProvider> mRasterDataProvider;
168 int mBand = -1;
169 QgsRectangle mExtent;
170 QgsLocaleAwareNumericLineEditDelegate *mValueDelegate = nullptr;
171 QgsColorRampLegendNodeSettings mLegendSettings;
172
173 int mBlockChanges = 0;
174};
175
176#endif // QGSCOLORRAMPSHADERWIDGET_H
ShaderClassificationMethod
Color ramp shader classification methods.
Definition qgis.h:1403
Settings for a color ramp legend node.
A widget for configuring numeric ranges associated with a color ramp.
~QgsColorRampShaderWidget() override
void classificationModeChanged(Qgis::ShaderClassificationMethod mode)
Classification mode changed.
void minimumMaximumChangedFromTree(double minimum, double maximum)
Color ramp tree has changed.
void widgetChanged()
Widget changed.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Base class for raster data providers.
A rectangle specified with double values.