#pragma once

#include "QtViewBase.h"

#include "SceneMain.h"
#include "GLWidgetList.h"

#include <C2/gl/Projection.h>
#include <C2/gl/Manipulator.h>



class View2D : public QtViewBase
{
	Q_OBJECT

public:
	View2D(void);

	virtual bool InitializeView(MyGLWidget* ParentWidget);
	void RegisterScene(SceneMain* scene);

	void ResetView(void);

	virtual void FinalizeView(void);

	virtual void OnPaint(void);
	virtual void OnResize(int width, int height);

	virtual void OnMousePress(QMouseEvent *e);
	virtual void OnMouseRelease(QMouseEvent *e);
	virtual void OnMouseDoubleClick(QMouseEvent *e);
	virtual void OnMouseMove(QMouseEvent *e);

	virtual void OnWheel(QWheelEvent *e);

	void FitView(void);

	void RepaintParent(void);

private:
	gl::GlTexture* GetPrimaryTexture(void);

	void DrawBackTexture(void);
	void DrawOptions(void);
	void DrawObjects(void);
	void DrawObject(GeomObject& obj);


public:
	GLWidgetList* m_Widgets;

	SceneMain* m_Scene;

	lib_gl::CameraManipulator m_Manip;
	lib_gl::OrthoProjection   m_Projection;

	QPointF m_LastMousePos;

	bool m_DrawVerts;
	bool m_EnableTexture;
	bool m_UseFixTexute;

	bool m_RepeatTexture;
};
