Sat, 24 Mar 2018 11:57:24 +0200
reorganized headers
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 |
1006
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
8 | * (at your option) any later version. |
655
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 | #pragma once |
1136
9a7a945c0e93
Rearranged declarations in basics.h
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
20 | #include <QFile> |
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:
1162
diff
changeset
|
21 | #include <QMatrix4x4> |
1319 | 22 | #include <QMetaType> |
23 | #include <QObject> | |
24 | #include <QSet> | |
25 | #include <QString> | |
26 | #include <QStringList> | |
27 | #include <QVector> | |
28 | #include <QVector3D> | |
29 | #include "generics/functions.h" | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | |
1319 | 31 | #ifndef __GNUC__ |
32 | # define __attribute__(X) | |
1311
8d22e1dd272d
ported qOverload to drop minimum Qt requirement down to 5.5
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
33 | #endif |
8d22e1dd272d
ported qOverload to drop minimum Qt requirement down to 5.5
Teemu Piippo <teemu@hecknology.net>
parents:
1308
diff
changeset
|
34 | |
1319 | 35 | #define DEFINE_CLASS(SELF, SUPER) \ |
36 | public: \ | |
37 | using Self = SELF; \ | |
38 | using Super = SUPER; | |
39 | ||
40 | // TODO: get rid of this | |
41 | #ifdef WIN32 | |
42 | # define DIRSLASH "\\" | |
43 | # define DIRSLASH_CHAR '\\' | |
44 | #else // WIN32 | |
45 | # define DIRSLASH "/" | |
46 | # define DIRSLASH_CHAR '/' | |
47 | #endif // WIN32 | |
48 | ||
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:
1162
diff
changeset
|
49 | using GLRotationMatrix = QMatrix4x4; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | enum Axis |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | X, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | Y, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | Z |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | }; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | |
1305
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
58 | enum Winding |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
59 | { |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
60 | NoWinding, |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
61 | CounterClockwise, |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
62 | Clockwise, |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
63 | }; |
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
64 | |
1319 | 65 | /* |
66 | * Special operator definition that implements the XOR operator for windings. | |
67 | * However, if either winding is NoWinding, then this function returns NoWinding. | |
68 | */ | |
69 | inline Winding operator^(Winding one, Winding other) | |
70 | { | |
71 | if (one == NoWinding or other == NoWinding) | |
72 | return NoWinding; | |
73 | else | |
74 | return static_cast<Winding>(static_cast<int>(one) ^ static_cast<int>(other)); | |
75 | } | |
1305
31627acdd4b5
Bfc red/green view almost completely fixed
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
76 | |
1319 | 77 | inline Winding& operator^=(Winding& one, Winding other) |
78 | { | |
79 | one = one ^ other; | |
80 | return one; | |
81 | } | |
82 | ||
83 | static const double pi = 3.14159265358979323846; | |
84 | ||
85 | /* | |
86 | * Returns the norm of a vector. | |
87 | */ | |
1064
4c7a353cf583
Replaced '.length()' with 'length()' where appropriate
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
88 | static inline qreal abs(const QVector3D &vector) |
4c7a353cf583
Replaced '.length()' with 'length()' where appropriate
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
89 | { |
4c7a353cf583
Replaced '.length()' with 'length()' where appropriate
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
90 | return vector.length(); |
4c7a353cf583
Replaced '.length()' with 'length()' where appropriate
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
91 | } |
4c7a353cf583
Replaced '.length()' with 'length()' where appropriate
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
92 | |
1319 | 93 | using ApplyToMatrixFunction = std::function<void(int, double&)>; |
94 | using ApplyToMatrixConstFunction = std::function<void(int, double)>; | |
1122
795d1c3554b9
Added the RingAdapter class and interfacing ring() function and simplified some math in GLCompiler with it
Teemu Piippo <teemu@hecknology.net>
parents:
1079
diff
changeset
|
95 | |
1319 | 96 | void applyToMatrix(class Matrix& a, ApplyToMatrixFunction func); |
97 | void applyToMatrix(const class Matrix& a, ApplyToMatrixConstFunction func); | |
98 | QString formatFileSize(qint64 size); | |
99 | int gcd(int a, int b); | |
100 | QString joinStrings(const QList<class StringFormatArg>& values, QString delimeter = " "); | |
101 | void roundToDecimals(double& value, int decimals); | |
102 | void simplify(int& numerator, int& denominator); |