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_CORE_GERBERAPERTURELIST_H
21 #define LIBREPCB_CORE_GERBERAPERTURELIST_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../fileio/filepath.h"
27 #include "../geometry/path.h"
28 #include "../types/length.h"
29 #include "../types/uuid.h"
30 #include "gerberattribute.h"
31 
32 #include <QtCore>
33 
34 #include <optional.hpp>
35 
36 /*******************************************************************************
37  * Namespace / Forward Declarations
38  ******************************************************************************/
39 namespace librepcb {
40 
41 class Angle;
42 
43 /*******************************************************************************
44  * Class GerberApertureList
45  ******************************************************************************/
46 
68 class GerberApertureList final {
69  Q_DECLARE_TR_FUNCTIONS(GerberApertureList)
70 
71 public:
72  // Types
73  using Function = tl::optional<GerberAttribute::ApertureFunction>;
74 
75  // Constructors / Destructor
76  GerberApertureList() noexcept;
77  GerberApertureList(const GerberApertureList& other) = delete;
78  ~GerberApertureList() noexcept;
79 
80  // Getters
81 
87  QString generateString() const noexcept;
88 
89  // General Methods
90 
100  int addCircle(const UnsignedLength& dia, Function function);
101 
114  int addObround(const PositiveLength& w, const PositiveLength& h,
115  const Angle& rot, Function function) noexcept;
116 
127  int addRect(const PositiveLength& w, const PositiveLength& h,
128  const Angle& rot, Function function) noexcept;
129 
140  int addOctagon(const PositiveLength& w, const PositiveLength& h,
141  const Angle& rot, Function function) noexcept;
142 
143  // Operator Overloadings
144  GerberApertureList& operator=(const GerberApertureList& rhs) = delete;
145 
146 private: // Methods
164  int addOutline(const QString& name, Path path, const Angle& rot,
165  Function function) noexcept;
166 
179  int addAperture(QString aperture, Function function) noexcept;
180 
181 private: // Data
188  QMap<int, std::pair<Function, QString>> mApertures;
189 };
190 
191 /*******************************************************************************
192  * End of File
193  ******************************************************************************/
194 
195 } // namespace librepcb
196 
197 #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:34
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:73
QMap< int, std::pair< Function, QString > > mApertures
Definition: gerberaperturelist.h:188
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:793
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:68
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:673