LibrePCB Developers Documentation
layer.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_LAYER_H
21#define LIBREPCB_CORE_LAYER_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include <QtCore>
27
28/*******************************************************************************
29 * Namespace / Forward Declarations
30 ******************************************************************************/
31namespace librepcb {
32
33/*******************************************************************************
34 * Class Layer
35 ******************************************************************************/
36
40class Layer final {
41 Q_DECLARE_TR_FUNCTIONS(Layer)
42
43public:
44 // Types
45 enum class Flag : quint32 {
46 NumberMask = 0xFFU,
47 Schematic = (1 << 8),
48 Board = (1 << 16),
49 Top = (1 << 17),
50 Inner = (1 << 18),
51 Bottom = (1 << 19),
52 Copper = (1 << 20),
53 StopMask = (1 << 21),
54 SolderPaste = (1 << 22),
55 BoardEdge = (1 << 23),
56 PackageOutline = (1 << 24),
57 PackageCourtyard = (1 << 25),
58 PolygonsRepresentAreas = (1 << 26),
59 };
60 Q_DECLARE_FLAGS(Flags, Flag)
61
62 // Constructors / Destructor
63 Layer() = delete;
64 Layer(const Layer& other) noexcept;
65 ~Layer() noexcept;
66
67 // Getters
68
74 const QString& getId() const noexcept { return mId; }
75
81 const QString& getNameTr() const noexcept { return mNameTr; }
82
90 const QString& getThemeColor() const noexcept { return mThemeColor; }
91
97 bool isSchematic() const noexcept { return mFlags.testFlag(Flag::Schematic); }
98
104 bool isBoard() const noexcept { return mFlags.testFlag(Flag::Board); }
105
111 bool isTop() const noexcept { return mFlags.testFlag(Flag::Top); }
112
118 bool isInner() const noexcept { return mFlags.testFlag(Flag::Inner); }
119
125 bool isBottom() const noexcept { return mFlags.testFlag(Flag::Bottom); }
126
132 bool isCopper() const noexcept { return mFlags.testFlag(Flag::Copper); }
133
139 bool isStopMask() const noexcept { return mFlags.testFlag(Flag::StopMask); }
140
146 bool isSolderPaste() const noexcept {
147 return mFlags.testFlag(Flag::SolderPaste);
148 }
149
158 bool isBoardEdge() const noexcept { return mFlags.testFlag(Flag::BoardEdge); }
159
165 bool isPackageOutline() const noexcept {
166 return mFlags.testFlag(Flag::PackageOutline);
167 }
168
174 bool isPackageCourtyard() const noexcept {
175 return mFlags.testFlag(Flag::PackageCourtyard);
176 }
177
183 bool getPolygonsRepresentAreas() const noexcept {
184 return mFlags.testFlag(Flag::PolygonsRepresentAreas);
185 }
186
192 int getCopperNumber() const noexcept { return mFlags & Flag::NumberMask; }
193
203 const Layer& mirrored(int innerLayers = -1) const noexcept;
204
205 // Operator Overloadings
206 Layer& operator=(const Layer& rhs) noexcept = delete;
207 bool operator==(const Layer& rhs) const noexcept { return this == &rhs; }
208 bool operator!=(const Layer& rhs) const noexcept { return this != &rhs; }
209
210 // Static Methods
211 static const Layer& schematicSheetFrames() noexcept;
212 static const Layer& schematicDocumentation() noexcept;
213 static const Layer& schematicComments() noexcept;
214 static const Layer& schematicGuide() noexcept;
215 static const Layer& symbolOutlines() noexcept;
216 static const Layer& symbolHiddenGrabAreas() noexcept;
217 static const Layer& symbolNames() noexcept;
218 static const Layer& symbolValues() noexcept;
219 static const Layer& symbolPinNames() noexcept; // Used by Eagle import
220 static const Layer& boardSheetFrames() noexcept;
221 static const Layer& boardOutlines() noexcept;
222 static const Layer& boardCutouts() noexcept;
223 static const Layer& boardPlatedCutouts() noexcept;
224 static const Layer& boardMeasures() noexcept;
225 static const Layer& boardAlignment() noexcept;
226 static const Layer& boardDocumentation() noexcept;
227 static const Layer& boardComments() noexcept;
228 static const Layer& boardGuide() noexcept;
229 static const Layer& topNames() noexcept;
230 static const Layer& botNames() noexcept;
231 static const Layer& topValues() noexcept;
232 static const Layer& botValues() noexcept;
233 static const Layer& topLegend() noexcept;
234 static const Layer& botLegend() noexcept;
235 static const Layer& topDocumentation() noexcept;
236 static const Layer& botDocumentation() noexcept;
237 static const Layer& topPackageOutlines() noexcept;
238 static const Layer& botPackageOutlines() noexcept;
239 static const Layer& topCourtyard() noexcept;
240 static const Layer& botCourtyard() noexcept;
241 static const Layer& topHiddenGrabAreas() noexcept;
242 static const Layer& botHiddenGrabAreas() noexcept;
243 static const Layer& topStopMask() noexcept;
244 static const Layer& botStopMask() noexcept;
245 static const Layer& topSolderPaste() noexcept;
246 static const Layer& botSolderPaste() noexcept;
247 static const Layer& topFinish() noexcept;
248 static const Layer& botFinish() noexcept;
249 static const Layer& topGlue() noexcept;
250 static const Layer& botGlue() noexcept;
251 static const Layer& topCopper() noexcept;
252 static const Layer& botCopper() noexcept;
253 static const QVector<const Layer*>& innerCopper() noexcept;
254 static const Layer* innerCopper(int number) noexcept;
255 static int innerCopperCount() noexcept;
256 static const Layer* copper(int number) noexcept;
257
263 static const QVector<const Layer*>& all() noexcept;
264
274 static const Layer& get(const QString& id);
275
284 static bool lessThan(const Layer* a, const Layer* b) noexcept;
285
286private: // Methods
287 Layer(const QString& id, const QString& nameTr, const QString& themeColor,
288 Flags flags) noexcept;
289
290private: // Data
291 const QString mId;
292 const QString mNameTr;
293 const QString mThemeColor;
294 const Flags mFlags;
295};
296
297/*******************************************************************************
298 * End of File
299 ******************************************************************************/
300
301} // namespace librepcb
302
303Q_DECLARE_OPERATORS_FOR_FLAGS(librepcb::Layer::Flags)
304Q_DECLARE_METATYPE(const librepcb::Layer*)
305
306#endif
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:73
The Layer class provides all supported geometry layers.
Definition: layer.h:40
static const Layer & topLegend() noexcept
Definition: layer.cpp:227
static const Layer * copper(int number) noexcept
Definition: layer.cpp:387
const QString & getNameTr() const noexcept
Get the name of the Layer (human readable and translated)
Definition: layer.h:81
static const Layer & symbolNames() noexcept
Definition: layer.cpp:128
bool isBottom() const noexcept
Check if this is a bottom board layer.
Definition: layer.h:125
static const Layer & boardGuide() noexcept
Definition: layer.cpp:197
const Layer & mirrored(int innerLayers=-1) const noexcept
Mirror this layer to the other board side.
Definition: layer.cpp:59
static const Layer & boardSheetFrames() noexcept
Definition: layer.cpp:146
static const Layer & symbolOutlines() noexcept
Definition: layer.cpp:116
static int innerCopperCount() noexcept
Definition: layer.cpp:383
static const Layer & topSolderPaste() noexcept
Definition: layer.cpp:313
static bool lessThan(const Layer *a, const Layer *b) noexcept
Comparison for sorting layers by function.
Definition: layer.cpp:458
static const Layer & topFinish() noexcept
Definition: layer.cpp:327
static const Layer & schematicDocumentation() noexcept
Definition: layer.cpp:98
static const Layer & schematicGuide() noexcept
Definition: layer.cpp:110
static const Layer & topCourtyard() noexcept
Definition: layer.cpp:269
bool isBoardEdge() const noexcept
Check if this is a layer defining the board edge.
Definition: layer.h:158
bool isTop() const noexcept
Check if this is a top board layer.
Definition: layer.h:111
static const Layer & botCopper() noexcept
Definition: layer.cpp:357
static const QVector< const Layer * > & all() noexcept
Get a list of all available layers.
Definition: layer.cpp:397
static const Layer & boardPlatedCutouts() noexcept
Definition: layer.cpp:166
static const Layer & botSolderPaste() noexcept
Definition: layer.cpp:320
const QString mNameTr
Definition: layer.h:292
const QString & getThemeColor() const noexcept
Get the name of the corresponding theme color.
Definition: layer.h:90
static const Layer & boardOutlines() noexcept
Definition: layer.cpp:152
static const Layer & get(const QString &id)
Get a layer by its identifier.
Definition: layer.cpp:449
static const Layer & symbolValues() noexcept
Definition: layer.cpp:134
static const Layer & topNames() noexcept
Definition: layer.cpp:203
static const Layer & botGlue() noexcept
Definition: layer.cpp:345
static const Layer & botDocumentation() noexcept
Definition: layer.cpp:246
const QString & getId() const noexcept
Get the identifier used for serialization.
Definition: layer.h:74
static const Layer & boardAlignment() noexcept
Definition: layer.cpp:179
static const Layer & botPackageOutlines() noexcept
Definition: layer.cpp:261
static const Layer & boardDocumentation() noexcept
Definition: layer.cpp:185
static const Layer & topStopMask() noexcept
Definition: layer.cpp:299
bool isBoard() const noexcept
Check if this is a board layer.
Definition: layer.h:104
bool isSchematic() const noexcept
Check if this is a schematic layer.
Definition: layer.h:97
const QString mThemeColor
Definition: layer.h:293
const Flags mFlags
Definition: layer.h:294
static const Layer & boardMeasures() noexcept
Definition: layer.cpp:173
bool isPackageCourtyard() const noexcept
Check if this is a package courtyard layer.
Definition: layer.h:174
static const Layer & botNames() noexcept
Definition: layer.cpp:209
static const Layer & topPackageOutlines() noexcept
Definition: layer.cpp:253
static const Layer & botLegend() noexcept
Definition: layer.cpp:233
static const Layer & topCopper() noexcept
Definition: layer.cpp:351
bool isPackageOutline() const noexcept
Check if this is a package outline layer.
Definition: layer.h:165
static const Layer & symbolPinNames() noexcept
Definition: layer.cpp:140
static const Layer & schematicComments() noexcept
Definition: layer.cpp:104
static const Layer & boardComments() noexcept
Definition: layer.cpp:191
Flag
Definition: layer.h:45
@ NumberMask
Copper layer number (0 = top, 64 = bottom)..
static const Layer & botStopMask() noexcept
Definition: layer.cpp:306
static const Layer & symbolHiddenGrabAreas() noexcept
Definition: layer.cpp:122
bool isSolderPaste() const noexcept
Check if this is a solder paste layer.
Definition: layer.h:146
bool getPolygonsRepresentAreas() const noexcept
Check if polygons on this layers always represent areas.
Definition: layer.h:183
bool operator!=(const Layer &rhs) const noexcept
Definition: layer.h:208
static const Layer & boardCutouts() noexcept
Definition: layer.cpp:159
static const QVector< const Layer * > & innerCopper() noexcept
Definition: layer.cpp:364
static const Layer & botValues() noexcept
Definition: layer.cpp:221
int getCopperNumber() const noexcept
Get the copper layer number.
Definition: layer.h:192
const QString mId
Definition: layer.h:291
static const Layer & schematicSheetFrames() noexcept
Definition: layer.cpp:92
bool isStopMask() const noexcept
Check if this is a stop mask layer.
Definition: layer.h:139
static const Layer & botCourtyard() noexcept
Definition: layer.cpp:277
static const Layer & topValues() noexcept
Definition: layer.cpp:215
static const Layer & topGlue() noexcept
Definition: layer.cpp:339
bool isInner() const noexcept
Check if this is an inner board layer.
Definition: layer.h:118
bool isCopper() const noexcept
Check if this is a copper layer.
Definition: layer.h:132
static const Layer & botFinish() noexcept
Definition: layer.cpp:333
static const Layer & topDocumentation() noexcept
Definition: layer.cpp:239
static const Layer & topHiddenGrabAreas() noexcept
Definition: layer.cpp:285
static const Layer & botHiddenGrabAreas() noexcept
Definition: layer.cpp:292
The Schematic class represents one schematic page of a project and is always part of a circuit.
Definition: schematic.h:74
Definition: occmodel.cpp:77