Mon, 19 Jul 2021 23:41:52 +0300
added preview layer code and fixed build warnings
#pragma once #include "gl/partrenderer.h" #include "gl/gridprogram.h" #include "gl/axesprogram.h" class Canvas : public PartRenderer { Q_OBJECT public: struct MouseClickInfo; enum PreviewLayerName : std::int8_t { DrawToolPreview }; struct PreviewLayer { QSet<geom::NPolygon> polygons; QColor color{64, 255, 128}; }; static constexpr int NUM_PREVIEW_LAYERS = 1; Canvas( Model* model, DocumentManager* documents, const ldraw::ColorTable& colorTable, QWidget* parent = nullptr); const PreviewLayer& getPreviewLayer(PreviewLayerName name) const; PreviewLayer& modifyPreviewLayer(PreviewLayerName name); public slots: void handleSelectionChange(const QSet<ldraw::id_t>& selectedIds, const QSet<ldraw::id_t>& deselectedIds); protected: void mouseMoveEvent(QMouseEvent* event) override; void mousePressEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override; void initializeGL() override; void paintGL() override; signals: void newStatusText(const QString& newStatusText); void selectionChanged(const QSet<ldraw::id_t>& newSelection); void mouseClick(const MouseClickInfo& info); private: void updateGridMatrix(); glm::vec3 cameraVector() const; bool isGridPerpendicularToScreen(float threshold) const; std::optional<GridProgram> gridProgram; std::optional<AxesProgram> axesProgram; std::optional<glm::vec3> worldPosition; glm::mat4 gridMatrix; geom::Plane gridPlane; int totalMouseMove = 0; QSet<ldraw::id_t> selection; PreviewLayer previewLayers[NUM_PREVIEW_LAYERS]; }; struct Canvas::MouseClickInfo { bool click; };