QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
qgsgraduatedhistogramwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgraduatedhistogramwidget.h
3  -----------------------------
4  begin : May 2015
5  copyright : (C) 2015 by Nyall Dawson
6  email : nyall dot dawson 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 QGSGRADUATEDHISTOGRAMWIDGET_H
18 #define QGSGRADUATEDHISTOGRAMWIDGET_H
19 
20 #include "qgshistogramwidget.h"
21 #include "qgis_sip.h"
22 #include "qgis_gui.h"
23 
24 class QwtPlotPicker;
25 class QgsGraduatedHistogramEventFilter;
26 
37 {
38  Q_OBJECT
39 
40  public:
41 
46  QgsGraduatedHistogramWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
47 
53  void setRenderer( QgsGraduatedSymbolRenderer *renderer );
54 
55  signals:
56 
62  void rangesModified( bool rangesAdded );
63 
64  protected:
65 
66  void drawHistogram() override;
67 
68  private slots:
69 
70  void mousePress( double value );
71  void mouseRelease( double value );
72 
73  private:
74 
75  QgsGraduatedSymbolRenderer *mRenderer = nullptr;
76  QwtPlotPicker *mHistoPicker = nullptr;
77  QgsGraduatedHistogramEventFilter *mFilter = nullptr;
78  double mPressedValue = 0;
79 
80  void findClosestRange( double value, int &closestRangeIndex, int &pixelDistance ) const;
81 
82  QwtPlotHistogram *createPlotHistogram( const QString &title, const QColor &color ) const;
83 
84 };
85 
86 
87 #ifndef SIP_RUN
88 //
89 // NOTE:
90 // For private use by QgsGraduatedHistogramWidget only,
91 // not part of stable api or exposed to Python bindings
92 //
94 class GUI_EXPORT QgsGraduatedHistogramEventFilter: public QObject
95 {
96  Q_OBJECT
97 
98  public:
99 
100  QgsGraduatedHistogramEventFilter( QwtPlot *plot );
101 
102  bool eventFilter( QObject *object, QEvent *event ) override;
103 
104  signals:
105 
106  void mousePress( double );
107  void mouseRelease( double );
108 
109  private:
110 
111  QwtPlot *mPlot = nullptr;
112  double posToValue( QPointF point ) const;
113 };
115 #endif
116 
117 #endif //QGSGRADUATEDHISTOGRAMWIDGET_H
Graphical histogram for displaying distribution of field values and editing range breaks for a QgsGra...
void rangesModified(bool rangesAdded)
Emitted when the user modifies the graduated ranges using the histogram widget.
Graphical histogram for displaying distributions of field values.
virtual void drawHistogram()
Updates and redraws the histogram.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53