Tue, 15 Mar 2022 18:52:48 +0200
- Add editors for string and bool properties
- Add invert action
24 | 1 | /* |
2 | * LDForge: LDraw parts authoring CAD | |
3 | * Copyright (C) 2013 - 2020 Teemu Piippo | |
4 | * | |
5 | * This program is free software: you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation, either version 3 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
0 | 19 | #pragma once |
2 | 20 | #include <QString> |
21 | #include <QVector> | |
22 | #include <QSet> | |
96 | 23 | #include <QDebug> |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
24 | #include <memory> |
3 | 25 | #include "basics.h" |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
7
diff
changeset
|
26 | #include "utility.h" |
20 | 27 | #include "maths.h" |
55 | 28 | #include "geometry.h" |
63
f7dd937667a5
omg functional programming
Teemu Piippo <teemu@hecknology.net>
parents:
55
diff
changeset
|
29 | #include "functional.h" |
2 | 30 | |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
31 | namespace settingGroups |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
32 | { |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
33 | // List of setting groups |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
34 | constexpr char mainwindow[] = "mainwindow"; |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
35 | } |
21 | 36 | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
37 | namespace ldraw |
21 | 38 | { |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
39 | class Object; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
40 | |
21 | 41 | // Uniquely identifies a model body object |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
42 | template<typename T> |
21 | 43 | struct Id |
44 | { | |
46 | 45 | std::int32_t value; |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
46 | template<typename A, typename B> |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
47 | static constexpr bool is_base_or_base_of = std::disjunction_v<std::is_base_of<A, B>, std::is_base_of<B, A>>; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
48 | template<typename R, typename = std::enable_if_t<is_base_or_base_of<T, R>>> |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
49 | constexpr bool operator<(ldraw::Id<R> other) const |
26 | 50 | { |
51 | return this->value < other.value; | |
52 | } | |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
53 | friend constexpr unsigned int qHash(ldraw::Id<T> id) |
51 | 54 | { |
55 | return qHash(id.value); | |
56 | } | |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
57 | // Allow comparing ids as long as they are related |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
58 | template<typename R, typename = std::enable_if_t<is_base_or_base_of<T, R>>> |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
59 | friend bool operator==(ldraw::Id<T> one, ldraw::Id<R> other) |
51 | 60 | { |
61 | return one.value == other.value; | |
62 | } | |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
63 | // Allow upcasting |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
64 | template<typename R, typename = std::enable_if_t<std::is_base_of_v<R, T>>> |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
65 | constexpr operator Id<R>() const |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
66 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
67 | return Id<R>{this->value}; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
68 | } |
21 | 69 | }; |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
70 | |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
71 | using id_t = Id<Object>; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
72 | using triangleid_t = Id<class Triangle>; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
73 | using quadrilateralid_t = Id<class Quadrilateral>; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
74 | using edgeid_t = Id<class EdgeLine>; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
75 | using conditionaledgeid_t = Id<class ConditionalEdge>; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
76 | using subfileid_t = Id<class SubfileReference>; |
141 | 77 | using commentid_t = Id<class Comment>; |
78 | using metacommandid_t = Id<class MetaCommand>; | |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
79 | |
81
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
73
diff
changeset
|
80 | constexpr struct NullId |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
81 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
82 | template<typename T> |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
83 | constexpr operator Id<T>() const |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
84 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
85 | return Id<T>{0}; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
86 | } |
81
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
73
diff
changeset
|
87 | static constexpr decltype(ldraw::id_t::value) value = 0; |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
88 | } NULL_ID = {}; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
89 | |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
90 | template<typename T> |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
91 | inline bool operator==(Id<T> one, decltype(NULL_ID)) |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
92 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
93 | return one.value == 0; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
94 | } |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
95 | |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
96 | template<typename T> |
107
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
101
diff
changeset
|
97 | inline bool operator!=(Id<T> one, decltype(NULL_ID)) |
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
101
diff
changeset
|
98 | { |
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
101
diff
changeset
|
99 | return one.value != 0; |
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
101
diff
changeset
|
100 | } |
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
101
diff
changeset
|
101 | |
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
101
diff
changeset
|
102 | template<typename T> |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
103 | inline bool operator<(Id<T> one, decltype(NULL_ID)) |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
104 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
105 | return one.value < 0; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
64
diff
changeset
|
106 | } |
21 | 107 | } |
22
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
108 | |
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
109 | constexpr std::size_t operator""_z(const unsigned long long int x) |
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
110 | { |
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
111 | return static_cast<std::size_t>(x); |
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
112 | } |
26 | 113 | |
114 | inline QString operator""_q(const char* string, const unsigned long int length) | |
115 | { | |
116 | Q_UNUSED(length) | |
117 | return QString{string}; | |
118 | } | |
119 | ||
120 | inline QPointF pointToPointF(const QPoint& point) | |
121 | { | |
122 | return {static_cast<qreal>(point.x()), static_cast<qreal>(point.y())}; | |
123 | } | |
124 | ||
125 | inline QPoint pointFToPoint(const QPointF& point) | |
126 | { | |
127 | return {static_cast<int>(std::round(point.x())), static_cast<int>(std::round(point.y()))}; | |
128 | } | |
129 | ||
113 | 130 | inline QSizeF sizeToSizeF(const QSize& size) |
131 | { | |
132 | return {static_cast<qreal>(size.width()), static_cast<qreal>(size.height())}; | |
133 | } | |
134 | ||
26 | 135 | /** |
136 | * \brief Hints to the specified vector that a certain amount of new elements are going to be added. | |
137 | * \param vector vector to consider | |
138 | * \param amount amount of new elements to expect | |
139 | */ | |
140 | template<typename T> | |
141 | void reserveMore(std::vector<T>& vector, std::size_t amount) | |
142 | { | |
143 | vector.reserve(vector.size() + amount); | |
144 | } | |
64
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
145 | |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
146 | inline QString vectorToString(const glm::vec2& vec) |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
147 | { |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
148 | return "(%1, %2)"_q |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
149 | .arg(toDouble(vec.x)) |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
150 | .arg(toDouble(vec.y)); |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
151 | } |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
152 | |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
153 | inline QString vectorToString(const glm::vec3& vec) |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
154 | { |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
155 | return "(%1, %2, %3)"_q |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
156 | .arg(toDouble(vec.x)) |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
157 | .arg(toDouble(vec.y)) |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
158 | .arg(toDouble(vec.z)); |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
159 | } |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
160 | |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
161 | inline QString vectorToString(const glm::vec4& vec) |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
162 | { |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
163 | return "(%1, %2, %3, %4)"_q |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
164 | .arg(toDouble(vec.x)) |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
165 | .arg(toDouble(vec.y)) |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
166 | .arg(toDouble(vec.z)) |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
167 | .arg(toDouble(vec.w)); |
f99d52b1646b
grid snapping now also works with transformed grids
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
168 | } |
97 | 169 | |
170 | template<typename K, typename V> | |
171 | struct KeyValuePair | |
172 | { | |
173 | K key; | |
174 | V value; | |
175 | }; | |
176 | ||
177 | template<typename K, typename V, typename IteratorType> | |
178 | struct MapItemsIterator : IteratorType | |
179 | { | |
180 | template<typename... Ts> | |
181 | MapItemsIterator(Ts&&... args) : IteratorType{args...} {} | |
182 | auto operator*() const | |
183 | { | |
101
910890292639
added references to items()
Teemu Piippo <teemu@hecknology.net>
parents:
97
diff
changeset
|
184 | return KeyValuePair<const K&, V&>{this->key(), this->value()}; |
97 | 185 | } |
186 | }; | |
187 | ||
188 | template<typename K, typename V, typename MapType, typename IteratorType> | |
189 | struct MapItems | |
190 | { | |
191 | MapType& map; | |
192 | IteratorType begin() | |
193 | { | |
194 | return IteratorType(this->map.begin()); | |
195 | } | |
196 | ||
197 | IteratorType end() | |
198 | { | |
199 | return IteratorType(this->map.end()); | |
200 | } | |
201 | }; | |
202 | ||
203 | /* | |
204 | * Python's dict.items for QMap: use in a for loop to iterate a map to | |
205 | * get both keys and values. Iteration yields KeyValuePairs. | |
206 | */ | |
207 | template<typename K, typename V> | |
208 | auto items(const QMap<K, V>& map) | |
209 | { | |
210 | return MapItems< | |
211 | const K&, | |
212 | const V&, | |
213 | const QMap<K, V>, | |
214 | MapItemsIterator<K, const V, typename QMap<K, V>::const_iterator> | |
215 | >{map}; | |
216 | } | |
217 | ||
218 | template<typename K, typename V> | |
219 | auto items(QMap<K, V>& map) | |
220 | { | |
221 | return MapItems< | |
222 | const K&, | |
223 | V&, | |
224 | QMap<K, V>, | |
225 | MapItemsIterator<K, const V, typename QMap<K, V>::iterator> | |
226 | >{map}; | |
227 | } | |
132
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
228 | |
148 | 229 | template<typename T, typename IdentifierType> |
230 | struct TypeValue | |
231 | { | |
232 | T value; | |
233 | bool operator==(TypeValue<T, IdentifierType> other) const | |
234 | { | |
235 | return value == other.value; | |
236 | } | |
237 | bool operator!=(TypeValue<T, IdentifierType> other) const | |
238 | { | |
239 | return value != other.value; | |
240 | } | |
241 | bool operator<(TypeValue<T, IdentifierType> other) const | |
242 | { | |
243 | return value < other.value; | |
244 | } | |
245 | bool operator>(TypeValue<T, IdentifierType> other) const | |
246 | { | |
247 | return value > other.value; | |
248 | } | |
249 | bool operator<=(TypeValue<T, IdentifierType> other) const | |
250 | { | |
251 | return value <= other.value; | |
252 | } | |
253 | bool operator>=(TypeValue<T, IdentifierType> other) const | |
254 | { | |
255 | return value >= other.value; | |
256 | } | |
257 | }; | |
258 | ||
259 | template<typename T, typename R> | |
260 | int qHash(TypeValue<T, R> value) | |
261 | { | |
262 | return qHash(value.value); | |
263 | } | |
264 | ||
265 | using ModelId = TypeValue<int, struct TypeValueModelId>; | |
266 | ||
132
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
267 | /** |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
268 | * Iterates a @c glm::mat |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
269 | */ |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
270 | template<int X, int Y, typename T, glm::qualifier Q, typename Fn> |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
271 | void iter_matrix(const glm::mat<X, Y, T, Q>& matrix, Fn&& fn) |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
272 | { |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
273 | for (int i = 0; i < X; ++i) |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
274 | { |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
275 | for (int j = 0; j < Y; ++j) |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
276 | { |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
277 | fn(i, j, matrix[i][j]); |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
278 | } |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
279 | } |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
280 | } |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
281 | |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
282 | QDataStream& operator<<(QDataStream&, const glm::vec3&); |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
283 | QDataStream& operator>>(QDataStream&, glm::vec3&); |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
284 | |
134
f77d2230e87c
Add remaining serialize methods
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
285 | template<int X, int Y, typename T, glm::qualifier Q> |
132
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
286 | QDataStream& operator<<(QDataStream& stream, const glm::mat<X, Y, T, Q>& mat) |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
287 | { |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
288 | iter_matrix(mat, [&stream](int, int, float x) |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
289 | { |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
290 | stream << x; |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
291 | }); |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
292 | return stream; |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
293 | } |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
294 | |
134
f77d2230e87c
Add remaining serialize methods
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
295 | template<int X, int Y, typename T, glm::qualifier Q> |
132
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
296 | QDataStream& operator>>(QDataStream& stream, glm::mat<X, Y, T, Q>& mat) |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
297 | { |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
298 | iter_matrix(mat, [&stream](int, int, float x) |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
299 | { |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
300 | stream >> x; |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
301 | }); |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
302 | return stream; |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
113
diff
changeset
|
303 | } |