#ifndef VIEWPORTWIDGET_H #define VIEWPORTWIDGET_H #include #include #include #include #include #include class ViewCube; class SketchGrid; class Document; class FeatureBrowser; class ViewportWidget : public QOpenGLWidget, protected QOpenGLFunctions { Q_OBJECT public: enum class SketchPlane { NONE, XY, XZ, YZ }; explicit ViewportWidget(QWidget *parent = nullptr); ~ViewportWidget(); void startSketch(SketchPlane plane); void setDocument(Document* document); protected: void initializeGL() override; void paintGL() override; void resizeGL(int w, int h) override; void mousePressEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; void wheelEvent(QWheelEvent *event) override; private: QVector3D project(const QVector3D& worldCoord, const QMatrix4x4& modelView, const QMatrix4x4& projection, const QRect& viewport); void drawAxisLabels(QPainter& painter, const QMatrix4x4& modelView, const QMatrix4x4& projection); QMatrix4x4 projection; ViewCube* m_viewCube; SketchGrid* m_sketchGrid = nullptr; FeatureBrowser* m_featureBrowser = nullptr; SketchPlane m_currentPlane = SketchPlane::NONE; float xRot = 0; float yRot = 0; float zoom = -5.0f; float panX = 0; float panY = 0; QPoint lastPos; }; #endif // VIEWPORTWIDGET_H