QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "qgsconfig.h"
22#include "ui_qgscolorrampshaderwidgetbase.h"
23
24#include "qgis_gui.h"
25#include "qgis_sip.h"
27#include "qgscolorrampshader.h"
28#include "qgsrectangle.h"
29
30#include <QPointer>
31#include <QStyledItemDelegate>
32
34class QgsLocaleAwareNumericLineEditDelegate;
35
49class GUI_EXPORT QgsColorRampShaderWidget : public QWidget, protected Ui::QgsColorRampShaderWidgetBase
50{
51 Q_OBJECT
52
53 public:
55 QgsColorRampShaderWidget( QWidget *parent = nullptr );
57
60
63
65 void setRasterBand( int band );
66
68 void setExtent( const QgsRectangle &extent );
69
71 void setMinimumMaximumAndClassify( double minimum, double maximum );
72
74 void setMinimumMaximum( double minimum, double maximum );
75
77 double minimum() const;
78
80 double maximum() const;
81
84
86 void setFromShader( const QgsColorRampShader &colorRampShader );
87
88 signals:
91
94
97
98 public slots:
99
103 void classify();
104
107
108 protected:
110 void populateColormapTreeWidget( const QList<QgsColorRampShader::ColorRampItem> &colorRampItems );
111
112 private:
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#endif // QGSCOLORRAMPSHADERWIDGET_H
ShaderClassificationMethod
Color ramp shader classification methods.
Definition qgis.h:1440
Settings for a color ramp legend node.
~QgsColorRampShaderWidget() override
void setExtent(const QgsRectangle &extent)
Sets extent, only when used for raster layer.
void setMinimumMaximumAndClassify(double minimum, double maximum)
Sets min max and classify color tree.
void initializeForUseWithRasterLayer()
Allows quantile classification mode for raster layers.
void classificationModeChanged(Qgis::ShaderClassificationMethod mode)
Classification mode changed.
void populateColormapTreeWidget(const QList< QgsColorRampShader::ColorRampItem > &colorRampItems)
Populates color ramp tree from ramp items.
QgsColorRampShaderWidget(QWidget *parent=nullptr)
Creates new color ramp shader widget.
void minimumMaximumChangedFromTree(double minimum, double maximum)
Color ramp tree has changed.
void classify()
Executes the single band pseudo raster classification.
void widgetChanged()
Widget changed.
double minimum() const
Gets min value.
void setFromShader(const QgsColorRampShader &colorRampShader)
Sets widget state from the color ramp shader.
double maximum() const
Gets max value.
void setMinimumMaximum(double minimum, double maximum)
Sets min max.
QgsColorRampShader shader() const
Returns shared function used in the renderer.
void setRasterBand(int band)
Sets raster band, only when used for raster layer.
void setRasterDataProvider(QgsRasterDataProvider *dp)
Associates raster with the widget, only when used for raster layer.
void loadMinimumMaximumFromTree()
Loads min and max values from color ramp tree.
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.