QGIS API Documentation  2.99.0-Master (7d4f81d)
qgssinglebandpseudocolorrendererwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssinglebandpseudocolorrendererwidget.h
3  ----------------------------------------
4  begin : February 2012
5  copyright : (C) 2012 by Marco Hugentobler
6  email : marco at sourcepole dot ch
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 QGSSINGLEBANDCOLORRENDERERWIDGET_H
19 #define QGSSINGLEBANDCOLORRENDERERWIDGET_H
20 
22 #include "qgis_sip.h"
23 #include "qgscolorrampshader.h"
24 #include "qgsrasterrenderer.h"
25 #include "ui_qgssinglebandpseudocolorrendererwidgetbase.h"
26 #include "qgis_gui.h"
27 
29 
33 class GUI_EXPORT QgsSingleBandPseudoColorRendererWidget: public QgsRasterRendererWidget, private Ui::QgsSingleBandPseudoColorRendererWidgetBase
34 {
35 
36  Q_OBJECT
37 
38  public:
39 
41 
42  static QgsRasterRendererWidget *create( QgsRasterLayer *layer, const QgsRectangle &extent ) SIP_FACTORY { return new QgsSingleBandPseudoColorRendererWidget( layer, extent ); }
43  QgsRasterRenderer *renderer() override;
44  void setMapCanvas( QgsMapCanvas *canvas ) override;
45  void doComputations() override;
46  QgsRasterMinMaxWidget *minMaxWidget() override { return mMinMaxWidget; }
47 
48  void setFromRenderer( const QgsRasterRenderer *r );
49 
50  public slots:
51 
54  void classify();
56  void loadMinMax( int bandNo, double min, double max );
57 
58  private:
59 
60  enum Column
61  {
62  ValueColumn = 0,
63  ColorColumn = 1,
64  LabelColumn = 2,
65  };
66 
67  void populateColormapTreeWidget( const QList<QgsColorRampShader::ColorRampItem> &colorRampItems );
68 
73  void autoLabel();
74 
76  void setUnitFromLabels();
77 
78  QMenu *contextMenu = nullptr;
79 
80  private slots:
81 
82  void applyColorRamp();
83  void on_mAddEntryButton_clicked();
84  void on_mDeleteEntryButton_clicked();
85  void on_mLoadFromBandButton_clicked();
86  void on_mLoadFromFileButton_clicked();
87  void on_mExportToFileButton_clicked();
88  void on_mUnitLineEdit_textEdited( const QString &text ) { Q_UNUSED( text ); autoLabel(); }
89  void on_mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
90  void mColormapTreeWidget_itemEdited( QTreeWidgetItem *item, int column );
91  void bandChanged();
92  void on_mColorInterpolationComboBox_currentIndexChanged( int index );
93  void on_mMinLineEdit_textChanged( const QString & ) { resetClassifyButton(); }
94  void on_mMaxLineEdit_textChanged( const QString & ) { resetClassifyButton(); }
95  void on_mMinLineEdit_textEdited( const QString &text ) ;
96  void on_mMaxLineEdit_textEdited( const QString &text ) ;
97  void on_mClassificationModeComboBox_currentIndexChanged( int index );
98  void changeColor();
99  void changeOpacity();
100 
101  private:
102 
103  void setLineEditValue( QLineEdit *lineEdit, double value );
104  double lineEditValue( const QLineEdit *lineEdit ) const;
105  void resetClassifyButton();
106  QgsRasterMinMaxWidget *mMinMaxWidget = nullptr;
107  bool mDisableMinMaxWidgetRefresh;
108  int mMinMaxOrigin;
109 
110  void minMaxModified();
111 };
112 
113 
114 #endif // QGSSINGLEBANDCOLORRENDERERWIDGET_H
A rectangle specified with double values.
Definition: qgsrectangle.h:38
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:73
virtual void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
QgsRasterMinMaxWidget * minMaxWidget() override
Return min/max widget when it exists.
static QgsRasterRendererWidget * create(QgsRasterLayer *layer, const QgsRectangle &extent)
#define SIP_FACTORY
Definition: qgis_sip.h:69
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
Definition: MathUtils.cc:452
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
Definition: MathUtils.cc:437
virtual void doComputations()
Load programmatically with current values.
virtual QgsRasterRenderer * renderer()=0
Raster renderer pipe that applies colors to a raster.