| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | // W A R N I N G |
| 5 | // ------------- |
| 6 | // |
| 7 | // This file is not part of the Qt Chart API. It exists purely as an |
| 8 | // implementation detail. This header file may change from version to |
| 9 | // version without notice, or even be removed. |
| 10 | // |
| 11 | // We mean it. |
| 12 | |
| 13 | #ifndef BOXWHISKERS_H |
| 14 | #define BOXWHISKERS_H |
| 15 | |
| 16 | #include <private/boxwhiskersdata_p.h> |
| 17 | #include <QtCharts/QChartGlobal> |
| 18 | #include <QtCharts/private/qchartglobal_p.h> |
| 19 | #include <private/abstractdomain_p.h> |
| 20 | #include <QtCharts/QBoxSet> |
| 21 | #include <QtWidgets/QGraphicsRectItem> |
| 22 | #include <QtWidgets/QGraphicsLineItem> |
| 23 | #include <QtWidgets/QGraphicsLayoutItem> |
| 24 | #include <QtGui/QPainterPath> |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | class QBarSet; |
| 29 | |
| 30 | class Q_CHARTS_EXPORT BoxWhiskers : public QGraphicsObject |
| 31 | { |
| 32 | Q_OBJECT |
| 33 | |
| 34 | public: |
| 35 | BoxWhiskers(QBoxSet *set, AbstractDomain *domain, QGraphicsObject *parent); |
| 36 | ~BoxWhiskers(); |
| 37 | |
| 38 | void setBrush(const QBrush &brush); |
| 39 | void setPen(const QPen &pen); |
| 40 | void setLayout(const BoxWhiskersData &data); |
| 41 | void setBoxOutlined(const bool outlined) { m_boxOutlined = outlined; } |
| 42 | void setBoxWidth(const qreal width); |
| 43 | |
| 44 | void mousePressEvent(QGraphicsSceneMouseEvent *event) override; |
| 45 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; |
| 46 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; |
| 47 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; |
| 48 | void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; |
| 49 | |
| 50 | QRectF boundingRect() const override; |
| 51 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override; |
| 52 | |
| 53 | void updateGeometry(AbstractDomain *domain); |
| 54 | protected: |
| 55 | QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; |
| 56 | void setGeometry(const QRectF &rect); |
| 57 | |
| 58 | Q_SIGNALS: |
| 59 | void clicked(QBoxSet *boxset); |
| 60 | void hovered(bool status, QBoxSet *boxset); |
| 61 | void pressed(QBoxSet *boxset); |
| 62 | void released(QBoxSet *boxset); |
| 63 | void doubleClicked(QBoxSet *boxset); |
| 64 | |
| 65 | private: |
| 66 | friend class BoxPlotChartItem; |
| 67 | friend class BoxPlotAnimation; |
| 68 | |
| 69 | QBoxSet *m_boxSet; |
| 70 | AbstractDomain *m_domain; |
| 71 | QPainterPath m_boxPath; |
| 72 | QRectF m_boundingRect; |
| 73 | Q_DECL_UNUSED_MEMBER |
| 74 | bool m_hovering; |
| 75 | bool m_validData; |
| 76 | QBrush m_brush; |
| 77 | QPen m_pen; |
| 78 | QPen m_medianPen; |
| 79 | QPen m_outlinePen; |
| 80 | bool m_boxOutlined; |
| 81 | qreal m_boxWidth; |
| 82 | BoxWhiskersData m_data; |
| 83 | QSizeF m_domainSize; |
| 84 | QRectF m_middleBox; |
| 85 | qreal m_geometryMedian; |
| 86 | qreal m_geometryLeft; |
| 87 | qreal m_geometryRight; |
| 88 | |
| 89 | bool m_mousePressed; |
| 90 | }; |
| 91 | |
| 92 | QT_END_NAMESPACE |
| 93 | |
| 94 | #endif // BOXWHISKERS_H |
| 95 |
