]> git.sur5r.net Git - fstl/blob - src/canvas.h
Cross-thread lambda functions fail on win32
[fstl] / src / canvas.h
1 #ifndef CANVAS_H
2 #define CANVAS_H
3
4 #include <QWidget>
5 #include <QtOpenGL/QGLWidget>
6 #include <QtOpenGL/QGLShaderProgram>
7 #include <QMatrix4x4>
8
9 class GLMesh;
10 class Mesh;
11 class Backdrop;
12
13 class Canvas : public QGLWidget
14 {
15     Q_OBJECT
16
17 public:
18     Canvas(const QGLFormat& format, QWidget* parent=0);
19
20     void initializeGL();
21     void paintEvent(QPaintEvent* event);
22     ~Canvas();
23
24 public slots:
25     void set_status(const QString& s);
26     void clear_status();
27     void load_mesh(Mesh* m);
28
29
30 protected:
31     void mousePressEvent(QMouseEvent* event);
32     void mouseReleaseEvent(QMouseEvent* event);
33     void mouseMoveEvent(QMouseEvent* event);
34
35
36 private:
37     void draw_mesh();
38
39     QMatrix4x4 transform_matrix() const;
40     QMatrix4x4 view_matrix() const;
41
42     QGLShaderProgram mesh_shader;
43     QGLShaderProgram quad_shader;
44
45     GLMesh* mesh;
46     Backdrop* backdrop;
47
48     QVector3D center;
49     float scale;
50     float tilt;
51     float yaw;
52
53     QPoint mouse_pos;
54     QString status;
55 };
56
57 #endif // CANVAS_H