00001 #include <GL/glew.h> 00002 #include <qgl.h> 00003 #include <wrap/gl/glwraptetra.h> 00004 #include <wrap/gl/pick.h> 00005 #include <wrap/gui/trackball.h> 00006 #include "myclasses.h" 00007 #include "tetrastats.h" 00008 00009 00010 00011 class MyGLWidget: public QGLWidget{ 00012 00013 Q_OBJECT 00014 00015 private : 00016 int _H; 00017 int _W; 00018 vcg::Trackball Track; 00019 vcg::GLWrapTetra<MyTetraMesh::TetraContainer > *WT; 00020 00021 GLdouble projection[16]; 00022 GLdouble modelMatrix[16]; 00023 GLint viewport[4]; 00024 00025 00026 int modality;//rendering modality 00027 enum mousemod {MMTrackball, MMSection,MMNavigateSection};//modality of using mouse 00028 mousemod mouse_modality; 00029 00030 00031 vcg::Trackball TrackClip; 00032 00034 int _ShowBar; 00035 00036 enum { 00037 SIMPLEX = 0x00000001, // show vertex number and tetrahedrons number 00038 PHYSICS = 0x00000002, // show also physical information about the mesh 00039 QUALITY = 0x00000004, // show informations about aspect ratio 00040 }; 00041 00042 00043 public: 00044 00045 MyGLWidget( QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WFlags f = 0 ); 00046 00047 virtual void glDraw(); 00048 void resizeGL( int w, int h ); 00049 virtual void mousePressEvent ( QMouseEvent * e ); 00050 virtual void mouseReleaseEvent(QMouseEvent * e ); 00051 virtual void mouseMoveEvent ( QMouseEvent * e ); 00052 virtual void wheelEvent ( QWheelEvent * e ); 00053 virtual void keyPressEvent(QKeyEvent *k); 00054 virtual void initializeGL(); 00055 virtual void SaveMatrix(); 00056 void DrawTetraMesh(); 00057 void DrawBox(); 00058 bool ShowTextSimplex(); 00059 bool ShowTextPhysics(); 00060 bool ShowTextQuality(); 00061 void DrawTextInfo(); 00062 void LoadMatrix(); 00063 00064 public slots: 00065 00067 void setBox(){ 00068 modality=0; 00069 repaint(); 00070 }; 00071 00073 void setWire(){ 00074 modality=1; 00075 repaint(); 00076 }; 00077 00079 void setHidden(){ 00080 modality=2; 00081 repaint(); 00082 }; 00083 00085 void setFlat(){ 00086 modality=3; 00087 repaint(); 00088 }; 00089 00091 void setFlatWire(){ 00092 modality=4; 00093 repaint(); 00094 }; 00095 00097 void setSmooth(){ 00098 modality=5; 00099 repaint(); 00100 }; 00101 00103 void setSmallTetra() 00104 { 00105 modality=6; 00106 repaint(); 00107 }; 00108 00109 //set trackball modality 00110 void TrackMouseModality() 00111 { 00112 mouse_modality=MMTrackball; 00113 }; 00114 00115 //set trackball modality 00116 void SectionMouseModality() 00117 { 00118 mouse_modality=MMSection; 00119 }; 00120 00122 void SwitchTextSimplex() 00123 { 00124 if (ShowTextSimplex()) 00125 _ShowBar&=~SIMPLEX; 00126 else 00127 _ShowBar|=SIMPLEX; 00128 repaint(); 00129 }; 00130 00132 void SwitchTextPhysics() 00133 { 00134 if (ShowTextPhysics()) 00135 _ShowBar&=~PHYSICS; 00136 else 00137 _ShowBar|=PHYSICS; 00138 repaint(); 00139 }; 00140 00142 void SwitchTextQuality() 00143 { 00144 if (ShowTextQuality()) 00145 _ShowBar&=~QUALITY; 00146 else 00147 _ShowBar|=QUALITY; 00148 repaint(); 00149 }; 00150 00151 };