Wed, 22 Jan 2020 22:41:17 +0200
modelview matrix set up
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 | ||
23 | struct Color | |
24 | { | |
25 | qint32 index; | |
26 | }; | |
27 | ||
26 | 28 | class ColorTable |
29 | { | |
30 | public: | |
31 | struct ColorDefinition | |
32 | { | |
33 | QColor faceColor; | |
34 | QColor edgeColor; | |
35 | QString name; | |
36 | }; | |
37 | void clear(); | |
38 | Result load(QIODevice& device, QTextStream& errors); | |
39 | const ColorDefinition& operator[](Color index) const; | |
40 | static const ColorDefinition unknownColor; | |
41 | private: | |
42 | void loadColorFromString(const QString& string); | |
43 | QMap<qint32, ColorDefinition> definitions; | |
44 | }; | |
45 | ||
21 | 46 | inline bool operator==(const Color& one, const Color& other) |
47 | { | |
48 | return one.index == other.index; | |
49 | } | |
50 | ||
51 | inline bool operator!=(const Color& one, const Color& other) | |
52 | { | |
53 | return one.index != other.index; | |
54 | } | |
55 | ||
56 | inline bool operator<(const Color& one, const Color& other) | |
57 | { | |
58 | return one.index < other.index; | |
59 | } | |
60 | ||
61 | inline bool operator<=(const Color& one, const Color& other) | |
62 | { | |
63 | return one.index <= other.index; | |
64 | } | |
65 | ||
66 | inline bool operator>(const Color& one, const Color& other) | |
67 | { | |
68 | return one.index > other.index; | |
69 | } | |
70 | ||
71 | inline bool operator>=(const Color& one, const Color& other) | |
72 | { | |
73 | return one.index >= other.index; | |
74 | } | |
75 | ||
3 | 76 | namespace colors |
77 | { | |
78 | static constexpr Color black {0}; | |
79 | static constexpr Color blue {1}; | |
80 | static constexpr Color green {2}; | |
81 | static constexpr Color red {4}; | |
82 | static constexpr Color yellow {14}; | |
83 | static constexpr Color white {15}; | |
84 | static constexpr Color main {16}; | |
85 | static constexpr Color edge {24}; | |
86 | } |