Thu, 27 Feb 2020 12:23:42 +0200
use glm::project instead of figuring out the conversion manually...
24 | 1 | /* |
2 | * LDForge: LDraw parts authoring CAD | |
3 | * Copyright (C) 2013 - 2020 Teemu Piippo | |
4 | * | |
5 | * This program is free software: you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation, either version 3 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
3 | 19 | #pragma once |
26 | 20 | #include <QColor> |
3 | 21 | #include "main.h" |
22 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
23 | namespace ldraw |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
24 | { |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
25 | struct Color; |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
26 | class ColorTable; |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
27 | } |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
28 | |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
29 | struct ldraw::Color |
3 | 30 | { |
31 | qint32 index; | |
32 | }; | |
33 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
34 | class ldraw::ColorTable |
26 | 35 | { |
36 | public: | |
37 | struct ColorDefinition | |
38 | { | |
39 | QColor faceColor; | |
40 | QColor edgeColor; | |
41 | QString name; | |
42 | }; | |
43 | void clear(); | |
44 | Result load(QIODevice& device, QTextStream& errors); | |
45 | const ColorDefinition& operator[](Color index) const; | |
46 | static const ColorDefinition unknownColor; | |
47 | private: | |
48 | void loadColorFromString(const QString& string); | |
49 | QMap<qint32, ColorDefinition> definitions; | |
50 | }; | |
51 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
52 | inline bool operator==(const ldraw::Color& one, const ldraw::Color& other) |
21 | 53 | { |
54 | return one.index == other.index; | |
55 | } | |
56 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
57 | inline bool operator!=(const ldraw::Color& one, const ldraw::Color& other) |
21 | 58 | { |
59 | return one.index != other.index; | |
60 | } | |
61 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
62 | inline bool operator<(const ldraw::Color& one, const ldraw::Color& other) |
21 | 63 | { |
64 | return one.index < other.index; | |
65 | } | |
66 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
67 | inline bool operator<=(const ldraw::Color& one, const ldraw::Color& other) |
21 | 68 | { |
69 | return one.index <= other.index; | |
70 | } | |
71 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
72 | inline bool operator>(const ldraw::Color& one, const ldraw::Color& other) |
21 | 73 | { |
74 | return one.index > other.index; | |
75 | } | |
76 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
77 | inline bool operator>=(const ldraw::Color& one, const ldraw::Color& other) |
21 | 78 | { |
79 | return one.index >= other.index; | |
80 | } | |
81 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
82 | namespace ldraw |
3 | 83 | { |
84 | static constexpr Color black {0}; | |
85 | static constexpr Color blue {1}; | |
86 | static constexpr Color green {2}; | |
87 | static constexpr Color red {4}; | |
88 | static constexpr Color yellow {14}; | |
89 | static constexpr Color white {15}; | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
90 | static constexpr Color mainColor {16}; |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
91 | static constexpr Color edgeColor {24}; |
3 | 92 | } |
43
08dc62e03a6d
made edges white in dark backgrounds
Teemu Piippo <teemu@hecknology.net>
parents:
35
diff
changeset
|
93 | |
08dc62e03a6d
made edges white in dark backgrounds
Teemu Piippo <teemu@hecknology.net>
parents:
35
diff
changeset
|
94 | double luma(const QColor& color); |