Mon, 10 Mar 2014 14:29:12 +0200
- fixed zoom value not being initialized properly + some other minor things
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2013, 2014 Santeri Piippo |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
641
425b169a82aa
- changed header guards into #pragma once
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
19 | #pragma once |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QString> |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include <QObject> |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include <QStringList> |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include <QMetaType> |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
641
diff
changeset
|
24 | #include "Macros.h" |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | class LDObject; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | class QFile; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | class QTextStream; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | using int8 = qint8; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | using int16 = qint16; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | using int32 = qint32; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | using int64 = qint64; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | using uint8 = quint8; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | using uint16 = quint16; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | using uint32 = quint32; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | using uint64 = quint64; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
39 | template<typename T, typename R> |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
40 | using Pair = std::pair<T, R>; |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | enum Axis |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | X, |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | Y, |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | Z |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | }; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | // ============================================================================= |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | // |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | class LDObject; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | using LDObjectList = QList<LDObject*>; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
54 | //! |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
55 | //! \brief A mathematical 3 x 3 matrix |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
56 | //! |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | class Matrix |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | public: |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
60 | //! Constructs a matrix with undetermined values. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | Matrix() {} |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
62 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
63 | //! Constructs a matrix with the given values. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
64 | //! \note \c vals is expected to have exactly 9 elements. |
653
a9966d51ebf1
- fixed various compilation issues
Santeri Piippo <crimsondusk64@gmail.com>
parents:
649
diff
changeset
|
65 | Matrix (const std::initializer_list<double>& vals); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
66 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
67 | //! Constructs a matrix all 9 elements initialized to the same value. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
68 | //! \param fillval the value to initialize the matrix coordinates as |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | Matrix (double fillval); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
70 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
71 | //! Constructs a matrix with a C-array. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
72 | //! \note \c vals is expected to have exactly 9 elements. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | Matrix (double vals[]); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
75 | //! Calculates the matrix's determinant. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
76 | //! \returns the calculated determinant. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | double getDeterminant() const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
78 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
79 | //! Multiplies this matrix with \c other |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
80 | //! \param other the matrix to multiply with. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
81 | //! \returns the resulting matrix |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
82 | //! \note a.mult(b) is not equivalent to b.mult(a)! |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | Matrix mult (const Matrix& other) const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
84 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
85 | //! Prints the matrix to stdout. |
644
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
642
diff
changeset
|
86 | void dump() const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
87 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
88 | //! \returns a string representation of the matrix. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | QString toString() const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
90 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
91 | //! Zeroes the matrix out. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | void zero(); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
93 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
94 | //! Assigns the matrix values to the values of \c other. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
95 | //! \param other the matrix to assign this to. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
96 | //! \returns a reference to self |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | Matrix& operator= (const Matrix& other); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
99 | //! \returns a mutable reference to a value by \c idx |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
100 | inline double& value (int idx) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | return m_vals[idx]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
105 | //! An overload of \c value() for const matrices. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
106 | //! \returns a const reference to a value by \c idx |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
107 | inline const double& value (int idx) const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | return m_vals[idx]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
112 | //! An operator overload for \c mult(). |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
113 | //! \returns the multiplied matrix. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | inline Matrix operator* (const Matrix& other) const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | return mult (other); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
119 | //! An operator overload for \c value(). |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
120 | //! \returns a mutable reference to a value by \c idx |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | inline double& operator[] (int idx) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | { |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
123 | return value (idx); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
126 | //! An operator overload for \c value() const. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
127 | //! \returns a const reference to a value by \c idx |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | inline const double& operator[] (int idx) const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | { |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
130 | return value (idx); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
133 | //! \param other the matrix to check against |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
134 | //! \returns whether the two matrices have the same values. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | bool operator== (const Matrix& other) const; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | private: |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | double m_vals[9]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
139 | }; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
141 | //! |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
142 | //! \brief A vertex in 3D space |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
143 | //! |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
144 | //! Contains a single point in 3D space. Not to be confused with |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
145 | //! LDVertex, which is a vertex used in an LDraw part file. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
146 | //! |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
147 | //! This also sees use as a position vector. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
148 | //! |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | class Vertex |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | public: |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
152 | //! Constructs a zero vertex |
653
a9966d51ebf1
- fixed various compilation issues
Santeri Piippo <crimsondusk64@gmail.com>
parents:
649
diff
changeset
|
153 | Vertex() : |
a9966d51ebf1
- fixed various compilation issues
Santeri Piippo <crimsondusk64@gmail.com>
parents:
649
diff
changeset
|
154 | m_coords{0, 0, 0} {} |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
155 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
156 | //! Constructs a vertex with the given \c x, \c y and \c z. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | Vertex (double x, double y, double z); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
159 | //! \returns the distance from this vertex to \c other |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
160 | double distanceTo (const Vertex& other) const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
161 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
162 | //! \returns the vertex at the midpoint between this and \c other |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
163 | Vertex midpoint (const Vertex& other); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
164 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
165 | //! Moves this vertex using \param other as a position vector. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
166 | void move (const Vertex& other); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
167 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
168 | //! Yields a string representation of the vertex. The string returned |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
169 | //! can possibly be mangled. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
170 | //! - As mangled: {1.5, 2.8, 3.14} |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
171 | //! - Without mangling: 1.5 2.8 3.14 |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
172 | //! |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
173 | //! The mangled version is suitable for printing to the user, the |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
174 | //! non-mangled one is used when writing the vertex to LDraw files. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
175 | //! |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
176 | //! \returns a string representation of this vertex |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
177 | //! \param mangled whether to return a mangled representation or not |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
178 | QString toString (bool mangled) const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
179 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
180 | //! Transforms this vertex with \c matr as transformation matrix |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
181 | //! and \c pos as the position column of the 4x4 matrix. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | void transform (const Matrix& matr, const Vertex& pos); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
183 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
184 | //! An operator overload for \c move(). |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | Vertex& operator+= (const Vertex& other); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
186 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
187 | //! An operator overload for \c move(), using a temporary vertex. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | Vertex operator+ (const Vertex& other) const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
189 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
190 | //! Divides all values by \c d. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
191 | Vertex operator/ (const double d) const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
192 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
193 | //! Divides all values by \c d. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
194 | Vertex& operator/= (const double d); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
195 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
196 | //! Checks whether this vertex has the same values as \c other. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
197 | bool operator== (const Vertex& other) const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
198 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
199 | //! Checks whether this vertex has different values than \c other. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
200 | bool operator!= (const Vertex& other) const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
201 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
202 | //! \returns a negated version the vertex |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
203 | Vertex operator-() const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
204 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
205 | //! \returns whether the vertex has lesser values than \c other. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
206 | int operator< (const Vertex& other) const; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
207 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
208 | //! An operator overload for \c getCoordinate(). |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
209 | inline double& operator[] (const Axis ax) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
210 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | return getCoordinate ((int) ax); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
213 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
214 | //! An operator overload for \c getCoordinate() const. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
215 | inline const double& operator[] (const Axis ax) const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
216 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
217 | return getCoordinate ((int) ax); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
218 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
219 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
220 | //! An operator overload for \c getCoordinate(). |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
221 | inline double& operator[] (const int ax) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
222 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
223 | return getCoordinate (ax); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
224 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
225 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
226 | //! An operator overload for \c getCoordinate() const. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
227 | inline const double& operator[] (const int ax) const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
228 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
229 | return getCoordinate (ax); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
230 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
231 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
232 | //! \returns a mutable reference for the coordinate designated by \param n. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
233 | inline double& getCoordinate (int n) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
234 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
235 | return m_coords[n]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
236 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
237 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
238 | //! An overload of \c getCoordinate for const vertices. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
239 | //! \returns a const reference for the coordinate designated by \param n. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
240 | inline const double& getCoordinate (int n) const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
241 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
242 | return m_coords[n]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
243 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
244 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
245 | //! \returns a mutable reference to X. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
246 | inline double& x() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
247 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
248 | return m_coords[X]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
249 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
250 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
251 | //! An overload of \c x() for const vertices. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
252 | //! \returns a const reference to X. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
253 | inline const double& x() const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
254 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
255 | return m_coords[X]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
256 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
257 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
258 | //! \returns a mutable reference to Y. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
259 | inline double& y() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
260 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
261 | return m_coords[Y]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
262 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
263 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
264 | //! An overload of \c y() for const vertices. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
265 | //! \returns a const reference to Y. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
266 | inline const double& y() const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
267 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
268 | return m_coords[Y]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
269 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
270 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
271 | //! \returns a mutable reference to Z. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
272 | inline double& z() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
273 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
274 | return m_coords[Z]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
275 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
276 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
277 | //! An overload of \c z() for const vertices. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
278 | //! \returns a const reference to Z. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
279 | inline const double& z() const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
280 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
281 | return m_coords[Z]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
282 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
283 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
284 | private: |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
285 | double m_coords[3]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
286 | }; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
287 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
288 | Q_DECLARE_METATYPE (Vertex) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
289 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
290 | //! |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
291 | //! Defines a bounding box that encompasses a given set of objects. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
292 | //! vertex0 is the minimum vertex, vertex1 is the maximum vertex. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
293 | // |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
294 | class LDBoundingBox |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
295 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
641
diff
changeset
|
296 | PROPERTY (private, bool, isEmpty, setEmpty, STOCK_WRITE) |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
641
diff
changeset
|
297 | PROPERTY (private, Vertex, vertex0, setVertex0, STOCK_WRITE) |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
641
diff
changeset
|
298 | PROPERTY (private, Vertex, vertex1, setVertex1, STOCK_WRITE) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
299 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
300 | public: |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
301 | //! Constructs an empty bounding box. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
302 | LDBoundingBox(); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
303 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
304 | //! Clears the bounding box |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
305 | void reset(); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
306 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
307 | //! Calculates the bounding box's values from the objects in the current |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
308 | //! document. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
309 | void calculateFromCurrentDocument(); |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
310 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
311 | //! \returns the length of the bounding box on the longest measure. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
312 | double longestMeasurement() const; |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
313 | |
649 | 314 | //! Calculates the given \c obj to the bounding box, adjusting |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
315 | //! extremas if necessary. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
316 | void calcObject (LDObject* obj); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
317 | |
649 | 318 | //! Calculates the given \c vertex to the bounding box, adjusting |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
319 | //! extremas if necessary. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
320 | void calcVertex (const Vertex& vertex); |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
321 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
322 | //! \returns the center of the bounding box. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
323 | Vertex center() const; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
324 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
325 | //! An operator overload for \c calcObject() |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
326 | LDBoundingBox& operator<< (LDObject* obj); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
327 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
328 | //! An operator overload for \c calcVertex() |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
329 | LDBoundingBox& operator<< (const Vertex& v); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
330 | }; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
331 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
332 | extern const Vertex g_origin; // Vertex at (0, 0, 0) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
333 | extern const Matrix g_identity; // Identity matrix |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
334 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
335 | static const double pi = 3.14159265358979323846; |