Tue, 14 Feb 2017 08:15:58 +0200
Fixed the free camera icon not showing up anymore.
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 |
1072 | 3 | * Copyright (C) 2013 - 2017 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 | |
1044 | 23 | /* |
24 | * ColorData | |
25 | * | |
26 | * This class contains the model data for LDConfig-defined colors. | |
27 | */ | |
998 | 28 | class ColorData |
29 | { | |
30 | public: | |
31 | struct Entry | |
32 | { | |
33 | QString name; | |
34 | QColor faceColor; | |
35 | QColor edgeColor; | |
36 | }; | |
37 | ||
38 | ColorData(); | |
39 | void loadFromLdconfig(); | |
1044 | 40 | bool contains(int code) const; |
41 | const Entry& get(int code) const; | |
998 | 42 | |
43 | private: | |
1044 | 44 | Entry m_data[512]; |
998 | 45 | }; |
46 | ||
1044 | 47 | /* |
48 | * LDColor | |
49 | * | |
50 | * This class represents an LDraw color. For a color index, this class provides information for that color. | |
51 | * It only contains the index of the color. Therefore it is a wrapper around an integer and should be passed by value. | |
52 | */ | |
946 | 53 | class LDColor |
54 | { | |
55 | public: | |
1044 | 56 | LDColor(); |
57 | LDColor(qint32 index); | |
58 | LDColor(const LDColor& other) = default; | |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
59 | |
946 | 60 | bool isLDConfigColor() const; |
61 | bool isValid() const; | |
62 | QString name() const; | |
63 | QString hexcode() const; | |
64 | QColor faceColor() const; | |
65 | QColor edgeColor() const; | |
66 | qint32 index() const; | |
67 | bool isDirect() const; | |
68 | QString indexString() const; | |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
69 | |
1114
ffd49a28f49e
Moved some global constants into appropriate namespaces.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
70 | static const LDColor nullColor; |
ffd49a28f49e
Moved some global constants into appropriate namespaces.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
71 | static void initColors(); |
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
|
72 | |
1044 | 73 | LDColor& operator=(qint32 index) { m_index = index; return *this; } |
74 | LDColor& operator=(const LDColor &other) = default; | |
946 | 75 | LDColor operator++() { return ++m_index; } |
1044 | 76 | LDColor operator++(int) { return m_index++; } |
946 | 77 | LDColor operator--() { return --m_index; } |
1044 | 78 | LDColor operator--(int) { return m_index--; } |
79 | bool operator==(LDColor other) const { return index() == other.index(); } | |
80 | bool operator!=(LDColor other) const { return index() != other.index(); } | |
81 | bool operator<(LDColor other) const { return index() < other.index(); } | |
82 | bool operator<=(LDColor other) const { return index() <= other.index(); } | |
83 | bool operator>(LDColor other) const { return index() > other.index(); } | |
84 | bool operator>=(LDColor other) const { return index() >= other.index(); } | |
946 | 85 | |
86 | private: | |
1114
ffd49a28f49e
Moved some global constants into appropriate namespaces.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
87 | static ColorData* colorData; |
998 | 88 | const ColorData::Entry& data() const; |
89 | ||
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
844
diff
changeset
|
90 | 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
|
91 | }; |
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
|
92 | |
1031
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
93 | 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
|
94 | |
1044 | 95 | /* |
96 | * LDConfigParser | |
97 | * | |
98 | * Parses LDConfig.ldr. | |
99 | */ | |
946 | 100 | class LDConfigParser |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | { |
946 | 102 | public: |
1044 | 103 | LDConfigParser(QString inputText); |
946 | 104 | |
1044 | 105 | bool getToken(QString& tokenText, int position); |
106 | bool findToken(int& tokenPosition, QString needle, int args); | |
107 | bool compareToken(int inPos, QString text); | |
108 | bool parseTag(QString key, QString& value); | |
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
|
109 | |
946 | 110 | private: |
111 | QStringList m_tokens; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | }; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | |
1044 | 114 | int luma(const QColor& col); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
844
diff
changeset
|
115 | |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
844
diff
changeset
|
116 | enum |
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
844
diff
changeset
|
117 | { |
946 | 118 | MainColor = 16, |
119 | EdgeColor = 24, | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
844
diff
changeset
|
120 | }; |