LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 "../units/all_length_units.h"
29 #include "../uuid.h"
30 
31 #include <QtCore>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 namespace librepcb {
37 
38 /*******************************************************************************
39  * Class GerberApertureList
40  ******************************************************************************/
41 
45 class GerberApertureList final {
46  Q_DECLARE_TR_FUNCTIONS(GerberApertureList)
47 
48 public:
49  // Constructors / Destructor
50  // GerberApertureList() = delete;
51  GerberApertureList(const GerberApertureList& other) = delete;
52  GerberApertureList() noexcept;
53  ~GerberApertureList() noexcept;
54 
55  // Getters
56  QString generateString() const noexcept;
57 
58  // General Methods
59  int setCircle(const UnsignedLength& dia, const UnsignedLength& hole);
60  int setRect(const UnsignedLength& w, const UnsignedLength& h,
61  const Angle& rot, const UnsignedLength& hole) noexcept;
62  int setObround(const UnsignedLength& w, const UnsignedLength& h,
63  const Angle& rot, const UnsignedLength& hole) noexcept;
64  int setRegularPolygon(const UnsignedLength& dia, int n, const Angle& rot,
65  const UnsignedLength& hole) noexcept;
66  void reset() noexcept;
67 
68  // Operator Overloadings
69  GerberApertureList& operator=(const GerberApertureList& rhs) = delete;
70 
71 private:
72  // Private Methods
73  int setCurrentAperture(const QString& aperture) noexcept;
74  void addMacro(const QString& macro) noexcept;
75 
76  // Aperture Generator Methods
77  static QString generateCircle(const UnsignedLength& dia,
78  const UnsignedLength& hole) noexcept;
79  static QString generateRect(const UnsignedLength& w, const UnsignedLength& h,
80  const UnsignedLength& hole) noexcept;
81  static QString generateObround(const UnsignedLength& w,
82  const UnsignedLength& h,
83  const UnsignedLength& hole) noexcept;
84  static QString generateRegularPolygon(const UnsignedLength& dia, int n,
85  const Angle& rot,
86  const UnsignedLength& hole) noexcept;
87  static QString generateRotatedRectMacro();
88  static QString generateRotatedRectMacroWithHole();
89  static QString generateRotatedObroundMacro();
90  static QString generateRotatedObroundMacroWithHole();
91  static QString generateRotatedRect(const UnsignedLength& w,
92  const UnsignedLength& h, const Angle& rot,
93  const UnsignedLength& hole) noexcept;
94  static QString generateRotatedObround(const UnsignedLength& w,
95  const UnsignedLength& h,
96  const Angle& rot,
97  const UnsignedLength& hole) noexcept;
98 
99  QList<QString> mApertureMacros;
100  QMap<int, QString>
102 };
103 
104 /*******************************************************************************
105  * End of File
106  ******************************************************************************/
107 
108 } // namespace librepcb
109 
110 #endif // LIBREPCB_GERBERAPERTURELIST_H
void reset() noexcept
Definition: gerberaperturelist.cpp:121
QList< QString > mApertureMacros
Definition: gerberaperturelist.h:99
GerberApertureList & operator=(const GerberApertureList &rhs)=delete
int setRegularPolygon(const UnsignedLength &dia, int n, const Angle &rot, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:107
static QString generateRegularPolygon(const UnsignedLength &dia, int n, const Angle &rot, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:181
static QString generateRect(const UnsignedLength &w, const UnsignedLength &h, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:159
int setCircle(const UnsignedLength &dia, const UnsignedLength &hole)
Definition: gerberaperturelist.cpp:64
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
~GerberApertureList() noexcept
Definition: gerberaperturelist.cpp:39
int setRect(const UnsignedLength &w, const UnsignedLength &h, const Angle &rot, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:69
void addMacro(const QString &macro) noexcept
Definition: gerberaperturelist.cpp:140
static QString generateRotatedRect(const UnsignedLength &w, const UnsignedLength &h, const Angle &rot, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:213
static QString generateRotatedRectMacroWithHole()
Definition: gerberaperturelist.cpp:195
int setCurrentAperture(const QString &aperture) noexcept
Definition: gerberaperturelist.cpp:130
QString generateString() const noexcept
Definition: gerberaperturelist.cpp:46
static QString generateRotatedRectMacro()
Definition: gerberaperturelist.cpp:190
static QString generateRotatedObround(const UnsignedLength &w, const UnsignedLength &h, const Angle &rot, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:226
static QString generateObround(const UnsignedLength &w, const UnsignedLength &h, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:170
int setObround(const UnsignedLength &w, const UnsignedLength &h, const Angle &rot, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:88
static QString generateCircle(const UnsignedLength &dia, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:150
QMap< int, QString > mApertures
key: aperture number (>= 10); value: aperture definition
Definition: gerberaperturelist.h:101
GerberApertureList() noexcept
Definition: gerberaperturelist.cpp:36
static QString generateRotatedObroundMacroWithHole()
Definition: gerberaperturelist.cpp:206
The GerberApertureList class.
Definition: gerberaperturelist.h:45
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:659
static QString generateRotatedObroundMacro()
Definition: gerberaperturelist.cpp:200