view.h 2.64 KB
Newer Older
1 2 3
#ifndef _VIEW_H_
#define _VIEW_H_

4 5
#include <GL/glew.h>
#include <QGLViewer/qglviewer.h>
6 7 8 9

#include "types.h"
#include "Utils/gl_matrices.h"

Pierre Kraemer's avatar
Pierre Kraemer committed
10 11
class ViewButtonArea;
class ViewButton;
12 13 14 15 16 17

class View : public QGLViewer
{
	Q_OBJECT

public:
18 19 20
	static unsigned int viewCount;

	View(const QString& name, Window* w, QWidget* parent, const QGLWidget* shareWidget = NULL);
21 22
	~View();

Pierre Kraemer's avatar
Pierre Kraemer committed
23 24 25 26 27 28 29
	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; }

	virtual void initGL();
30 31 32 33 34 35
	virtual void updateGL();
	virtual void draw();
	void drawText();
	void drawButtons();

	void keyPressEvent(QKeyEvent* event);
Pierre Kraemer's avatar
Pierre Kraemer committed
36
	void keyReleaseEvent(QKeyEvent *event);
37 38 39 40 41 42 43 44 45 46 47 48
	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);

Pierre Kraemer's avatar
Pierre Kraemer committed
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
	/*********************************************************
	 * MANAGE LINKED CAMERA
	 *********************************************************/

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

	/*********************************************************
	 * MANAGE LINKED PLUGINS
	 *********************************************************/

	void linkPlugin(Plugin* plugin);
	void unlinkPlugin(Plugin* plugin);
	QList<Plugin*> getLinkedPlugins() { return l_plugins; }
	bool isLinkedToPlugin(Plugin* plugin) { return l_plugins.contains(plugin); }

	/*********************************************************
	 * MANAGE LINKED MAPS
	 *********************************************************/

	void linkMap(MapHandler* map);
	void unlinkMap(MapHandler* map);
	QList<MapHandler*> getLinkedMaps() { return l_maps; }
	bool isLinkedToMap(MapHandler* map) { return l_maps.contains(map); }


75 76 77 78 79 80 81 82


	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 86 87

protected:
	QString m_name;
Pierre Kraemer's avatar
Pierre Kraemer committed
88
	Window* m_window;
89

90
	Camera* m_currentCamera;
Pierre Kraemer's avatar
Pierre Kraemer committed
91 92
	QList<Plugin*> l_plugins;
	QList<MapHandler*> l_maps;
93

Pierre Kraemer's avatar
Pierre Kraemer committed
94
	ViewButtonArea* m_buttonArea;
95

Pierre Kraemer's avatar
Pierre Kraemer committed
96 97 98 99
	ViewButton* m_cameraButton;
	ViewButton* m_pluginsButton;
	ViewButton* m_mapsButton;
	ViewButton* m_closeButton;
100

Pierre Kraemer's avatar
Pierre Kraemer committed
101
	QString m_textInfo;
Pierre Kraemer's avatar
Pierre Kraemer committed
102 103 104

public slots:
	void cb_cameraView();
105

Pierre Kraemer's avatar
Pierre Kraemer committed
106 107
//signals:
//	void currentCameraChanged(Camera* camera);
108 109 110
};

#endif