diff -r 94c92c923713 -r 40a1cf2f38f5 src/ui/canvas.h --- a/src/ui/canvas.h Sun Jul 25 13:49:37 2021 +0300 +++ b/src/ui/canvas.h Sun Jul 25 16:26:38 2021 +0300 @@ -1,4 +1,5 @@ #pragma once +#include #include #include #include "gl/partrenderer.h" @@ -11,38 +12,17 @@ public: struct MouseClickInfo; struct MouseMoveInfo; - enum PreviewLayerName : std::int8_t - { - DrawToolPreview - }; - struct PreviewLayer - { - struct Point - { - glm::vec3 location; - QBrush brush = {}; - QPen pen = {}; - }; - struct Polygon - { - geom::NPolygon geometry; - QBrush brush = {}; - QPen pen = {}; - }; - QVector points; - QVector polygons; - }; - static constexpr int NUM_PREVIEW_LAYERS = 1; - + using OverpaintCallback = std::function; Canvas( Model* model, DocumentManager* documents, const ldraw::ColorTable& colorTable, QWidget* parent = nullptr); - const PreviewLayer& getPreviewLayer(PreviewLayerName name) const; - PreviewLayer& modifyPreviewLayer(PreviewLayerName name); void clearSelection(); void addToSelection(ldraw::id_t id); + void setOverpaintCallback(OverpaintCallback fn); + void drawWorldPoint(QPainter* painter, const glm::vec3& worldPoint) const; + void drawWorldPolygon(QPainter* painter, const std::vector& points); public slots: void handleSelectionChange(const QSet& selectedIds, const QSet& deselectedIds); protected: @@ -67,7 +47,7 @@ geom::Plane gridPlane; int totalMouseMove = 0; QSet selection; - PreviewLayer previewLayers[NUM_PREVIEW_LAYERS]; + OverpaintCallback overpaintCallback = nullptr; }; struct Canvas::MouseClickInfo