#ifndef _CANVASPOINTGRABBER_H_
#define _CANVASPOINTGRABBER_H_

#include <QPoint>
#include <QObject>
#include <vector>

class Canvas;
class QMouseEvent;

class CanvasPointGrabber : public QObject
{
	Q_OBJECT

public:
	enum State
	{
		STATE_EMPTY,
		STATE_GRABBING,
		STATE_READY
	};

	static const int MAX_POINTS = 2*39;

public:
	CanvasPointGrabber( Canvas* canvas );
	virtual ~CanvasPointGrabber();

	inline int getNumPoints() const { return _numPoints; }
	inline const QPoint& getPoint( int i ) const { return _points[i]; }

	inline Canvas* getCanvas() const { return _canvas; }

	inline State getState() const { return _currentState; }
	inline bool isGrabbing() const { return _currentState == STATE_GRABBING; }
	inline bool isReady() const { return _currentState == STATE_READY; }

	inline void forceReady() { _currentState = STATE_READY; }

	void startGrabbing();
	void stopGrabbing();

	void decorateGL( Canvas* canvas );

private slots:
	void mousePressed( QMouseEvent* event );

private:
	Canvas* _canvas;

	int _numPoints;
	QPoint _points[MAX_POINTS];

	State _currentState;
};

#endif
