Tue, 14 Jun 2022 20:35:11 +0300
fix comment
24 | 1 | /* |
2 | * LDForge: LDraw parts authoring CAD | |
3 | * Copyright (C) 2013 - 2020 Teemu Piippo | |
4 | * | |
5 | * This program is free software: you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation, either version 3 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
47 | 19 | #include <QMouseEvent> |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
20 | #include <QPainter> |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
21 | #include "document.h" |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
22 | #include "model.h" |
191
d355d4c52d51
made editing tools not a polymorphic class tree
Teemu Piippo <teemu@hecknology.net>
parents:
188
diff
changeset
|
23 | #include "ui/objecteditor.h" |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
24 | #include "gl/partrenderer.h" |
125
f127982d3412
Move tools under Document instead of MainWindow
Teemu Piippo <teemu@hecknology.net>
parents:
124
diff
changeset
|
25 | |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
26 | EditTools::EditTools(QObject* parent) : |
214
8e1fe64ce4e3
begin refactor of gl side
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
205
diff
changeset
|
27 | QObject{parent}, |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
28 | RenderLayer{} |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
29 | { |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
30 | } |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
31 | |
214
8e1fe64ce4e3
begin refactor of gl side
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
205
diff
changeset
|
32 | EditTools::~EditTools() |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
33 | { |
9
8b9780700b5e
added saving of splitter state and recent files
Teemu Piippo <teemu@hecknology.net>
parents:
8
diff
changeset
|
34 | } |
36
bbb901b97404
added render style storage
Teemu Piippo <teemu@hecknology.net>
parents:
35
diff
changeset
|
35 | |
214
8e1fe64ce4e3
begin refactor of gl side
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
205
diff
changeset
|
36 | void EditTools::setEditMode(EditingMode mode) |
125
f127982d3412
Move tools under Document instead of MainWindow
Teemu Piippo <teemu@hecknology.net>
parents:
124
diff
changeset
|
37 | { |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
38 | this->mode = mode; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
39 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
40 | |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
41 | void EditTools::setGridMatrix(const glm::mat4& gridMatrix) |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
42 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
43 | this->gridMatrix = gridMatrix; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
44 | this->gridPlane = planeFromTriangle({ |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
45 | this->gridMatrix * glm::vec4{0, 0, 0, 1}, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
46 | this->gridMatrix * glm::vec4{1, 0, 0, 1}, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
47 | this->gridMatrix * glm::vec4{0, 1, 0, 1}, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
48 | }); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
49 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
50 | |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
51 | void EditTools::mvpMatrixChanged(const glm::mat4& matrix) |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
52 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
53 | this->mvpMatrix = matrix; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
54 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
55 | |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
56 | void EditTools::mouseMoved(const QMouseEvent* event) |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
57 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
58 | this->worldPosition = this->renderer->screenToModelCoordinates(event->pos(), this->gridPlane); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
59 | if (this->worldPosition.has_value()) |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
60 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
61 | // Snap the position to grid. This procedure is basically the "change of basis" and almost follows the |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
62 | // A⁻¹ × M × A formula which is used to perform a transformation in some other coordinate system, except |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
63 | // we actually use the inverted matrix first and the regular one last to perform the transformation of |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
64 | // grid coordinates in our XY coordinate system. Also, we're rounding the coordinates which is obviously |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
65 | // not a linear transformation, but fits the pattern anyway. |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
66 | // First transform the coordinates to the XY plane... |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
67 | this->worldPosition = glm::inverse(this->gridMatrix) * glm::vec4{*this->worldPosition, 1}; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
68 | // Then round the coordinates to integer precision... |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
69 | this->worldPosition = glm::round(*this->worldPosition); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
70 | // And finally transform it back to grid coordinates by transforming it with the |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
71 | // grid matrix. |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
72 | this->worldPosition = this->gridMatrix * glm::vec4{*this->worldPosition, 1}; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
73 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
74 | this->updatePreviewPolygon(); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
75 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
76 | |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
77 | static QVector<QPointF> convertWorldPointsToScreenPoints( |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
78 | const std::vector<glm::vec3> &worldPoints, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
79 | const PartRenderer* renderer) |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
80 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
81 | QVector<QPointF> points2d; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
82 | points2d.reserve(worldPoints.size()); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
83 | for (const glm::vec3& point : worldPoints) |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
84 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
85 | points2d.push_back(renderer->modelToScreenCoordinates(point)); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
86 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
87 | return points2d; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
88 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
89 | |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
90 | static Winding worldPolygonWinding( |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
91 | const std::vector<glm::vec3> &points, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
92 | const PartRenderer* renderer) |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
93 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
94 | return winding(QPolygonF{convertWorldPointsToScreenPoints(points, renderer)}); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
95 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
96 | |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
97 | static void drawWorldPoint( |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
98 | QPainter* painter, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
99 | const glm::vec3& worldPoint, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
100 | const PartRenderer* renderer) |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
101 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
102 | const QPointF center = renderer->modelToScreenCoordinates(worldPoint); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
103 | painter->drawEllipse(inscribe(CircleF{center, 5})); |
125
f127982d3412
Move tools under Document instead of MainWindow
Teemu Piippo <teemu@hecknology.net>
parents:
124
diff
changeset
|
104 | } |
f127982d3412
Move tools under Document instead of MainWindow
Teemu Piippo <teemu@hecknology.net>
parents:
124
diff
changeset
|
105 | |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
106 | static void drawWorldPolyline( |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
107 | QPainter *painter, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
108 | const std::vector<glm::vec3> &points, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
109 | const PartRenderer* renderer) |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
110 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
111 | painter->drawPolyline(QPolygonF{convertWorldPointsToScreenPoints(points, renderer)}); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
112 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
113 | |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
114 | static void drawWorldPolygon( |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
115 | QPainter* painter, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
116 | const std::vector<glm::vec3> &points, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
117 | const PartRenderer* renderer) |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
118 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
119 | painter->drawPolygon(QPolygonF{convertWorldPointsToScreenPoints(points, renderer)}); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
120 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
121 | |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
122 | void EditTools::overpaint(QPainter* painter) |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
123 | { |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
124 | struct Pens |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
125 | { |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
126 | const QBrush pointBrush; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
127 | const QPen pointPen; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
128 | const QPen polygonPen; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
129 | const QPen badPolygonPen; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
130 | const QBrush greenPolygonBrush; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
131 | const QBrush redPolygonBrush; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
132 | }; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
133 | static const Pens brightPens{ |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
134 | .pointBrush = {Qt::white}, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
135 | .pointPen = {QBrush{Qt::black}, 2.0}, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
136 | .polygonPen = {QBrush{Qt::black}, 2.0, Qt::DashLine}, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
137 | .badPolygonPen = {QBrush{Qt::red}, 2.0, Qt::DashLine}, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
138 | .greenPolygonBrush = {QColor{64, 255, 128, 192}}, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
139 | .redPolygonBrush = {QColor{255, 96, 96, 192}}, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
140 | }; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
141 | static const Pens darkPens{ |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
142 | .pointBrush = {Qt::black}, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
143 | .pointPen = {QBrush{Qt::white}, 2.0}, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
144 | .polygonPen = {QBrush{Qt::white}, 2.0, Qt::DashLine}, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
145 | .badPolygonPen = {QBrush{Qt::red}, 2.0, Qt::DashLine}, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
146 | .greenPolygonBrush = {QColor{64, 255, 128, 192}}, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
147 | .redPolygonBrush = {QColor{255, 96, 96, 192}}, |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
148 | }; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
149 | const Pens& pens = (this->renderer->isDark() ? darkPens : brightPens); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
150 | switch(this->mode) { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
151 | case SelectMode: |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
152 | break; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
153 | case DrawMode: |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
154 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
155 | painter->setPen(this->isconcave ? pens.badPolygonPen : pens.polygonPen); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
156 | if (this->previewPolygon.size() > 2 and not this->isconcave) |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
157 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
158 | if (worldPolygonWinding(this->previewPolygon, this->renderer) == Winding::Clockwise) { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
159 | painter->setBrush(pens.greenPolygonBrush); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
160 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
161 | else { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
162 | painter->setBrush(pens.redPolygonBrush); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
163 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
164 | drawWorldPolygon(painter, this->previewPolygon, this->renderer); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
165 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
166 | else { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
167 | drawWorldPolyline(painter, this->previewPolygon, this->renderer); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
168 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
169 | painter->setBrush(pens.pointBrush); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
170 | painter->setPen(pens.pointPen); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
171 | for (const glm::vec3& point : this->polygon) { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
172 | drawWorldPoint(painter, point, this->renderer); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
173 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
174 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
175 | break; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
176 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
177 | if (this->worldPosition.has_value()) |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
178 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
179 | painter->setRenderHint(QPainter::Antialiasing); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
180 | painter->setPen(Qt::white); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
181 | painter->setBrush(Qt::green); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
182 | const QPointF pos = this->renderer->modelToScreenCoordinates(*this->worldPosition); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
183 | painter->drawEllipse(pos, 5, 5); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
184 | painter->drawText(pos + QPointF{5, 5}, vectorToString(*this->worldPosition)); |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
185 | } |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
186 | } |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
187 | |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
188 | void EditTools::updatePreviewPolygon() |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
189 | { |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
190 | this->previewPolygon = this->polygon; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
191 | if (this->worldPosition.has_value()) { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
192 | this->previewPolygon.resize(this->polygon.size() + 1); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
193 | this->previewPolygon.back() = *this->worldPosition; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
194 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
195 | if (this->previewPolygon.size() > 2) |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
196 | { |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
197 | this->isconcave = not isConvex(this->previewPolygon); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
198 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
199 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
200 | |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
201 | void EditTools::removeLastPoint() |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
202 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
203 | if (this->polygon.size() > 0) |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
204 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
205 | this->polygon.erase(this->polygon.end() - 1); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
206 | this->updatePreviewPolygon(); |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
207 | } |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
208 | } |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
209 | |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
210 | bool isCloseToExistingPoints(const std::vector<glm::vec3>& points, const glm::vec3 &pos) |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
211 | { |
201
5d201ee4a9c3
Continue giant refactor
Teemu Piippo <teemu@hecknology.net>
parents:
200
diff
changeset
|
212 | return any(points, std::bind(isclose, std::placeholders::_1, pos)); |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
213 | } |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
214 | |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
215 | EditingMode EditTools::currentEditingMode() const |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
216 | { |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
217 | return this->mode; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
218 | } |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
219 | |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
220 | void EditTools::mouseClick(const QMouseEvent* event) |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
221 | { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
222 | switch(this->mode) { |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
223 | case SelectMode: |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
224 | if (event->button() == Qt::LeftButton) { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
225 | const ModelId highlighted = this->renderer->pick(event->pos()); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
226 | Q_EMIT this->select({highlighted}, false); |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
227 | } |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
228 | break; |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
229 | case DrawMode: |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
230 | if (event->button() == Qt::LeftButton and this->worldPosition.has_value()) { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
231 | if (isCloseToExistingPoints(this->polygon, *this->worldPosition)) { |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
232 | this->closeShape(); |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
233 | } |
214
8e1fe64ce4e3
begin refactor of gl side
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
205
diff
changeset
|
234 | else { |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
235 | this->polygon.push_back(*this->worldPosition); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
236 | this->updatePreviewPolygon(); |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
237 | } |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
238 | } |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
239 | else if (true |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
240 | and event->button() == Qt::RightButton |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
241 | and this->polygon.size() > 0 |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
242 | ) { |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
243 | this->polygon.erase(this->polygon.end() - 1); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
244 | updatePreviewPolygon(); |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
245 | } |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
246 | break; |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
247 | } |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
248 | } |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
249 | |
214
8e1fe64ce4e3
begin refactor of gl side
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
205
diff
changeset
|
250 | void EditTools::closeShape() |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
251 | { |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
252 | if (this->polygon.size() >= 2 and this->polygon.size() <= 4) { |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
253 | switch (this->polygon.size()) { |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
254 | case 2: |
204
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
255 | Q_EMIT this->modelAction(AppendToModel{ |
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
256 | .newElement = Colored<LineSegment>{ |
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
257 | LineSegment{ |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
258 | .p1 = this->polygon[0], |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
259 | .p2 = this->polygon[1], |
204
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
260 | }, |
205 | 261 | EDGE_COLOR, |
204
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
262 | } |
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
263 | }); |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
264 | break; |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
265 | case 3: |
204
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
266 | Q_EMIT this->modelAction(AppendToModel{ |
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
267 | .newElement = Colored<Triangle>{ |
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
268 | Triangle{ |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
269 | .p1 = this->polygon[0], |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
270 | .p2 = this->polygon[1], |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
271 | .p3 = this->polygon[2], |
204
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
272 | }, |
205 | 273 | MAIN_COLOR, |
204
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
274 | } |
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
275 | }); |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
276 | break; |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
277 | case 4: |
204
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
278 | Q_EMIT this->modelAction(AppendToModel{ |
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
279 | .newElement = Colored<Quadrilateral>{ |
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
280 | Quadrilateral{ |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
281 | .p1 = this->polygon[0], |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
282 | .p2 = this->polygon[1], |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
283 | .p3 = this->polygon[2], |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
284 | .p4 = this->polygon[3], |
204
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
285 | }, |
205 | 286 | MAIN_COLOR, |
204
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
287 | } |
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
288 | }); |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
289 | break; |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
290 | } |
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
291 | } |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
292 | this->polygon.clear(); |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
293 | this->updatePreviewPolygon(); |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
294 | } |