piesliceitem_p.h
80 lines
| 2.3 KiB
| text/x-c
|
CLexer
Jani Honkonen
|
r794 | /**************************************************************************** | ||
** | ||||
** Copyright (C) 2012 Digia Plc | ||||
** All rights reserved. | ||||
** For any questions to Digia, please use contact form at http://qt.digia.com | ||||
** | ||||
** This file is part of the Qt Commercial Charts Add-on. | ||||
** | ||||
** $QT_BEGIN_LICENSE$ | ||||
** Licensees holding valid Qt Commercial licenses may use this file in | ||||
** accordance with the Qt Commercial License Agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and Digia. | ||||
** | ||||
** If you have questions regarding the use of this file, please use | ||||
** contact form at http://qt.digia.com | ||||
** $QT_END_LICENSE$ | ||||
** | ||||
****************************************************************************/ | ||||
Jani Honkonen
|
r673 | #ifndef PIESLICEITEM_H | ||
#define PIESLICEITEM_H | ||||
Tero Ahola
|
r51 | |||
#include "qchartglobal.h" | ||||
Tero Ahola
|
r103 | #include "charttheme_p.h" | ||
Jani Honkonen
|
r157 | #include "qpieseries.h" | ||
Jani Honkonen
|
r818 | #include "pieslicedata_p.h" | ||
Tero Ahola
|
r51 | #include <QGraphicsItem> | ||
#include <QRectF> | ||||
#include <QColor> | ||||
Jani Honkonen
|
r157 | #include <QPen> | ||
Tero Ahola
|
r51 | |||
Jani Honkonen
|
r413 | #define PIESLICE_LABEL_GAP 5 | ||
Tero Ahola
|
r51 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||
Jani Honkonen
|
r568 | class PieChartItem; | ||
Jani Honkonen
|
r174 | class PieSliceLabel; | ||
Jani Honkonen
|
r203 | class QPieSlice; | ||
Tero Ahola
|
r51 | |||
Jani Honkonen
|
r673 | class PieSliceItem : public QGraphicsObject | ||
Tero Ahola
|
r51 | { | ||
Jani Honkonen
|
r174 | Q_OBJECT | ||
Tero Ahola
|
r51 | public: | ||
Jani Honkonen
|
r673 | PieSliceItem(QGraphicsItem* parent = 0); | ||
~PieSliceItem(); | ||||
Tero Ahola
|
r51 | |||
Jani Honkonen
|
r1074 | // from QGraphicsItem | ||
Tero Ahola
|
r51 | QRectF boundingRect() const; | ||
QPainterPath shape() const; | ||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | ||||
Jani Honkonen
|
r142 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event); | ||
Jani Honkonen
|
r157 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); | ||
Jani Honkonen
|
r142 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | ||
Tero Ahola
|
r51 | |||
Jani Honkonen
|
r1074 | void setLayout(const PieSliceData &sliceData); | ||
static QPointF sliceCenter(QPointF point, qreal radius, QPieSlice *slice); | ||||
Jani Honkonen
|
r174 | Q_SIGNALS: | ||
Jani Honkonen
|
r707 | void clicked(Qt::MouseButtons buttons); | ||
Jani Honkonen
|
r1009 | void hovered(bool state); | ||
Jani Honkonen
|
r157 | |||
Jani Honkonen
|
r1074 | private: | ||
Jani Honkonen
|
r203 | void updateGeometry(); | ||
Jani Honkonen
|
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); | ||||
QRectF labelTextRect(QFont font, QString text); | ||||
Jani Honkonen
|
r289 | |||
Jani Honkonen
|
r142 | private: | ||
Jani Honkonen
|
r668 | PieSliceData m_data; | ||
Jani Honkonen
|
r621 | QRectF m_boundingRect; | ||
Jani Honkonen
|
r437 | QPainterPath m_slicePath; | ||
QPainterPath m_labelArmPath; | ||||
QRectF m_labelTextRect; | ||||
Jani Honkonen
|
r1083 | bool m_hovered; | ||
Tero Ahola
|
r51 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
Jani Honkonen
|
r673 | #endif // PIESLICEITEM_H | ||