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  ******************************************************************************/
31 namespace librepcb {
32 
33 class Uuid;
34 
35 /*******************************************************************************
36  * Class GerberAttribute
37  ******************************************************************************/
38 
42 class GerberAttribute final {
43  Q_DECLARE_TR_FUNCTIONS(GerberAttribute)
44 
45 public:
46  // Types
47  enum class Type { Invalid, File, Aperture, Object, Delete };
48  enum class Polarity { Positive, Negative };
49  enum class BoardSide { Top, Bottom };
50  enum class CopperSide { Top, Inner, Bottom };
51  enum class ApertureFunction {
52  // Available on all layers:
53  Profile,
54 
55  // Available only on drill/rout layers:
56  ViaDrill,
57  ComponentDrill,
58  MechanicalDrill,
59 
60  // Available only on copper layers:
61  Conductor,
62  NonConductor,
63  ComponentPad,
64  SmdPadCopperDefined,
65  SmdPadSolderMaskDefined,
66  ViaPad,
67  };
68 
69  // Constructors / Destructor
70  GerberAttribute() noexcept;
71  GerberAttribute(const GerberAttribute& other) noexcept;
72  ~GerberAttribute() noexcept;
73 
74  // Getters
75  Type getType() const noexcept { return mType; }
76  const QString& getKey() const noexcept { return mKey; }
77  const QStringList& getValues() const noexcept { return mValues; }
78 
79  // General Methods
80  QString toGerberString() const noexcept;
81  QString toExcellonString() const noexcept;
82 
83  // Operator Overloadings
84  GerberAttribute& operator=(const GerberAttribute& rhs) noexcept;
85  bool operator==(const GerberAttribute& rhs) const noexcept;
86 
87  // Static Methods
88  static GerberAttribute unset(const QString& key) noexcept;
90  const QString& vendor, const QString& application,
91  const QString& version) noexcept;
92  static GerberAttribute fileCreationDate(const QDateTime& date) noexcept;
93  static GerberAttribute fileProjectId(const QString& name, const Uuid& uuid,
94  const QString& revision) noexcept;
95  static GerberAttribute filePartSingle() noexcept;
97  const QString& identifier) noexcept;
98  static GerberAttribute fileFunctionProfile(bool plated) noexcept;
99  static GerberAttribute fileFunctionCopper(int layer,
100  CopperSide side) noexcept;
101  static GerberAttribute fileFunctionSolderMask(BoardSide side) noexcept;
102  static GerberAttribute fileFunctionLegend(BoardSide side) noexcept;
103  static GerberAttribute fileFunctionPaste(BoardSide side) noexcept;
104  static GerberAttribute fileFunctionPlatedThroughHole(int fromLayer,
105  int toLayer) noexcept;
107  int toLayer) noexcept;
108  static GerberAttribute fileFunctionMixedPlating(int fromLayer,
109  int toLayer) noexcept;
110  static GerberAttribute filePolarity(Polarity polarity) noexcept;
111  static GerberAttribute fileMd5(const QString& md5) noexcept;
112  static GerberAttribute apertureFunction(ApertureFunction function) noexcept;
114  bool plated, ApertureFunction function) noexcept;
115  static GerberAttribute objectNet(const QString& net) noexcept;
116  static GerberAttribute objectComponent(const QString& component) noexcept;
117  static GerberAttribute objectPin(const QString& component, const QString& pin,
118  const QString& signal) noexcept;
119 
120 private: // Methods
121  GerberAttribute(Type type, const QString& key,
122  const QStringList& values) noexcept;
123  QString toString() const noexcept;
124  static QString escapeValue(const QString& value) noexcept;
125 
126 private: // Data
128  QString mKey;
129  QStringList mValues;
130 };
131 
132 /*******************************************************************************
133  * End of File
134  ******************************************************************************/
135 
136 } // namespace librepcb
137 
138 #endif
static GerberAttribute apertureFunction(ApertureFunction function) noexcept
Definition: gerberattribute.cpp:282
static QString escapeValue(const QString &value) noexcept
Definition: gerberattribute.cpp:365
QString mKey
Definition: gerberattribute.h:128
static GerberAttribute fileCreationDate(const QDateTime &date) noexcept
Definition: gerberattribute.cpp:134
static GerberAttribute fileGenerationSoftware(const QString &vendor, const QString &application, const QString &version) noexcept
Definition: gerberattribute.cpp:124
static GerberAttribute apertureFunctionMixedPlatingDrill(bool plated, ApertureFunction function) noexcept
Definition: gerberattribute.cpp:327
static GerberAttribute fileMd5(const QString &md5) noexcept
Definition: gerberattribute.cpp:278
Definition: airwiresbuilder.cpp:34
GerberAttribute & operator=(const GerberAttribute &rhs) noexcept
Definition: gerberattribute.cpp:74
Polarity
Definition: gerberattribute.h:48
static GerberAttribute fileFunctionNonPlatedThroughHole(int fromLayer, int toLayer) noexcept
Definition: gerberattribute.cpp:243
Type
Definition: gerberattribute.h:47
QString toExcellonString() const noexcept
Definition: gerberattribute.cpp:66
static GerberAttribute fileFunctionMixedPlating(int fromLayer, int toLayer) noexcept
Definition: gerberattribute.cpp:250
static GerberAttribute fileFunctionCopper(int layer, CopperSide side) noexcept
Definition: gerberattribute.cpp:164
static GerberAttribute fileProjectId(const QString &name, const Uuid &uuid, const QString &revision) noexcept
Definition: gerberattribute.cpp:140
static GerberAttribute fileFunctionProfile(bool plated) noexcept
Definition: gerberattribute.cpp:159
QStringList mValues
Definition: gerberattribute.h:129
~GerberAttribute() noexcept
Definition: gerberattribute.cpp:51
CopperSide
Definition: gerberattribute.h:50
static GerberAttribute fileFunctionLegend(BoardSide side) noexcept
Definition: gerberattribute.cpp:206
static GerberAttribute filePartSingle() noexcept
Definition: gerberattribute.cpp:146
ApertureFunction
Definition: gerberattribute.h:51
static GerberAttribute fileFunctionPaste(BoardSide side) noexcept
Definition: gerberattribute.cpp:221
static GerberAttribute fileFunctionSolderMask(BoardSide side) noexcept
Definition: gerberattribute.cpp:188
static GerberAttribute fileFunctionPlatedThroughHole(int fromLayer, int toLayer) noexcept
Definition: gerberattribute.cpp:236
A Gerber X2 attribute.
Definition: gerberattribute.h:42
static GerberAttribute objectNet(const QString &net) noexcept
Definition: gerberattribute.cpp:342
const QStringList & getValues() const noexcept
Definition: gerberattribute.h:77
bool operator==(const GerberAttribute &rhs) const noexcept
Definition: gerberattribute.cpp:82
GerberAttribute() noexcept
Definition: gerberattribute.cpp:38
static GerberAttribute objectComponent(const QString &component) noexcept
Definition: gerberattribute.cpp:346
static GerberAttribute unset(const QString &key) noexcept
Definition: gerberattribute.cpp:120
const QString & getKey() const noexcept
Definition: gerberattribute.h:76
BoardSide
Definition: gerberattribute.h:49
static GerberAttribute fileSameCoordinates(const QString &identifier) noexcept
Definition: gerberattribute.cpp:150
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
static GerberAttribute filePolarity(Polarity polarity) noexcept
Definition: gerberattribute.cpp:262
Type mType
Definition: gerberattribute.h:127
QString toString() const noexcept
Definition: gerberattribute.cpp:90
static GerberAttribute objectPin(const QString &component, const QString &pin, const QString &signal) noexcept
Definition: gerberattribute.cpp:351
QString toGerberString() const noexcept
Definition: gerberattribute.cpp:58
Type getType() const noexcept
Definition: gerberattribute.h:75