view.h 4.54 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

Sylvain Thery's avatar
Sylvain Thery committed
17 18 19
#include "camera.h"
#include "viewButtonArea.h"
#include "plugin_interaction.h"
Sylvain Thery's avatar
Sylvain Thery committed
20

Thery Sylvain's avatar
Thery Sylvain committed
21
#include "dll.h"
Sylvain Thery's avatar
Sylvain Thery committed
22

Pierre Kraemer's avatar
Pierre Kraemer committed
23 24 25 26 27 28
namespace CGoGN
{

namespace SCHNApps
{

Sylvain Thery's avatar
Sylvain Thery committed
29 30 31 32
//class Camera;
//class ViewButtonArea;
//class ViewButton;
//class PluginInteraction;
Pierre Kraemer's avatar
Pierre Kraemer committed
33

Sylvain Thery's avatar
Sylvain Thery committed
34
class SCHNAPPS_API View : public QGLViewer
Pierre Kraemer's avatar
Pierre Kraemer committed
35 36 37 38 39 40 41 42
{
	Q_OBJECT

	friend class SCHNApps;

public:
	static unsigned int viewCount;

Sylvain Thery's avatar
Sylvain Thery committed
43 44
	View(const QString& name, SCHNApps* s);
	View(const QString& name, SCHNApps* s, const QGLWidget* shareWidget);
Pierre Kraemer's avatar
Pierre Kraemer committed
45 46 47 48
	~View();

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

49
	void getBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax) const { bbMin = m_bbMin; bbMax = m_bbMax; }
50

Pierre Kraemer's avatar
Pierre Kraemer committed
51 52 53 54 55 56 57 58 59 60
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; }
61 62
	bool usesCamera(Camera* c) const { return m_currentCamera == c; }
	bool usesCamera(const QString& name) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

	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
83 84
	bool b_updatingUI;

Pierre Kraemer's avatar
Pierre Kraemer committed
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
	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;

private slots:
106 107
	void closeDialogs();

108 109
	void selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur);

Pierre Kraemer's avatar
Pierre Kraemer committed
110 111 112 113
	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
114 115 116 117 118 119
	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);
120 121
	void mapCheckStateChanged(QListWidgetItem* item);

Sylvain Thery's avatar
Sylvain Thery committed
122 123
	void pluginEnabled(Plugin *plugin);
	void pluginDisabled(Plugin *plugin);
124 125
	void pluginCheckStateChanged(QListWidgetItem* item);

Sylvain Thery's avatar
Sylvain Thery committed
126 127 128 129
	void cameraAdded(Camera* camera);
	void cameraRemoved(Camera* camera);
	void cameraCheckStateChanged(QListWidgetItem* item);

130 131
	void updateBoundingBox();

Pierre Kraemer's avatar
Pierre Kraemer committed
132 133 134 135 136 137 138 139 140
signals:
	void currentCameraChanged(Camera*, Camera*);

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

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

141 142
	void boundingBoxChanged();

Pierre Kraemer's avatar
Pierre Kraemer committed
143 144 145 146 147 148 149
protected:
	QString m_name;
	SCHNApps* m_schnapps;

	Camera* m_currentCamera;
	QList<PluginInteraction*> l_plugins;
	QList<MapHandlerGen*> l_maps;
150 151 152

	qglviewer::Vec m_bbMin;
	qglviewer::Vec m_bbMax;
Pierre Kraemer's avatar
Pierre Kraemer committed
153 154 155 156 157 158 159

	ViewButtonArea* m_buttonArea;

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

Sylvain Thery's avatar
Sylvain Thery committed
160 161 162 163 164
	ViewButtonArea* m_buttonAreaLeft;
	ViewButton* m_mapsButton;
	ViewButton* m_pluginsButton;
	ViewButton* m_camerasButton;

Pierre Kraemer's avatar
Pierre Kraemer committed
165
	QString m_textInfo;
Sylvain Thery's avatar
Sylvain Thery committed
166 167 168 169 170

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

171 172
	Utils::Drawer* m_frameDrawer;

173 174
	Utils::Texture<2, Geom::Vec3uc>* m_textureWallpaper;
	Utils::ShaderWallPaper* m_shaderWallpaper;
175 176

	bool b_saveSnapshots;
Pierre Kraemer's avatar
Pierre Kraemer committed
177 178 179 180 181 182 183
};

} // namespace SCHNApps

} // namespace CGoGN

#endif