Mon, 24 Aug 2020 23:00:50 +0300
merge commit
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 | { |
89 | 31 | qint32 index = 0; |
3 | 32 | }; |
33 | ||
89 | 34 | Q_DECLARE_METATYPE(ldraw::Color) |
35 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
36 | class ldraw::ColorTable |
26 | 37 | { |
38 | public: | |
39 | struct ColorDefinition | |
40 | { | |
41 | QColor faceColor; | |
42 | QColor edgeColor; | |
43 | QString name; | |
44 | }; | |
45 | void clear(); | |
46 | Result load(QIODevice& device, QTextStream& errors); | |
47 | const ColorDefinition& operator[](Color index) const; | |
48 | static const ColorDefinition unknownColor; | |
49 | private: | |
50 | void loadColorFromString(const QString& string); | |
51 | QMap<qint32, ColorDefinition> definitions; | |
52 | }; | |
53 | ||
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
54 | namespace ldraw |
21 | 55 | { |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
56 | inline bool operator==(const ldraw::Color& one, const ldraw::Color& other) |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
57 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
58 | return one.index == other.index; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
59 | } |
21 | 60 | |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
61 | inline bool operator!=(const ldraw::Color& one, const ldraw::Color& other) |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
62 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
63 | return one.index != other.index; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
64 | } |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
65 | |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
66 | inline bool operator<(const ldraw::Color& one, const ldraw::Color& other) |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
67 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
68 | return one.index < other.index; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
69 | } |
21 | 70 | |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
71 | inline bool operator<=(const ldraw::Color& one, const ldraw::Color& other) |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
72 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
73 | return one.index <= other.index; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
74 | } |
21 | 75 | |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
76 | inline bool operator>(const ldraw::Color& one, const ldraw::Color& other) |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
77 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
78 | return one.index > other.index; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
79 | } |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
80 | |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
81 | inline bool operator>=(const ldraw::Color& one, const ldraw::Color& other) |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
82 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
83 | return one.index >= other.index; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
84 | } |
21 | 85 | } |
86 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
87 | namespace ldraw |
3 | 88 | { |
89 | static constexpr Color black {0}; | |
90 | static constexpr Color blue {1}; | |
91 | static constexpr Color green {2}; | |
92 | static constexpr Color red {4}; | |
93 | static constexpr Color yellow {14}; | |
94 | 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
|
95 | 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
|
96 | static constexpr Color edgeColor {24}; |
3 | 97 | } |
43
08dc62e03a6d
made edges white in dark backgrounds
Teemu Piippo <teemu@hecknology.net>
parents:
35
diff
changeset
|
98 | |
08dc62e03a6d
made edges white in dark backgrounds
Teemu Piippo <teemu@hecknology.net>
parents:
35
diff
changeset
|
99 | double luma(const QColor& color); |