QGIS API Documentation  2.15.0-Master (972fc9f)
qgsrasterhistogramwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrasterrendererwidget.h
3  ---------------------------
4  begin : July 2012
5  copyright : (C) 2012 by Etienne Tourigny
6  email : etourigny dot dev at gmail dot com
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 #ifndef QGSRASTERHISTOGRAMWIDGET_H
18 #define QGSRASTERHISTOGRAMWIDGET_H
19 
20 #include "ui_qgsrasterhistogramwidgetbase.h"
21 
22 #include "qgsmapstylepanel.h"
23 
24 class QgsRasterLayer;
26 class QwtPlotPicker;
27 class QwtPlotMarker;
28 class QwtPlotZoomer;
29 
30 // fix for qwt5/qwt6 QwtDoublePoint vs. QPointF
31 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000
32 typedef QPointF QwtDoublePoint;
33 #endif
34 
39 class GUI_EXPORT QgsRasterHistogramWidget : public QgsLayerStylingPanel, private Ui::QgsRasterHistogramWidgetBase
40 {
41  Q_OBJECT
42 
43  public:
44  QgsRasterHistogramWidget( QgsRasterLayer *lyr, QWidget *parent = nullptr );
46 
48  bool histoSaveAsImage( const QString& theFilename, int width = 600, int height = 600, int quality = -1 );
49 
51  void setRendererWidget( const QString& name, QgsRasterRendererWidget* rendererWidget = nullptr );
52 
54  void setActive( bool theActiveFlag );
55 
57  bool computeHistogram( bool forceComputeFlag );
58 
60  void histoAction( const QString &actionName, bool actionFlag = true );
61 
63  void setSelectedBand( int index );
64 
65  public slots:
67  void refreshHistogram();
69  void on_mSaveAsImageButton_clicked();
70 
71  void apply() override;
72 
73  private slots:
75  void on_cboHistoBand_currentIndexChanged( int );
77  void applyHistoMin();
78  void applyHistoMax();
80  void on_btnHistoMin_toggled();
81  void on_btnHistoMax_toggled();
83  void histoPickerSelected( QPointF );
87  void histoPickerSelectedQwt5( QwtDoublePoint );
89  void histoActionTriggered( QAction* );
91  void updateHistoMarkers();
93  void on_btnHistoCompute_clicked();
94 
95  private:
96 
97  enum HistoShowBands
98  {
99  ShowAll = 0,
100  ShowSelected = 1,
101  ShowRGB = 2
102  };
103 
105  QgsRasterLayer * mRasterLayer;
107  QgsRasterRendererWidget* mRendererWidget;
109  QString mRendererName;
110 
111  QwtPlotPicker* mHistoPicker;
112  QwtPlotZoomer* mHistoZoomer;
113  QwtPlotMarker* mHistoMarkerMin;
114  QwtPlotMarker* mHistoMarkerMax;
115  double mHistoMin;
116  double mHistoMax;
117  QVector<QColor> mHistoColors;
118  bool mHistoShowMarkers;
119  bool mHistoZoomToMinMax;
120  bool mHistoUpdateStyleToMinMax;
121  bool mHistoDrawLines;
122  /* bool mHistoLoadApplyAll; */
123  HistoShowBands mHistoShowBands;
125  QList< int > histoSelectedBands();
127  QList< int > rendererSelectedBands();
128  QPair< QString, QString > rendererMinMax( int theBandNo );
129 };
130 #endif
static unsigned index
virtual void apply()=0
Called when changes to the layer need to be made.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
A panel widget that can be shown in the map style dock.