diff options
Diffstat (limited to 'graphicsscene.h')
-rw-r--r-- | graphicsscene.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/graphicsscene.h b/graphicsscene.h new file mode 100644 index 0000000..9618cf7 --- /dev/null +++ b/graphicsscene.h @@ -0,0 +1,57 @@ +#ifndef GRAPHICSSCENE_H +#define GRAPHICSSCENE_H + +#include "point3d.h" + +#include <QFutureWatcher> +#include <QGraphicsScene> + +class Model; + +class GraphicsScene : public QGraphicsScene +{ + Q_OBJECT + +public: + GraphicsScene(); + + void drawBackground(QPainter *painter, const QRectF &rect); + +public slots: + void setModel(Model *model); + void enableAutoRotate(bool enabled); + void enableWireframe(bool enabled); + void enableNormals(bool enabled); + void setLightPosition(int pos); + void setModelColor(QRgb color); + void setBackgroundColor(QRgb color); + +protected: + void mousePressEvent(QGraphicsSceneMouseEvent *event); + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); + void mouseMoveEvent(QGraphicsSceneMouseEvent *event); + void wheelEvent(QGraphicsSceneWheelEvent * wheelEvent); + +private: + void updateMatrix(); + void updateRotation(const QPointF &last, const QPointF ¤t); + + bool m_wireframeEnabled; + bool m_normalsEnabled; + bool m_autoRotate; + bool m_rotating; + + Point3d m_axis; + float m_angle; + float m_lightPos; + float m_distance; + + QRgb m_backgroundColor; + QRgb m_modelColor; + + Model *m_model; + + float m_matrix[4][4]; +}; + +#endif |