Tue, 11 Apr 2023 22:39:18 +0300
Split GL preferences that affect GL build to a new build preferences structure, modifying that requires rebuild, modifying render preferences does not
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 | ||
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
19 | #pragma once |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
20 | #include <memory> |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
21 | #include <QWidget> |
125
f127982d3412
Move tools under Document instead of MainWindow
Teemu Piippo <teemu@hecknology.net>
parents:
121
diff
changeset
|
22 | #include <QToolBar> |
264
76a025db4948
Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
263
diff
changeset
|
23 | #include "src/model.h" |
76a025db4948
Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
263
diff
changeset
|
24 | #include "src/vertexmap.h" |
76a025db4948
Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
263
diff
changeset
|
25 | #include "src/gl/common.h" |
322
a39f454a3d7f
Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
315
diff
changeset
|
26 | #include "src/inputvertices.h" |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
27 | |
374
75efc3ba5a56
More refactor and renaming
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
333
diff
changeset
|
28 | enum class editing_mode_e |
215
34c6e7bc4ee1
Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
29 | { |
374
75efc3ba5a56
More refactor and renaming
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
333
diff
changeset
|
30 | select, |
75efc3ba5a56
More refactor and renaming
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
333
diff
changeset
|
31 | draw, |
75efc3ba5a56
More refactor and renaming
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
333
diff
changeset
|
32 | circle |
215
34c6e7bc4ee1
Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
33 | }; |
34c6e7bc4ee1
Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
34 | |
374
75efc3ba5a56
More refactor and renaming
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
333
diff
changeset
|
35 | Q_DECLARE_METATYPE(editing_mode_e) |
215
34c6e7bc4ee1
Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
36 | |
204
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
37 | Q_DECLARE_METATYPE(ModelAction) |
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
38 | |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
215
diff
changeset
|
39 | class EditTools final : public QObject, public RenderLayer |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
40 | { |
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
41 | Q_OBJECT |
322
a39f454a3d7f
Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
315
diff
changeset
|
42 | InputVertices inputPolygon; |
374
75efc3ba5a56
More refactor and renaming
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
333
diff
changeset
|
43 | editing_mode_e mode = editing_mode_e::select; |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
215
diff
changeset
|
44 | glm::mat4 mvpMatrix; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
215
diff
changeset
|
45 | glm::mat4 gridMatrix{1}; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
215
diff
changeset
|
46 | Plane gridPlane; |
314
4642ba1218e8
Added rudimentary cylinder extrusion into circle tool.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
311
diff
changeset
|
47 | QPointF localPosition; |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
215
diff
changeset
|
48 | opt<glm::vec3> worldPosition; |
232
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
228
diff
changeset
|
49 | CircleToolOptions circleToolOptions = { |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
228
diff
changeset
|
50 | .fraction = {16, 16}, |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
228
diff
changeset
|
51 | .type = CircularPrimitive::Circle, |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
228
diff
changeset
|
52 | }; |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
53 | public: |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
215
diff
changeset
|
54 | explicit EditTools(QObject *parent = nullptr); |
214
8e1fe64ce4e3
begin refactor of gl side
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
205
diff
changeset
|
55 | ~EditTools() override; |
118 | 56 | void applyToVertices(VertexMap::ApplyFunction fn) const; |
314
4642ba1218e8
Added rudimentary cylinder extrusion into circle tool.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
311
diff
changeset
|
57 | [[nodiscard]] const QSet<ModelId> selectedObjects() const; |
374
75efc3ba5a56
More refactor and renaming
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
333
diff
changeset
|
58 | [[nodiscard]] editing_mode_e currentEditingMode() const; |
75efc3ba5a56
More refactor and renaming
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
333
diff
changeset
|
59 | Q_SLOT void setEditMode(editing_mode_e mode); |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
215
diff
changeset
|
60 | Q_SLOT void setGridMatrix(const glm::mat4& gridMatrix); |
232
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
228
diff
changeset
|
61 | Q_SLOT void setCircleToolOptions(const CircleToolOptions& options); |
112 | 62 | Q_SIGNALS: |
47 | 63 | void newStatusText(const QString& newStatusText); |
204
52e10e8d88cc
Concentrate model editing into one coroutine inside main()
Teemu Piippo <teemu@hecknology.net>
parents:
203
diff
changeset
|
64 | void modelAction(const ModelAction& action); |
333
07e65a4c6611
Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
322
diff
changeset
|
65 | void select(const QSet<std::int32_t>& ids, bool retain); |
311
fab454611f9b
Use different cursors depending on edit mode
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
309
diff
changeset
|
66 | void suggestCursor(const QCursor& cursor); |
217
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
215
diff
changeset
|
67 | protected: |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
215
diff
changeset
|
68 | void mvpMatrixChanged(const glm::mat4& matrix) override; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
215
diff
changeset
|
69 | void mouseMoved(const QMouseEvent* event) override; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
215
diff
changeset
|
70 | void mouseClick(const QMouseEvent* event) override; |
6d95c1a41e6e
reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
215
diff
changeset
|
71 | void overpaint(QPainter* painter) override; |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
72 | private: |
314
4642ba1218e8
Added rudimentary cylinder extrusion into circle tool.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
311
diff
changeset
|
73 | [[nodiscard]] const std::vector<ModelAction> modelActions() const; |
4642ba1218e8
Added rudimentary cylinder extrusion into circle tool.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
311
diff
changeset
|
74 | [[nodiscard]] const std::vector<ModelAction> circleModeActions() const; |
4642ba1218e8
Added rudimentary cylinder extrusion into circle tool.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
311
diff
changeset
|
75 | [[nodiscard]] const std::vector<ModelAction> drawModeActions() const; |
311
fab454611f9b
Use different cursors depending on edit mode
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
309
diff
changeset
|
76 | bool usePolygon() const; |
197
0e729e681a2c
move drawState to Document
Teemu Piippo <teemu@hecknology.net>
parents:
191
diff
changeset
|
77 | void closeShape(); |
228 | 78 | void renderPreview(QPainter* painter, const void* pensptr); |
315
23b47902d857
Improve preview of cylinder extrusion
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
314
diff
changeset
|
79 | [[nodiscard]] opt<float> cylinderHeight() const; |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
80 | }; |