#ifndef WIDGETS_GRAPHPLOTTER_CURSORLAYER_H
#define WIDGETS_GRAPHPLOTTER_CURSORLAYER_H

#include "PlotterItemGroup.h"


// -- TDE NAMESPACE ----------------------------------------------------

namespace TDE {

// -- Widgets NAMESPACE ------------------------------------------------

namespace Widgets {

namespace Plot {


class CursorLayer;

typedef SHARED_PTR<CursorLayer> CursorLayerPtr;

typedef F_FUNCTION<void (GraphPlotter& gp, Point scrPoint, std::vector< std::pair<DataSetPtr, Point> >)> CoordinatesCb;

enum Direction { LEFT, RIGHT, UP, DOWN };

class CursorLayer : public PlotterItemGroup
{
public:
	CursorLayer(GraphPlotter* plotterPtr);

	virtual void _draw();

	virtual const QPoint& cursorPos() const { return m_pos; }
	virtual QPoint cursorPos(const QPoint& pos);

	virtual QPoint moveCursor(Direction direction);

	virtual CoordinatesCb coordinatesCallback() const { return m_coords_cb; }
	virtual CoordinatesCb coordinatesCallback(CoordinatesCb cb);

	virtual const QPoint& zoomStart() const { return m_zoom_start; }
	virtual QPoint zoomStart(const QPoint& pos);

	virtual const QPoint& zoomUpdate() const { return m_zoom_end; }
	virtual QPoint zoomUpdate(const QPoint& pos);

	virtual const QPoint& zoomEnd() const { return m_zoom_end; }
	virtual QPoint zoomEnd(const QPoint& pos);

protected:
	virtual DataSetPtr _dataSetForTransform() const;

private:
	void _notifyCb();

	QPoint m_pos;

	bool m_elastic_mode;
	QPoint m_zoom_start;
	QPoint m_zoom_end;

	CoordinatesCb m_coords_cb;
};


} /* end of namespace Plot */

} /* end of namespace Widgets */

} /* end of namespace TDE */

#endif /* WIDGETS_GRAPHPLOTTER_CURSORLAYER_H */
