src/qvgui/qvglcanvas.h

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007, 2008. PARP Research Group.
00003  *      <http://perception.inf.um.es>
00004  *      University of Murcia, Spain.
00005  *
00006  *      This file is part of the QVision library.
00007  *
00008  *      QVision is free software: you can redistribute it and/or modify
00009  *      it under the terms of the GNU Lesser General Public License as
00010  *      published by the Free Software Foundation, version 3 of the License.
00011  *
00012  *      QVision is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *      GNU Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with QVision. If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00024 
00025 #ifndef QVGLCANVAS_H
00026 #define QVGLCANVAS_H
00027 
00028 #include <QVWorker>
00029 #include <QVMatrix>
00030 #include <QVQuaternion>
00031 
00032 #include <qvgui/qv3dmodel.h>
00033 
00034 #ifndef DOXYGEN_IGNORE_THIS
00035 
00064 class QVGLCanvas : public QGLWidget, public QVPropertyContainer
00065 {
00066 Q_OBJECT
00067 
00068 public:
00069         QVGLCanvas(const QString &title, QWidget* parent = 0);
00070         ~QVGLCanvas ();
00071 
00072         virtual void init() {};
00073         virtual void display() {};
00074         virtual void reshape(int w, int h) {};
00075 
00076         void linkModelMatrix(QVWorker &worker, const QString &matrixPropertyName, const QString &objectName);
00077         void add(const QV3DModel &model, const QString &name);
00078         GLuint bindTexture(const QVImage<uChar,3> &image, GLenum target = GL_TEXTURE_2D);
00079         //GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D);
00080         //GLuint bindTexture(const QVImage<uChar>);
00081 
00082 signals:
00083         void closed();
00084 
00085 protected:
00086 
00087         void initializeGL();
00088         void paintGL();
00089         void resizeGL(int w, int h );
00090 
00091         void drawModels();
00092 
00093         void mousePressEvent(QMouseEvent * event);
00094         void mouseReleaseEvent(QMouseEvent *event);
00095         void mouseMoveEvent(QMouseEvent *event);
00096         void wheelEvent(QWheelEvent *event);
00097         void keyPressEvent(QKeyEvent *event);
00098         
00099         void closeEvent(QCloseEvent * event);
00100 
00101         int beginx, beginy;
00102         QVQuaternion trackballQuat;
00103         double zoom;
00104         bool pressedleft,pressedright;
00105         double maxwide;
00106         double cx,cy,cz;
00107 };
00108 
00109 #endif
00110 #endif