src/plottables/plottable-statisticalbox.h Source File

· · ·
plottable-statisticalbox.h
Go to the documentation of this file.
1 /***************************************************************************
2 ** **
3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
5 ** **
6 ** This program is free software: you can redistribute it and/or modify **
7 ** it under the terms of the GNU General Public License as published by **
8 ** the Free Software Foundation, either version 3 of the License, or **
9 ** (at your option) any later version. **
10 ** **
11 ** This program is distributed in the hope that it will be useful, **
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of **
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
14 ** GNU General Public License for more details. **
15 ** **
16 ** You should have received a copy of the GNU General Public License **
17 ** along with this program. If not, see http://www.gnu.org/licenses/. **
18 ** **
19 ****************************************************************************
20 ** Author: Emanuel Eichhammer **
21 ** Website/Contact: http://www.qcustomplot.com/ **
22 ** Date: 04.11.13 **
23 ** Version: 1.1.0 **
24 ****************************************************************************/
26 #ifndef QCP_PLOTTABLE_STATISTICALBOX_H
27 #define QCP_PLOTTABLE_STATISTICALBOX_H
28
29 #include "../global.h"
30 #include "../range.h"
31 #include "../plottable.h"
32 #include "../painter.h"
33
34 class QCPPainter;
35 class QCPAxis;
36
37 class QCP_LIB_DECL QCPStatisticalBox : public QCPAbstractPlottable
38 {
39 Q_OBJECT
41 Q_PROPERTY(double key READ key WRITE setKey)
42 Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
43 Q_PROPERTY(double lowerQuartile READ lowerQuartile WRITE setLowerQuartile)
44 Q_PROPERTY(double median READ median WRITE setMedian)
45 Q_PROPERTY(double upperQuartile READ upperQuartile WRITE setUpperQuartile)
46 Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
47 Q_PROPERTY(QVector<double> outliers READ outliers WRITE setOutliers)
48 Q_PROPERTY(double width READ width WRITE setWidth)
49 Q_PROPERTY(double whiskerWidth READ whiskerWidth WRITE setWhiskerWidth)
50 Q_PROPERTY(QPen whiskerPen READ whiskerPen WRITE setWhiskerPen)
51 Q_PROPERTY(QPen whiskerBarPen READ whiskerBarPen WRITE setWhiskerBarPen)
52 Q_PROPERTY(QPen medianPen READ medianPen WRITE setMedianPen)
53 Q_PROPERTY(QCPScatterStyle outlierStyle READ outlierStyle WRITE setOutlierStyle)
55 public:
56 explicit QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis);
57
58 // getters:
59 double key() const { return mKey; }
60 double minimum() const { return mMinimum; }
61 double lowerQuartile() const { return mLowerQuartile; }
62 double median() const { return mMedian; }
63 double upperQuartile() const { return mUpperQuartile; }
64 double maximum() const { return mMaximum; }
65 QVector<double> outliers() const { return mOutliers; }
66 double width() const { return mWidth; }
67 double whiskerWidth() const { return mWhiskerWidth; }
68 QPen whiskerPen() const { return mWhiskerPen; }
69 QPen whiskerBarPen() const { return mWhiskerBarPen; }
70 QPen medianPen() const { return mMedianPen; }
71 QCPScatterStyle outlierStyle() const { return mOutlierStyle; }
72
73 // setters:
74 void setKey(double key);
75 void setMinimum(double value);
76 void setLowerQuartile(double value);
77 void setMedian(double value);
78 void setUpperQuartile(double value);
79 void setMaximum(double value);
80 void setOutliers(const QVector<double> &values);
81 void setData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum);
82 void setWidth(double width);
83 void setWhiskerWidth(double width);
84 void setWhiskerPen(const QPen &pen);
85 void setWhiskerBarPen(const QPen &pen);
86 void setMedianPen(const QPen &pen);
87 void setOutlierStyle(const QCPScatterStyle &style);
88
89 // non-property methods:
90 virtual void clearData();
91 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
92
93 protected:
94 // property members:
95 QVector<double> mOutliers;
96 double mKey, mMinimum, mLowerQuartile, mMedian, mUpperQuartile, mMaximum;
97 double mWidth;
98 double mWhiskerWidth;
99 QPen mWhiskerPen, mWhiskerBarPen, mMedianPen;
100 QCPScatterStyle mOutlierStyle;
101
102 // reimplemented virtual methods:
103 virtual void draw(QCPPainter *painter);
104 virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
105 virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=sdBoth) const;
106 virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=sdBoth) const;
107
108 // introduced virtual methods:
109 virtual void drawQuartileBox(QCPPainter *painter, QRectF *quartileBox=0) const;
110 virtual void drawMedian(QCPPainter *painter) const;
111 virtual void drawWhiskers(QCPPainter *painter) const;
112 virtual void drawOutliers(QCPPainter *painter) const;
113
114 friend class QCustomPlot;
115 friend class QCPLegend;
116 };
117
118 #endif // QCP_PLOTTABLE_STATISTICALBOX_H
Generated with Doxygen 1.8.1.2