QGIS API Documentation  2.99.0-Master (bdf46d7)
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 
23 #include "qgis_gui.h"
24 
25 class QgsRasterLayer;
27 class QwtPlotPicker;
28 class QwtPlotMarker;
29 class QwtPlotZoomer;
30 
31 // fix for qwt5/qwt6 QwtDoublePoint vs. QPointF
32 typedef QPointF QwtDoublePoint;
33 
38 class GUI_EXPORT QgsRasterHistogramWidget : public QgsMapLayerConfigWidget, private Ui::QgsRasterHistogramWidgetBase
39 {
40  Q_OBJECT
41 
42  public:
43  QgsRasterHistogramWidget( QgsRasterLayer *lyr, QWidget *parent = nullptr );
44 
46  bool histoSaveAsImage( const QString &filename, int width = 600, int height = 600, int quality = -1 );
47 
49  void setRendererWidget( const QString &name, QgsRasterRendererWidget *rendererWidget = nullptr );
50 
52  void setActive( bool activeFlag );
53 
55  bool computeHistogram( bool forceComputeFlag );
56 
58  void histoAction( const QString &actionName, bool actionFlag = true );
59 
61  void setSelectedBand( int index );
62 
63  public slots:
65  void refreshHistogram();
67  void on_mSaveAsImageButton_clicked();
68 
69  void apply() override;
70 
71  private slots:
73  void on_cboHistoBand_currentIndexChanged( int );
75  void applyHistoMin();
76  void applyHistoMax();
78  void on_btnHistoMin_toggled();
79  void on_btnHistoMax_toggled();
81  void histoPickerSelected( QPointF );
82 
86  void histoPickerSelectedQwt5( QwtDoublePoint );
88  void histoActionTriggered( QAction * );
90  void updateHistoMarkers();
92  void on_btnHistoCompute_clicked();
93 
94  private:
95 
96  enum HistoShowBands
97  {
98  ShowAll = 0,
99  ShowSelected = 1,
100  ShowRGB = 2
101  };
102 
104  QgsRasterLayer *mRasterLayer = nullptr;
106  QgsRasterRendererWidget *mRendererWidget = nullptr;
108  QString mRendererName;
109 
110  QwtPlotPicker *mHistoPicker = nullptr;
111  QwtPlotZoomer *mHistoZoomer = nullptr;
112  QwtPlotMarker *mHistoMarkerMin = nullptr;
113  QwtPlotMarker *mHistoMarkerMax = nullptr;
114  double mHistoMin;
115  double mHistoMax;
116  QVector<QColor> mHistoColors;
117  bool mHistoShowMarkers;
118  bool mHistoZoomToMinMax;
119  bool mHistoUpdateStyleToMinMax;
120  bool mHistoDrawLines;
121  /* bool mHistoLoadApplyAll; */
122  HistoShowBands mHistoShowBands;
124  QList< int > histoSelectedBands();
126  QList< int > rendererSelectedBands();
127  QPair< QString, QString > rendererMinMax( int bandNo );
128 };
129 #endif
A panel widget that can be shown in the map style dock.
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.
QPointF QwtDoublePoint
QPointF QwtDoublePoint