view.h 2.96 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
class CameraViewDialog;
class PluginsViewDialog;
class MapsViewDialog;

17 18 19 20 21
class View : public QGLViewer
{
	Q_OBJECT

public:
22 23 24
	static unsigned int viewCount;

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

Pierre Kraemer's avatar
Pierre Kraemer committed
27 28 29 30 31 32
	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; }

33 34
	virtual void init();
	virtual void preDraw();
35
	virtual void draw();
36 37 38
	virtual void postDraw();
	virtual void resizeGL(int width, int height);

39 40 41 42
	void drawText();
	void drawButtons();

	void keyPressEvent(QKeyEvent* event);
Pierre Kraemer's avatar
Pierre Kraemer committed
43
	void keyReleaseEvent(QKeyEvent *event);
44 45 46 47 48 49 50 51 52 53
	void mousePressEvent(QMouseEvent* event);
	void mouseReleaseEvent(QMouseEvent* event);
	void mouseMoveEvent(QMouseEvent* event);
	void wheelEvent(QWheelEvent* event);

	void drawOverpaint(QPainter *painter);

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

Pierre Kraemer's avatar
Pierre Kraemer committed
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
	/*********************************************************
	 * 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); }


80 81 82 83 84 85 86 87


	void updateTextInfo();

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

Pierre Kraemer's avatar
Pierre Kraemer committed
88 89
	void setCurrentModelViewMatrix(const glm::mat4& mvm);
	void setCurrentProjectionMatrix(const glm::mat4& pm);
90 91 92

protected:
	QString m_name;
Pierre Kraemer's avatar
Pierre Kraemer committed
93
	Window* m_window;
94

95
	Camera* m_currentCamera;
Pierre Kraemer's avatar
Pierre Kraemer committed
96 97
	QList<Plugin*> l_plugins;
	QList<MapHandler*> l_maps;
98

Pierre Kraemer's avatar
Pierre Kraemer committed
99
	ViewButtonArea* m_buttonArea;
100

Pierre Kraemer's avatar
Pierre Kraemer committed
101 102 103 104
	ViewButton* m_cameraButton;
	ViewButton* m_pluginsButton;
	ViewButton* m_mapsButton;
	ViewButton* m_closeButton;
105

Pierre Kraemer's avatar
Pierre Kraemer committed
106
	QString m_textInfo;
Pierre Kraemer's avatar
Pierre Kraemer committed
107

108 109 110 111
	CameraViewDialog* m_cameraViewDialog;
	PluginsViewDialog* m_pluginsViewDialog;
	MapsViewDialog* m_mapsViewDialog;

Pierre Kraemer's avatar
Pierre Kraemer committed
112
public slots:
113 114 115 116
	void cb_cameraView(int x, int y);
	void cb_pluginsView(int x, int y);
	void cb_mapsView(int x, int y);
	void cb_closeView(int x, int y);
117

Pierre Kraemer's avatar
Pierre Kraemer committed
118 119
//signals:
//	void currentCameraChanged(Camera* camera);
120 121 122
};

#endif