piesliceitem_p.h
59 lines
| 1.6 KiB
| text/x-c
|
CLexer
|
r673 | #ifndef PIESLICEITEM_H | ||
#define PIESLICEITEM_H | ||||
|
r51 | |||
#include "qchartglobal.h" | ||||
|
r103 | #include "charttheme_p.h" | ||
|
r157 | #include "qpieseries.h" | ||
|
r669 | #include "qpiesliceprivate_p.h" | ||
|
r51 | #include <QGraphicsItem> | ||
#include <QRectF> | ||||
#include <QColor> | ||||
|
r157 | #include <QPen> | ||
|
r51 | |||
|
r413 | #define PIESLICE_LABEL_GAP 5 | ||
|
r51 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||
|
r568 | class PieChartItem; | ||
|
r174 | class PieSliceLabel; | ||
|
r203 | class QPieSlice; | ||
|
r51 | |||
|
r673 | class PieSliceItem : public QGraphicsObject | ||
|
r51 | { | ||
|
r174 | Q_OBJECT | ||
|
r51 | public: | ||
|
r673 | PieSliceItem(QGraphicsItem* parent = 0); | ||
~PieSliceItem(); | ||||
|
r51 | |||
public: // from QGraphicsItem | ||||
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); | ||
|
r51 | |||
|
r174 | Q_SIGNALS: | ||
void clicked(); | ||||
|
r203 | void hoverEnter(); | ||
void hoverLeave(); | ||||
|
r157 | |||
|
r566 | public: | ||
|
r668 | void setSliceData(PieSliceData sliceData); | ||
|
r203 | void updateGeometry(); | ||
|
r566 | static QPointF sliceCenter(QPointF point, qreal radius, QPieSlice *slice); | ||
static QPainterPath slicePath(QPointF center, qreal radius, qreal startAngle, qreal angleSpan, qreal* centerAngle, QPointF* armStart); | ||||
|
r437 | static QPainterPath labelArmPath(QPointF start, qreal angle, qreal length, qreal textWidth, QPointF* textStart); | ||
static QRectF labelTextRect(QFont font, QString text); | ||||
|
r289 | |||
|
r142 | private: | ||
|
r668 | PieSliceData m_data; | ||
|
r621 | QRectF m_boundingRect; | ||
|
r437 | QPainterPath m_slicePath; | ||
QPainterPath m_labelArmPath; | ||||
QRectF m_labelTextRect; | ||||
|
r51 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
|
r673 | #endif // PIESLICEITEM_H | ||