view.h 2.83 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
#ifndef _VIEW_H_
#define _VIEW_H_

#include <iostream>

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

# include <QKeyEvent>
#include <QList>
#include <QWidget>
Pierre Kraemer's avatar
Pierre Kraemer committed
12
#include <QGLContext>
13 14 15 16 17 18 19 20 21 22 23 24

#include "Utils/gl_matrices.h"

class Scene;
class Camera;
class Context;

class View : public QGLViewer
{
	Q_OBJECT

public:
Pierre Kraemer's avatar
Pierre Kraemer committed
25
	View(const QString& name, Window* w, Scene* s, Camera* c, QWidget* parent, const QGLWidget* shareWidget = NULL);
26 27
	~View();

Pierre Kraemer's avatar
Pierre Kraemer committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
	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();
49 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
	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
83 84
	void setCurrentModelViewMatrix(const glm::mat4& mvm);
	void setCurrentProjectionMatrix(const glm::mat4& pm);
85

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

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

protected:
	QString m_name;
Pierre Kraemer's avatar
Pierre Kraemer committed
93
	Window* m_window;
Pierre Kraemer's avatar
Pierre Kraemer committed
94
	Scene* m_scene;
Pierre Kraemer's avatar
Pierre Kraemer committed
95
	QGLContext* m_context;
96 97
	Camera* m_currentCamera;

Pierre Kraemer's avatar
Pierre Kraemer committed
98
//	ViewButtonArea* m_buttonArea;
99

Pierre Kraemer's avatar
Pierre Kraemer committed
100 101 102 103 104 105 106 107 108 109
//	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;
110

Pierre Kraemer's avatar
Pierre Kraemer committed
111
//	bool b_showButtons;
112

Pierre Kraemer's avatar
Pierre Kraemer committed
113 114
	QString m_textInfo;
	bool b_drawText;
115

Pierre Kraemer's avatar
Pierre Kraemer committed
116 117 118 119 120 121
//public slots:
//	void linkView();
//	void unlinkView();
//	void cameraGesture();
//	void cameraSceneGesture();
//	void closeView();
122

Pierre Kraemer's avatar
Pierre Kraemer committed
123 124
//signals:
//	void currentCameraChanged(Camera* camera);
125 126 127
};

#endif