QGIS API Documentation  2.99.0-Master (b681b7b)
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 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000
33 typedef QPointF QwtDoublePoint;
34 #endif
35 
41 class GUI_EXPORT QgsRasterHistogramWidget : public QgsMapLayerConfigWidget, private Ui::QgsRasterHistogramWidgetBase
42 {
43  Q_OBJECT
44 
45  public:
46  QgsRasterHistogramWidget( QgsRasterLayer *lyr, QWidget *parent = nullptr );
47 
49  bool histoSaveAsImage( const QString& filename, int width = 600, int height = 600, int quality = -1 );
50 
52  void setRendererWidget( const QString& name, QgsRasterRendererWidget* rendererWidget = nullptr );
53 
55  void setActive( bool activeFlag );
56 
58  bool computeHistogram( bool forceComputeFlag );
59 
61  void histoAction( const QString &actionName, bool actionFlag = true );
62 
64  void setSelectedBand( int index );
65 
66  public slots:
68  void refreshHistogram();
70  void on_mSaveAsImageButton_clicked();
71 
72  void apply() override;
73 
74  private slots:
76  void on_cboHistoBand_currentIndexChanged( int );
78  void applyHistoMin();
79  void applyHistoMax();
81  void on_btnHistoMin_toggled();
82  void on_btnHistoMax_toggled();
84  void histoPickerSelected( QPointF );
85 
89  void histoPickerSelectedQwt5( QwtDoublePoint );
91  void histoActionTriggered( QAction* );
93  void updateHistoMarkers();
95  void on_btnHistoCompute_clicked();
96 
97  private:
98 
99  enum HistoShowBands
100  {
101  ShowAll = 0,
102  ShowSelected = 1,
103  ShowRGB = 2
104  };
105 
107  QgsRasterLayer * mRasterLayer = nullptr;
109  QgsRasterRendererWidget* mRendererWidget = nullptr;
111  QString mRendererName;
112 
113  QwtPlotPicker* mHistoPicker = nullptr;
114  QwtPlotZoomer* mHistoZoomer = nullptr;
115  QwtPlotMarker* mHistoMarkerMin = nullptr;
116  QwtPlotMarker* mHistoMarkerMax = nullptr;
117  double mHistoMin;
118  double mHistoMax;
119  QVector<QColor> mHistoColors;
120  bool mHistoShowMarkers;
121  bool mHistoZoomToMinMax;
122  bool mHistoUpdateStyleToMinMax;
123  bool mHistoDrawLines;
124  /* bool mHistoLoadApplyAll; */
125  HistoShowBands mHistoShowBands;
127  QList< int > histoSelectedBands();
129  QList< int > rendererSelectedBands();
130  QPair< QString, QString > rendererMinMax( int bandNo );
131 };
132 #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.