QGIS API Documentation  2.99.0-Master (19b062c)
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 
34 class GUI_EXPORT QgsSingleBandPseudoColorRendererWidget: public QgsRasterRendererWidget, private Ui::QgsSingleBandPseudoColorRendererWidgetBase
35 {
36 
37  Q_OBJECT
38 
39  public:
40 
42 
43  static QgsRasterRendererWidget *create( QgsRasterLayer *layer, const QgsRectangle &extent ) SIP_FACTORY { return new QgsSingleBandPseudoColorRendererWidget( layer, extent ); }
44  QgsRasterRenderer *renderer() override;
45  void setMapCanvas( QgsMapCanvas *canvas ) override;
46  void doComputations() override;
47  QgsRasterMinMaxWidget *minMaxWidget() override { return mMinMaxWidget; }
48 
49  void setFromRenderer( const QgsRasterRenderer *r );
50 
51  public slots:
52 
56  void classify();
58  void loadMinMax( int bandNo, double min, double max );
59 
60  private:
61 
62  enum Column
63  {
64  ValueColumn = 0,
65  ColorColumn = 1,
66  LabelColumn = 2,
67  };
68 
69  void populateColormapTreeWidget( const QList<QgsColorRampShader::ColorRampItem> &colorRampItems );
70 
76  void autoLabel();
77 
79  void setUnitFromLabels();
80 
81  QMenu *contextMenu = nullptr;
82 
83  private slots:
84 
85  void applyColorRamp();
86  void mAddEntryButton_clicked();
87  void mDeleteEntryButton_clicked();
88  void mLoadFromBandButton_clicked();
89  void mLoadFromFileButton_clicked();
90  void mExportToFileButton_clicked();
91  void mUnitLineEdit_textEdited( const QString &text ) { Q_UNUSED( text ); autoLabel(); }
92  void mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
93  void mColormapTreeWidget_itemEdited( QTreeWidgetItem *item, int column );
94  void bandChanged();
95  void mColorInterpolationComboBox_currentIndexChanged( int index );
96  void mMinLineEdit_textChanged( const QString & ) { resetClassifyButton(); }
97  void mMaxLineEdit_textChanged( const QString & ) { resetClassifyButton(); }
98  void mMinLineEdit_textEdited( const QString &text );
99  void mMaxLineEdit_textEdited( const QString &text );
100  void mClassificationModeComboBox_currentIndexChanged( int index );
101  void changeColor();
102  void changeOpacity();
103 
104  private:
105 
106  void setLineEditValue( QLineEdit *lineEdit, double value );
107  double lineEditValue( const QLineEdit *lineEdit ) const;
108  void resetClassifyButton();
109  QgsRasterMinMaxWidget *mMinMaxWidget = nullptr;
110  bool mDisableMinMaxWidgetRefresh;
111  int mMinMaxOrigin;
112 
113  void minMaxModified();
114 };
115 
116 
117 #endif // QGSSINGLEBANDCOLORRENDERERWIDGET_H
A rectangle specified with double values.
Definition: qgsrectangle.h:39
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:74
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
virtual void doComputations()
Load programmatically with current values.
virtual QgsRasterRenderer * renderer()=0
Raster renderer pipe that applies colors to a raster.