QGIS API Documentation  3.0.2-Girona (307d082)
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 );
60  void loadMinMaxFromTree();
61 
62  private:
63 
64  enum Column
65  {
66  ValueColumn = 0,
67  ColorColumn = 1,
68  LabelColumn = 2,
69  };
70 
71  void populateColormapTreeWidget( const QList<QgsColorRampShader::ColorRampItem> &colorRampItems );
72 
78  void autoLabel();
79 
81  void setUnitFromLabels();
82 
83  QMenu *contextMenu = nullptr;
84 
85  private slots:
86 
87  void applyColorRamp();
88  void mAddEntryButton_clicked();
89  void mDeleteEntryButton_clicked();
90  void mLoadFromBandButton_clicked();
91  void mLoadFromFileButton_clicked();
92  void mExportToFileButton_clicked();
93  void mUnitLineEdit_textEdited( const QString &text ) { Q_UNUSED( text ); autoLabel(); }
94  void mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
95  void mColormapTreeWidget_itemEdited( QTreeWidgetItem *item, int column );
96  void bandChanged();
97  void mColorInterpolationComboBox_currentIndexChanged( int index );
98  void mMinLineEdit_textChanged( const QString & ) { resetClassifyButton(); }
99  void mMaxLineEdit_textChanged( const QString & ) { resetClassifyButton(); }
100  void mMinLineEdit_textEdited( const QString &text );
101  void mMaxLineEdit_textEdited( const QString &text );
102  void mClassificationModeComboBox_currentIndexChanged( int index );
103  void changeColor();
104  void changeOpacity();
105 
106  private:
107 
108  void setLineEditValue( QLineEdit *lineEdit, double value );
109  double lineEditValue( const QLineEdit *lineEdit ) const;
110  void resetClassifyButton();
111  QgsRasterMinMaxWidget *mMinMaxWidget = nullptr;
112  int mMinMaxOrigin;
113 
114  void minMaxModified();
115 };
116 
117 
118 #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.