src/colors.h

Sat, 01 Feb 2020 15:33:57 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 01 Feb 2020 15:33:57 +0200
changeset 37
90443fb328ea
parent 35
98906a94732f
child 43
08dc62e03a6d
permissions
-rw-r--r--

wired renderstyle up

24
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
1 /*
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
2 * LDForge: LDraw parts authoring CAD
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
3 * Copyright (C) 2013 - 2020 Teemu Piippo
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
4 *
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
5 * This program is free software: you can redistribute it and/or modify
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
6 * it under the terms of the GNU General Public License as published by
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
8 * (at your option) any later version.
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
9 *
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
10 * This program is distributed in the hope that it will be useful,
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
13 * GNU General Public License for more details.
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
14 *
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
15 * You should have received a copy of the GNU General Public License
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
17 */
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
18
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 #pragma once
26
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
20 #include <QColor>
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
21 #include "main.h"
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
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
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
30 {
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
31 qint32 index;
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
32 };
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
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
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
35 {
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
36 public:
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
37 struct ColorDefinition
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
38 {
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
39 QColor faceColor;
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
40 QColor edgeColor;
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
41 QString name;
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
42 };
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
43 void clear();
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
44 Result load(QIODevice& device, QTextStream& errors);
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
45 const ColorDefinition& operator[](Color index) const;
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
46 static const ColorDefinition unknownColor;
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
47 private:
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
48 void loadColorFromString(const QString& string);
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
49 QMap<qint32, ColorDefinition> definitions;
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
50 };
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 24
diff changeset
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
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
53 {
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
54 return one.index == other.index;
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
55 }
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
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
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
58 {
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
59 return one.index != other.index;
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
60 }
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
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
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
63 {
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
64 return one.index < other.index;
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
65 }
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
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
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
68 {
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
69 return one.index <= other.index;
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
70 }
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
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
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
73 {
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
74 return one.index > other.index;
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
75 }
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
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
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
78 {
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
79 return one.index >= other.index;
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
80 }
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
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
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
83 {
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
84 static constexpr Color black {0};
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
85 static constexpr Color blue {1};
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
86 static constexpr Color green {2};
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
87 static constexpr Color red {4};
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
88 static constexpr Color yellow {14};
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
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
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
92 }

mercurial