QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 "qgis_sip.h"
22 #include "qgscolorrampshader.h"
23 #include "qgsrasterrenderer.h"
24 #include "qgscolorschemelist.h"
25 #include "ui_qgscolorrampshaderwidgetbase.h"
26 #include "qgis_gui.h"
28 
30 
42 class GUI_EXPORT QgsColorRampShaderWidget: public QWidget, protected Ui::QgsColorRampShaderWidgetBase
43 {
44 
45  Q_OBJECT
46 
47  public:
48 
50  QgsColorRampShaderWidget( QWidget *parent = nullptr );
51 
53  void initializeForUseWithRasterLayer();
54 
56  void setRasterDataProvider( QgsRasterDataProvider *dp );
57 
59  void setRasterBand( int band );
60 
62  void setExtent( const QgsRectangle &extent );
63 
65  void setMinimumMaximumAndClassify( double minimum, double maximum );
66 
68  void setMinimumMaximum( double minimum, double maximum );
69 
71  double minimum() const;
72 
74  double maximum() const;
75 
77  QgsColorRampShader shader() const;
78 
80  void setFromShader( const QgsColorRampShader &colorRampShader );
81 
82  signals:
84  void minimumMaximumChangedFromTree( double minimum, double maximum );
85 
87  void widgetChanged();
88 
90  void classificationModeChanged( QgsColorRampShader::ClassificationMode mode );
91 
92  public slots:
93 
97  void classify();
98 
100  void loadMinimumMaximumFromTree();
101 
102  protected:
104  void populateColormapTreeWidget( const QList<QgsColorRampShader::ColorRampItem> &colorRampItems );
105 
106  private:
107 
108  enum Column
109  {
110  ValueColumn = 0,
111  ColorColumn = 1,
112  LabelColumn = 2,
113  };
114 
120  void autoLabel();
121 
123  void setUnitFromLabels();
124 
125  QMenu *contextMenu = nullptr;
126 
127  private slots:
128 
129  void applyColorRamp();
130  void mAddEntryButton_clicked();
131  void mDeleteEntryButton_clicked();
132  void mLoadFromBandButton_clicked();
133  void mLoadFromFileButton_clicked();
134  void mExportToFileButton_clicked();
135  void mUnitLineEdit_textEdited( const QString &text ) { Q_UNUSED( text ) autoLabel(); }
136  void mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
137  void mColormapTreeWidget_itemEdited( QTreeWidgetItem *item, int column );
138  void mColorInterpolationComboBox_currentIndexChanged( int index );
139  void mClassificationModeComboBox_currentIndexChanged( int index );
140  void changeColor();
141  void changeOpacity();
142 
143  private:
144  void setLineEditValue( QLineEdit *lineEdit, double value );
145  double lineEditValue( const QLineEdit *lineEdit ) const;
146  void resetClassifyButton();
147 
148  QgsColorSwatchDelegate *mSwatchDelegate = nullptr;
149 
150  double mMin = std::numeric_limits<double>::quiet_NaN();
151  double mMax = std::numeric_limits<double>::quiet_NaN();
152 
153  // For mode with raster layer
154  QgsRasterDataProvider *mRasterDataProvider = nullptr;
155  int mBand = -1;
156  QgsRectangle mExtent;
157 
158 };
159 
160 #endif // QGSCOLORRAMPSHADERWIDGET_H
QgsColorSwatchDelegate
Definition: qgscolorschemelist.h:36
QgsColorRampShaderWidget
Definition: qgscolorrampshaderwidget.h:42
qgscolorrampshader.h
qgsrasterrenderer.h
QgsColorRampShader
Definition: qgscolorrampshader.h:39
qgsrasterrendererwidget.h
QgsRectangle
Definition: qgsrectangle.h:41
qgis_sip.h
QgsColorRampShader::ClassificationMode
ClassificationMode
Classification modes used to create the color ramp shader.
Definition: qgscolorrampshader.h:53
QgsRasterDataProvider
Definition: qgsrasterdataprovider.h:88
qgscolorschemelist.h