PARP Research Group University of Murcia, Spain


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(const QString &title, float worldx1=-1.0, float worldy1=-1.0, float worldz1=-1.0, float worldx2=1.0, float worldy2=1.0, float worldz2=1.0, bool dr_box=TRUE, bool dr_center=TRUE, QWidget* parent=0);
00071         ~QVGLCanvas ();
00072 
00073         virtual void init() {};
00074         virtual void display() {};
00075         virtual void reshape(int w, int h) {};
00076 
00077         void linkModelMatrix(QVWorker &worker, const QString &matrixPropertyName, const QString &objectName);
00078         void add(const QV3DModel &model, const QString &name);
00079         GLuint bindTexture(const QVImage<uChar,3> &image, GLenum target = GL_TEXTURE_2D);
00080         //GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D);
00081         //GLuint bindTexture(const QVImage<uChar>);
00082 
00083 signals:
00084         void closed();
00085 
00086 protected:
00087 
00088         void initializeGL();
00089         void paintGL();
00090         void resizeGL(int w, int h );
00091 
00092         void drawModels();
00093 
00094         void mousePressEvent(QMouseEvent * event);
00095         void mouseReleaseEvent(QMouseEvent *event);
00096         void mouseMoveEvent(QMouseEvent *event);
00097         void wheelEvent(QWheelEvent *event);
00098         void keyPressEvent(QKeyEvent *event);
00099         
00100         void closeEvent(QCloseEvent * event);
00101 
00102 private:
00103         void draw_center_of_rotation();
00104         void draw_world_box();
00105         
00106         int beginx, beginy;
00107         QVQuaternion trackballQuat;
00108         double zoom;
00109         bool pressedleft,pressedright;
00110         double cx,cy,cz;
00111         double wx1,wy1,wz1,wx2,wy2,wz2; /* Real world limits */
00112         double widex,widey,widez,maxwide; /* Real world widths */
00113         bool dr_box,dr_center;
00114 };
00115 
00116 #endif
00117 #endif



QVision framework. PARP research group, copyright 2007, 2008.