Sun, 14 Feb 2016 03:19:28 +0200
Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Added transform.h that may or may not prove useful sometime
Added linelength.py that was missing from a prior commit
Converted the various boolean members of LDDocument to flags
1006
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
1 | /* |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1014
f0a8ecb6a357
Happy new year 2016!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1008
diff
changeset
|
3 | * Copyright (C) 2013 - 2016 Teemu Piippo |
1006
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
4 | * |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
8 | * (at your option) any later version. |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
9 | * |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
13 | * GNU General Public License for more details. |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
14 | * |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
17 | */ |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
18 | |
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
19 | #include <QKeyEvent> |
876
f040f0fb3795
- renamed line loop to line path, updated changelog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
875
diff
changeset
|
20 | #include "linePathMode.h" |
874
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include "../glRenderer.h" |
962
a4b463a7ee82
Rename MainWindow files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
958
diff
changeset
|
22 | #include "../mainwindow.h" |
874
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | |
876
f040f0fb3795
- renamed line loop to line path, updated changelog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
875
diff
changeset
|
24 | LinePathMode::LinePathMode (GLRenderer *renderer) : |
874
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | Super (renderer) {} |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | |
876
f040f0fb3795
- renamed line loop to line path, updated changelog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
875
diff
changeset
|
27 | void LinePathMode::render (QPainter& painter) const |
874
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | { |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | QVector<QPointF> points; |
1008
74cb432812d3
Fixed circle, rectangle and line path modes not working anymore. Add blip coordinates to curve and line path modes. Circle mode for now only can show the coordinates of the initial blip
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
30 | QList<Vertex> points3d = m_drawedVerts; |
875
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
31 | points3d << renderer()->position3D(); |
874
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | |
875
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
33 | for (Vertex const& vrt : points3d) |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
962
diff
changeset
|
34 | points << renderer()->convert3dTo2d (vrt); |
874
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | painter.setPen (renderer()->textPen()); |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
945
diff
changeset
|
38 | if (points.size() == points3d.size()) |
875
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
39 | { |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
945
diff
changeset
|
40 | for (int i = 0; i < points.size() - 1; ++i) |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
945
diff
changeset
|
41 | { |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
945
diff
changeset
|
42 | painter.drawLine (QLineF (points[i], points[i + 1])); |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
945
diff
changeset
|
43 | drawLength (painter, points3d[i], points3d[i + 1], points[i], points[i + 1]); |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
945
diff
changeset
|
44 | } |
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
945
diff
changeset
|
45 | |
1008
74cb432812d3
Fixed circle, rectangle and line path modes not working anymore. Add blip coordinates to curve and line path modes. Circle mode for now only can show the coordinates of the initial blip
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
46 | for (int i = 0; i < points.size(); ++i) |
74cb432812d3
Fixed circle, rectangle and line path modes not working anymore. Add blip coordinates to curve and line path modes. Circle mode for now only can show the coordinates of the initial blip
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
47 | { |
74cb432812d3
Fixed circle, rectangle and line path modes not working anymore. Add blip coordinates to curve and line path modes. Circle mode for now only can show the coordinates of the initial blip
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
48 | const QPointF& point = points[i]; |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
945
diff
changeset
|
49 | renderer()->drawBlip (painter, point); |
1008
74cb432812d3
Fixed circle, rectangle and line path modes not working anymore. Add blip coordinates to curve and line path modes. Circle mode for now only can show the coordinates of the initial blip
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
50 | renderer()->drawBlipCoordinates (painter, points3d[i], point); |
74cb432812d3
Fixed circle, rectangle and line path modes not working anymore. Add blip coordinates to curve and line path modes. Circle mode for now only can show the coordinates of the initial blip
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
51 | } |
875
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
52 | } |
874
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | } |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | |
876
f040f0fb3795
- renamed line loop to line path, updated changelog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
875
diff
changeset
|
55 | bool LinePathMode::mouseReleased (MouseEventData const& data) |
874
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | { |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | if (Super::mouseReleased (data)) |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | return true; |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | if (data.releasedButtons & Qt::LeftButton) |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | { |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | addDrawnVertex (renderer()->position3D()); |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | return true; |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | } |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | return false; |
ba75c789667e
- added line loop mode (doesn't actually create anything yet)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | } |
875
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
68 | |
876
f040f0fb3795
- renamed line loop to line path, updated changelog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
875
diff
changeset
|
69 | bool LinePathMode::preAddVertex (Vertex const& pos) |
875
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
70 | { |
1008
74cb432812d3
Fixed circle, rectangle and line path modes not working anymore. Add blip coordinates to curve and line path modes. Circle mode for now only can show the coordinates of the initial blip
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
71 | // If we picked the vertex we last drew, stop drawing |
875
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
72 | if (not m_drawedVerts.isEmpty() and pos == m_drawedVerts.last()) |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
73 | { |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
74 | endDraw(); |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
75 | return true; |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
76 | } |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
77 | |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
78 | return false; |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
79 | } |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
80 | |
876
f040f0fb3795
- renamed line loop to line path, updated changelog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
875
diff
changeset
|
81 | void LinePathMode::endDraw() |
875
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
82 | { |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
83 | LDObjectList objs; |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
84 | |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
85 | for (int i = 0; i < m_drawedVerts.size() - 1; ++i) |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
86 | { |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
876
diff
changeset
|
87 | LDLine* line = LDSpawn<LDLine>(); |
875
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
88 | line->setVertex (0, m_drawedVerts[i]); |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
89 | line->setVertex (1, m_drawedVerts[i + 1]); |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
90 | objs << line; |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
91 | } |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
92 | |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
93 | finishDraw (objs); |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
94 | } |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
95 | |
876
f040f0fb3795
- renamed line loop to line path, updated changelog
Teemu Piippo <crimsondusk64@gmail.com>
parents:
875
diff
changeset
|
96 | bool LinePathMode::keyReleased (QKeyEvent* ev) |
875
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
97 | { |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
98 | if (Super::keyReleased (ev)) |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
99 | return true; |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
100 | |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
101 | if (ev->key() == Qt::Key_Enter or ev->key() == Qt::Key_Return) |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
102 | { |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
103 | endDraw(); |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
104 | return true; |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
105 | } |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
106 | |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
107 | return false; |
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
874
diff
changeset
|
108 | } |