piesliceitem_p.h
96 lines
| 2.9 KiB
| text/x-c
|
CLexer
|
r794 | /**************************************************************************** | ||
** | ||||
|
r2776 | ** Copyright (C) 2015 The Qt Company Ltd | ||
|
r794 | ** All rights reserved. | ||
|
r2776 | ** For any questions to The Qt Company, please use contact form at http://qt.io | ||
|
r794 | ** | ||
|
r2740 | ** This file is part of the Qt Charts module. | ||
|
r794 | ** | ||
|
r2740 | ** Licensees holding valid commercial license for Qt may use this file in | ||
** accordance with the Qt License Agreement provided with the Software | ||||
** or, alternatively, in accordance with the terms contained in a written | ||||
|
r2776 | ** agreement between you and The Qt Company. | ||
|
r794 | ** | ||
** If you have questions regarding the use of this file, please use | ||||
|
r2740 | ** contact form at http://qt.io | ||
|
r794 | ** | ||
****************************************************************************/ | ||||
|
r1366 | // W A R N I N G | ||
// ------------- | ||||
// | ||||
|
r2807 | // This file is not part of the Qt Chart API. It exists purely as an | ||
|
r1366 | // implementation detail. This header file may change from version to | ||
// version without notice, or even be removed. | ||||
// | ||||
// We mean it. | ||||
|
r673 | #ifndef PIESLICEITEM_H | ||
#define PIESLICEITEM_H | ||||
|
r51 | |||
|
r2714 | #include <QtCharts/QChartGlobal> | ||
#include <private/charttheme_p.h> | ||||
#include <QtCharts/QPieSeries> | ||||
#include <private/pieslicedata_p.h> | ||||
#include <QtWidgets/QGraphicsItem> | ||||
#include <QtCore/QRectF> | ||||
#include <QtGui/QColor> | ||||
#include <QtGui/QPen> | ||||
|
r51 | |||
|
r413 | #define PIESLICE_LABEL_GAP 5 | ||
|
r2712 | QT_CHARTS_BEGIN_NAMESPACE | ||
|
r568 | class PieChartItem; | ||
|
r174 | class PieSliceLabel; | ||
|
r203 | class QPieSlice; | ||
|
r51 | |||
|
r673 | class PieSliceItem : public QGraphicsObject | ||
|
r51 | { | ||
|
r174 | Q_OBJECT | ||
|
r51 | public: | ||
|
r2104 | PieSliceItem(QGraphicsItem *parent = 0); | ||
|
r673 | ~PieSliceItem(); | ||
|
r51 | |||
|
r1074 | // from QGraphicsItem | ||
|
r51 | QRectF boundingRect() const; | ||
QPainterPath shape() const; | ||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | ||||
|
r142 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event); | ||
|
r157 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); | ||
|
r142 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | ||
|
r2739 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); | ||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); | ||||
|
r51 | |||
|
r1074 | void setLayout(const PieSliceData &sliceData); | ||
static QPointF sliceCenter(QPointF point, qreal radius, QPieSlice *slice); | ||||
|
r174 | Q_SIGNALS: | ||
|
r707 | void clicked(Qt::MouseButtons buttons); | ||
|
r1009 | void hovered(bool state); | ||
|
r2739 | void pressed(Qt::MouseButtons buttons); | ||
void released(Qt::MouseButtons buttons); | ||||
void doubleClicked(Qt::MouseButtons buttons); | ||||
|
r157 | |||
|
r1074 | private: | ||
|
r203 | void updateGeometry(); | ||
|
r972 | QPainterPath slicePath(QPointF center, qreal radius, qreal startAngle, qreal angleSpan, qreal *centerAngle, QPointF *armStart); | ||
QPainterPath labelArmPath(QPointF start, qreal angle, qreal length, qreal textWidth, QPointF *textStart); | ||||
|
r289 | |||
|
r142 | private: | ||
|
r668 | PieSliceData m_data; | ||
|
r621 | QRectF m_boundingRect; | ||
|
r437 | QPainterPath m_slicePath; | ||
QPainterPath m_labelArmPath; | ||||
QRectF m_labelTextRect; | ||||
|
r1083 | bool m_hovered; | ||
|
r2626 | QGraphicsTextItem *m_labelItem; | ||
|
r2321 | |||
|
r2739 | bool m_mousePressed; | ||
|
r2321 | friend class PieSliceAnimation; | ||
|
r51 | }; | ||
|
r2712 | QT_CHARTS_END_NAMESPACE | ||
|
r51 | |||
|
r673 | #endif // PIESLICEITEM_H | ||