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