view.h 3.79 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
	Camera* getCurrentCamera() const { return m_currentCamera; }
Pierre Kraemer's avatar
Pierre Kraemer committed
68
69
70
71
72
73
74
75
	void setCurrentCamera(Camera* c);

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

	void linkPlugin(Plugin* plugin);
	void unlinkPlugin(Plugin* plugin);
76
77
	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
78
79
80
81
82

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

83
84
	void linkMap(MapHandlerGen* map);
	void unlinkMap(MapHandlerGen* map);
85
86
	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
87

88
	void updateViewBB();
Pierre Kraemer's avatar
Pierre Kraemer committed
89

90
91
92
	/*********************************************************
	 * MANAGE MATRICES
	 *********************************************************/
93

94
95
96
	glm::mat4 getCurrentModelViewMatrix() const;
	glm::mat4 getCurrentProjectionMatrix() const;
	glm::mat4 getCurrentModelViewProjectionMatrix() const;
97
98
99

protected:
	QString m_name;
Pierre Kraemer's avatar
Pierre Kraemer committed
100
	Window* m_window;
101

102
	Camera* m_currentCamera;
Pierre Kraemer's avatar
Pierre Kraemer committed
103
	QList<Plugin*> l_plugins;
104
105
	QList<MapHandlerGen*> l_maps;

Pierre Kraemer's avatar
Pierre Kraemer committed
106
	ViewButtonArea* m_buttonArea;
107

Pierre Kraemer's avatar
Pierre Kraemer committed
108
109
110
111
	ViewButton* m_cameraButton;
	ViewButton* m_pluginsButton;
	ViewButton* m_mapsButton;
	ViewButton* m_closeButton;
Pierre Kraemer's avatar
Pierre Kraemer committed
112
113
	ViewButton* m_VsplitButton;
	ViewButton* m_HsplitButton;
114

Pierre Kraemer's avatar
Pierre Kraemer committed
115
	QString m_textInfo;
Pierre Kraemer's avatar
Pierre Kraemer committed
116

117
118
119
120
	CameraViewDialog* m_cameraViewDialog;
	PluginsViewDialog* m_pluginsViewDialog;
	MapsViewDialog* m_mapsViewDialog;

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

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

signals:
	void currentCameraChanged(Camera*);

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

	void pluginLinked(Plugin*);
	void pluginUnlinked(Plugin*);
141
142
};

Pierre Kraemer's avatar
Pierre Kraemer committed
143
144
145
146
} // namespace SCHNApps

} // namespace CGoGN

147
#endif