00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
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
00081
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;
00112 double widex,widey,widez,maxwide;
00113 bool dr_box,dr_center;
00114 };
00115
00116 #endif
00117 #endif