view.h 2.82 KB
Newer Older
1 2 3 4 5 6 7 8
#ifndef _VIEW_H_
#define _VIEW_H_

#include <iostream>

#include "types.h"
#include "viewButtonArea.h"

9
#include <QKeyEvent>
10 11
#include <QList>
#include <QWidget>
Pierre Kraemer's avatar
Pierre Kraemer committed
12
#include <QGLContext>
13 14 15

#include "Utils/gl_matrices.h"

16
class Window;
17 18
class Scene;
class Camera;
19
//class Context;
20 21 22 23 24 25

class View : public QGLViewer
{
	Q_OBJECT

public:
26
	View(const QString& name, Window* w, QWidget* parent);
27 28
	~View();

Pierre Kraemer's avatar
Pierre Kraemer committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
	const QString& getName() { return m_name; }
	void setName(const QString& name) { m_name = name; }

	Window* getWindow() { return m_window; }
	void setWindow(Window* w) { m_window = w; }

	Scene* getScene() { return m_scene; }
	void setScene(Scene* s) { m_scene = s; }

	Camera* getCurrentCamera() { return m_currentCamera; }
	void setCurrentCamera(Camera* c)
	{
		m_currentCamera = c;
		updateTextInfo();
		updateGL();
	}

	QGLContext* getContext() { return m_context; }
	void setContext(QGLContext* c) { m_context = c; }

	virtual void initGL();
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
	virtual void updateGL();
	virtual void draw();
	void drawText();
	void drawButtons();

	void keyPressEvent(QKeyEvent* event);
	void keyReleaseEvent(QKeyEvent *e);
	void mousePressEvent(QMouseEvent* event);
	void mouseReleaseEvent(QMouseEvent* event);
	void mouseMoveEvent(QMouseEvent* event);
	void wheelEvent(QWheelEvent* event);

	virtual void resizeGL(int width, int height);

	void drawOverpaint(QPainter *painter);

//	virtual void paintGL() { update(); }
//	virtual void paintEvent(QPaintEvent *event);

	void enableLinking(bool b = true);
	void enableUnlinking(bool b = true);
	void enableCameraGesture(bool b = true);
	void enableSceneCameraGesture(bool b = true);
	void enableViewClose(bool b = true);

//	void addUnlinkButton();
//	void removeUnlinkButton();

	void updateTextInfo();

	glm::mat4 getCurrentModelViewMatrix();
	glm::mat4 getCurrentProjectionMatrix();
	glm::mat4 getCurrentModelViewProjectionMatrix();

Pierre Kraemer's avatar
Pierre Kraemer committed
84 85
	void setCurrentModelViewMatrix(const glm::mat4& mvm);
	void setCurrentProjectionMatrix(const glm::mat4& pm);
86

Pierre Kraemer's avatar
Pierre Kraemer committed
87 88
//	void addViewButton(ViewButton* viewButton);
//	void removeViewButton(ViewButton* viewButton);
89

Pierre Kraemer's avatar
Pierre Kraemer committed
90
//	void setShowButtons(bool b) { b_showButtons = b; }
91 92

protected:
93 94
	static unsigned int viewCount;

95
	QString m_name;
Pierre Kraemer's avatar
Pierre Kraemer committed
96 97
	Window* m_window;
	QGLContext* m_context;
98 99

	Scene* m_scene;
100 101
	Camera* m_currentCamera;

Pierre Kraemer's avatar
Pierre Kraemer committed
102
//	ViewButtonArea* m_buttonArea;
103

Pierre Kraemer's avatar
Pierre Kraemer committed
104 105 106 107 108 109 110 111 112 113
//	ViewButton* m_linkButton;
//	bool m_linkViewEnabled;
//	ViewButton* m_unlinkButton;
//	bool m_unlinkViewEnabled;
//	ViewButton* m_cameraButton;
//	bool m_cameraEnabled;
//	ViewButton* m_cameraSceneButton;
//	bool m_cameraSceneEnabled;
//	ViewButton* m_closeViewButton;
//	bool m_closeViewEnabled;
114

Pierre Kraemer's avatar
Pierre Kraemer committed
115
//	bool b_showButtons;
116

Pierre Kraemer's avatar
Pierre Kraemer committed
117 118
	QString m_textInfo;
	bool b_drawText;
119

Pierre Kraemer's avatar
Pierre Kraemer committed
120 121 122 123 124 125
//public slots:
//	void linkView();
//	void unlinkView();
//	void cameraGesture();
//	void cameraSceneGesture();
//	void closeView();
126

Pierre Kraemer's avatar
Pierre Kraemer committed
127 128
//signals:
//	void currentCameraChanged(Camera* camera);
129 130 131
};

#endif