Fri, 17 Sep 2021 22:43:22 +0300
add missing change to document.cpp
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; |
94
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
89
diff
changeset
|
27 | Color directColor(const QColor& color); |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
89
diff
changeset
|
28 | bool isDirectColor(Color color); |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
89
diff
changeset
|
29 | QColor directColorFace(Color color); |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
89
diff
changeset
|
30 | QColor colorFace(Color color, const ColorTable& colorTable); |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
31 | } |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
32 | |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
33 | struct ldraw::Color |
3 | 34 | { |
89 | 35 | qint32 index = 0; |
3 | 36 | }; |
37 | ||
89 | 38 | Q_DECLARE_METATYPE(ldraw::Color) |
39 | ||
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
40 | class ldraw::ColorTable |
26 | 41 | { |
42 | public: | |
43 | struct ColorDefinition | |
44 | { | |
45 | QColor faceColor; | |
46 | QColor edgeColor; | |
47 | QString name; | |
94
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
89
diff
changeset
|
48 | QString displayName; |
26 | 49 | }; |
50 | void clear(); | |
51 | Result load(QIODevice& device, QTextStream& errors); | |
52 | const ColorDefinition& operator[](Color index) const; | |
53 | static const ColorDefinition unknownColor; | |
94
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
89
diff
changeset
|
54 | auto begin() const { return this->definitions.begin(); } |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
89
diff
changeset
|
55 | auto end() const { return this->definitions.end(); } |
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
89
diff
changeset
|
56 | int size() const { return this->definitions.size(); } |
26 | 57 | private: |
58 | void loadColorFromString(const QString& string); | |
94
164f53fb5921
added a color select dialog
Teemu Piippo <teemu@hecknology.net>
parents:
89
diff
changeset
|
59 | std::map<qint32, ColorDefinition> definitions; |
26 | 60 | }; |
61 | ||
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
62 | namespace ldraw |
21 | 63 | { |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
64 | 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
|
65 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
66 | return one.index == other.index; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
67 | } |
21 | 68 | |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
69 | 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
|
70 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
71 | return one.index != other.index; |
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 | |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
74 | 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
|
75 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
76 | return one.index < other.index; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
77 | } |
21 | 78 | |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
79 | 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
|
80 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
81 | return one.index <= other.index; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
82 | } |
21 | 83 | |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
84 | 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
|
85 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
86 | return one.index > other.index; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
87 | } |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
88 | |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
89 | 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
|
90 | { |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
91 | return one.index >= other.index; |
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
43
diff
changeset
|
92 | } |
21 | 93 | } |
94 | ||
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 | namespace ldraw |
3 | 96 | { |
97 | static constexpr Color black {0}; | |
98 | static constexpr Color blue {1}; | |
99 | static constexpr Color green {2}; | |
100 | static constexpr Color red {4}; | |
101 | static constexpr Color yellow {14}; | |
102 | 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
|
103 | 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
|
104 | static constexpr Color edgeColor {24}; |
3 | 105 | } |
43
08dc62e03a6d
made edges white in dark backgrounds
Teemu Piippo <teemu@hecknology.net>
parents:
35
diff
changeset
|
106 | |
08dc62e03a6d
made edges white in dark backgrounds
Teemu Piippo <teemu@hecknology.net>
parents:
35
diff
changeset
|
107 | double luma(const QColor& color); |