#ifndef OPENGLSCENE_H #define OPENGLSCENE_H #include "point3d.h" #include #include class Model; class OpenGLScene : public QGraphicsScene { Q_OBJECT public: OpenGLScene(); void drawBackground(QPainter *painter, const QRectF &rect); QColor backgroundColor() const; QColor modelColor() const; public slots: void setModel(Model *model); void enableWireframe(bool enabled); void enableNormals(bool enabled); void setLightPosition(int pos); void setModelColor(const QColor &color); void setBackgroundColor(const QColor &color); protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void wheelEvent(QGraphicsSceneWheelEvent * wheelEvent); private: bool m_wireframeEnabled; bool m_normalsEnabled; float m_lightPos; float m_distance; QColor m_modelColor; QColor m_backgroundColor; Model *m_model; QTime m_time; int m_lastTime; int m_mouseEventTime; Point3d m_rotation; Point3d m_angularMomentum; Point3d m_accumulatedMomentum; }; #endif