piesliceitem_p.h
59 lines
| 1.6 KiB
| text/x-c
|
CLexer
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
|
r669 | #include "qpiesliceprivate_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 | |||
public: // from QGraphicsItem | ||||
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
|
r174 | Q_SIGNALS: | ||
void clicked(); | ||||
Jani Honkonen
|
r203 | void hoverEnter(); | ||
void hoverLeave(); | ||||
Jani Honkonen
|
r157 | |||
Jani Honkonen
|
r566 | public: | ||
Jani Honkonen
|
r668 | void setSliceData(PieSliceData sliceData); | ||
Jani Honkonen
|
r203 | void updateGeometry(); | ||
Jani Honkonen
|
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); | ||||
Jani Honkonen
|
r437 | static QPainterPath labelArmPath(QPointF start, qreal angle, qreal length, qreal textWidth, QPointF* textStart); | ||
static 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; | ||||
Tero Ahola
|
r51 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
Jani Honkonen
|
r673 | #endif // PIESLICEITEM_H | ||