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 ******************************************************************************/
39namespace librepcb {
40
41class Angle;
42
43/*******************************************************************************
44 * Class GerberApertureList
45 ******************************************************************************/
46
68class GerberApertureList final {
69 Q_DECLARE_TR_FUNCTIONS(GerberApertureList)
70
71public:
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
128 int addRect(const PositiveLength& w, const PositiveLength& h,
129 const UnsignedLength& r, const Angle& rot,
130 Function function) noexcept;
131
143 int addOctagon(const PositiveLength& w, const PositiveLength& h,
144 const UnsignedLength& r, const Angle& rot,
145 Function function) noexcept;
146
156 int addOutline(const StraightAreaPath& path, const Angle& rot,
157 Function function) noexcept;
158
164 int addComponentMain() noexcept;
165
173 int addComponentPin(bool isPin1) noexcept;
174
175 // Operator Overloadings
176 GerberApertureList& operator=(const GerberApertureList& rhs) = delete;
177
178private: // Methods
191 int addOutline(const QString& name, const Path& path, const Angle& rot,
192 Function function) noexcept;
193
204 QString buildOutlineMacro(Path path, const Angle& rot) const noexcept;
205
218 int addAperture(QString aperture, Function function) noexcept;
219
220private: // Data
227 QMap<int, std::pair<Function, QString>> mApertures;
228};
229
230/*******************************************************************************
231 * End of File
232 ******************************************************************************/
233
234} // namespace librepcb
235
236#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
A helper class to generate the aperture definitions for a Gerber file.
Definition: gerberaperturelist.h:68
int addObround(const PositiveLength &w, const PositiveLength &h, const Angle &rot, Function function) noexcept
Add an obround aperture.
Definition: gerberaperturelist.cpp:81
int addComponentPin(bool isPin1) noexcept
Add a component pin aperture (for component layers only)
Definition: gerberaperturelist.cpp:264
int addCircle(const UnsignedLength &dia, Function function)
Add a circle aperture.
Definition: gerberaperturelist.cpp:75
int addOutline(const StraightAreaPath &path, const Angle &rot, Function function) noexcept
Add a custom outline aperture.
Definition: gerberaperturelist.cpp:251
int addOctagon(const PositiveLength &w, const PositiveLength &h, const UnsignedLength &r, const Angle &rot, Function function) noexcept
Add an octagon aperture.
Definition: gerberaperturelist.cpp:193
QMap< int, std::pair< Function, QString > > mApertures
Definition: gerberaperturelist.h:227
tl::optional< GerberAttribute::ApertureFunction > Function
Definition: gerberaperturelist.h:73
QString buildOutlineMacro(Path path, const Angle &rot) const noexcept
Internal helper for addOutline()
Definition: gerberaperturelist.cpp:290
QString generateString() const noexcept
Generate the aperture definitions string.
Definition: gerberaperturelist.cpp:48
int addRect(const PositiveLength &w, const PositiveLength &h, const UnsignedLength &r, const Angle &rot, Function function) noexcept
Add a rectangular aperture.
Definition: gerberaperturelist.cpp:127
GerberApertureList() noexcept
Definition: gerberaperturelist.cpp:38
int addAperture(QString aperture, Function function) noexcept
Helper method to actually add a new or get an existing aperture.
Definition: gerberaperturelist.cpp:304
int addComponentMain() noexcept
Add a component main aperture (for component layers only)
Definition: gerberaperturelist.cpp:257
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition: path.h:58
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696
type_safe::constrained_type< Path, StraightAreaPathConstraint, StraightAreaPathVerifier > StraightAreaPath
Definition: path.h:265