LibrePCB Developers Documentation
gerberattribute.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_GERBERATTRIBUTE_H
21#define LIBREPCB_CORE_GERBERATTRIBUTE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include <QtCore>
27
28/*******************************************************************************
29 * Namespace / Forward Declarations
30 ******************************************************************************/
31namespace librepcb {
32
33class Angle;
34class Uuid;
35
36/*******************************************************************************
37 * Class GerberAttribute
38 ******************************************************************************/
39
43class GerberAttribute final {
44 Q_DECLARE_TR_FUNCTIONS(GerberAttribute)
45
46public:
47 // Types
48 enum class Type { Invalid, File, Aperture, Object, Delete };
49 enum class Polarity { Positive, Negative };
50 enum class BoardSide { Top, Bottom };
51 enum class CopperSide { Top, Inner, Bottom };
52 enum class MountType { Tht, Smt, Fiducial, Other };
53 enum class ApertureFunction {
54 // Available on all layers:
55 Profile,
56
57 // Available only on drill/rout layers:
58 ViaDrill,
59 ComponentDrill,
60 ComponentDrillPressFit,
61 MechanicalDrill,
62
63 // Available only on copper layers:
64 Conductor,
65 NonConductor,
66 ComponentPad,
67 SmdPadCopperDefined,
68 SmdPadSolderMaskDefined,
69 BgaPadCopperDefined,
70 BgaPadSolderMaskDefined,
71 ConnectorPad,
72 HeatsinkPad,
73 ViaPad,
74 TestPad,
75 FiducialPadLocal,
76 FiducialPadGlobal,
77
78 // Available only on component layers:
79 ComponentMain,
80 ComponentPin,
81 ComponentOutlineBody,
82 ComponentOutlineCourtyard,
83 };
84
85 // Constructors / Destructor
86 GerberAttribute() noexcept;
87 GerberAttribute(const GerberAttribute& other) noexcept;
88 ~GerberAttribute() noexcept;
89
90 // Getters
91 Type getType() const noexcept { return mType; }
92 const QString& getKey() const noexcept { return mKey; }
93 const QStringList& getValues() const noexcept { return mValues; }
94
95 // General Methods
96 QString toGerberString() const noexcept;
97 QString toExcellonString() const noexcept;
98
99 // Operator Overloadings
100 GerberAttribute& operator=(const GerberAttribute& rhs) noexcept;
101 bool operator==(const GerberAttribute& rhs) const noexcept;
102
103 // Static Methods
104 static GerberAttribute unset(const QString& key) noexcept;
106 const QString& vendor, const QString& application,
107 const QString& version) noexcept;
108 static GerberAttribute fileCreationDate(const QDateTime& date) noexcept;
109 static GerberAttribute fileProjectId(const QString& name, const Uuid& uuid,
110 const QString& revision) noexcept;
111 static GerberAttribute filePartSingle() noexcept;
113 const QString& identifier) noexcept;
114 static GerberAttribute fileFunctionProfile(bool plated) noexcept;
115 static GerberAttribute fileFunctionCopper(int layer,
116 CopperSide side) noexcept;
118 static GerberAttribute fileFunctionLegend(BoardSide side) noexcept;
119 static GerberAttribute fileFunctionPaste(BoardSide side) noexcept;
121 int toLayer) noexcept;
123 int toLayer) noexcept;
124 static GerberAttribute fileFunctionMixedPlating(int fromLayer,
125 int toLayer) noexcept;
126 static GerberAttribute fileFunctionComponent(int layer,
127 BoardSide side) noexcept;
128 static GerberAttribute filePolarity(Polarity polarity) noexcept;
129 static GerberAttribute fileMd5(const QString& md5) noexcept;
130 static GerberAttribute apertureFunction(ApertureFunction function) noexcept;
132 bool plated, ApertureFunction function) noexcept;
133 static GerberAttribute objectNet(const QString& net) noexcept;
134 static GerberAttribute objectComponent(const QString& component) noexcept;
135 static GerberAttribute objectPin(const QString& component, const QString& pin,
136 const QString& signal) noexcept;
137 static GerberAttribute componentRotation(const Angle& rotation) noexcept;
139 const QString& manufacturer) noexcept;
140 static GerberAttribute componentMpn(const QString& mpn) noexcept;
141 static GerberAttribute componentValue(const QString& value) noexcept;
142 static GerberAttribute componentMountType(MountType type) noexcept;
143 static GerberAttribute componentFootprint(const QString& footprint) noexcept;
144
145private: // Methods
146 GerberAttribute(Type type, const QString& key,
147 const QStringList& values) noexcept;
148 QString toString() const noexcept;
149 static QString escapeValue(const QString& value, bool strictAscii) noexcept;
150
151private: // Data
153 QString mKey;
154 QStringList mValues;
155};
156
157/*******************************************************************************
158 * End of File
159 ******************************************************************************/
160
161} // namespace librepcb
162
163#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
A Gerber X2 attribute.
Definition: gerberattribute.h:43
QString toGerberString() const noexcept
Definition: gerberattribute.cpp:59
const QString & getKey() const noexcept
Definition: gerberattribute.h:92
MountType
Definition: gerberattribute.h:52
static GerberAttribute componentFootprint(const QString &footprint) noexcept
Definition: gerberattribute.cpp:487
static GerberAttribute fileFunctionMixedPlating(int fromLayer, int toLayer) noexcept
Definition: gerberattribute.cpp:269
static GerberAttribute componentMountType(MountType type) noexcept
Definition: gerberattribute.cpp:464
Type
Definition: gerberattribute.h:48
static GerberAttribute fileGenerationSoftware(const QString &vendor, const QString &application, const QString &version) noexcept
Definition: gerberattribute.cpp:135
QString toString() const noexcept
Definition: gerberattribute.cpp:91
static GerberAttribute fileFunctionSolderMask(BoardSide side) noexcept
Definition: gerberattribute.cpp:201
static GerberAttribute objectPin(const QString &component, const QString &pin, const QString &signal) noexcept
Definition: gerberattribute.cpp:436
BoardSide
Definition: gerberattribute.h:50
static GerberAttribute fileFunctionProfile(bool plated) noexcept
Definition: gerberattribute.cpp:170
const QStringList & getValues() const noexcept
Definition: gerberattribute.h:93
QStringList mValues
Definition: gerberattribute.h:154
static GerberAttribute fileFunctionCopper(int layer, CopperSide side) noexcept
Definition: gerberattribute.cpp:175
Type getType() const noexcept
Definition: gerberattribute.h:91
static GerberAttribute fileSameCoordinates(const QString &identifier) noexcept
Definition: gerberattribute.cpp:161
static GerberAttribute apertureFunction(ApertureFunction function) noexcept
Definition: gerberattribute.cpp:322
static GerberAttribute componentManufacturer(const QString &manufacturer) noexcept
Definition: gerberattribute.cpp:451
ApertureFunction
Definition: gerberattribute.h:53
QString toExcellonString() const noexcept
Definition: gerberattribute.cpp:67
Polarity
Definition: gerberattribute.h:49
static GerberAttribute componentRotation(const Angle &rotation) noexcept
Definition: gerberattribute.cpp:446
static GerberAttribute unset(const QString &key) noexcept
Definition: gerberattribute.cpp:131
static QString escapeValue(const QString &value, bool strictAscii) noexcept
Definition: gerberattribute.cpp:496
static GerberAttribute fileFunctionComponent(int layer, BoardSide side) noexcept
Definition: gerberattribute.cpp:281
static GerberAttribute fileFunctionPlatedThroughHole(int fromLayer, int toLayer) noexcept
Definition: gerberattribute.cpp:255
static GerberAttribute componentMpn(const QString &mpn) noexcept
Definition: gerberattribute.cpp:456
CopperSide
Definition: gerberattribute.h:51
static GerberAttribute fileMd5(const QString &md5) noexcept
Definition: gerberattribute.cpp:318
static GerberAttribute objectComponent(const QString &component) noexcept
Definition: gerberattribute.cpp:431
QString mKey
Definition: gerberattribute.h:153
static GerberAttribute componentValue(const QString &value) noexcept
Definition: gerberattribute.cpp:460
static GerberAttribute filePolarity(Polarity polarity) noexcept
Definition: gerberattribute.cpp:302
static GerberAttribute fileFunctionPaste(BoardSide side) noexcept
Definition: gerberattribute.cpp:238
static GerberAttribute fileProjectId(const QString &name, const Uuid &uuid, const QString &revision) noexcept
Definition: gerberattribute.cpp:151
static GerberAttribute objectNet(const QString &net) noexcept
Definition: gerberattribute.cpp:427
static GerberAttribute fileFunctionLegend(BoardSide side) noexcept
Definition: gerberattribute.cpp:221
Type mType
Definition: gerberattribute.h:152
GerberAttribute() noexcept
Definition: gerberattribute.cpp:39
static GerberAttribute filePartSingle() noexcept
Definition: gerberattribute.cpp:157
static GerberAttribute fileFunctionNonPlatedThroughHole(int fromLayer, int toLayer) noexcept
Definition: gerberattribute.cpp:262
static GerberAttribute apertureFunctionMixedPlatingDrill(bool plated, ApertureFunction function) noexcept
Definition: gerberattribute.cpp:412
static GerberAttribute fileCreationDate(const QDateTime &date) noexcept
Definition: gerberattribute.cpp:145
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77