linechartitem_p.h
74 lines
| 2.1 KiB
| text/x-c
|
CLexer
Michal Klocek
|
r144 | #ifndef LINECHARTITEM_H | ||
#define LINECHARTITEM_H | ||||
Michal Klocek
|
r21 | |||
Tero Ahola
|
r30 | #include "qchartglobal.h" | ||
Tero Ahola
|
r104 | #include "chartitem_p.h" | ||
Michal Klocek
|
r139 | #include <QPen> | ||
Michal Klocek
|
r21 | |||
Tero Ahola
|
r30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||
Michal Klocek
|
r21 | |||
Michal Klocek
|
r131 | class ChartPresenter; | ||
Michal Klocek
|
r144 | class QLineChartSeries; | ||
Michal Klocek
|
r131 | class LineChartAnimationItem; | ||
Michal Klocek
|
r21 | |||
Michal Klocek
|
r144 | class LineChartItem : public QObject , public ChartItem | ||
Michal Klocek
|
r21 | { | ||
Michal Klocek
|
r131 | Q_OBJECT | ||
Michal Klocek
|
r21 | public: | ||
Michal Klocek
|
r144 | LineChartItem(ChartPresenter* presenter, QLineChartSeries* series,QGraphicsItem *parent = 0); | ||
~ LineChartItem(){}; | ||||
Michal Klocek
|
r21 | |||
//from QGraphicsItem | ||||
Michal Klocek
|
r67 | QRectF boundingRect() const; | ||
Tero Ahola
|
r108 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | ||
Michal Klocek
|
r131 | QPainterPath shape() const; | ||
Michal Klocek
|
r139 | |||
void setPen(const QPen& pen); | ||||
const Domain& domain() const { return m_domain;} | ||||
Michal Klocek
|
r21 | |||
Michal Klocek
|
r131 | virtual void addPoint(const QPointF& ); | ||
virtual void addPoints(const QVector<QPointF>& points); | ||||
virtual void removePoint(const QPointF& point); | ||||
virtual void setPoint(const QPointF& oldPoint, const QPointF& newPoint); | ||||
virtual void setPoint(int index,const QPointF& point); | ||||
Michal Klocek
|
r185 | void setPointsVisible(bool visible); | ||
Michal Klocek
|
r131 | void clear(); | ||
void clearView(); | ||||
int count() const { return m_data.size();} | ||||
const QVector<QPointF>& points(){ return m_data;} | ||||
protected: | ||||
virtual void updateGeometry(); | ||||
virtual void updateData(); | ||||
virtual void updateDomain(); | ||||
//refactor | ||||
Michal Klocek
|
r144 | void calculatePoint(QPointF& point, int index, const QLineChartSeries* series,const QSizeF& size, const Domain& domain) const; | ||
void calculatePoints(QVector<QPointF>& points,QHash<int,int>& hash,const QLineChartSeries* series, const QSizeF& size, const Domain& domain) const; | ||||
Michal Klocek
|
r131 | |||
Michal Klocek
|
r139 | protected slots: | ||
void handleModelChanged(int index); | ||||
void handleDomainChanged(const Domain& domain); | ||||
void handleGeometryChanged(const QRectF& size); | ||||
Michal Klocek
|
r21 | |||
private: | ||||
Michal Klocek
|
r131 | ChartPresenter* m_presenter; | ||
QPainterPath m_path; | ||||
QSizeF m_size; | ||||
QRectF m_rect; | ||||
Michal Klocek
|
r150 | QRectF m_clipRect; | ||
Michal Klocek
|
r131 | Domain m_domain; | ||
QList<QGraphicsItem*> m_points; | ||||
QVector<QPointF> m_data; | ||||
QHash<int,int> m_hash; | ||||
Michal Klocek
|
r144 | QLineChartSeries* m_series; | ||
Michal Klocek
|
r139 | QPen m_pen; | ||
Michal Klocek
|
r131 | bool m_dirtyData; | ||
bool m_dirtyGeometry; | ||||
bool m_dirtyDomain; | ||||
Michal Klocek
|
r21 | }; | ||
Tero Ahola
|
r30 | QTCOMMERCIALCHART_END_NAMESPACE | ||
Michal Klocek
|
r21 | |||
#endif | ||||