Fri, 23 Mar 2018 21:30:24 +0200
reworked Vertex, no longer a QVector3D subclass
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1072 | 3 | * Copyright (C) 2013 - 2017 Teemu Piippo |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include "miscallenous.h" |
1147
a26568aa3cce
Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
20 | #include "linetypes/modelobject.h" |
1145
02264bf0108d
Renamed ldDocument.cpp → lddocument.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
21 | #include "lddocument.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
23 | void Vertex::transform(const Matrix& matrix, const Vertex& pos) |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
24 | { |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
25 | double x2 = (matrix(0, 0) * x) + (matrix(0, 1) * y) + (matrix(0, 2) * z) + pos.x; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
26 | double y2 = (matrix(1, 0) * x) + (matrix(1, 1) * y) + (matrix(1, 2) * z) + pos.y; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
27 | double z2 = (matrix(2, 0) * x) + (matrix(2, 1) * y) + (matrix(2, 2) * z) + pos.z; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
28 | this->x = x2; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
29 | this->y = y2; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
30 | this->z = z2; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
31 | } |
733
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
714
diff
changeset
|
32 | |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
33 | void Vertex::apply(ApplyFunction func) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
35 | func(X, this->x); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
36 | func(Y, this->y); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
37 | func(Z, this->z); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
38 | } |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
39 | |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
40 | void Vertex::apply(ApplyConstFunction func) const |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
41 | { |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
42 | func(X, this->x); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
43 | func(Y, this->y); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
44 | func(Z, this->z); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
47 | double& Vertex::operator[](Axis axis) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
49 | switch (axis) |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
50 | { |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
51 | case X: |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
52 | return this->x; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
54 | case Y: |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
55 | return this->y; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
56 | |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
57 | case Z: |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
58 | return this->z; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
59 | |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
60 | default: |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
61 | return ::sink<double>(); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
62 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
65 | double Vertex::operator[] (Axis axis) const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
67 | switch (axis) |
733
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
714
diff
changeset
|
68 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
69 | case X: |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
70 | return this->x; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
71 | |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
72 | case Y: |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
73 | return this->y; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
74 | |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
75 | case Z: |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
76 | return this->z; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
77 | |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
78 | default: |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
79 | return 0.0; |
733
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
714
diff
changeset
|
80 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
83 | void Vertex::setCoordinate (Axis axis, qreal value) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
85 | (*this)[axis] = value; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
786
diff
changeset
|
88 | QString Vertex::toString (bool mangled) const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | { |
733
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
714
diff
changeset
|
90 | if (mangled) |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
91 | return ::format("(%1, %2, %3)", this->x, this->y, this->z); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
92 | else |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
93 | return ::format("%1 %2 %3", this->x, this->y, this->z); |
733
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
714
diff
changeset
|
94 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | |
1002
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
96 | Vertex Vertex::operator* (qreal scalar) const |
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
97 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
98 | return {this->x * scalar, this->y * scalar, this->z * scalar}; |
1002
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
99 | } |
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
100 | |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
101 | Vertex& Vertex::operator+=(const QVector3D& other) |
1002
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
102 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
103 | this->x += other.x(); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
104 | this->y += other.y(); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
105 | this->z += other.z(); |
1002
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
106 | return *this; |
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
107 | } |
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
108 | |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
109 | Vertex Vertex::operator+(const QVector3D& other) const |
1002
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
110 | { |
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
111 | Vertex result (*this); |
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
112 | result += other; |
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
113 | return result; |
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
114 | } |
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
115 | |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
116 | QVector3D Vertex::toVector() const |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
117 | { |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
118 | return { |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
119 | static_cast<float>(this->x), |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
120 | static_cast<float>(this->y), |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
121 | static_cast<float>(this->z) |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
122 | }; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
123 | } |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
124 | |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
125 | Vertex Vertex::operator- (const QVector3D& vector) const |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
126 | { |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
127 | Vertex result = *this; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
128 | result -= vector; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
129 | return result; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
130 | } |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
131 | |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
132 | Vertex& Vertex::operator-= (const QVector3D& vector) |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
133 | { |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
134 | this->x -= vector.x(); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
135 | this->y -= vector.y(); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
136 | this->z -= vector.z(); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
137 | return *this; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
138 | } |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
139 | |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
140 | QVector3D Vertex::operator- (const Vertex& other) const |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
141 | { |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
142 | return { |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
143 | static_cast<float>(this->x - other.x), |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
144 | static_cast<float>(this->y - other.y), |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
145 | static_cast<float>(this->z - other.z) |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
146 | }; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
147 | } |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
148 | |
1002
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
149 | Vertex& Vertex::operator*= (qreal scalar) |
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
150 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
151 | x *= scalar; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
152 | y *= scalar; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
153 | z *= scalar; |
1002
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
154 | return *this; |
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
155 | } |
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
156 | |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
157 | bool Vertex::operator==(const Vertex& other) const |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
158 | { |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
159 | return this->x == other.x and this->y == other.y and this->z == other.z; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
160 | } |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
161 | |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
162 | bool Vertex::operator!=(const Vertex& other) const |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
163 | { |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
164 | return not (*this == other); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
165 | } |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
166 | |
733
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
714
diff
changeset
|
167 | bool Vertex::operator< (const Vertex& other) const |
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
714
diff
changeset
|
168 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
169 | if (not qFuzzyCompare(this->x, other.x)) |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
170 | return this->x < other.x; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
171 | else if (not qFuzzyCompare(this->y, other.y)) |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
172 | return this->y < other.y; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
173 | else |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
174 | return this->z < other.z; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
175 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
176 | |
1177
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
177 | /* |
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
178 | * Transforms this vertex with a tranformation matrix and returns the result. |
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
179 | */ |
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
180 | Vertex Vertex::transformed(const GLRotationMatrix& matrix) const |
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
181 | { |
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
182 | return { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
183 | matrix(0, 0) * this->x |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
184 | + matrix(0, 1) * this->y |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
185 | + matrix(0, 2) * this->z, |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
186 | matrix(1, 0) * this->x |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
187 | + matrix(1, 1) * this->y |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
188 | + matrix(1, 2) * this->z, |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
189 | matrix(2, 0) * this->x |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
190 | + matrix(2, 1) * this->y |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
191 | + matrix(2, 2) * this->z, |
1177
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
192 | }; |
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
193 | } |
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1147
diff
changeset
|
194 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
195 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
196 | // |
1013
fa025ba493d8
Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1011
diff
changeset
|
197 | BoundingBox::BoundingBox() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
198 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | reset(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
200 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
201 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
203 | // |
1013
fa025ba493d8
Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1011
diff
changeset
|
204 | BoundingBox& BoundingBox::operator<< (const Vertex& v) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
205 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
206 | calcVertex (v); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
207 | return *this; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
208 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
209 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
210 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | // |
1013
fa025ba493d8
Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1011
diff
changeset
|
212 | void BoundingBox::calcVertex (const Vertex& vertex) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
213 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
214 | m_vertex0.x = qMin(vertex.x, m_vertex0.x); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
215 | m_vertex0.y = qMin(vertex.y, m_vertex0.y); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
216 | m_vertex0.z = qMin(vertex.z, m_vertex0.z); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
217 | m_vertex1.x = qMax(vertex.x, m_vertex1.x); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
218 | m_vertex1.y = qMax(vertex.y, m_vertex1.y); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
219 | m_vertex1.z = qMax(vertex.z, m_vertex1.z); |
1010
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
220 | m_isEmpty = false; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
221 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
222 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
223 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
224 | // |
1010
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
225 | // Clears the bounding box |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
226 | // |
1013
fa025ba493d8
Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1011
diff
changeset
|
227 | void BoundingBox::reset() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
228 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
229 | m_vertex0 = {10000.0, 10000.0, 10000.0}; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
230 | m_vertex1 = {-10000.0, -10000.0, -10000.0}; |
1010
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
231 | m_isEmpty = true; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
232 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
233 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
234 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
235 | // |
1010
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
236 | // Returns the length of the bounding box on the longest measure. |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
237 | // |
1013
fa025ba493d8
Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1011
diff
changeset
|
238 | double BoundingBox::longestMeasurement() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
239 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
240 | double xscale = m_vertex0.x - m_vertex1.x; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
241 | double yscale = m_vertex0.y - m_vertex1.y; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
242 | double zscale = m_vertex0.z - m_vertex1.z; |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
243 | double size = qMax(xscale, qMax(yscale, zscale)); |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
244 | return qMax(qAbs(size / 2.0), 1.0); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
245 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
246 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
247 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
248 | // |
1010
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
249 | // Yields the center of the bounding box. |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
250 | // |
1013
fa025ba493d8
Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1011
diff
changeset
|
251 | Vertex BoundingBox::center() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
252 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
253 | return { |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
254 | (m_vertex0.x + m_vertex1.x) / 2, |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
255 | (m_vertex0.y + m_vertex1.y) / 2, |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
256 | (m_vertex0.z + m_vertex1.z) / 2 |
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
257 | }; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
258 | } |
1010
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
259 | |
1013
fa025ba493d8
Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1011
diff
changeset
|
260 | bool BoundingBox::isEmpty() const |
1010
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
261 | { |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
262 | return m_isEmpty; |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
263 | } |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
264 | |
1013
fa025ba493d8
Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1011
diff
changeset
|
265 | const Vertex& BoundingBox::vertex0() const |
1010
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
266 | { |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
267 | return m_vertex0; |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
268 | } |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
269 | |
1013
fa025ba493d8
Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1011
diff
changeset
|
270 | const Vertex& BoundingBox::vertex1() const |
1010
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
271 | { |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
272 | return m_vertex1; |
1031
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
273 | } |
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
274 | |
1036
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1031
diff
changeset
|
275 | // http://stackoverflow.com/a/18204188/3629665 |
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1031
diff
changeset
|
276 | template<typename T> |
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1031
diff
changeset
|
277 | inline int rotl10(T x) |
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1031
diff
changeset
|
278 | { |
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1031
diff
changeset
|
279 | return (((x) << 10) | (((x) >> 22) & 0x000000ff)); |
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1031
diff
changeset
|
280 | } |
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1031
diff
changeset
|
281 | |
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1031
diff
changeset
|
282 | template<typename T> |
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1031
diff
changeset
|
283 | inline int rotl20(T x) |
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1031
diff
changeset
|
284 | { |
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1031
diff
changeset
|
285 | return (((x) << 20) | (((x) >> 12) & 0x000000ff)); |
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1031
diff
changeset
|
286 | } |
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1031
diff
changeset
|
287 | |
1031
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
288 | uint qHash(const Vertex& key) |
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
289 | { |
1313
4baed9f54de3
reworked Vertex, no longer a QVector3D subclass
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
290 | return qHash(key.x) ^ rotl10(qHash(key.y)) ^ rotl20(qHash(key.z)); |
1031
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
291 | } |
1053 | 292 | |
293 | /* | |
294 | * getRadialPoint | |
295 | * | |
296 | * Gets an ordinate of a point in circle. | |
297 | * If func == sin, then this gets the Y co-ordinate, if func == cos, then X co-ordinate. | |
298 | */ | |
299 | double getRadialPoint(int segment, int divisions, double(*func)(double)) | |
300 | { | |
301 | return (*func)((segment * 2 * pi) / divisions); | |
302 | } | |
303 | ||
304 | /* | |
305 | * makeCircle | |
306 | * | |
307 | * Creates a possibly partial circle rim. | |
308 | * Divisions is how many segments the circle makes if up if it's full. | |
309 | * Segments is now many segments are added. | |
310 | * Radius is the radius of the circle. | |
311 | * | |
312 | * If divisions == segments, this yields a full circle rim. | |
313 | * The rendered circle is returned as a vector of lines. | |
314 | */ | |
315 | QVector<QLineF> makeCircle(int segments, int divisions, double radius) | |
316 | { | |
317 | QVector<QLineF> lines; | |
318 | ||
319 | for (int i = 0; i < segments; ++i) | |
320 | { | |
321 | double x0 = radius * getRadialPoint(i, divisions, cos); | |
322 | double x1 = radius * getRadialPoint(i + 1, divisions, cos); | |
323 | double z0 = radius * getRadialPoint(i, divisions, sin); | |
324 | double z1 = radius * getRadialPoint(i + 1, divisions, sin); | |
325 | lines.append(QLineF {QPointF {x0, z0}, QPointF {x1, z1}}); | |
326 | } | |
327 | ||
328 | return lines; | |
329 | } | |
1181
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
330 | |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
331 | /* |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
332 | * Computes the shortest distance from a point to a rectangle. |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
333 | * |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
334 | * The code originates from the Unity3D wiki, and was translated from C# to Qt by me (Teemu Piippo): |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
335 | * |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
336 | * Original code: |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
337 | * http://wiki.unity3d.com/index.php/Distance_from_a_point_to_a_rectangle |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
338 | * |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
339 | * Copyright 2013 Philip Peterson. |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
340 | * |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
341 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
342 | * of this software and associated documentation files (the "Software"), to |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
343 | * deal in the Software without restriction, including without limitation the |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
344 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
345 | * sell copies of the Software, and to permit persons to whom the Software is |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
346 | * furnished to do so, subject to the following conditions: |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
347 | * |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
348 | * The above copyright notice and this permission notice shall be included in |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
349 | * all copies or substantial portions of the Software. |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
350 | * |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
351 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
352 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
353 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
354 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
355 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
356 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
357 | * IN THE SOFTWARE. |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
358 | */ |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
359 | qreal distanceFromPointToRectangle(const QPointF& point, const QRectF& rectangle) |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
360 | { |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
361 | // Calculate a distance between a point and a rectangle. |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
362 | // The area around/in the rectangle is defined in terms of |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
363 | // several regions: |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
364 | // |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
365 | // O--x |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
366 | // | |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
367 | // y |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
368 | // |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
369 | // |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
370 | // I | II | III |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
371 | // ======+==========+====== --yMin |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
372 | // VIII | IX (in) | IV |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
373 | // ======+==========+====== --yMax |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
374 | // VII | VI | V |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
375 | // |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
376 | // |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
377 | // Note that the +y direction is down because of Unity's GUI coordinates. |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
378 | |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
379 | if (point.x() < rectangle.left()) |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
380 | { |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
381 | // Region I, VIII, or VII |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
382 | if (point.y() < rectangle.top()) // I |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
383 | return QLineF {point, rectangle.topLeft()}.length(); |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
384 | else if (point.y() > rectangle.bottom()) // VII |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
385 | return QLineF {point, rectangle.bottomLeft()}.length(); |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
386 | else // VIII |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
387 | return rectangle.left() - point.x(); |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
388 | } |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
389 | else if (point.x() > rectangle.right()) |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
390 | { |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
391 | // Region III, IV, or V |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
392 | if (point.y() < rectangle.top()) // III |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
393 | return QLineF {point, rectangle.topRight()}.length(); |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
394 | else if (point.y() > rectangle.bottom()) // V |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
395 | return QLineF {point, rectangle.bottomRight()}.length(); |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
396 | else // IV |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
397 | return point.x() - rectangle.right(); |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
398 | } |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
399 | else |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
400 | { |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
401 | // Region II, IX, or VI |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
402 | if (point.y() < rectangle.top()) // II |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
403 | return rectangle.top() - point.y(); |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
404 | else if (point.y() > rectangle.bottom()) // VI |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
405 | return point.y() - rectangle.bottom(); |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
406 | else // IX |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
407 | return 0; |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
408 | } |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
409 | } |
1305
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
410 | |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
411 | /* |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
412 | * Special operator definition that implements the XOR operator for windings. |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
413 | * However, if either winding is NoWinding, then this function returns NoWinding. |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
414 | */ |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
415 | Winding operator^(Winding one, Winding other) |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
416 | { |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
417 | if (one == NoWinding or other == NoWinding) |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
418 | return NoWinding; |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
419 | else |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
420 | return static_cast<Winding>(static_cast<int>(one) ^ static_cast<int>(other)); |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
421 | } |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
422 | |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
423 | Winding& operator^=(Winding& one, Winding other) |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
424 | { |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
425 | one = one ^ other; |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
426 | return one; |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1181
diff
changeset
|
427 | } |
1308
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
1305
diff
changeset
|
428 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
1305
diff
changeset
|
429 | QDataStream& operator<<(QDataStream& out, const Library& library) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
1305
diff
changeset
|
430 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
1305
diff
changeset
|
431 | return out << library.path << library.role; |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
1305
diff
changeset
|
432 | } |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
1305
diff
changeset
|
433 | |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
1305
diff
changeset
|
434 | QDataStream& operator>>(QDataStream &in, Library& library) |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
1305
diff
changeset
|
435 | { |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
1305
diff
changeset
|
436 | return in >> library.path >> enum_cast<>(library.role); |
dcc8c02530c2
Begin rework to add support for multiple libraries
Teemu Piippo <teemu@hecknology.net>
parents:
1305
diff
changeset
|
437 | } |