#ifndef _TOOL3D_H_
#define _TOOL3D_H_


#include "../basic/basic_types.h"
#include "../geometry/geometry_types.h"

#include <QPoint>

class Vertex;
class PaintCanvas;
class QMouseEvent;
class VertexGroup;

namespace Tl {


	class Tool3D 
	{
	public:
		Tool3D(PaintCanvas* canvas) ;

		virtual ~Tool3D() {}

	public:
		virtual void press(QMouseEvent *e) = 0;
		virtual void release(QMouseEvent *e) = 0;
		virtual void move(QMouseEvent *e) = 0;
		virtual void drag(QMouseEvent *e) = 0;

		virtual void reset() = 0;

		virtual void draw() const = 0;

		virtual void status(const std::string& value);

	public:
		virtual PaintCanvas* canvas() const;
		virtual void set_canvas(PaintCanvas* canvas);

		Line3f		get_mouse_line_in_3d_space(const QPoint& pos) const ;

		// NOTE: pointing to the outside of the screen
		Vector3f	get_view_direction_in_3d_space(const QPoint& pos) const ;

		Point3f		get_intersect_point(const Plane3f& plane, const QPoint& pos, bool& success) const;
		Vertex*     get_intersect_vertex(const VertexGroup* g, const QPoint& pos, float bbox_ratio = 0.01f) const;

	protected:
		PaintCanvas*  canvas_ ;

		bool  left_button_down_;
		bool  right_button_down_;
	} ;

	//________________________________________________________________

	class EmptyTool3D : public Tool3D 
	{
	public:
		EmptyTool3D(PaintCanvas* canvas) ;
		virtual ~EmptyTool3D() {}

	public:
		virtual void press(QMouseEvent *) {}
		virtual void release(QMouseEvent *) {}
		virtual void move(QMouseEvent *) {}
		virtual void drag(QMouseEvent *) {}
		virtual void reset() {}

		virtual void draw() const {}
	} ;

}


#endif
