QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 
41 class GUI_EXPORT QgsRasterHistogramWidget : public QgsMapLayerConfigWidget, private Ui::QgsRasterHistogramWidgetBase
42 {
43  Q_OBJECT
44 
45  public:
46 
50  QgsRasterHistogramWidget( QgsRasterLayer *layer, QWidget *parent SIP_TRANSFERTHIS = nullptr );
51 
53  bool histoSaveAsImage( const QString &filename, int width = 600, int height = 600, int quality = -1 );
54 
56  void setRendererWidget( const QString &name, QgsRasterRendererWidget *rendererWidget = nullptr );
57 
59  void setActive( bool activeFlag );
60 
62  bool computeHistogram( bool forceComputeFlag );
63 
65  void histoAction( const QString &actionName, bool actionFlag = true );
66 
68  void setSelectedBand( int index );
69 
70  public slots:
72  void refreshHistogram();
73 
74  void apply() override;
75 
76  private slots:
78  void mSaveAsImageButton_clicked();
80  void cboHistoBand_currentIndexChanged( int );
82  void applyHistoMin();
83  void applyHistoMax();
85  void btnHistoMin_toggled();
86  void btnHistoMax_toggled();
88  void histoPickerSelected( QPointF );
89 
94  void histoPickerSelectedQwt5( QwtDoublePoint ) SIP_SKIP;
96  void histoActionTriggered( QAction * );
98  void updateHistoMarkers();
100  void btnHistoCompute_clicked();
101 
102  private:
103 
104  enum HistoShowBands
105  {
106  ShowAll = 0,
107  ShowSelected = 1,
108  ShowRGB = 2
109  };
110 
112  QgsRasterLayer *mRasterLayer = nullptr;
114  QgsRasterRendererWidget *mRendererWidget = nullptr;
116  QString mRendererName;
117 
118  QwtPlotPicker *mHistoPicker = nullptr;
119  QwtPlotZoomer *mHistoZoomer = nullptr;
120  QwtPlotMarker *mHistoMarkerMin = nullptr;
121  QwtPlotMarker *mHistoMarkerMax = nullptr;
122  double mHistoMin;
123  double mHistoMax;
124  QVector<QColor> mHistoColors;
125  bool mHistoShowMarkers;
126  bool mHistoZoomToMinMax;
127  bool mHistoUpdateStyleToMinMax;
128  bool mHistoDrawLines;
129  /* bool mHistoLoadApplyAll; */
130  HistoShowBands mHistoShowBands;
132  QList< int > histoSelectedBands();
134  QList< int > rendererSelectedBands();
135  QPair< QString, QString > rendererMinMax( int bandNo );
136 };
137 #endif
A panel widget that can be shown in the map style dock.
virtual void apply()=0
Called when changes to the layer need to be made.
Represents a raster layer.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_SKIP
Definition: qgis_sip.h:126
QPointF QwtDoublePoint