QGIS API Documentation  3.24.2-Tisler (13c1a02865)
qgshistogram.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgshistogram.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 
18 #ifndef QGSHISTOGRAM_H
19 #define QGSHISTOGRAM_H
20 
21 #include <QList>
22 
23 #include "qgis_core.h"
24 #include "qgsfeedback.h"
25 
26 class QgsVectorLayer;
27 
28 
37 class CORE_EXPORT QgsHistogram
38 {
39  public:
40 
44  QgsHistogram() = default;
45 
46  virtual ~QgsHistogram() = default;
47 
52  void setValues( const QList<double> &values );
53 
62  bool setValues( const QgsVectorLayer *layer, const QString &fieldOrExpression, QgsFeedback *feedback = nullptr );
63 
71  double optimalBinWidth() const;
72 
81  int optimalNumberBins() const;
82 
90  QList<double> binEdges( int bins ) const;
91 
98  QList<int> counts( int bins ) const;
99 
100  private:
101 
102  QList<double> mValues;
103  double mMax = 0;
104  double mMin = 0;
105  double mIQR = 0;
106 
107  void prepareValues();
108 
109 };
110 
111 #endif // QGSHISTOGRAM_H
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
Calculator for a numeric histogram from a list of values.
Definition: qgshistogram.h:38
QgsHistogram()=default
Constructor for QgsHistogram.
virtual ~QgsHistogram()=default
Represents a vector layer which manages a vector based data sets.