src/ui/canvas.h

changeset 105
6ca6e8c647d4
parent 104
cd4df75924b7
child 106
128efb9d148b
equal deleted inserted replaced
104:cd4df75924b7 105:6ca6e8c647d4
6 class Canvas : public PartRenderer 6 class Canvas : public PartRenderer
7 { 7 {
8 Q_OBJECT 8 Q_OBJECT
9 public: 9 public:
10 struct MouseClickInfo; 10 struct MouseClickInfo;
11 enum PreviewLayerName : std::int8_t
12 {
13 DrawToolPreview
14 };
15 struct PreviewLayer
16 {
17 QSet<geom::NPolygon> polygons;
18 QColor color{64, 255, 128};
19 };
20 static constexpr int NUM_PREVIEW_LAYERS = 1;
21
11 Canvas( 22 Canvas(
12 Model* model, 23 Model* model,
13 DocumentManager* documents, 24 DocumentManager* documents,
14 const ldraw::ColorTable& colorTable, 25 const ldraw::ColorTable& colorTable,
15 QWidget* parent = nullptr); 26 QWidget* parent = nullptr);
27 const PreviewLayer& getPreviewLayer(PreviewLayerName name) const;
28 PreviewLayer& modifyPreviewLayer(PreviewLayerName name);
16 public slots: 29 public slots:
17 void handleSelectionChange(const QSet<ldraw::id_t>& selectedIds, const QSet<ldraw::id_t>& deselectedIds); 30 void handleSelectionChange(const QSet<ldraw::id_t>& selectedIds, const QSet<ldraw::id_t>& deselectedIds);
18 protected: 31 protected:
19 void mouseMoveEvent(QMouseEvent* event) override; 32 void mouseMoveEvent(QMouseEvent* event) override;
20 void mousePressEvent(QMouseEvent* event) override; 33 void mousePressEvent(QMouseEvent* event) override;
34 std::optional<glm::vec3> worldPosition; 47 std::optional<glm::vec3> worldPosition;
35 glm::mat4 gridMatrix; 48 glm::mat4 gridMatrix;
36 geom::Plane gridPlane; 49 geom::Plane gridPlane;
37 int totalMouseMove = 0; 50 int totalMouseMove = 0;
38 QSet<ldraw::id_t> selection; 51 QSet<ldraw::id_t> selection;
52 PreviewLayer previewLayers[NUM_PREVIEW_LAYERS];
39 }; 53 };
40 54
41 struct Canvas::MouseClickInfo 55 struct Canvas::MouseClickInfo
42 { 56 {
43 bool click; 57 bool click;

mercurial