#ifndef ZPR_H
#define ZPR_H

#include <GL/gl.h>
#include <GL/glu.h>
#include <wx/wx.h>

class ZPR
{
private:
	double _left, _right, _bottom, _top, _zNear, _zFar;
	
	int  _mouseX,_mouseY;
	bool _mouseLeft,_mouseMiddle, _mouseRight;
	double _dragPosX, _dragPosY,_dragPosZ;
	double _matrix[16], _matrixInverse[16];
	
	float _lastScale; // Nghia

	GLfloat zprReferencePoint[4];
	
	int MOUSE_DOWN;
	bool CtrlDown;

	double vlen(double x,double y,double z);
	void pos(double *px,double *py,double *pz,const int x,const int y,const int *viewport);
	void getMatrix();
	void invertMatrix(const GLdouble *m, GLdouble *out);
	void zprPick(GLdouble x, GLdouble y,GLdouble delX, GLdouble delY);
	void Get3Dto2D(float xf, float yf, float zf, float &xi, float &yi, float &zbuffer);

public:	
	ZPR();
	~ZPR();
	void zprReshape(int w,int h);
	void zprKeyboardDown(wxKeyEvent* event);
	void zprKeyboardUp(wxKeyEvent *event);
	void zprMouse(wxMouseEvent *event);
	void zprMotion(wxMouseEvent *event);
	void GetReference(float &x, float &y, float &z);
	void SetReference(float x, float y, float z);
	void SetView(int view);
	void CenterReference();
	void ReleaseAllInput();
};

#endif
