00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef GLAREA_H_
00034 #define GLAREA_H_
00035
00037 #include <GL/glew.h>
00038 #include <QtOpenGL/QGLWidget>
00039
00041 #include <vcg/simplex/vertex/base.h>
00042 #include <vcg/simplex/face/base.h>
00043 #include <vcg/complex/trimesh/base.h>
00044 #include <vcg/complex/trimesh/update/bounding.h>
00045 #include <vcg/complex/trimesh/update/normal.h>
00046 #include <vcg/complex/trimesh/create/platonic.h>
00047
00049 #include <wrap/io_trimesh/import.h>
00050 #include <wrap/gl/trimesh.h>
00051 #include <wrap/gui/trackball.h>
00052
00054
00055 using namespace vcg;
00056 class CFace;
00057 class CVertex;
00058
00059 struct MyUsedTypes : public UsedTypes< Use<CVertex> ::AsVertexType,
00060 Use<CFace> ::AsFaceType>{};
00061
00063 class CVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags>{};
00064 class CFace : public vcg::Face< MyUsedTypes, vcg::face::VertexRef, vcg::face::Normal3f, vcg::face::BitFlags > {};
00065 class CMesh : public vcg::tri::TriMesh< std::vector<CVertex>, std::vector<CFace> > {};
00066
00067 class GLArea:public QGLWidget
00068 {
00069 Q_OBJECT
00070 public:
00071 GLArea (QWidget * parent = 0);
00073 enum DrawMode{SMOOTH=0,POINTS,WIRE,FLATWIRE,HIDDEN,FLAT};
00074 public slots:
00076 void selectDrawMode(int mode);
00077 void loadMesh(QString filename);
00078 void loadTetrahedron();
00079 void loadDodecahedron();
00080 signals:
00082 void setStatusBar(QString message);
00083 protected:
00085 void initializeGL ();
00086 void resizeGL (int w, int h);
00087 void paintGL ();
00089 void keyReleaseEvent(QKeyEvent * e);
00090 void keyPressEvent(QKeyEvent * e);
00091 void mousePressEvent(QMouseEvent*e);
00092 void mouseMoveEvent(QMouseEvent*e);
00093 void mouseReleaseEvent(QMouseEvent*e);
00094 void wheelEvent(QWheelEvent*e);
00095 private:
00097 CMesh mesh;
00099 vcg::GlTrimesh<CMesh> glWrap;
00101 vcg::Trackball track;
00103 DrawMode drawmode;
00105 void initMesh(QString message);
00106 };
00107
00108 #endif