LibrePCB Developers Documentation
gerberaperturelist.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_GERBERAPERTURELIST_H
21 #define LIBREPCB_GERBERAPERTURELIST_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../exceptions.h"
27 #include "../fileio/filepath.h"
28 #include "../geometry/path.h"
29 #include "../units/all_length_units.h"
30 #include "../uuid.h"
31 #include "gerberattribute.h"
32 
33 #include <QtCore>
34 
35 #include <optional.hpp>
36 
37 /*******************************************************************************
38  * Namespace / Forward Declarations
39  ******************************************************************************/
40 namespace librepcb {
41 
42 /*******************************************************************************
43  * Class GerberApertureList
44  ******************************************************************************/
45 
67 class GerberApertureList final {
68  Q_DECLARE_TR_FUNCTIONS(GerberApertureList)
69 
70 public:
71  // Types
72  using Function = tl::optional<GerberAttribute::ApertureFunction>;
73 
74  // Constructors / Destructor
75  GerberApertureList() noexcept;
76  GerberApertureList(const GerberApertureList& other) = delete;
77  ~GerberApertureList() noexcept;
78 
79  // Getters
80 
86  QString generateString() const noexcept;
87 
88  // General Methods
89 
99  int addCircle(const UnsignedLength& dia, Function function);
100 
113  int addObround(const PositiveLength& w, const PositiveLength& h,
114  const Angle& rot, Function function) noexcept;
115 
126  int addRect(const PositiveLength& w, const PositiveLength& h,
127  const Angle& rot, Function function) noexcept;
128 
139  int addOctagon(const PositiveLength& w, const PositiveLength& h,
140  const Angle& rot, Function function) noexcept;
141 
142  // Operator Overloadings
143  GerberApertureList& operator=(const GerberApertureList& rhs) = delete;
144 
145 private: // Methods
163  int addOutline(const QString& name, Path path, const Angle& rot,
164  Function function) noexcept;
165 
178  int addAperture(QString aperture, Function function) noexcept;
179 
180 private: // Data
187  QMap<int, std::pair<Function, QString>> mApertures;
188 };
189 
190 /*******************************************************************************
191  * End of File
192  ******************************************************************************/
193 
194 } // namespace librepcb
195 
196 #endif
int addCircle(const UnsignedLength &dia, Function function)
Add a circle aperture.
Definition: gerberaperturelist.cpp:75
int addRect(const PositiveLength &w, const PositiveLength &h, const Angle &rot, Function function) noexcept
Add a rectangular aperture.
Definition: gerberaperturelist.cpp:127
Definition: airwiresbuilder.cpp:32
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
int addObround(const PositiveLength &w, const PositiveLength &h, const Angle &rot, Function function) noexcept
Add an obround aperture.
Definition: gerberaperturelist.cpp:81
int addOutline(const QString &name, Path path, const Angle &rot, Function function) noexcept
Add a custom outline aperture.
Definition: gerberaperturelist.cpp:195
int addAperture(QString aperture, Function function) noexcept
Helper method to actually add a new or get an existing aperture.
Definition: gerberaperturelist.cpp:212
tl::optional< GerberAttribute::ApertureFunction > Function
Definition: gerberaperturelist.h:72
QMap< int, std::pair< Function, QString > > mApertures
Definition: gerberaperturelist.h:187
QString generateString() const noexcept
Generate the aperture definitions string.
Definition: gerberaperturelist.cpp:48
The Path class represents a list of vertices connected by straight lines or circular arc segments...
Definition: path.h:53
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:792
GerberApertureList() noexcept
Definition: gerberaperturelist.cpp:38
int addOctagon(const PositiveLength &w, const PositiveLength &h, const Angle &rot, Function function) noexcept
Add an octagon aperture.
Definition: gerberaperturelist.cpp:161
A helper class to generate the aperture definitions for a Gerber file.
Definition: gerberaperturelist.h:67
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:672