QGIS API Documentation  2.15.0-Master (02a0ebe)
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 
27  private Ui::QgsSingleBandPseudoColorRendererWidgetBase
28 {
29  Q_OBJECT
30  public:
31  enum Mode
32  {
33  Continuous = 1, // Using breaks from color palette
34  EqualInterval = 2,
35  Quantile = 3
36  };
37 
40 
41  static QgsRasterRendererWidget* create( QgsRasterLayer* layer, const QgsRectangle &theExtent ) { return new QgsSingleBandPseudoColorRendererWidget( layer, theExtent ); }
42  QgsRasterRenderer* renderer() override;
43 
44  void setFromRenderer( const QgsRasterRenderer* r );
45 
46  public slots:
47  void loadMinMax( int theBandNo, double theMin, double theMax, int theOrigin );
48 
49  private:
50  enum Column
51  {
52  ValueColumn = 0,
53  ColorColumn = 1,
54  LabelColumn = 2,
55  };
56 
57  void populateColormapTreeWidget( const QList<QgsColorRampShader::ColorRampItem>& colorRampItems );
58  void autoLabel();
59  void setUnitFromLabels();
60 
61  private slots:
62  void on_mAddEntryButton_clicked();
63  void on_mDeleteEntryButton_clicked();
64  void on_mNumberOfEntriesSpinBox_valueChanged();
65  void on_mClassifyButton_clicked();
66  void on_mLoadFromBandButton_clicked();
67  void on_mLoadFromFileButton_clicked();
68  void on_mExportToFileButton_clicked();
69  void on_mUnitLineEdit_textEdited( const QString & text ) { Q_UNUSED( text ); autoLabel(); }
70  void on_mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem* item, int column );
71  void mColormapTreeWidget_itemEdited( QTreeWidgetItem* item, int column );
72  void on_mBandComboBox_currentIndexChanged( int index );
73  void on_mColorInterpolationComboBox_currentIndexChanged( int index );
74  void on_mMinLineEdit_textChanged( const QString & text ) { Q_UNUSED( text ); resetClassifyButton(); }
75  void on_mMaxLineEdit_textChanged( const QString & text ) { Q_UNUSED( text ); resetClassifyButton(); }
76  void on_mMinLineEdit_textEdited( const QString & text ) { Q_UNUSED( text ); mMinMaxOrigin = QgsRasterRenderer::MinMaxUser; showMinMaxOrigin(); }
77  void on_mMaxLineEdit_textEdited( const QString & text ) { Q_UNUSED( text ); mMinMaxOrigin = QgsRasterRenderer::MinMaxUser; showMinMaxOrigin(); }
78  void on_mClassificationModeComboBox_currentIndexChanged( int index );
79  void on_mColorRampComboBox_currentIndexChanged( int index );
80 
81  private:
82  void setLineEditValue( QLineEdit *theLineEdit, double theValue );
83  double lineEditValue( const QLineEdit *theLineEdit ) const;
84  void resetClassifyButton();
85  void showMinMaxOrigin();
86  QgsRasterMinMaxWidget * mMinMaxWidget;
87  int mMinMaxOrigin;
88 };
89 
93 class GUI_EXPORT QgsTreeWidgetItem: public QObject, public QTreeWidgetItem
94 {
95  Q_OBJECT
96  public:
98  explicit QgsTreeWidgetItem( QTreeWidget * parent, int type = Type ) : QTreeWidgetItem( parent, type ) {}
99 
101  virtual void setData( int column, int role, const QVariant & value );
102  virtual bool operator< ( const QTreeWidgetItem & other ) const;
103 
104  signals:
106  void itemEdited( QTreeWidgetItem* item, int column );
107 };
108 
109 #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)
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.