QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
22 class QwtPlotPicker;
23 class QgsGraduatedHistogramEventFilter;
24 
34 {
35  Q_OBJECT
36 
37  public:
38 
42  QgsGraduatedHistogramWidget( QWidget *parent = nullptr );
44 
49  void setRenderer( QgsGraduatedSymbolRendererV2* renderer );
50 
51  signals:
52 
57  void rangesModified( bool rangesAdded );
58 
59  protected:
60 
61  virtual void drawHistogram() override;
62 
63  private slots:
64 
65  void mousePress( double value );
66  void mouseRelease( double value );
67 
68  private:
69 
71  QwtPlotPicker* mHistoPicker;
72  QgsGraduatedHistogramEventFilter* mFilter;
73  double mPressedValue;
74 
75  void findClosestRange( double value, int &closestRangeIndex, int &pixelDistance ) const;
76 
77 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000
78  QwtPlotHistogram* createPlotHistogram( const QString& title, const QColor& color ) const;
79 #else
80  HistogramItem* createHistoItem( const QString& title, const QColor& color ) const;
81 #endif
82 
83 };
84 
85 //
86 // NOTE:
87 // For private use by QgsGraduatedHistogramWidget only,
88 // not part of stable api or exposed to Python bindings
89 //
91 class GUI_EXPORT QgsGraduatedHistogramEventFilter: public QObject
92 {
93  Q_OBJECT
94 
95  public:
96 
97  QgsGraduatedHistogramEventFilter( QwtPlot *plot );
98 
99  virtual ~QgsGraduatedHistogramEventFilter() {}
100 
101  virtual bool eventFilter( QObject* object, QEvent* event ) override;
102 
103  signals:
104 
105  void mousePress( double );
106  void mouseRelease( double );
107 
108  private:
109 
110  QwtPlot* mPlot;
111  double posToValue( QPointF point ) const;
112 };
114 
115 #endif //QGSGRADUATEDHISTOGRAMWIDGET_H
Graphical histogram for displaying distribution of field values and editing range breaks for a QgsGra...
virtual bool eventFilter(QObject *watched, QEvent *event)
virtual void drawHistogram()
Updates and redraws the histogram.
Graphical histogram for displaying distributions of field values.