QGIS API Documentation  2.99.0-Master (c558d51)
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 
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 
40 class GUI_EXPORT QgsRasterHistogramWidget : public QgsMapLayerConfigWidget, private Ui::QgsRasterHistogramWidgetBase
41 {
42  Q_OBJECT
43 
44  public:
45  QgsRasterHistogramWidget( QgsRasterLayer *lyr, QWidget *parent = nullptr );
47 
49  bool histoSaveAsImage( const QString& theFilename, int width = 600, int height = 600, int quality = -1 );
50 
52  void setRendererWidget( const QString& name, QgsRasterRendererWidget* rendererWidget = nullptr );
53 
55  void setActive( bool theActiveFlag );
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;
109  QgsRasterRendererWidget* mRendererWidget;
111  QString mRendererName;
112 
113  QwtPlotPicker* mHistoPicker;
114  QwtPlotZoomer* mHistoZoomer;
115  QwtPlotMarker* mHistoMarkerMin;
116  QwtPlotMarker* mHistoMarkerMax;
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 theBandNo );
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.