#ifndef ANALOGGRAPHITEM_H
#define ANALOGGRAPHITEM_H

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

class CGraphAnalogDataPair
{
public:
    CGraphAnalogDataPair(qreal Value, quint64 Time);
    qreal mValue;   //changed from qint32
    quint64 mTime;
};

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

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

	unsigned int DisplayData(quint64 StartTime, quint64 StopTime);
    void SetData(QList<CGraphAnalogDataPair*> *DataList);
    void SetLabel(QString label,int Offset);
    void SetAbsoluteLimits(quint64 StartTime,quint64 EndTime){mAbsoluteStartTime = StartTime; mAbsoluteEndTime = EndTime;}
	void AddHorizontalLine(qreal YPosition);
	qreal GetValueForTime(quint64 time);

	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:

	bool mDataValid;
    quint64 mStartTime, mStopTime, mAbsoluteEndTime,mAbsoluteStartTime;
	QVector<QLine> mLinesList;
	QString mLabelTitle;
    QGraphicsTextItem *mLabel;
	QPixmap *mGraphPixmap;
	qreal mYScaling,mXScaling;
	qreal mYOffset;
	qreal mHorizLineYPos;
	QLine *mHorizLine;

	QPainterPath mPainterPath;



};

#endif // ANALOGGRAPHITEM_H
