view.h 3.81 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"

Pierre Kraemer's avatar
Pierre Kraemer committed
11 12 13 14 15 16
namespace CGoGN
{

namespace SCHNApps
{

Pierre Kraemer's avatar
Pierre Kraemer committed
17 18
class ViewButtonArea;
class ViewButton;
19

20 21 22 23
class CameraViewDialog;
class PluginsViewDialog;
class MapsViewDialog;

24 25 26 27 28
class View : public QGLViewer
{
	Q_OBJECT

public:
29 30
	static unsigned int viewCount;

Pierre Kraemer's avatar
Pierre Kraemer committed
31
	View(const QString& name, Window* w, const QGLWidget* shareWidget = NULL);
32 33
	~View();

34
	const QString& getName() const { return m_name; }
35 36 37

public slots:
	QString getName() { return m_name; }
Pierre Kraemer's avatar
Pierre Kraemer committed
38 39
	void setName(const QString& name) { m_name = name; }

40
	Window* getWindow() const { return m_window; }
Pierre Kraemer's avatar
Pierre Kraemer committed
41 42
	void setWindow(Window* w) { m_window = w; }

43 44
	bool isCurrentView() const { return m_window->getCurrentView() == this; }

45
public:
46 47
	virtual void init();
	virtual void preDraw();
48
	virtual void draw();
49 50 51
	virtual void postDraw();
	virtual void resizeGL(int width, int height);

52 53
	void drawText();
	void drawButtons();
54
	void drawFrame();
55 56

	void keyPressEvent(QKeyEvent* event);
Pierre Kraemer's avatar
Pierre Kraemer committed
57
	void keyReleaseEvent(QKeyEvent *event);
58 59 60 61 62
	void mousePressEvent(QMouseEvent* event);
	void mouseReleaseEvent(QMouseEvent* event);
	void mouseMoveEvent(QMouseEvent* event);
	void wheelEvent(QWheelEvent* event);

Pierre Kraemer's avatar
Pierre Kraemer committed
63 64 65 66
	/*********************************************************
	 * MANAGE LINKED CAMERA
	 *********************************************************/

67
public slots:
68
	Camera* getCurrentCamera() const { return m_currentCamera; }
69 70

public:
Pierre Kraemer's avatar
Pierre Kraemer committed
71 72 73 74 75 76 77 78
	void setCurrentCamera(Camera* c);

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

	void linkPlugin(Plugin* plugin);
	void unlinkPlugin(Plugin* plugin);
79 80
	const QList<Plugin*>& getLinkedPlugins() const { return l_plugins; }
	bool isLinkedToPlugin(Plugin* plugin) const { return l_plugins.contains(plugin); }
Pierre Kraemer's avatar
Pierre Kraemer committed
81 82 83 84 85

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

86 87
	void linkMap(MapHandlerGen* map);
	void unlinkMap(MapHandlerGen* map);
88 89
	const QList<MapHandlerGen*>& getLinkedMaps() const { return l_maps; }
	bool isLinkedToMap(MapHandlerGen* map) const { return l_maps.contains(map); }
Pierre Kraemer's avatar
Pierre Kraemer committed
90

91
	void updateViewBB();
Pierre Kraemer's avatar
Pierre Kraemer committed
92

93 94 95
	/*********************************************************
	 * MANAGE MATRICES
	 *********************************************************/
96

97 98 99
	glm::mat4 getCurrentModelViewMatrix() const;
	glm::mat4 getCurrentProjectionMatrix() const;
	glm::mat4 getCurrentModelViewProjectionMatrix() const;
100 101 102

protected:
	QString m_name;
Pierre Kraemer's avatar
Pierre Kraemer committed
103
	Window* m_window;
104

105
	Camera* m_currentCamera;
Pierre Kraemer's avatar
Pierre Kraemer committed
106
	QList<Plugin*> l_plugins;
107 108
	QList<MapHandlerGen*> l_maps;

Pierre Kraemer's avatar
Pierre Kraemer committed
109
	ViewButtonArea* m_buttonArea;
110

Pierre Kraemer's avatar
Pierre Kraemer committed
111 112 113 114
	ViewButton* m_cameraButton;
	ViewButton* m_pluginsButton;
	ViewButton* m_mapsButton;
	ViewButton* m_closeButton;
Pierre Kraemer's avatar
Pierre Kraemer committed
115 116
	ViewButton* m_VsplitButton;
	ViewButton* m_HsplitButton;
117

Pierre Kraemer's avatar
Pierre Kraemer committed
118
	QString m_textInfo;
Pierre Kraemer's avatar
Pierre Kraemer committed
119

120 121 122 123
	CameraViewDialog* m_cameraViewDialog;
	PluginsViewDialog* m_pluginsViewDialog;
	MapsViewDialog* m_mapsViewDialog;

Pierre Kraemer's avatar
Pierre Kraemer committed
124
public slots:
125 126 127 128
	CameraViewDialog* getCameraViewDialog() { return m_cameraViewDialog; }
	PluginsViewDialog* getPluginsViewDialog() { return m_pluginsViewDialog; }
	MapsViewDialog* getMapsViewDialog() { return m_mapsViewDialog; }

129 130 131 132
	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
133 134
	void cb_VsplitView(int x, int y, int globalX, int globalY);
	void cb_HsplitView(int x, int y, int globalX, int globalY);
135 136 137 138 139 140 141 142 143

signals:
	void currentCameraChanged(Camera*);

	void mapLinked(MapHandlerGen*);
	void mapUnlinked(MapHandlerGen*);

	void pluginLinked(Plugin*);
	void pluginUnlinked(Plugin*);
144 145
};

Pierre Kraemer's avatar
Pierre Kraemer committed
146 147 148 149
} // namespace SCHNApps

} // namespace CGoGN

150
#endif