QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgshistogramwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgshistogramwidget.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 QGSHISTOGRAMWIDGET_H
18#define QGSHISTOGRAMWIDGET_H
19
20#include "ui_qgshistogramwidgetbase.h"
21#include "qgis_sip.h"
22
23#include "qgshistogram.h"
26#include <QPen>
27#include <QBrush>
28#include "qgis_gui.h"
29
30class QgsVectorLayer;
32class QwtPlotPicker;
33class QwtPlotMarker;
34class QwtPlot;
35class HistogramItem;
36class QwtPlotHistogram;
37
38// fix for qwt5/qwt6 QwtDoublePoint vs. QPointF
39typedef QPointF QwtDoublePoint;
40
48class GUI_EXPORT QgsHistogramWidget : public QWidget, private Ui::QgsHistogramWidgetBase
49{
50 Q_OBJECT
51
52 public:
53
61 QgsHistogramWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, QgsVectorLayer *layer = nullptr, const QString &fieldOrExp = QString() );
62
63 ~QgsHistogramWidget() override;
64
70 QgsVectorLayer *layer() { return mVectorLayer; }
71
78 QString sourceFieldExp() const { return mSourceFieldExp; }
79
88 void setPen( const QPen &pen ) { mPen = pen; }
89
95 QPen pen() const { return mPen; }
96
104 void setBrush( const QBrush &brush ) { mBrush = brush; }
105
111 QBrush brush() const { return mBrush; }
112
119 void setGraduatedRanges( const QgsRangeList &ranges );
120
127 QgsRangeList graduatedRanges() const { return mRanges; }
128
134 QString xAxisTitle() const { return mXAxisTitle; }
135
142 void setXAxisTitle( const QString &title ) { mXAxisTitle = title; }
143
149 QString yAxisTitle() const { return mYAxisTitle; }
150
157 void setYAxisTitle( const QString &title ) { mYAxisTitle = title; }
158
159 public slots:
160
164 void refreshValues();
165
170 void refresh();
171
177 void setLayer( QgsVectorLayer *layer );
178
184 void setSourceFieldExp( const QString &fieldOrExp );
185
186 protected:
187
191 virtual void drawHistogram();
192
193 QwtPlot *mPlot = nullptr;
195 QList< QwtPlotMarker * > mRangeMarkers;
196
197 private:
198
199 QgsVectorLayer *mVectorLayer = nullptr;
200 QString mSourceFieldExp;
201 QList<double> mValues;
203 QgsHistogram mHistogram;
204 QVector<QColor> mHistoColors;
205 QPen mPen;
206 QBrush mBrush;
207 QPen mMeanPen;
208 QPen mStdevPen;
209 QPen mGridPen;
210 QString mXAxisTitle;
211 QString mYAxisTitle;
212
213 void clearHistogram();
214
215 QwtPlotHistogram *createPlotHistogram( const QString &title, const QBrush &brush, const QPen &pen = Qt::NoPen ) const;
216
217};
218
219#endif //QGSHISTOGRAMWIDGET_H
A vector feature renderer which uses numeric attributes to classify features into different ranges.
Graphical histogram for displaying distributions of field values.
QString xAxisTitle() const
Returns the title for the histogram's x-axis.
QList< QwtPlotMarker * > mRangeMarkers
QgsRangeList graduatedRanges() const
Returns the graduated ranges associated with the histogram.
QPen pen() const
Returns the pen used when drawing histogram bars.
void setYAxisTitle(const QString &title)
Sets the title for the histogram's y-axis.
void setPen(const QPen &pen)
Sets the pen to use when drawing histogram bars.
QString sourceFieldExp() const
Returns the source field name or expression used to calculate values displayed in the histogram.
void setXAxisTitle(const QString &title)
Sets the title for the histogram's x-axis.
void setBrush(const QBrush &brush)
Sets the brush used for drawing histogram bars.
QBrush brush() const
Returns the brush used when drawing histogram bars.
QgsVectorLayer * layer()
Returns the layer currently associated with the widget.
QString yAxisTitle() const
Returns the title for the histogram's y-axis.
Calculator for a numeric histogram from a list of values.
Calculator for summary statistics for a list of doubles.
Represents a vector layer which manages a vector based data sets.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
QPointF QwtDoublePoint
QList< QgsRendererRange > QgsRangeList