#ifndef SIMULATIONGRAPHICVIEW_H
#define SIMULATIONGRAPHICVIEW_H

#include <QWidget>
#include "ui_simulationgraphicview.h"

//class SimulationGraphicView : public QWidget
//{
//	Q_OBJECT
//
//public:
//	SimulationGraphicView(QWidget *parent = 0);
//	~SimulationGraphicView();
//
//private:
//	Ui::SimulationGraphicViewClass ui;
//};



#include <QDialog>
#include <QGraphicsScene>
#include <QGraphicsLineItem>
#include <QTimer>

#include "simulation_graphic.h"

class LineInfo
{
public:
	LineInfo() { _graphPol = NULL; _refLine = NULL; _refText = NULL; }

	QGraphicsPathItem *_graphPol;
	QPainterPath _points;
	QGraphicsLineItem *_refLine;
	QGraphicsTextItem *_refText;
	QPen _pen;
	QString _text;
};

typedef QVector<LineInfo*> LineInfoVector;

class GraphInfo
{
public:
	GraphInfo() { _xString = "X"; _yString = "Y"; _refParent = NULL; _axisParent = NULL; _linesParent = NULL; }
	~GraphInfo();

	QGraphicsItemGroup *_refParent;
	QGraphicsItemGroup *_axisParent;
	QGraphicsItemGroup *_linesParent;
	LineInfoVector _lines;
	QString _xString, _yString, _title;
	double _maxX, _maxY, _minX, _minY;
};

typedef QVector<GraphInfo*> GraphInfoVector;

class SimulationGraphicView : public QWidget
{
	Q_OBJECT

public:
	SimulationGraphicView(QWidget *parent = 0);
	~SimulationGraphicView();

	void setGraphic(SimulationGraphic *graph);

protected:
	bool event(QEvent *e);

	bool needToUpdate();

	void clearData();

protected slots:
	void viewPoints();
	void updateScene();
	void showRefStateChanged(int state);

private:
	Ui::SimulationGraphicViewClass ui;
	QMatrix _matrix;
	GraphInfo *_graphInfo;
	double _maxX, _maxY, _minX, _minY;
	double _lastWidth, _lastHeight;
	bool _updatePending;
};


#endif // SIMULATIONGRAPHICVIEW_H
