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
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef OPENMESHAPPS_QGLVIEWERWIDGET_HH
00044 #define OPENMESHAPPS_QGLVIEWERWIDGET_HH
00045
00046
00047
00048
00049
00050 #include <OpenMesh/Core/Geometry/VectorT.hh>
00051 #include <qgl.h>
00052 #include <string>
00053 #include <vector>
00054
00055
00056
00057
00058
00059 class QPopupMenu;
00060
00061
00062
00063
00064
00065 class QGLViewerWidget : public QGLWidget
00066 {
00067
00068 Q_OBJECT
00069
00070 public:
00071
00072
00073 QGLViewerWidget( QWidget* _parent=0, const char* _name=0 );
00074
00075
00076 virtual ~QGLViewerWidget();
00077
00078
00079
00080
00081 void set_scene_pos( const OpenMesh::Vec3f& _center, float _radius );
00082
00083
00084
00085 void view_all();
00086
00088 void add_draw_mode(const std::string& _s);
00089
00090 float radius() const { return radius_; }
00091 const OpenMesh::Vec3f& center() const { return center_; }
00092
00093 const GLdouble* modelview_matrix() const { return modelview_matrix_; }
00094 const GLdouble* projection_matrix() const { return projection_matrix_; }
00095 void set_modelview_matrix(const GLdouble _modelview_matrix[16])
00096 { memcpy(modelview_matrix_, _modelview_matrix, 16*sizeof(GLdouble)); }
00097 void set_projection_matrix(const GLdouble _projection_matrix[16])
00098 { memcpy(projection_matrix_, _projection_matrix, 16*sizeof(GLdouble)); }
00099
00100 float fovy() const { return 45.0f; }
00101
00102 protected:
00103
00104
00105 virtual void draw_scene(const std::string& _draw_mode);
00106
00107 double performance(void);
00108
00109 private slots:
00110
00111
00112 void slotPopupMenu(int _id);
00113
00114 private:
00115
00116
00117 void initializeGL();
00118
00119
00120 void paintGL();
00121
00122
00123 void resizeGL( int w, int h );
00124
00125 protected:
00126
00127
00128 virtual void mousePressEvent( QMouseEvent* );
00129 virtual void mouseReleaseEvent( QMouseEvent* );
00130 virtual void mouseMoveEvent( QMouseEvent* );
00131 virtual void wheelEvent( QWheelEvent* );
00132 virtual void keyPressEvent( QKeyEvent* );
00133
00134 private:
00135
00136
00137 void update_projection_matrix();
00138
00139 protected:
00140
00141 void translate(const OpenMesh::Vec3f& _trans);
00142
00143
00144 void rotate(const OpenMesh::Vec3f& _axis, float _angle);
00145
00146 OpenMesh::Vec3f center_;
00147 float radius_;
00148
00149 GLdouble projection_matrix_[16],
00150 modelview_matrix_[16];
00151
00152
00153
00154 QPopupMenu* popup_menu_;
00155 unsigned int draw_mode_;
00156 unsigned int n_draw_modes_;
00157 std::vector<std::string> draw_mode_names_;
00158
00159
00160
00161
00162 bool map_to_sphere(const QPoint& _point, OpenMesh::Vec3f& _result);
00163
00164 QPoint last_point_2D_;
00165 OpenMesh::Vec3f last_point_3D_;
00166 bool last_point_ok_;
00167
00168 };
00169
00170
00171
00172 #endif // OPENMESHAPPS_QGLVIEWERWIDGET_HH
00173
00174