QGIS API Documentation  2.99.0-Master (009e47e)
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 #include "qgis_sip.h"
22 #include "qgis.h"
23 
25 #include "qgis_gui.h"
26 
27 class QgsRasterLayer;
29 class QwtPlotPicker;
30 class QwtPlotMarker;
31 class QwtPlotZoomer;
32 
33 // fix for qwt5/qwt6 QwtDoublePoint vs. QPointF
34 typedef QPointF QwtDoublePoint SIP_SKIP;
35 
40 class GUI_EXPORT QgsRasterHistogramWidget : public QgsMapLayerConfigWidget, private Ui::QgsRasterHistogramWidgetBase
41 {
42  Q_OBJECT
43 
44  public:
45  QgsRasterHistogramWidget( QgsRasterLayer *lyr, QWidget *parent SIP_TRANSFERTHIS = 0 );
46 
48  bool histoSaveAsImage( const QString &filename, int width = 600, int height = 600, int quality = -1 );
49 
51  void setRendererWidget( const QString &name, QgsRasterRendererWidget *rendererWidget = nullptr );
52 
54  void setActive( bool activeFlag );
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 );
84 
88  void histoPickerSelectedQwt5( QwtDoublePoint ) SIP_SKIP;
90  void histoActionTriggered( QAction * );
92  void updateHistoMarkers();
94  void on_btnHistoCompute_clicked();
95 
96  private:
97 
98  enum HistoShowBands
99  {
100  ShowAll = 0,
101  ShowSelected = 1,
102  ShowRGB = 2
103  };
104 
106  QgsRasterLayer *mRasterLayer = nullptr;
108  QgsRasterRendererWidget *mRendererWidget = nullptr;
110  QString mRendererName;
111 
112  QwtPlotPicker *mHistoPicker = nullptr;
113  QwtPlotZoomer *mHistoZoomer = nullptr;
114  QwtPlotMarker *mHistoMarkerMin = nullptr;
115  QwtPlotMarker *mHistoMarkerMax = nullptr;
116  double mHistoMin;
117  double mHistoMax;
118  QVector<QColor> mHistoColors;
119  bool mHistoShowMarkers;
120  bool mHistoZoomToMinMax;
121  bool mHistoUpdateStyleToMinMax;
122  bool mHistoDrawLines;
123  /* bool mHistoLoadApplyAll; */
124  HistoShowBands mHistoShowBands;
126  QList< int > histoSelectedBands();
128  QList< int > rendererSelectedBands();
129  QPair< QString, QString > rendererMinMax( int bandNo );
130 };
131 #endif
A panel widget that can be shown in the map style dock.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:34
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
#define SIP_SKIP
Definition: qgis_sip.h:107