1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Charts module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30// W A R N I N G
31// -------------
32//
33// This file is not part of the Qt Chart API. It exists purely as an
34// implementation detail. This header file may change from version to
35// version without notice, or even be removed.
36//
37// We mean it.
38
39#ifndef BOXWHISKERS_H
40#define BOXWHISKERS_H
41
42#include <private/boxwhiskersdata_p.h>
43#include <QtCharts/QChartGlobal>
44#include <QtCharts/private/qchartglobal_p.h>
45#include <private/abstractdomain_p.h>
46#include <QtCharts/QBoxSet>
47#include <QtWidgets/QGraphicsRectItem>
48#include <QtWidgets/QGraphicsLineItem>
49#include <QtWidgets/QGraphicsLayoutItem>
50#include <QtGui/QPainterPath>
51
52QT_CHARTS_BEGIN_NAMESPACE
53
54class QBarSet;
55
56class Q_CHARTS_PRIVATE_EXPORT BoxWhiskers : public QGraphicsObject
57{
58 Q_OBJECT
59
60public:
61 BoxWhiskers(QBoxSet *set, AbstractDomain *domain, QGraphicsObject *parent);
62 ~BoxWhiskers();
63
64 void setBrush(const QBrush &brush);
65 void setPen(const QPen &pen);
66 void setLayout(const BoxWhiskersData &data);
67 void setBoxOutlined(const bool outlined) { m_boxOutlined = outlined; }
68 void setBoxWidth(const qreal width);
69
70 void mousePressEvent(QGraphicsSceneMouseEvent *event);
71 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
72 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
73 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
74 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
75
76 QRectF boundingRect() const;
77 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
78
79 void updateGeometry(AbstractDomain *domain);
80protected:
81 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const;
82 void setGeometry(const QRectF &rect);
83
84Q_SIGNALS:
85 void clicked(QBoxSet *boxset);
86 void hovered(bool status, QBoxSet *boxset);
87 void pressed(QBoxSet *boxset);
88 void released(QBoxSet *boxset);
89 void doubleClicked(QBoxSet *boxset);
90
91private:
92 friend class BoxPlotChartItem;
93 friend class BoxPlotAnimation;
94
95 QBoxSet *m_boxSet;
96 AbstractDomain *m_domain;
97 QPainterPath m_boxPath;
98 QRectF m_boundingRect;
99 bool m_hovering;
100 bool m_validData;
101 QBrush m_brush;
102 QPen m_pen;
103 QPen m_medianPen;
104 QPen m_outlinePen;
105 bool m_boxOutlined;
106 qreal m_boxWidth;
107 BoxWhiskersData m_data;
108 QSizeF m_domainSize;
109 QRectF m_middleBox;
110 qreal m_geometryMedian;
111 qreal m_geometryLeft;
112 qreal m_geometryRight;
113
114 bool m_mousePressed;
115};
116
117QT_CHARTS_END_NAMESPACE
118
119#endif // BOXWHISKERS_H
120

source code of qtcharts/src/charts/boxplotchart/boxwhiskers_p.h