#ifndef CGRAPHITEM_H
#define CGRAPHITEM_H

#include <GlobalDefine.h>
#include <QGraphicsWidget>
#include <QRect>
#include <QTimeLine>
#include <QList>
#include <QPainterPath>

class CGraphDiscreteDataPair
{
public:
	CGraphDiscreteDataPair(quint32 Value, quint64 Time);
	quint32 mValue;
	quint64 mTime;
};


class CGraphItem : public QGraphicsWidget
{
	 Q_OBJECT
public:
	CGraphItem(QGraphicsItem *Parent = 0);
	~CGraphItem();

    QList<CGraphDiscreteDataPair*> *mDataSet;
    QGraphicsRectItem *mBackgroundRect;

//	unsigned int DisplayData(quint32 StartIndex, quint32 StopIndex);
	unsigned int DisplayData(quint64 StartTime, quint64 StopTime);
    void SetData(QList<CGraphDiscreteDataPair*> *DataList);
//	void UpdateDisplay(void);
    void SetLabel(QString label,int Offset);

	virtual void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
	virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
	virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
	virtual void resizeEvent(QGraphicsSceneResizeEvent *event);

private:
	//quint64 mTimeSpan;
	//quint64 mOffset;
	bool mDataValid;
	//quint32 mStartIndex,mStopIndex;
	quint64 mStartTime, mStopTime;
	QVector<QLine> mLinesList;
    QGraphicsTextItem *mLabel;

	QPixmap *mGraphPixmap;



};

#endif // CGRAPHITEM_H
