QGIS API Documentation  2.17.0-Master (dfeb663)
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 
21 #include "qgsrasterminmaxwidget.h"
23 #include "qgscolorrampshader.h"
24 #include "ui_qgssinglebandpseudocolorrendererwidgetbase.h"
25 
30  private Ui::QgsSingleBandPseudoColorRendererWidgetBase
31 {
32  Q_OBJECT
33  public:
34  enum Mode
35  {
36  Continuous = 1, // Using breaks from color palette
37  EqualInterval = 2,
38  Quantile = 3
39  };
40 
43 
44  static QgsRasterRendererWidget* create( QgsRasterLayer* layer, const QgsRectangle &theExtent ) { return new QgsSingleBandPseudoColorRendererWidget( layer, theExtent ); }
45  QgsRasterRenderer* renderer() override;
46  void setMapCanvas( QgsMapCanvas* canvas ) override;
47 
48  void setFromRenderer( const QgsRasterRenderer* r );
49 
50  public slots:
51  void loadMinMax( int theBandNo, double theMin, double theMax, int theOrigin );
52 
53  private:
54  enum Column
55  {
56  ValueColumn = 0,
57  ColorColumn = 1,
58  LabelColumn = 2,
59  };
60 
61  void populateColormapTreeWidget( const QList<QgsColorRampShader::ColorRampItem>& colorRampItems );
62  void autoLabel();
63  void setUnitFromLabels();
64 
65  private slots:
66  void on_mAddEntryButton_clicked();
67  void on_mDeleteEntryButton_clicked();
68  void on_mNumberOfEntriesSpinBox_valueChanged();
69  void on_mClassifyButton_clicked();
70  void on_mLoadFromBandButton_clicked();
71  void on_mLoadFromFileButton_clicked();
72  void on_mExportToFileButton_clicked();
73  void on_mUnitLineEdit_textEdited( const QString & text ) { Q_UNUSED( text ); autoLabel(); }
74  void on_mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem* item, int column );
75  void mColormapTreeWidget_itemEdited( QTreeWidgetItem* item, int column );
76  void on_mBandComboBox_currentIndexChanged( int index );
77  void on_mColorInterpolationComboBox_currentIndexChanged( int index );
78  void on_mMinLineEdit_textChanged( const QString & text ) { Q_UNUSED( text ); resetClassifyButton(); }
79  void on_mMaxLineEdit_textChanged( const QString & text ) { Q_UNUSED( text ); resetClassifyButton(); }
80  void on_mMinLineEdit_textEdited( const QString & text ) { Q_UNUSED( text ); mMinMaxOrigin = QgsRasterRenderer::MinMaxUser; showMinMaxOrigin(); }
81  void on_mMaxLineEdit_textEdited( const QString & text ) { Q_UNUSED( text ); mMinMaxOrigin = QgsRasterRenderer::MinMaxUser; showMinMaxOrigin(); }
82  void on_mClassificationModeComboBox_currentIndexChanged( int index );
83  void on_mColorRampComboBox_currentIndexChanged( int index );
84 
85  private:
86  void setLineEditValue( QLineEdit *theLineEdit, double theValue );
87  double lineEditValue( const QLineEdit *theLineEdit ) const;
88  void resetClassifyButton();
89  void showMinMaxOrigin();
90  QgsRasterMinMaxWidget * mMinMaxWidget;
91  int mMinMaxOrigin;
92 };
93 
97 class GUI_EXPORT QgsTreeWidgetItem: public QObject, public QTreeWidgetItem
98 {
99  Q_OBJECT
100  public:
102  explicit QgsTreeWidgetItem( QTreeWidget * parent, int type = Type ) : QTreeWidgetItem( parent, type ) {}
103 
105  virtual void setData( int column, int role, const QVariant & value );
106  virtual bool operator< ( const QTreeWidgetItem & other ) const;
107 
108  signals:
110  void itemEdited( QTreeWidgetItem* item, int column );
111 };
112 
113 #endif // QGSSINGLEBANDCOLORRENDERERWIDGET_H
static unsigned index
A rectangle specified with double values.
Definition: qgsrectangle.h:35
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
virtual void setData(int column, int role, const QVariant &value)
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:109
virtual void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
virtual bool operator<(const QTreeWidgetItem &other) const
QgsTreeWidgetItem(QTreeWidget *parent, int type=Type)
Constructs a tree widget item of the specified type and appends it to the items in the given parent...
static QgsRasterRendererWidget * create(QgsRasterLayer *layer, const QgsRectangle &theExtent)
Custom QTreeWidgetItem with extra signal when item is edited and numeric sorting. ...
virtual QgsRasterRenderer * renderer()=0
Raster renderer pipe that applies colors to a raster.