Wed, 05 Mar 2014 05:30:36 +0200
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2013, 2014 Santeri Piippo |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include "Main.h" |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include "LDObject.h" |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include "Document.h" |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include "Misc.h" |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include "MainWindow.h" |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include "EditHistory.h" |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include "GLRenderer.h" |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | #include "Colors.h" |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | cfg (String, ld_defaultname, ""); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | cfg (String, ld_defaultuser, ""); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | cfg (Int, ld_defaultlicense, 0); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | // List of all LDObjects |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | static LDObjectList g_LDObjects; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | // ============================================================================= |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | // LDObject constructors |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
37 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | LDObject::LDObject() : |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
39 | m_isHidden (false), |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
40 | m_isSelected (false), |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
41 | m_parent (null), |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
42 | m_document (null), |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
43 | m_isGLInit (false), |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | qObjListEntry (null) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | memset (m_coords, 0, sizeof m_coords); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | chooseID(); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | g_LDObjects << this; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
52 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | void LDObject::chooseID() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | int32 id = 1; // 0 shalt be null |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | for (LDObject* obj : g_LDObjects) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | assert (obj != this); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
61 | if (obj->id() >= id) |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
62 | id = obj->id() + 1; |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | setID (id); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
69 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | void LDObject::setVertexCoord (int i, Axis ax, double value) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | { |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
72 | Vertex v = vertex (i); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | v[ax] = value; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | setVertex (i, v); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | LDError::LDError() {} |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
80 | // |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
81 | QString LDComment::asText() const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
83 | return fmt ("0 %1", text()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
87 | // |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
88 | QString LDSubfile::asText() const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
90 | QString val = fmt ("1 %1 %2 ", color(), position()); |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
91 | val += transform().toString(); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | val += ' '; |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
93 | val += fileInfo()->name(); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | return val; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
98 | // |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
99 | QString LDLine::asText() const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
101 | QString val = fmt ("2 %1", color()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | for (int i = 0; i < 2; ++i) |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
104 | val += fmt (" %1", vertex (i)); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | return val; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
110 | // |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
111 | QString LDTriangle::asText() const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
113 | QString val = fmt ("3 %1", color()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | for (int i = 0; i < 3; ++i) |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
116 | val += fmt (" %1", vertex (i)); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | return val; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
122 | // |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
123 | QString LDQuad::asText() const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
125 | QString val = fmt ("4 %1", color()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | for (int i = 0; i < 4; ++i) |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
128 | val += fmt (" %1", vertex (i)); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | return val; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
133 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
134 | // |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
135 | QString LDCondLine::asText() const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
137 | QString val = fmt ("5 %1", color()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
139 | // Add the coordinates |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | for (int i = 0; i < 4; ++i) |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
141 | val += fmt (" %1", vertex (i)); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
142 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | return val; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
145 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
147 | // |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
148 | QString LDError::asText() const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
150 | return contents(); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
154 | // |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
155 | QString LDVertex::asText() const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
156 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
157 | return fmt ("0 !LDFORGE VERTEX %1 %2", color(), pos); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
160 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
161 | // |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
162 | QString LDEmpty::asText() const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
163 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
164 | return ""; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
165 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
166 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
167 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
168 | // |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
169 | const char* LDBFC::k_statementStrings[] = |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
170 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
171 | "CERTIFY CCW", |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
172 | "CCW", |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
173 | "CERTIFY CW", |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
174 | "CW", |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
175 | "NOCERTIFY", |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
176 | "INVERTNEXT", |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | "CLIP", |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
178 | "CLIP CCW", |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
179 | "CLIP CW", |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
180 | "NOCLIP", |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
181 | }; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
183 | QString LDBFC::asText() const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | { |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
185 | return fmt ("0 BFC %1", LDBFC::k_statementStrings[m_statement]); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
186 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
187 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
189 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
190 | QList<LDTriangle*> LDQuad::splitToTriangles() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
191 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
192 | // Create the two triangles based on this quadrilateral: |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | // 0---3 0---3 3 |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
194 | // | | | / /| |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
195 | // | | ==> | / / | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
196 | // | | |/ / | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
197 | // 1---2 1 1---2 |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
198 | LDTriangle* tri1 = new LDTriangle (vertex (0), vertex (1), vertex (3)); |
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
199 | LDTriangle* tri2 = new LDTriangle (vertex (1), vertex (2), vertex (3)); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
200 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
201 | // The triangles also inherit the quad's color |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
202 | tri1->setColor (color()); |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
203 | tri2->setColor (color()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
204 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
205 | QList<LDTriangle*> triangles; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
206 | triangles << tri1; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
207 | triangles << tri2; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
208 | return triangles; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
209 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
210 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
212 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
213 | void LDObject::replace (LDObject* other) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
214 | { |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
215 | long idx = lineNumber(); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
216 | assert (idx != -1); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
217 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
218 | // Replace the instance of the old object with the new object |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
219 | document()->setObject (idx, other); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
220 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
221 | // Remove the old object |
640
d4dda62c6600
- renamed LDObject::deleteSelf to LDObject::destroy
Santeri Piippo <crimsondusk64@gmail.com>
parents:
639
diff
changeset
|
222 | destroy(); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
223 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
224 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
225 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
226 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
227 | void LDObject::swap (LDObject* other) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
228 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
229 | assert (document() == other->document()); |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
230 | document()->swapObjects (this, other); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
231 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
232 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
233 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
234 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
235 | LDLine::LDLine (Vertex v1, Vertex v2) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
236 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
237 | setVertex (0, v1); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
238 | setVertex (1, v2); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
239 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
240 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
241 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
242 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
243 | LDQuad::LDQuad (const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
244 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
245 | setVertex (0, v0); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
246 | setVertex (1, v1); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
247 | setVertex (2, v2); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
248 | setVertex (3, v3); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
249 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
250 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
251 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
252 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
253 | LDObject::~LDObject() {} |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
254 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
255 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
256 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
257 | LDSubfile::~LDSubfile() {} |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
258 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
259 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
260 | // |
640
d4dda62c6600
- renamed LDObject::deleteSelf to LDObject::destroy
Santeri Piippo <crimsondusk64@gmail.com>
parents:
639
diff
changeset
|
261 | void LDObject::destroy() |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
262 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
263 | // If this object was selected, unselect it now |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
264 | if (isSelected()) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
265 | unselect(); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
266 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
267 | // If this object was associated to a file, remove it off it now |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
268 | if (document()) |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
269 | document()->forgetObject (this); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
270 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
271 | // Delete the GL lists |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
272 | GL::deleteLists (this); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
273 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
274 | // Remove this object from the list of LDObjects |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
275 | g_LDObjects.removeOne (this); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
276 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
277 | delete this; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
278 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
279 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
280 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
281 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
282 | static void transformObject (LDObject* obj, Matrix transform, Vertex pos, int parentcolor) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
283 | { |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
284 | switch (obj->type()) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
285 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
286 | case LDObject::ELine: |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
287 | case LDObject::ECondLine: |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
288 | case LDObject::ETriangle: |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
289 | case LDObject::EQuad: |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
290 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
291 | for (int i = 0; i < obj->vertices(); ++i) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
292 | { |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
293 | Vertex v = obj->vertex (i); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
294 | v.transform (transform, pos); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
295 | obj->setVertex (i, v); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
296 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
297 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
298 | break; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
299 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
300 | case LDObject::ESubfile: |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
301 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
302 | LDSubfile* ref = static_cast<LDSubfile*> (obj); |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
303 | Matrix newMatrix = transform * ref->transform(); |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
304 | Vertex newpos = ref->position(); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
305 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
306 | newpos.transform (transform, pos); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
307 | ref->setPosition (newpos); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
308 | ref->setTransform (newMatrix); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
309 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
310 | break; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
311 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
312 | default: |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
313 | break; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
314 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
315 | |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
316 | if (obj->color() == maincolor) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
317 | obj->setColor (parentcolor); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
318 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
319 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
320 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
321 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
322 | LDObjectList LDSubfile::inlineContents (InlineFlags flags) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
323 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
324 | LDObjectList objs = fileInfo()->inlineContents (flags); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
325 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
326 | // Transform the objects |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
327 | for (LDObject* obj : objs) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
328 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
329 | // Set the parent now so we know what inlined the object. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
330 | obj->setParent (this); |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
331 | transformObject (obj, transform(), position(), color()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
332 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
333 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
334 | return objs; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
335 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
336 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
337 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
338 | // |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
339 | long LDObject::lineNumber() const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
340 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
341 | assert (document() != null); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
342 | |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
343 | for (int i = 0; i < document()->getObjectCount(); ++i) |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
344 | if (document()->getObject (i) == this) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
345 | return i; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
346 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
347 | return -1; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
348 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
349 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
350 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
351 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
352 | void LDObject::moveObjects (LDObjectList objs, const bool up) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
353 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
354 | if (objs.isEmpty()) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
355 | return; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
356 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
357 | // If we move down, we need to iterate the array in reverse order. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
358 | const long start = up ? 0 : (objs.size() - 1); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
359 | const long end = up ? objs.size() : -1; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
360 | const long incr = up ? 1 : -1; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
361 | LDObjectList objsToCompile; |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
362 | LDDocument* file = objs[0]->document(); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
363 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
364 | for (long i = start; i != end; i += incr) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
365 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
366 | LDObject* obj = objs[i]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
367 | |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
368 | const long idx = obj->lineNumber(), |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
369 | target = idx + (up ? -1 : 1); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
370 | |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
371 | if ((up && idx == 0) || (!up && idx == (long) (file->objects().size() - 1))) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
372 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
373 | // One of the objects hit the extrema. If this happens, this should be the first |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
374 | // object to be iterated on. Thus, nothing has changed yet and it's safe to just |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
375 | // abort the entire operation. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
376 | assert (i == start); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
377 | return; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
378 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
379 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
380 | objsToCompile << obj; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
381 | objsToCompile << file->getObject (target); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
382 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
383 | obj->swap (file->getObject (target)); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
384 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
385 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
386 | removeDuplicates (objsToCompile); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
387 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
388 | // The objects need to be recompiled, otherwise their pick lists are left with |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
389 | // the wrong index colors which messes up selection. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
390 | for (LDObject* obj : objsToCompile) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
391 | g_win->R()->compileObject (obj); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
392 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
393 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
394 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
395 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
396 | QString LDObject::typeName (LDObject::Type type) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
397 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
398 | LDObject* obj = LDObject::getDefault (type); |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
399 | QString name = obj->typeName(); |
640
d4dda62c6600
- renamed LDObject::deleteSelf to LDObject::destroy
Santeri Piippo <crimsondusk64@gmail.com>
parents:
639
diff
changeset
|
400 | obj->destroy(); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
401 | return name; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
402 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
403 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
404 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
405 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
406 | QString LDObject::describeObjects (const LDObjectList& objs) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
407 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
408 | bool firstDetails = true; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
409 | QString text = ""; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
410 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
411 | if (objs.isEmpty()) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
412 | return "nothing"; // :) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
413 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
414 | for (long i = 0; i < ENumTypes; ++i) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
415 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
416 | Type objType = (Type) i; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
417 | int count = 0; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
418 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
419 | for (LDObject * obj : objs) |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
420 | if (obj->type() == objType) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
421 | count++; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
422 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
423 | if (count == 0) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
424 | continue; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
425 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
426 | if (!firstDetails) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
427 | text += ", "; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
428 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
429 | QString noun = fmt ("%1%2", typeName (objType), plural (count)); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
430 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
431 | // Plural of "vertex" is "vertices", correct that |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
432 | if (objType == EVertex && count != 1) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
433 | noun = "vertices"; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
434 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
435 | text += fmt ("%1 %2", count, noun); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
436 | firstDetails = false; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
437 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
438 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
439 | return text; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
440 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
441 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
442 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
443 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
444 | LDObject* LDObject::topLevelParent() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
445 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
446 | if (parent() == null) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
447 | return this; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
448 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
449 | LDObject* it = this; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
450 | |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
451 | while (it->parent() != null) |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
452 | it = it->parent(); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
453 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
454 | return it; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
455 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
456 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
457 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
458 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
459 | LDObject* LDObject::next() const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
460 | { |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
461 | long idx = lineNumber(); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
462 | assert (idx != -1); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
463 | |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
464 | if (idx == (long) document()->getObjectCount() - 1) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
465 | return null; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
466 | |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
467 | return document()->getObject (idx + 1); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
468 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
469 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
470 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
471 | // |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
472 | LDObject* LDObject::previous() const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
473 | { |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
474 | long idx = lineNumber(); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
475 | assert (idx != -1); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
476 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
477 | if (idx == 0) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
478 | return null; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
479 | |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
480 | return document()->getObject (idx - 1); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
481 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
482 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
483 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
484 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
485 | void LDObject::move (Vertex vect) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
486 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
487 | if (hasMatrix()) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
488 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
489 | LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (this); |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
490 | mo->setPosition (mo->position() + vect); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
491 | } |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
492 | elif (type() == LDObject::EVertex) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
493 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
494 | // ugh |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
495 | static_cast<LDVertex*> (this)->pos += vect; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
496 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
497 | else |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
498 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
499 | for (int i = 0; i < vertices(); ++i) |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
500 | setVertex (i, vertex (i) + vect); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
501 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
502 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
503 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
504 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
505 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
506 | #define CHECK_FOR_OBJ(N) \ |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
507 | if (type == LDObject::E##N) \ |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
508 | return new LD##N; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
509 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
510 | LDObject* LDObject::getDefault (const LDObject::Type type) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
511 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
512 | CHECK_FOR_OBJ (Comment) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
513 | CHECK_FOR_OBJ (BFC) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
514 | CHECK_FOR_OBJ (Line) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
515 | CHECK_FOR_OBJ (CondLine) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
516 | CHECK_FOR_OBJ (Subfile) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
517 | CHECK_FOR_OBJ (Triangle) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
518 | CHECK_FOR_OBJ (Quad) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
519 | CHECK_FOR_OBJ (Empty) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
520 | CHECK_FOR_OBJ (BFC) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
521 | CHECK_FOR_OBJ (Error) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
522 | CHECK_FOR_OBJ (Vertex) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
523 | CHECK_FOR_OBJ (Overlay) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
524 | return null; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
525 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
526 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
527 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
528 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
529 | void LDObject::invert() {} |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
530 | void LDBFC::invert() {} |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
531 | void LDEmpty::invert() {} |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
532 | void LDComment::invert() {} |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
533 | void LDError::invert() {} |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
534 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
535 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
536 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
537 | void LDTriangle::invert() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
538 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
539 | // Triangle goes 0 -> 1 -> 2, reversed: 0 -> 2 -> 1. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
540 | // Thus, we swap 1 and 2. |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
541 | Vertex tmp = vertex (1); |
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
542 | setVertex (1, vertex (2)); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
543 | setVertex (2, tmp); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
544 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
545 | return; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
546 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
547 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
548 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
549 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
550 | void LDQuad::invert() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
551 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
552 | // Quad: 0 -> 1 -> 2 -> 3 |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
553 | // rev: 0 -> 3 -> 2 -> 1 |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
554 | // Thus, we swap 1 and 3. |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
555 | Vertex tmp = vertex (1); |
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
556 | setVertex (1, vertex (3)); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
557 | setVertex (3, tmp); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
558 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
559 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
560 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
561 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
562 | void LDSubfile::invert() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
563 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
564 | // Subfiles are inverted when they're prefixed with |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
565 | // a BFC INVERTNEXT statement. Thus we need to toggle this status. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
566 | // For flat primitives it's sufficient that the determinant is |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
567 | // flipped but I don't have a method for checking flatness yet. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
568 | // Food for thought... |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
569 | |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
570 | int idx = lineNumber(); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
571 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
572 | if (idx > 0) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
573 | { |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
574 | LDBFC* bfc = dynamic_cast<LDBFC*> (previous()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
575 | |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
576 | if (bfc && bfc->statement() == LDBFC::InvertNext) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
577 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
578 | // This is prefixed with an invertnext, thus remove it. |
640
d4dda62c6600
- renamed LDObject::deleteSelf to LDObject::destroy
Santeri Piippo <crimsondusk64@gmail.com>
parents:
639
diff
changeset
|
579 | bfc->destroy(); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
580 | return; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
581 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
582 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
583 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
584 | // Not inverted, thus prefix it with a new invertnext. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
585 | LDBFC* bfc = new LDBFC (LDBFC::InvertNext); |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
586 | document()->insertObj (idx, bfc); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
587 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
588 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
589 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
590 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
591 | static void invertLine (LDObject* line) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
592 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
593 | // For lines, we swap the vertices. I don't think that a |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
594 | // cond-line's control points need to be swapped, do they? |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
595 | Vertex tmp = line->vertex (0); |
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
596 | line->setVertex (0, line->vertex (1)); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
597 | line->setVertex (1, tmp); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
598 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
599 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
600 | void LDLine::invert() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
601 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
602 | invertLine (this); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
603 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
604 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
605 | void LDCondLine::invert() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
606 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
607 | invertLine (this); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
608 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
609 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
610 | void LDVertex::invert() {} |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
611 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
612 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
613 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
614 | LDLine* LDCondLine::demote() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
615 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
616 | LDLine* repl = new LDLine; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
617 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
618 | for (int i = 0; i < repl->vertices(); ++i) |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
619 | repl->setVertex (i, vertex (i)); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
620 | |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
621 | repl->setColor (color()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
622 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
623 | replace (repl); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
624 | return repl; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
625 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
626 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
627 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
628 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
629 | LDObject* LDObject::fromID (int id) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
630 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
631 | for (LDObject* obj : g_LDObjects) |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
632 | if (obj->id() == id) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
633 | return obj; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
634 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
635 | return null; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
636 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
637 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
638 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
639 | // |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
640 | QString LDOverlay::asText() const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
641 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
642 | return fmt ("0 !LDFORGE OVERLAY %1 %2 %3 %4 %5 %6", |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
643 | fileName(), camera(), x(), y(), width(), height()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
644 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
645 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
646 | void LDOverlay::invert() {} |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
647 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
648 | // ============================================================================= |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
649 | // Hook the set accessors of certain properties to this changeProperty function. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
650 | // It takes care of history management so we can capture low-level changes, this |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
651 | // makes history stuff work out of the box. |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
652 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
653 | template<class T> static void changeProperty (LDObject* obj, T* ptr, const T& val) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
654 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
655 | long idx; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
656 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
657 | if (*ptr == val) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
658 | return; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
659 | |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
660 | if (obj->document() && (idx = obj->lineNumber()) != -1) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
661 | { |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
662 | QString before = obj->asText(); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
663 | *ptr = val; |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
664 | QString after = obj->asText(); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
665 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
666 | if (before != after) |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
667 | obj->document()->addToHistory (new EditHistory (idx, before, after)); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
668 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
669 | else |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
670 | *ptr = val; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
671 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
672 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
673 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
674 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
675 | void LDObject::setColor (const int& val) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
676 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
677 | changeProperty (this, &m_color, val); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
678 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
679 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
680 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
681 | // |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
682 | const Vertex& LDObject::vertex (int i) const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
683 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
684 | return m_coords[i]->data(); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
685 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
686 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
687 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
688 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
689 | void LDObject::setVertex (int i, const Vertex& vert) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
690 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
691 | changeProperty (this, &m_coords[i], LDSharedVertex::getSharedVertex (vert)); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
692 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
693 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
694 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
695 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
696 | void LDMatrixObject::setPosition (const Vertex& a) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
697 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
698 | changeProperty (linkPointer(), &m_position, LDSharedVertex::getSharedVertex (a)); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
699 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
700 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
701 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
702 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
703 | void LDMatrixObject::setTransform (const Matrix& val) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
704 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
705 | changeProperty (linkPointer(), &m_transform, val); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
706 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
707 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
708 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
709 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
710 | static QMap<Vertex, LDSharedVertex*> g_sharedVerts; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
711 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
712 | LDSharedVertex* LDSharedVertex::getSharedVertex (const Vertex& a) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
713 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
714 | auto it = g_sharedVerts.find (a); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
715 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
716 | if (it == g_sharedVerts.end()) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
717 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
718 | LDSharedVertex* v = new LDSharedVertex (a); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
719 | g_sharedVerts[a] = v; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
720 | return v; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
721 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
722 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
723 | return *it; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
724 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
725 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
726 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
727 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
728 | void LDSharedVertex::addRef (LDObject* a) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
729 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
730 | m_refs << a; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
731 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
732 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
733 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
734 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
735 | void LDSharedVertex::delRef (LDObject* a) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
736 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
737 | m_refs.removeOne (a); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
738 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
739 | if (m_refs.empty()) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
740 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
741 | g_sharedVerts.remove (m_data); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
742 | delete this; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
743 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
744 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
745 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
746 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
747 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
748 | void LDObject::select() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
749 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
750 | if (!document()) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
751 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
752 | log ("Warning: Object #%1 cannot be selected as it is not assigned a file!\n", id()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
753 | return; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
754 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
755 | |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
756 | document()->addToSelection (this); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
757 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
758 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
759 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
760 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
761 | void LDObject::unselect() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
762 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
763 | if (!document()) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
764 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
765 | log ("Warning: Object #%1 cannot be unselected as it is not assigned a file!\n", id()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
766 | return; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
767 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
768 | |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
769 | document()->removeFromSelection (this); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
770 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
771 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
772 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
773 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
774 | QString getLicenseText (int id) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
775 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
776 | switch (id) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
777 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
778 | case 0: |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
779 | return g_CALicense; |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
780 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
781 | case 1: |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
782 | return g_nonCALicense; |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
783 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
784 | case 2: |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
785 | return ""; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
786 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
787 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
788 | assert (false); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
789 | return ""; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
790 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
791 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
792 | // ============================================================================= |
639
851634b85893
- unified separator styles
Santeri Piippo <crimsondusk64@gmail.com>
parents:
638
diff
changeset
|
793 | // |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
794 | LDObject* LDObject::createCopy() const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
795 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
796 | /* |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
797 | LDObject* copy = clone(); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
798 | copy->setFile (null); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
799 | copy->setGLInit (false); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
800 | copy->chooseID(); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
801 | copy->setSelected (false); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
802 | */ |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
803 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
804 | /* |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
805 | LDObject* copy = getDefault (getType()); |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
806 | copy->setColor (color()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
807 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
808 | if (hasMatrix()) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
809 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
810 | LDMatrixObject* copyMo = static_cast<LDMatrixObject*> (copy); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
811 | const LDMatrixObject* mo = static_cast<const LDMatrixObject*> (this); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
812 | copyMo->setPosition (mo->getPosition()); |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
813 | copyMo->setTransform (mo->transform()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
814 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
815 | else |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
816 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
817 | for (int i = 0; i < vertices(); ++i) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
818 | copy->setVertex (getVertex (i)); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
819 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
820 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
821 | switch (getType()) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
822 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
823 | case Subfile: |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
824 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
825 | LDSubfile* copyRef = static_cast<LDSubfile*> (copy); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
826 | const LDSubfile* ref = static_cast<const LDSubfile*> (this); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
827 | |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
640
diff
changeset
|
828 | copyRef->setFileInfo (ref->fileInfo()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
829 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
830 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
831 | */ |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
832 | |
638
382226e40865
- renamed several LDObject methods
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
833 | LDObject* copy = parseLine (asText()); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
834 | return copy; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
835 | } |