46 #ifndef OPENMESHAPPS_QGLVIEWERWIDGET_HH
47 #define OPENMESHAPPS_QGLVIEWERWIDGET_HH
53 #include <OpenMesh/Core/Geometry/VectorT.hh>
54 #include <QtOpenGL/qgl.h>
55 #include <QGLShaderProgram>
76 typedef QGLWidget Super;
96 void set_scene_pos(
const OpenMesh::Vec3f& _center,
float _radius );
108 const std::string& current_draw_mode()
const
109 {
return draw_mode_ ? draw_mode_names_[draw_mode_-1] : nomode_; }
111 float radius()
const {
return radius_; }
112 const OpenMesh::Vec3f& center()
const {
return center_; }
114 const GLdouble* modelview_matrix()
const {
return modelview_matrix_; }
115 const GLdouble* projection_matrix()
const {
return projection_matrix_; }
117 float fovy()
const {
return 45.0f; }
119 QAction* findAction(
const char *name);
120 void addAction(QAction* action,
const char* name);
121 void removeAction(
const char* name);
122 void removeAction(QAction* action);
127 virtual void draw_scene(
const std::string& _draw_mode);
129 double performance(
void);
131 void setDefaultMaterial(
void);
132 void setDefaultLight(
void);
137 void slotDrawMode(QAction *_mode);
138 void slotSnapshot(
void );
146 bool QGLViewerWidget::prepareShaderProgram(
const QString& vertexShaderPath,
147 const QString& fragmentShaderPath );
153 void resizeGL(
int w,
int h );
158 virtual void mousePressEvent( QMouseEvent* );
159 virtual void mouseReleaseEvent( QMouseEvent* );
160 virtual void mouseMoveEvent( QMouseEvent* );
161 virtual void wheelEvent( QWheelEvent* );
162 virtual void keyPressEvent( QKeyEvent* );
167 void update_projection_matrix();
170 void translate(
const OpenMesh::Vec3f& _trans);
173 void rotate(
const OpenMesh::Vec3f& _axis,
float _angle);
175 OpenMesh::Vec3f center_;
178 GLdouble projection_matrix_[16],
179 modelview_matrix_[16];
181 QGLShaderProgram m_shader;
186 QActionGroup* draw_modes_group_;
187 typedef std::map<QString,QAction*> ActionMap;
188 ActionMap names_to_actions;
189 unsigned int draw_mode_;
190 unsigned int n_draw_modes_;
191 std::vector<std::string> draw_mode_names_;
192 static std::string nomode_;
197 bool map_to_sphere(
const QPoint& _point, OpenMesh::Vec3f& _result);
199 QPoint last_point_2D_;
200 OpenMesh::Vec3f last_point_3D_;
209 #endif // OPENMESHAPPS_QGLVIEWERWIDGET_HH