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
42class Layer final {
43 Q_DECLARE_TR_FUNCTIONS(Layer)
44
45public:
46 // Types
47 enum class Flag : quint32 {
48 NumberMask = 0xFFU,
49 Schematic = (1 << 8),
50 Board = (1 << 16),
51 Top = (1 << 17),
52 Inner = (1 << 18),
53 Bottom = (1 << 19),
54 Copper = (1 << 20),
55 StopMask = (1 << 21),
56 SolderPaste = (1 << 22),
57 BoardEdge = (1 << 23),
58 PackageOutline = (1 << 24),
59 PackageCourtyard = (1 << 25),
60 PolygonsRepresentAreas = (1 << 26),
61 };
62 Q_DECLARE_FLAGS(Flags, Flag)
63
64 // Constructors / Destructor
65 Layer() = delete;
66 Layer(const Layer& other) noexcept;
67 ~Layer() noexcept;
68
69 // Getters
70
76 const QString& getId() const noexcept { return mId; }
77
83 const QString& getNameTr() const noexcept { return mNameTr; }
84
92 const QString& getThemeColor() const noexcept { return mThemeColor; }
93
99 bool isSchematic() const noexcept { return mFlags.testFlag(Flag::Schematic); }
100
106 bool isBoard() const noexcept { return mFlags.testFlag(Flag::Board); }
107
113 bool isTop() const noexcept { return mFlags.testFlag(Flag::Top); }
114
120 bool isInner() const noexcept { return mFlags.testFlag(Flag::Inner); }
121
127 bool isBottom() const noexcept { return mFlags.testFlag(Flag::Bottom); }
128
134 bool isCopper() const noexcept { return mFlags.testFlag(Flag::Copper); }
135
141 bool isStopMask() const noexcept { return mFlags.testFlag(Flag::StopMask); }
142
148 bool isSolderPaste() const noexcept {
149 return mFlags.testFlag(Flag::SolderPaste);
150 }
151
160 bool isBoardEdge() const noexcept { return mFlags.testFlag(Flag::BoardEdge); }
161
167 bool isPackageOutline() const noexcept {
168 return mFlags.testFlag(Flag::PackageOutline);
169 }
170
176 bool isPackageCourtyard() const noexcept {
177 return mFlags.testFlag(Flag::PackageCourtyard);
178 }
179
185 bool getPolygonsRepresentAreas() const noexcept {
186 return mFlags.testFlag(Flag::PolygonsRepresentAreas);
187 }
188
194 int getCopperNumber() const noexcept { return mFlags & Flag::NumberMask; }
195
205 const Layer& mirrored(int innerLayers = -1) const noexcept;
206
207 // Operator Overloadings
208 Layer& operator=(const Layer& rhs) noexcept = delete;
209 bool operator==(const Layer& rhs) const noexcept { return this == &rhs; }
210 bool operator!=(const Layer& rhs) const noexcept { return this != &rhs; }
211
212 // Static Methods
213 static const Layer& schematicSheetFrames() noexcept;
214 static const Layer& schematicDocumentation() noexcept;
215 static const Layer& schematicComments() noexcept;
216 static const Layer& schematicGuide() noexcept;
217 static const Layer& symbolOutlines() noexcept;
218 static const Layer& symbolHiddenGrabAreas() noexcept;
219 static const Layer& symbolNames() noexcept;
220 static const Layer& symbolValues() noexcept;
221 static const Layer& symbolPinNames() noexcept; // Used by Eagle import
222 static const Layer& boardSheetFrames() noexcept;
223 static const Layer& boardOutlines() noexcept;
224 static const Layer& boardCutouts() noexcept;
225 static const Layer& boardPlatedCutouts() noexcept;
226 static const Layer& boardMeasures() noexcept;
227 static const Layer& boardAlignment() noexcept;
228 static const Layer& boardDocumentation() noexcept;
229 static const Layer& boardComments() noexcept;
230 static const Layer& boardGuide() noexcept;
231 static const Layer& topNames() noexcept;
232 static const Layer& botNames() noexcept;
233 static const Layer& topValues() noexcept;
234 static const Layer& botValues() noexcept;
235 static const Layer& topLegend() noexcept;
236 static const Layer& botLegend() noexcept;
237 static const Layer& topDocumentation() noexcept;
238 static const Layer& botDocumentation() noexcept;
239 static const Layer& topPackageOutlines() noexcept;
240 static const Layer& botPackageOutlines() noexcept;
241 static const Layer& topCourtyard() noexcept;
242 static const Layer& botCourtyard() noexcept;
243 static const Layer& topHiddenGrabAreas() noexcept;
244 static const Layer& botHiddenGrabAreas() noexcept;
245 static const Layer& topStopMask() noexcept;
246 static const Layer& botStopMask() noexcept;
247 static const Layer& topSolderPaste() noexcept;
248 static const Layer& botSolderPaste() noexcept;
249 static const Layer& topFinish() noexcept;
250 static const Layer& botFinish() noexcept;
251 static const Layer& topGlue() noexcept;
252 static const Layer& botGlue() noexcept;
253 static const Layer& topCopper() noexcept;
254 static const Layer& botCopper() noexcept;
255 static const QVector<const Layer*>& innerCopper() noexcept;
256 static const Layer* innerCopper(int number) noexcept;
257 static int innerCopperCount() noexcept;
258 static const Layer* copper(int number) noexcept;
259
265 static const QVector<const Layer*>& all() noexcept;
266
276 static const Layer& get(const QString& id);
277
286 static bool lessThan(const Layer* a, const Layer* b) noexcept;
287
288private: // Methods
289 Layer(const QString& id, const QString& nameTr, const QString& themeColor,
290 Flags flags) noexcept;
291
292private: // Data
293 const QString mId;
294 const QString mNameTr;
295 const QString mThemeColor;
296 const Flags mFlags;
297};
298
299/*******************************************************************************
300 * End of File
301 ******************************************************************************/
302
303} // namespace librepcb
304
305Q_DECLARE_OPERATORS_FOR_FLAGS(librepcb::Layer::Flags)
306Q_DECLARE_METATYPE(const librepcb::Layer*)
307
308#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:42
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:83
static const Layer & symbolNames() noexcept
Definition: layer.cpp:128
bool isBottom() const noexcept
Check if this is a bottom board layer.
Definition: layer.h:127
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:160
bool isTop() const noexcept
Check if this is a top board layer.
Definition: layer.h:113
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:294
const QString & getThemeColor() const noexcept
Get the name of the corresponding theme color.
Definition: layer.h:92
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:76
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:106
bool isSchematic() const noexcept
Check if this is a schematic layer.
Definition: layer.h:99
const QString mThemeColor
Definition: layer.h:295
const Flags mFlags
Definition: layer.h:296
static const Layer & boardMeasures() noexcept
Definition: layer.cpp:173
bool isPackageCourtyard() const noexcept
Check if this is a package courtyard layer.
Definition: layer.h:176
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:167
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:47
@ 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:148
bool getPolygonsRepresentAreas() const noexcept
Check if polygons on this layers always represent areas.
Definition: layer.h:185
bool operator!=(const Layer &rhs) const noexcept
Definition: layer.h:210
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:194
const QString mId
Definition: layer.h:293
static const Layer & schematicSheetFrames() noexcept
Definition: layer.cpp:92
bool isStopMask() const noexcept
Check if this is a stop mask layer.
Definition: layer.h:141
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:120
bool isCopper() const noexcept
Check if this is a copper layer.
Definition: layer.h:134
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