Sun, 08 May 2016 16:11:40 +0300
Enum stuff
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1014
f0a8ecb6a357
Happy new year 2016!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
998
diff
changeset
|
3 | * Copyright (C) 2013 - 2016 Teemu Piippo |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #pragma once |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QColor> |
974
b2fa5f89798a
Added a GuiUtilities class to contain useful non-MainWindow-related GUI functions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
21 | #include "basics.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | |
998 | 23 | class ColorData |
24 | { | |
25 | public: | |
26 | struct Entry | |
27 | { | |
28 | QString name; | |
29 | QString hexcode; | |
30 | QColor faceColor; | |
31 | QColor edgeColor; | |
32 | }; | |
33 | ||
34 | enum { EntryCount = 512 }; | |
35 | ColorData(); | |
36 | ~ColorData(); | |
37 | void loadFromLdconfig(); | |
38 | bool contains (int code) const; | |
39 | const Entry& get (int code) const; | |
40 | ||
41 | private: | |
42 | Entry m_data[EntryCount]; | |
43 | }; | |
44 | ||
946 | 45 | class LDColor |
46 | { | |
47 | public: | |
48 | LDColor() : m_index (0) {} | |
49 | LDColor (qint32 index) : m_index (index) {} | |
50 | LDColor (const LDColor& other) : m_index (other.m_index) {} | |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
51 | |
946 | 52 | bool isLDConfigColor() const; |
53 | bool isValid() const; | |
54 | QString name() const; | |
55 | QString hexcode() const; | |
56 | QColor faceColor() const; | |
57 | QColor edgeColor() const; | |
58 | qint32 index() const; | |
59 | int luma() const; | |
60 | int edgeLuma() const; | |
61 | bool isDirect() const; | |
62 | QString indexString() const; | |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
63 | |
946 | 64 | static LDColor nullColor() { return LDColor (-1); } |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
65 | |
946 | 66 | LDColor& operator= (qint32 index) { m_index = index; return *this; } |
67 | LDColor& operator= (LDColor other) { m_index = other.index(); return *this; } | |
68 | LDColor operator++() { return ++m_index; } | |
69 | LDColor operator++ (int) { return m_index++; } | |
70 | LDColor operator--() { return --m_index; } | |
71 | LDColor operator-- (int) { return m_index--; } | |
72 | ||
73 | bool operator== (LDColor other) const { return index() == other.index(); } | |
74 | bool operator!= (LDColor other) const { return index() != other.index(); } | |
75 | bool operator< (LDColor other) const { return index() < other.index(); } | |
76 | bool operator<= (LDColor other) const { return index() <= other.index(); } | |
77 | bool operator> (LDColor other) const { return index() > other.index(); } | |
78 | bool operator>= (LDColor other) const { return index() >= other.index(); } | |
79 | ||
80 | private: | |
998 | 81 | const ColorData::Entry& data() const; |
82 | ||
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
844
diff
changeset
|
83 | qint32 m_index; |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
84 | }; |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
85 | |
1031
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
86 | uint qHash(LDColor color); |
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
87 | |
946 | 88 | // |
89 | // Parses ldconfig.ldr | |
90 | // | |
91 | class LDConfigParser | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | { |
946 | 93 | public: |
94 | LDConfigParser (QString inText, char sep); | |
95 | ||
96 | bool getToken (QString& val, const int pos); | |
97 | bool findToken (int& result, char const* needle, int args); | |
98 | bool compareToken (int inPos, QString text); | |
998 | 99 | bool parseTag (char const* tag, QString& val); |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
100 | |
946 | 101 | inline QString operator[] (const int idx) |
102 | { | |
103 | return m_tokens[idx]; | |
104 | } | |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
105 | |
946 | 106 | private: |
107 | QStringList m_tokens; | |
108 | int m_pos; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | }; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | |
998 | 111 | void initColors(); |
112 | int luma (const QColor& col); | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
844
diff
changeset
|
113 | |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
844
diff
changeset
|
114 | enum |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
844
diff
changeset
|
115 | { |
946 | 116 | MainColor = 16, |
117 | EdgeColor = 24, | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
844
diff
changeset
|
118 | }; |