QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
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
45class GUI_EXPORT QgsColorRampShaderWidget: public QWidget, protected Ui::QgsColorRampShaderWidgetBase
46{
47
48 Q_OBJECT
49
50 public:
51
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:
107
109 void populateColormapTreeWidget( const QList<QgsColorRampShader::ColorRampItem> &colorRampItems );
110
111 private:
112
113 enum Column
114 {
115 ValueColumn = 0,
116 ColorColumn = 1,
117 LabelColumn = 2,
118 };
119
125 void autoLabel();
126
128 bool colormapMinMax( double &min, double &max ) const;
129
131 void setUnitFromLabels();
132
133 QMenu *contextMenu = nullptr;
134
135 private slots:
136
137 void applyColorRamp();
138 void updateColorRamp();
139 void mAddEntryButton_clicked();
140 void mDeleteEntryButton_clicked();
141 void mLoadFromBandButton_clicked();
142 void mLoadFromFileButton_clicked();
143 void mExportToFileButton_clicked();
144 void mUnitLineEdit_textEdited( const QString &text );
145 void mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
146 void mColormapTreeWidget_itemEdited( QTreeWidgetItem *item, int column );
147 void mColorInterpolationComboBox_currentIndexChanged( int index );
148 void mClassificationModeComboBox_currentIndexChanged( int index );
149 void changeColor();
150 void changeOpacity();
151 void showLegendSettings();
152
153 private:
154 void setLineEditValue( QLineEdit *lineEdit, double value );
155 double lineEditValue( const QLineEdit *lineEdit ) const;
156 void resetClassifyButton();
157
158 QString createLabel( QTreeWidgetItem *item, int row, const QString unit );
159
160#ifdef QGISDEBUG
162 void dumpClasses();
163#endif
164
165 double mMin = std::numeric_limits<double>::quiet_NaN();
166 double mMax = std::numeric_limits<double>::quiet_NaN();
167
168 // For mode with raster layer
169 QPointer< QgsRasterDataProvider > mRasterDataProvider;
170 int mBand = -1;
171 QgsRectangle mExtent;
172 QgsLocaleAwareNumericLineEditDelegate *mValueDelegate = nullptr;
173 QgsColorRampLegendNodeSettings mLegendSettings;
174
175 int mBlockChanges = 0;
176
177
178};
179
180#endif // QGSCOLORRAMPSHADERWIDGET_H
ShaderClassificationMethod
Color ramp shader classification methods.
Definition qgis.h:1350
Settings for a color ramp legend node.
It has 2 ways how to use it.
~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.