Mon, 24 Aug 2020 22:55:37 +0300
add comments
47 | 1 | #pragma once |
2 | #include "gl/partrenderer.h" | |
61
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
57
diff
changeset
|
3 | #include "gl/gridprogram.h" |
70 | 4 | #include "gl/axesprogram.h" |
47 | 5 | |
6 | class Canvas : public PartRenderer | |
7 | { | |
8 | Q_OBJECT | |
9 | public: | |
10 | Canvas( | |
11 | Model* model, | |
12 | DocumentManager* documents, | |
13 | const ldraw::ColorTable& colorTable, | |
14 | QWidget* parent = nullptr); | |
51 | 15 | public slots: |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
70
diff
changeset
|
16 | void handleSelectionChange(const QSet<ldraw::id_t>& selectedIds, const QSet<ldraw::id_t>& deselectedIds); |
47 | 17 | protected: |
18 | void mouseMoveEvent(QMouseEvent* event) override; | |
51 | 19 | void mousePressEvent(QMouseEvent* event) override; |
20 | void mouseReleaseEvent(QMouseEvent* event) override; | |
61
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
57
diff
changeset
|
21 | void initializeGL() override; |
57
5c0005f63319
use glm::unProject to implement screenToModelCoordinates
Teemu Piippo <teemu@hecknology.net>
parents:
51
diff
changeset
|
22 | void paintGL() override; |
47 | 23 | signals: |
24 | void newStatusText(const QString& newStatusText); | |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
70
diff
changeset
|
25 | void selectionChanged(const QSet<ldraw::id_t>& newSelection); |
51 | 26 | private: |
64
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
61
diff
changeset
|
27 | void updateGridMatrix(); |
67 | 28 | glm::vec3 cameraVector() const; |
66
77c819262b7a
added a method to find out if the view is perpendicular to grid
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
29 | bool isGridPerpendicularToScreen(float threshold) const; |
61
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
57
diff
changeset
|
30 | std::optional<GridProgram> gridProgram; |
70 | 31 | std::optional<AxesProgram> axesProgram; |
57
5c0005f63319
use glm::unProject to implement screenToModelCoordinates
Teemu Piippo <teemu@hecknology.net>
parents:
51
diff
changeset
|
32 | std::optional<glm::vec3> worldPosition; |
64
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
61
diff
changeset
|
33 | glm::mat4 gridMatrix; |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
61
diff
changeset
|
34 | geom::Plane gridPlane; |
51 | 35 | int totalMouseMove = 0; |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
70
diff
changeset
|
36 | QSet<ldraw::id_t> selection; |
47 | 37 | }; |