qtQGLV_glw.h 3.69 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
/*******************************************************************************
 * 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

#include <QApplication>
#include <QDesktopWidget>
#include <QMainWindow>
#include <QWidget>
#include <QtGui>
#include <GL/glew.h>
#include <QGLViewer/qglviewer.h>

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

namespace CGoGN { namespace Utils { class GLSLShader; } }

namespace CGoGN
{

namespace Utils
{

namespace QT
{
// forward definition
class SimpleQGLV;


class QGLView : public QGLViewer
{
	Q_OBJECT
protected:
	SimpleQGLV* m_sqgl;
	int W;
	int H;
	int m_state_modifier;
Sylvain Thery's avatar
Sylvain Thery committed
63
	int m_current_button;
Sylvain Thery's avatar
Sylvain Thery committed
64 65

public:
66
	QGLView(SimpleQGLV* ptr, QGLFormat& format, QWidget *parent = 0);
Sylvain Thery's avatar
Sylvain Thery committed
67 68
	~QGLView();

69
	void setObjectBB(float* bbmin, float* bbmax);
Sylvain Thery's avatar
Sylvain Thery committed
70 71 72 73 74 75 76 77 78 79 80 81 82
	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
83
	void mouseMoveEvent(QMouseEvent* event);
Sylvain Thery's avatar
Sylvain Thery committed
84 85 86 87 88 89 90 91 92
	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
93 94 95
	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
96 97 98 99 100 101 102 103 104 105 106 107 108
	QSize minimumSizeHint() const;
	QSize sizeHint() const;

};


} // namespace QT

} // namespace Utils

} // namespace CGoGN

#endif