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

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

#include "types.h"
8
#include "window.h"
9 10
#include "Utils/gl_matrices.h"

11 12
class ViewButtonArea;
class ViewButton;
13

14 15 16 17
class CameraViewDialog;
class PluginsViewDialog;
class MapsViewDialog;

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

public:
23 24
	static unsigned int viewCount;

Pierre Kraemer's avatar
Pierre Kraemer committed
25
	View(const QString& name, Window* w, const QGLWidget* shareWidget = NULL);
26 27
	~View();

28
	const QString& getName() const { return m_name; }
Pierre Kraemer's avatar
Pierre Kraemer committed
29 30
	void setName(const QString& name) { m_name = name; }

31
	Window* getWindow() const { return m_window; }
Pierre Kraemer's avatar
Pierre Kraemer committed
32 33
	void setWindow(Window* w) { m_window = w; }

34 35
	bool isCurrentView() const { return m_window->getCurrentView() == this; }

36 37
	virtual void init();
	virtual void preDraw();
38
	virtual void draw();
39 40 41
	virtual void postDraw();
	virtual void resizeGL(int width, int height);

42 43
	void drawText();
	void drawButtons();
44
	void drawFrame();
45 46

	void keyPressEvent(QKeyEvent* event);
47
	void keyReleaseEvent(QKeyEvent *event);
48 49 50 51 52
	void mousePressEvent(QMouseEvent* event);
	void mouseReleaseEvent(QMouseEvent* event);
	void mouseMoveEvent(QMouseEvent* event);
	void wheelEvent(QWheelEvent* event);

53 54 55 56
	/*********************************************************
	 * MANAGE LINKED CAMERA
	 *********************************************************/

57
	Camera* getCurrentCamera() const { return m_currentCamera; }
58 59 60 61 62 63 64 65
	void setCurrentCamera(Camera* c);

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

	void linkPlugin(Plugin* plugin);
	void unlinkPlugin(Plugin* plugin);
66 67
	const QList<Plugin*>& getLinkedPlugins() const { return l_plugins; }
	bool isLinkedToPlugin(Plugin* plugin) const { return l_plugins.contains(plugin); }
68 69 70 71 72

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

73 74
	void linkMap(MapHandlerGen* map);
	void unlinkMap(MapHandlerGen* map);
75 76
	const QList<MapHandlerGen*>& getLinkedMaps() const { return l_maps; }
	bool isLinkedToMap(MapHandlerGen* map) const { return l_maps.contains(map); }
77 78


79 80 81 82


	void updateTextInfo();

83 84 85
	glm::mat4 getCurrentModelViewMatrix() const;
	glm::mat4 getCurrentProjectionMatrix() const;
	glm::mat4 getCurrentModelViewProjectionMatrix() const;
86

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

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

94
	Camera* m_currentCamera;
95
	QList<Plugin*> l_plugins;
96 97 98 99
	QList<MapHandlerGen*> l_maps;

	qglviewer::Vec bbmin;
	qglviewer::Vec bbmax;
100

101
	ViewButtonArea* m_buttonArea;
102

103 104 105 106
	ViewButton* m_cameraButton;
	ViewButton* m_pluginsButton;
	ViewButton* m_mapsButton;
	ViewButton* m_closeButton;
Pierre Kraemer's avatar
Pierre Kraemer committed
107 108
	ViewButton* m_VsplitButton;
	ViewButton* m_HsplitButton;
109

Pierre Kraemer's avatar
Pierre Kraemer committed
110
	QString m_textInfo;
111

112 113 114 115
	CameraViewDialog* m_cameraViewDialog;
	PluginsViewDialog* m_pluginsViewDialog;
	MapsViewDialog* m_mapsViewDialog;

116
public slots:
117 118 119 120
	void cb_cameraView(int x, int y, int globalX, int globalY);
	void cb_pluginsView(int x, int y, int globalX, int globalY);
	void cb_mapsView(int x, int y, int globalX, int globalY);
	void cb_closeView(int x, int y, int globalX, int globalY);
Pierre Kraemer's avatar
Pierre Kraemer committed
121 122
	void cb_VsplitView(int x, int y, int globalX, int globalY);
	void cb_HsplitView(int x, int y, int globalX, int globalY);
123 124 125
};

#endif