#ifndef LINECHARTITEM_H #define LINECHARTITEM_H #include "qchartglobal.h" #include "chartitem_p.h" #include QTCOMMERCIALCHART_BEGIN_NAMESPACE class ChartPresenter; class QLineChartSeries; class LineChartAnimationItem; class LineChartItem : public QObject , public ChartItem { Q_OBJECT public: LineChartItem(ChartPresenter* presenter, QLineChartSeries* series,QGraphicsItem *parent = 0); ~ LineChartItem(){}; //from QGraphicsItem QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); QPainterPath shape() const; void setPen(const QPen& pen); const Domain& domain() const { return m_domain;} virtual void addPoint(const QPointF& ); virtual void addPoints(const QVector& points); virtual void removePoint(const QPointF& point); virtual void setPoint(const QPointF& oldPoint, const QPointF& newPoint); virtual void setPoint(int index,const QPointF& point); void clear(); void clearView(); int count() const { return m_data.size();} const QVector& points(){ return m_data;} protected: virtual void updateGeometry(); virtual void updateData(); virtual void updateDomain(); //refactor void calculatePoint(QPointF& point, int index, const QLineChartSeries* series,const QSizeF& size, const Domain& domain) const; void calculatePoints(QVector& points,QHash& hash,const QLineChartSeries* series, const QSizeF& size, const Domain& domain) const; protected slots: void handleModelChanged(int index); void handleDomainChanged(const Domain& domain); void handleGeometryChanged(const QRectF& size); private: ChartPresenter* m_presenter; QPainterPath m_path; QSizeF m_size; QRectF m_rect; QRectF m_clipRect; Domain m_domain; QList m_points; QVector m_data; QHash m_hash; QLineChartSeries* m_series; QPen m_pen; bool m_dirtyData; bool m_dirtyGeometry; bool m_dirtyDomain; }; QTCOMMERCIALCHART_END_NAMESPACE #endif