view.h 4.3 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
4
5
#ifndef _VIEW_H_
#define _VIEW_H_

#include <GL/glew.h>
#include <QGLViewer/qglviewer.h>
6
#include <QGLViewer/manipulatedFrame.h>
Pierre Kraemer's avatar
Pierre Kraemer committed
7

Sylvain Thery's avatar
Sylvain Thery committed
8
9
#include "dialogList.h"

Pierre Kraemer's avatar
Pierre Kraemer committed
10
11
#include "schnapps.h"
#include "Utils/gl_matrices.h"
12
#include "Utils/GLSLShader.h"
13
#include "Utils/Shaders/shaderWallPaper.h"
14
#include "Utils/drawer.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
15
16
17
18
19
20
21
22
23
24
25
26

namespace CGoGN
{

namespace SCHNApps
{

class Camera;
class ViewButtonArea;
class ViewButton;
class PluginInteraction;

Sylvain Thery's avatar
Sylvain Thery committed
27

Pierre Kraemer's avatar
Pierre Kraemer committed
28
29
30
31
32
33
34
35
36
class View : public QGLViewer
{
	Q_OBJECT

	friend class SCHNApps;

public:
	static unsigned int viewCount;

37
38
	View(const QString& name, SCHNApps* s, QGLFormat& format);
	View(const QString& name, SCHNApps* s,  QGLFormat& format, const QGLWidget* shareWidget);
Pierre Kraemer's avatar
Pierre Kraemer committed
39
40
41
42
	~View();

	const QString& getName() const { return m_name; }

43
	MapHandlerGen* lastSelectedMap() { return m_lastSelectedMap;}
Sylvain Thery's avatar
Sylvain Thery committed
44
45

	void closeDialogs();
46

Pierre Kraemer's avatar
Pierre Kraemer committed
47
48
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
75
76
77
public slots:
	QString getName() { return m_name; }
	SCHNApps* getSCHNApps() const { return m_schnapps; }

	bool isSelectedView() const { return m_schnapps->getSelectedView() == this; }

	void setCurrentCamera(Camera* c);
	void setCurrentCamera(const QString& name);

	Camera* getCurrentCamera() const { return m_currentCamera; }
	bool usesCamera(const QString& cameraName) const;

	void linkPlugin(PluginInteraction* plugin);
	void linkPlugin(const QString& name);
	void unlinkPlugin(PluginInteraction* plugin);
	void unlinkPlugin(const QString& name);

	const QList<PluginInteraction*>& getLinkedPlugins() const { return l_plugins; }
	bool isLinkedToPlugin(PluginInteraction* plugin) const { return l_plugins.contains(plugin); }
	bool isLinkedToPlugin(const QString& name) const;

	void linkMap(MapHandlerGen* map);
	void linkMap(const QString& name);
	void unlinkMap(MapHandlerGen* map);
	void unlinkMap(const QString& name);

	const QList<MapHandlerGen*>& getLinkedMaps() const { return l_maps; }
	bool isLinkedToMap(MapHandlerGen* map) const { return l_maps.contains(map); }
	bool isLinkedToMap(const QString& name) const;

private:
Sylvain Thery's avatar
Sylvain Thery committed
78
79
	bool b_updatingUI;

Pierre Kraemer's avatar
Pierre Kraemer committed
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
	virtual void init();
	virtual void preDraw();
	virtual void draw();
	virtual void postDraw();
	virtual void resizeGL(int width, int height);

	void drawButtons();
	void drawFrame();

	void keyPressEvent(QKeyEvent* event);
	void keyReleaseEvent(QKeyEvent *event);
	void mousePressEvent(QMouseEvent* event);
	void mouseReleaseEvent(QMouseEvent* event);
	void mouseMoveEvent(QMouseEvent* event);
	void wheelEvent(QWheelEvent* event);

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

Sylvain Thery's avatar
Sylvain Thery committed
100
//	void updateCurrentCameraBB();
Pierre Kraemer's avatar
Pierre Kraemer committed
101
102

private slots:
103
104
	void selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur);

Pierre Kraemer's avatar
Pierre Kraemer committed
105
106
107
108
	void ui_verticalSplitView(int x, int y, int globalX, int globalY);
	void ui_horizontalSplitView(int x, int y, int globalX, int globalY);
	void ui_closeView(int x, int y, int globalX, int globalY);

Sylvain Thery's avatar
Sylvain Thery committed
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
	void ui_mapsListView(int x, int y, int globalX, int globalY);
	void ui_pluginsListView(int x, int y, int globalX, int globalY);
	void ui_camerasListView(int x, int y, int globalX, int globalY);

	void mapAdded(MapHandlerGen* map);
	void mapRemoved(MapHandlerGen* map);
	void pluginEnabled(Plugin *plugin);
	void pluginDisabled(Plugin *plugin);
	void cameraAdded(Camera* camera);
	void cameraRemoved(Camera* camera);

	void mapCheckStateChanged(QListWidgetItem* item);
	void pluginCheckStateChanged(QListWidgetItem* item);
	void cameraCheckStateChanged(QListWidgetItem* item);

Pierre Kraemer's avatar
Pierre Kraemer committed
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
signals:
	void currentCameraChanged(Camera*, Camera*);

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

	void pluginLinked(PluginInteraction*);
	void pluginUnlinked(PluginInteraction*);

protected:
	QString m_name;
	SCHNApps* m_schnapps;

	Camera* m_currentCamera;
	QList<PluginInteraction*> l_plugins;
	QList<MapHandlerGen*> l_maps;
140
	MapHandlerGen* m_lastSelectedMap;
Pierre Kraemer's avatar
Pierre Kraemer committed
141
142
143
144
145
146
147

	ViewButtonArea* m_buttonArea;

	ViewButton* m_closeButton;
	ViewButton* m_VsplitButton;
	ViewButton* m_HsplitButton;

Sylvain Thery's avatar
Sylvain Thery committed
148
149
150
151
152
	ViewButtonArea* m_buttonAreaLeft;
	ViewButton* m_mapsButton;
	ViewButton* m_pluginsButton;
	ViewButton* m_camerasButton;

Pierre Kraemer's avatar
Pierre Kraemer committed
153
	QString m_textInfo;
Sylvain Thery's avatar
Sylvain Thery committed
154
155
156
157
158

	ListPopUp* m_dialogMaps;
	ListPopUp* m_dialogPlugins;
	ListPopUp* m_dialogCameras;

159
160
	Utils::Drawer* m_frameDrawer;

161
162
	Utils::Texture<2, Geom::Vec3uc>* m_textureWallpaper;
	Utils::ShaderWallPaper* m_shaderWallpaper;
Pierre Kraemer's avatar
Pierre Kraemer committed
163
164
165
166
167
168
169
};

} // namespace SCHNApps

} // namespace CGoGN

#endif