pieslice_p.h
80 lines
| 2.0 KiB
| text/x-c
|
CLexer
Tero Ahola
|
r51 | #ifndef PIESLICE_H | ||
#define PIESLICE_H | ||||
#include "qchartglobal.h" | ||||
Tero Ahola
|
r103 | #include "charttheme_p.h" | ||
Jani Honkonen
|
r157 | #include "qpieseries.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
|
r566 | class PieSliceLayout | ||
{ | ||||
public: | ||||
Jani Honkonen
|
r618 | QPieSlice* m_data; // TODO: get rid of this | ||
Jani Honkonen
|
r566 | QPointF m_center; | ||
qreal m_radius; | ||||
qreal m_startAngle; | ||||
qreal m_angleSpan; | ||||
}; | ||||
Jani Honkonen
|
r174 | class PieSlice : public QGraphicsObject | ||
Tero Ahola
|
r51 | { | ||
Jani Honkonen
|
r174 | Q_OBJECT | ||
Tero Ahola
|
r51 | public: | ||
Jani Honkonen
|
r203 | PieSlice(QGraphicsItem* parent = 0); | ||
Tero Ahola
|
r51 | ~PieSlice(); | ||
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: | ||
void setLayout(PieSliceLayout layout); | ||||
Jani Honkonen
|
r203 | void updateGeometry(); | ||
void updateData(const QPieSlice *sliceData); | ||||
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
|
r566 | PieSliceLayout m_layout; | ||
Jani Honkonen
|
r203 | |||
Jani Honkonen
|
r437 | QPainterPath m_slicePath; | ||
Jani Honkonen
|
r203 | bool m_isExploded; | ||
Jani Honkonen
|
r454 | qreal m_explodeDistanceFactor; | ||
Jani Honkonen
|
r437 | bool m_labelVisible; | ||
Jani Honkonen
|
r469 | QPen m_slicePen; | ||
QBrush m_sliceBrush; | ||||
Jani Honkonen
|
r437 | |||
QPainterPath m_labelArmPath; | ||||
Jani Honkonen
|
r454 | qreal m_labelArmLengthFactor; | ||
Jani Honkonen
|
r437 | QPen m_labelArmPen; | ||
QRectF m_labelTextRect; | ||||
QFont m_labelFont; | ||||
QString m_labelText; | ||||
Tero Ahola
|
r51 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
#endif // PIESLICE_H | ||||