Wed, 25 May 2022 17:56:30 +0300
delete unneeded things
26 | 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 | ||
19 | #include "colors.h" | |
20 | ||
139
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
21 | const ldraw::ColorDefinition ldraw::ColorTable::unknownColor{{}, {}, "Unknown", "???"}; |
26 | 22 | |
139
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
23 | /** |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
24 | * @brief Clears the color table |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
25 | */ |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
26 | void ldraw::ColorTable::clear() |
26 | 27 | { |
139
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
28 | this->definitions = {}; |
26 | 29 | } |
30 | ||
139
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
31 | /** |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
32 | * @brief Loads colors from LDConfig.ldr |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
33 | * @param device Opened LDConfig.ldr I/O device |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
34 | * @param errors Where to write any errors into |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
35 | * @returns whether or not it succeeded. |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
36 | */ |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
37 | Result ldraw::ColorTable::load(QIODevice& device, QTextStream& errors) |
26 | 38 | { |
39 | this->clear(); | |
40 | if (device.isReadable()) | |
41 | { | |
42 | QTextStream stream{&device}; | |
43 | QString line; | |
44 | while (stream.readLineInto(&line)) | |
45 | { | |
46 | this->loadColorFromString(line); | |
47 | } | |
48 | return Success; | |
49 | } | |
50 | else | |
51 | { | |
52 | errors << "could not read colors"; | |
53 | return Failure; | |
54 | } | |
55 | } | |
56 | ||
139
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
57 | /** |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
58 | * @brief Gets color information by color index. |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
59 | * @param color |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
60 | * @returns color table information |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
61 | */ |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
62 | const ldraw::ColorDefinition& ldraw::ColorTable::operator[](Color color) const |
26 | 63 | { |
64 | auto it = this->definitions.find(color.index); | |
65 | if (it != this->definitions.end()) | |
66 | { | |
94
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
67 | return it->second; |
26 | 68 | } |
69 | else | |
70 | { | |
71 | return unknownColor; | |
72 | } | |
73 | } | |
74 | ||
139
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
75 | /** |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
76 | * @brief Gets the amount of elements in the color table |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
77 | * @returns int |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
78 | */ |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
79 | int ldraw::ColorTable::size() const |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
80 | { |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
81 | return this->definitions.size(); |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
82 | } |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
83 | |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
84 | /** |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
85 | * @brief Parses an LDConfig.ldr line from a string |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
86 | * @param string LDConfig.ldr line to parse |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
87 | */ |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
88 | void ldraw::ColorTable::loadColorFromString(const QString& string) |
26 | 89 | { |
90 | const QRegExp pattern{ | |
91 | R"(^\s*0 \!COLOUR\s+([^\s]+)\s+)"_q + | |
92 | R"(CODE\s+(\d+)\s+)"_q + | |
93 | R"(VALUE\s+(\#[0-9a-fA-F]{3,6})\s+)"_q + | |
94 | R"(EDGE\s+(\#[0-9a-fA-F]{3,6}))"_q + | |
95 | R"((?:\s+ALPHA\s+(\d+))?)"_q | |
96 | }; | |
97 | if (pattern.indexIn(string) != -1) | |
98 | { | |
99 | const int code = pattern.cap(2).toInt(); | |
139
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
100 | ColorDefinition& definition = this->definitions[code]; |
26 | 101 | definition = {}; // in case there's an existing definition |
102 | definition.name = pattern.cap(1); | |
94
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
103 | definition.displayName = definition.name; |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
104 | definition.displayName.replace("_", " "); |
26 | 105 | definition.faceColor = pattern.cap(3); |
106 | definition.edgeColor = pattern.cap(4); | |
107 | if (not pattern.cap(5).isEmpty()) | |
108 | { | |
109 | const int alpha = pattern.cap(5).toInt(); | |
110 | definition.faceColor.setAlpha(alpha); | |
111 | } | |
112 | } | |
113 | } | |
43
08dc62e03a6d
made edges white in dark backgrounds
Teemu Piippo <teemu@hecknology.net>
parents:
35
diff
changeset
|
114 | |
139
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
115 | /** |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
116 | * @brief Calculates the luma-value for the given color. |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
117 | * @details c.f. https://en.wikipedia.org/wiki/Luma_(video) |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
118 | * @param color |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
119 | * @returns luma value [0, 1] |
43
08dc62e03a6d
made edges white in dark backgrounds
Teemu Piippo <teemu@hecknology.net>
parents:
35
diff
changeset
|
120 | */ |
08dc62e03a6d
made edges white in dark backgrounds
Teemu Piippo <teemu@hecknology.net>
parents:
35
diff
changeset
|
121 | double luma(const QColor& color) |
08dc62e03a6d
made edges white in dark backgrounds
Teemu Piippo <teemu@hecknology.net>
parents:
35
diff
changeset
|
122 | { |
08dc62e03a6d
made edges white in dark backgrounds
Teemu Piippo <teemu@hecknology.net>
parents:
35
diff
changeset
|
123 | return 0.2126 * color.redF() + 0.7152 * color.greenF() + 0.0722 * color.blueF(); |
08dc62e03a6d
made edges white in dark backgrounds
Teemu Piippo <teemu@hecknology.net>
parents:
35
diff
changeset
|
124 | } |
94
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
125 | |
139
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
126 | /** |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
127 | * @brief Returns a direct color index that codes the specified color value |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
128 | * @param color |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
129 | * @returns direct color index |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
130 | */ |
94
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
131 | ldraw::Color ldraw::directColor(const QColor& color) |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
132 | { |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
133 | return ldraw::Color{0x2000000 | (color.red() << 16) | (color.green() << 8) | color.blue()}; |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
134 | } |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
135 | |
139
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
136 | /** |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
137 | * @brief Checks whether or not the specified color index is a direct color |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
138 | * @param color Color to check |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
139 | * @returns bool |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
140 | */ |
94
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
141 | bool ldraw::isDirectColor(ldraw::Color color) |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
142 | { |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
143 | return color.index >= 0x2000000; |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
144 | } |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
145 | |
139
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
146 | /** |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
147 | * @brief Extracts the color value from a direct color index |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
148 | * @param color Direct color index |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
149 | * @returns color value. Returns a default-constructed QColor in case a non-direct color is given. |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
150 | */ |
94
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
151 | QColor ldraw::directColorFace(ldraw::Color color) |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
152 | { |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
153 | if (isDirectColor(color)) |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
154 | { |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
155 | return {(color.index >> 16) & 0xff, (color.index >> 8) & 0xff, color.index & 0xff}; |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
156 | } |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
157 | else |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
158 | { |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
159 | return {}; |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
160 | } |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
161 | } |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
162 | |
139
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
163 | /** |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
164 | * @brief Gets the face color for the specified color index |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
165 | * @param color Color index to get face color for |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
166 | * @param colorTable Color table to use for lookup |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
167 | * @returns QColor |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
168 | */ |
94
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
169 | QColor ldraw::colorFace(ldraw::Color color, const ldraw::ColorTable& colorTable) |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
170 | { |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
171 | if (isDirectColor(color)) |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
172 | { |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
173 | return directColorFace(color); |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
174 | } |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
175 | else |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
176 | { |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
177 | return colorTable[color].faceColor; |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
178 | } |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
179 | } |
132
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
94
diff
changeset
|
180 | |
178 | 181 | QColor ldraw::colorEdge(ldraw::Color color, const ldraw::ColorTable& colorTable) |
182 | { | |
183 | if (isDirectColor(color)) | |
184 | { | |
185 | QColor const faceColor = directColorFace(color); | |
186 | return (luma(faceColor) < 0.4) ? Qt::white : Qt::black; | |
187 | } | |
188 | else | |
189 | { | |
190 | return colorTable[color].faceColor; | |
191 | } | |
192 | } | |
193 | ||
139
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
194 | /** |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
195 | * @brief Writes a color index into a @c QDataStream |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
196 | * @param stream |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
197 | * @param color |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
198 | * @returns stream |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
199 | */ |
132
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
94
diff
changeset
|
200 | QDataStream& operator<<(QDataStream& stream, ldraw::Color color) |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
94
diff
changeset
|
201 | { |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
94
diff
changeset
|
202 | return stream << color.index; |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
94
diff
changeset
|
203 | } |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
94
diff
changeset
|
204 | |
139
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
205 | /** |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
206 | * @brief Reads a color index from a @c QDataStream |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
207 | * @param stream |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
208 | * @param color |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
209 | * @returns stream |
72098474d362
Document and refactor colors.cpp and colors.h
Teemu Piippo <teemu@hecknology.net>
parents:
132
diff
changeset
|
210 | */ |
132
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
94
diff
changeset
|
211 | QDataStream& operator>>(QDataStream& stream, ldraw::Color& color) |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
94
diff
changeset
|
212 | { |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
94
diff
changeset
|
213 | return stream >> color.index; |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
94
diff
changeset
|
214 | } |
178 | 215 | |
216 | QString ldraw::colorDisplayName(ldraw::Color color, const ldraw::ColorTable &colorTable) | |
217 | { | |
218 | if (isDirectColor(color)) | |
219 | { | |
220 | return directColorFace(color).name(); | |
221 | } | |
222 | else | |
223 | { | |
224 | return colorTable[color].displayName; | |
225 | } | |
226 | } |