1 #pragma once |
1 #pragma once |
|
2 #include <QBrush> |
|
3 #include <QPen> |
2 #include "gl/partrenderer.h" |
4 #include "gl/partrenderer.h" |
3 #include "gl/gridprogram.h" |
5 #include "gl/gridprogram.h" |
4 #include "gl/axesprogram.h" |
6 #include "gl/axesprogram.h" |
5 |
7 |
6 class Canvas : public PartRenderer |
8 class Canvas : public PartRenderer |
7 { |
9 { |
8 Q_OBJECT |
10 Q_OBJECT |
9 public: |
11 public: |
10 struct MouseClickInfo; |
12 struct MouseClickInfo; |
|
13 struct MouseMoveInfo; |
11 enum PreviewLayerName : std::int8_t |
14 enum PreviewLayerName : std::int8_t |
12 { |
15 { |
13 DrawToolPreview |
16 DrawToolPreview |
14 }; |
17 }; |
15 struct PreviewLayer |
18 struct PreviewLayer |
16 { |
19 { |
17 QVector<geom::NPolygon> polygons; |
20 struct Point |
18 QColor color{64, 255, 128}; |
21 { |
|
22 glm::vec3 location; |
|
23 QBrush brush = {}; |
|
24 QPen pen = {}; |
|
25 }; |
|
26 struct Polygon |
|
27 { |
|
28 geom::NPolygon geometry; |
|
29 QBrush brush = {}; |
|
30 QPen pen = {}; |
|
31 }; |
|
32 QVector<Point> points; |
|
33 QVector<Polygon> polygons; |
19 }; |
34 }; |
20 static constexpr int NUM_PREVIEW_LAYERS = 1; |
35 static constexpr int NUM_PREVIEW_LAYERS = 1; |
21 |
36 |
22 Canvas( |
37 Canvas( |
23 Model* model, |
38 Model* model, |
38 void paintGL() override; |
53 void paintGL() override; |
39 signals: |
54 signals: |
40 void newStatusText(const QString& newStatusText); |
55 void newStatusText(const QString& newStatusText); |
41 void selectionChanged(const QSet<ldraw::id_t>& newSelection); |
56 void selectionChanged(const QSet<ldraw::id_t>& newSelection); |
42 void mouseClick(const MouseClickInfo& info); |
57 void mouseClick(const MouseClickInfo& info); |
|
58 void mouseMove(const MouseMoveInfo& info); |
43 private: |
59 private: |
44 void updateGridMatrix(); |
60 void updateGridMatrix(); |
45 glm::vec3 cameraVector() const; |
61 glm::vec3 cameraVector() const; |
46 bool isGridPerpendicularToScreen(float threshold) const; |
62 bool isGridPerpendicularToScreen(float threshold) const; |
47 std::optional<GridProgram> gridProgram; |
63 std::optional<GridProgram> gridProgram; |