LibrePCB Developers Documentation
Loading...
Searching...
No Matches
pcbcolor.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_CORE_PCBCOLOR_H
21#define LIBREPCB_CORE_PCBCOLOR_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include <QtCore>
27#include <QtGui>
28
29/*******************************************************************************
30 * Namespace / Forward Declarations
31 ******************************************************************************/
32namespace librepcb {
33
34/*******************************************************************************
35 * Class PcbColor
36 ******************************************************************************/
37
41class PcbColor final {
42 Q_DECLARE_TR_FUNCTIONS(PcbColor)
43
44public:
45 // Types
46 enum class Flag : quint32 {
47 SolderResist = (1 << 0),
48 Silkscreen = (1 << 1),
49 };
50 Q_DECLARE_FLAGS(Flags, Flag)
51
52 // Constructors / Destructor
53 PcbColor() = delete;
54 PcbColor(const PcbColor& other) noexcept;
55 ~PcbColor() noexcept;
56
57 // Getters
58
64 const QString& getId() const noexcept { return mId; }
65
71 const QString& getNameTr() const noexcept { return mNameTr; }
72
79 const QColor& toSolderResistColor() const noexcept;
80
87 const QColor& toSilkscreenColor() const noexcept;
88
94 bool isAvailableForSolderResist() const noexcept {
95 return mFlags.testFlag(Flag::SolderResist);
96 }
97
103 bool isAvailableForSilkscreen() const noexcept {
104 return mFlags.testFlag(Flag::Silkscreen);
105 }
106
107 // Operator Overloadings
108 PcbColor& operator=(const PcbColor& rhs) noexcept = delete;
109 bool operator==(const PcbColor& rhs) const noexcept { return this == &rhs; }
110 bool operator!=(const PcbColor& rhs) const noexcept { return this != &rhs; }
111
112 // Static Methods
113 static const PcbColor& black() noexcept;
114 static const PcbColor& blackMatte() noexcept;
115 static const PcbColor& blue() noexcept;
116 static const PcbColor& clear() noexcept;
117 static const PcbColor& green() noexcept;
118 static const PcbColor& greenMatte() noexcept;
119 static const PcbColor& purple() noexcept;
120 static const PcbColor& red() noexcept;
121 static const PcbColor& white() noexcept;
122 static const PcbColor& yellow() noexcept;
123 static const PcbColor& other() noexcept;
124
130 static const QVector<const PcbColor*>& all() noexcept;
131
141 static const PcbColor& get(const QString& id);
142
143private: // Methods
144 PcbColor(const QString& id, const QString& nameTr, Flags flags,
145 const QColor& solderResistColor,
146 const QColor& silkscreenColor) noexcept;
147
148private: // Data
149 const QString mId;
150 const QString mNameTr;
151 const Flags mFlags;
152 const QColor mSolderResistColor;
153 const QColor mSilkscreenColor;
154};
155
156/*******************************************************************************
157 * End of File
158 ******************************************************************************/
159
160} // namespace librepcb
161
162Q_DECLARE_OPERATORS_FOR_FLAGS(librepcb::PcbColor::Flags)
163Q_DECLARE_METATYPE(const librepcb::PcbColor*)
164
165#endif
Predefined colors relevant for PCB fabrication.
Definition pcbcolor.h:41
const QString & getNameTr() const noexcept
Get the name of the color (human readable and translated)
Definition pcbcolor.h:71
bool isAvailableForSilkscreen() const noexcept
Check if this color is available for silkscreen.
Definition pcbcolor.h:103
bool operator!=(const PcbColor &rhs) const noexcept
Definition pcbcolor.h:110
static const PcbColor & blackMatte() noexcept
Definition pcbcolor.cpp:88
static const PcbColor & greenMatte() noexcept
Definition pcbcolor.cpp:112
static const PcbColor & green() noexcept
Definition pcbcolor.cpp:106
static const PcbColor & blue() noexcept
Definition pcbcolor.cpp:94
const QColor mSolderResistColor
Definition pcbcolor.h:152
static const QVector< const PcbColor * > & all() noexcept
Get a list of all available colors.
Definition pcbcolor.cpp:151
static const PcbColor & white() noexcept
Definition pcbcolor.cpp:130
const QString mNameTr
Definition pcbcolor.h:150
static const PcbColor & yellow() noexcept
Definition pcbcolor.cpp:137
static const PcbColor & other() noexcept
Definition pcbcolor.cpp:144
static const PcbColor & black() noexcept
Definition pcbcolor.cpp:81
const QString & getId() const noexcept
Get the identifier used for serialization.
Definition pcbcolor.h:64
const QColor & toSilkscreenColor() const noexcept
Get the actual color for silkscreen rendering.
Definition pcbcolor.cpp:72
bool operator==(const PcbColor &rhs) const noexcept
Definition pcbcolor.h:109
const Flags mFlags
Definition pcbcolor.h:151
const QColor & toSolderResistColor() const noexcept
Get the actual color for solder resist rendering.
Definition pcbcolor.cpp:67
const QColor mSilkscreenColor
Definition pcbcolor.h:153
bool isAvailableForSolderResist() const noexcept
Check if this color is available for solder resist.
Definition pcbcolor.h:94
Flag
Definition pcbcolor.h:46
@ Silkscreen
Color available for silkscreen.
@ SolderResist
Color available for solder resist.
static const PcbColor & purple() noexcept
Definition pcbcolor.cpp:118
PcbColor & operator=(const PcbColor &rhs) noexcept=delete
const QString mId
Definition pcbcolor.h:149
static const PcbColor & get(const QString &id)
Get a color by its identifier.
Definition pcbcolor.cpp:176
static const PcbColor & red() noexcept
Definition pcbcolor.cpp:124
static const PcbColor & clear() noexcept
Definition pcbcolor.cpp:100
Definition occmodel.cpp:76