QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 );
88  void histoPickerSelectedQwt5( QwtDoublePoint );
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;
108  QgsRasterRendererWidget* mRendererWidget;
110  QString mRendererName;
111 
112  QwtPlotPicker* mHistoPicker;
113  QwtPlotZoomer* mHistoZoomer;
114  QwtPlotMarker* mHistoMarkerMin;
115  QwtPlotMarker* mHistoMarkerMax;
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 theBandNo );
130 };
131 #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.