qtQGLV_glw.h 3.87 KB
Newer Older
Sylvain Thery's avatar
Sylvain Thery committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*******************************************************************************
 * CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
 * version 0.1                                                                  *
 * Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
 *                                                                              *
 * This library is free software; you can redistribute it and/or modify it      *
 * under the terms of the GNU Lesser General Public License as published by the *
 * Free Software Foundation; either version 2.1 of the License, or (at your     *
 * option) any later version.                                                   *
 *                                                                              *
 * This library is distributed in the hope that it will be useful, but WITHOUT  *
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License  *
 * for more details.                                                            *
 *                                                                              *
 * You should have received a copy of the GNU Lesser General Public License     *
 * along with this library; if not, write to the Free Software Foundation,      *
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
 *                                                                              *
 * Web site: http://cgogn.unistra.fr/                                           *
 * Contact information: cgogn@unistra.fr                                        *
 *                                                                              *
 *******************************************************************************/

#ifndef __QTQGLVIEWER_GLW_H
#define __QTQGLVIEWER_GLW_H

Sylvain Thery's avatar
Sylvain Thery committed
28 29
#include <GL/glew.h>

Sylvain Thery's avatar
Sylvain Thery committed
30 31 32 33
#include <QApplication>
#include <QDesktopWidget>
#include <QMainWindow>
#include <QWidget>
Sylvain Thery's avatar
Sylvain Thery committed
34
//#include <QtGui>
Sylvain Thery's avatar
Sylvain Thery committed
35 36 37 38 39 40 41 42 43
#include <QGLViewer/qglviewer.h>

#include <set>
#include <string>
#include "Geometry/vector_gen.h"
#include "Utils/gl_matrices.h"

namespace CGoGN { namespace Utils { class GLSLShader; } }

Sylvain Thery's avatar
Sylvain Thery committed
44 45 46 47 48 49
#ifdef WIN32
#if defined CGoGN_QT_DLL_EXPORT
#define CGoGN_UTILS_API __declspec(dllexport)
#else
#define CGoGN_UTILS_API __declspec(dllimport)
#endif
Thery Sylvain's avatar
Thery Sylvain committed
50 51
#else
#define CGoGN_UTILS_API
Sylvain Thery's avatar
Sylvain Thery committed
52 53
#endif

Sylvain Thery's avatar
Sylvain Thery committed
54 55 56 57 58 59 60 61 62 63 64 65
namespace CGoGN
{

namespace Utils
{

namespace QT
{
// forward definition
class SimpleQGLV;


Sylvain Thery's avatar
Sylvain Thery committed
66
class CGoGN_UTILS_API QGLView : public QGLViewer
Sylvain Thery's avatar
Sylvain Thery committed
67 68 69 70 71 72 73
{
	Q_OBJECT
protected:
	SimpleQGLV* m_sqgl;
	int W;
	int H;
	int m_state_modifier;
Sylvain Thery's avatar
Sylvain Thery committed
74
	int m_current_button;
Sylvain Thery's avatar
Sylvain Thery committed
75 76

public:
Sylvain Thery's avatar
Sylvain Thery committed
77
	QGLView(SimpleQGLV* ptr, QWidget *parent = 0);
Sylvain Thery's avatar
Sylvain Thery committed
78 79
	~QGLView();

80
	void setObjectBB(float* bbmin, float* bbmax);
Sylvain Thery's avatar
Sylvain Thery committed
81 82 83 84 85 86 87 88 89 90 91 92 93
	void setParamObject(float width, float* pos);
	void glMousePosition(int& x, int& y);

	virtual void init();
	virtual void preDraw();
	virtual void draw();
	virtual void postDraw() {}
	virtual void resizeGL(int width, int height);

	void mousePressEvent(QMouseEvent* event);
	void mouseReleaseEvent(QMouseEvent* event);
	void mouseClickEvent(QMouseEvent* event);
//	void mouseDoubleClickEvent(QMouseEvent* event);
Sylvain Thery's avatar
Sylvain Thery committed
94
	void mouseMoveEvent(QMouseEvent* event);
Sylvain Thery's avatar
Sylvain Thery committed
95 96 97 98 99 100 101 102 103
	void keyPressEvent(QKeyEvent* event);
	void keyReleaseEvent(QKeyEvent* event);
//	void wheelEvent(QWheelEvent* event);
	bool Shift() { return m_state_modifier & Qt::ShiftModifier; }
	bool Control() { return m_state_modifier & Qt::ControlModifier; }
	bool Alt() { return m_state_modifier & Qt::AltModifier; }
	int getHeight() const { return H; }
	int getWidth() const { return W; }

Sylvain Thery's avatar
Sylvain Thery committed
104 105 106
	GLfloat getOrthoScreenRay(int x, int y, Geom::Vec3f& rayA, Geom::Vec3f& rayB, int radius);
	float getWidthInWorld(unsigned int pixel_width, const Geom::Vec3f& center);

Sylvain Thery's avatar
Sylvain Thery committed
107 108 109 110 111 112 113 114 115 116 117 118 119
	QSize minimumSizeHint() const;
	QSize sizeHint() const;

};


} // namespace QT

} // namespace Utils

} // namespace CGoGN

#endif