QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 Q_OBJECT
48
49 public:
51 QgsColorRampShaderWidget( QWidget *parent = nullptr );
53
55 void initializeForUseWithRasterLayer();
56
58 void setRasterDataProvider( QgsRasterDataProvider *dp );
59
61 void setRasterBand( int band );
62
64 void setExtent( const QgsRectangle &extent );
65
67 void setMinimumMaximumAndClassify( double minimum, double maximum );
68
70 void setMinimumMaximum( double minimum, double maximum );
71
73 double minimum() const;
74
76 double maximum() const;
77
79 QgsColorRampShader shader() const;
80
82 void setFromShader( const QgsColorRampShader &colorRampShader );
83
84 signals:
86 void minimumMaximumChangedFromTree( double minimum, double maximum );
87
90
93
94 public slots:
95
99 void classify();
100
102 void loadMinimumMaximumFromTree();
103
104 protected:
106 void populateColormapTreeWidget( const QList<QgsColorRampShader::ColorRampItem> &colorRampItems );
107
108 private:
109 enum Column
110 {
111 ValueColumn = 0,
112 ColorColumn = 1,
113 LabelColumn = 2,
114 };
115
121 void autoLabel();
122
124 bool colormapMinMax( double &min, double &max ) const;
125
127 void setUnitFromLabels();
128
129 QMenu *contextMenu = nullptr;
130
131 private slots:
132
133 void applyColorRamp();
134 void updateColorRamp();
135 void mAddEntryButton_clicked();
136 void mDeleteEntryButton_clicked();
137 void mLoadFromBandButton_clicked();
138 void mLoadFromFileButton_clicked();
139 void mExportToFileButton_clicked();
140 void mUnitLineEdit_textEdited( const QString &text );
141 void mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
142 void mColormapTreeWidget_itemEdited( QTreeWidgetItem *item, int column );
143 void mColorInterpolationComboBox_currentIndexChanged( int index );
144 void mClassificationModeComboBox_currentIndexChanged( int index );
145 void changeColor();
146 void changeOpacity();
147 void showLegendSettings();
148
149 private:
150 void setLineEditValue( QLineEdit *lineEdit, double value );
151 double lineEditValue( const QLineEdit *lineEdit ) const;
152 void resetClassifyButton();
153
154 QString createLabel( QTreeWidgetItem *item, int row, const QString unit );
155
156#ifdef QGISDEBUG
158 void dumpClasses();
159#endif
160
161 double mMin = std::numeric_limits<double>::quiet_NaN();
162 double mMax = std::numeric_limits<double>::quiet_NaN();
163
164 // For mode with raster layer
165 QPointer<QgsRasterDataProvider> mRasterDataProvider;
166 int mBand = -1;
167 QgsRectangle mExtent;
168 QgsLocaleAwareNumericLineEditDelegate *mValueDelegate = nullptr;
169 QgsColorRampLegendNodeSettings mLegendSettings;
170
171 int mBlockChanges = 0;
172};
173
174#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.