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  int setOctagon(const UnsignedLength& w, const UnsignedLength& h,
67  const UnsignedLength& edge, const Angle& rot,
68  const UnsignedLength& hole) noexcept;
69  void reset() noexcept;
70 
71  // Operator Overloadings
72  GerberApertureList& operator=(const GerberApertureList& rhs) = delete;
73 
74 private:
75  // Private Methods
76  int setCurrentAperture(const QString& aperture) noexcept;
77  void addMacro(const QString& macro) noexcept;
78 
79  // Aperture Generator Methods
80  static QString generateCircle(const UnsignedLength& dia,
81  const UnsignedLength& hole) noexcept;
82  static QString generateRect(const UnsignedLength& w, const UnsignedLength& h,
83  const UnsignedLength& hole) noexcept;
84  static QString generateObround(const UnsignedLength& w,
85  const UnsignedLength& h,
86  const UnsignedLength& hole) noexcept;
87  static QString generateRegularPolygon(const UnsignedLength& dia, int n,
88  const Angle& rot,
89  const UnsignedLength& hole) noexcept;
90  static QString generateRotatedRectMacro();
91  static QString generateRotatedRectMacroWithHole();
92  static QString generateRotatedObroundMacro();
93  static QString generateRotatedObroundMacroWithHole();
94  static QString generateRotatedOctagonMacro();
95  static QString generateRotatedOctagonMacroWithHole();
96  static QString generateRotatedRect(const UnsignedLength& w,
97  const UnsignedLength& h, const Angle& rot,
98  const UnsignedLength& hole) noexcept;
99  static QString generateRotatedObround(const UnsignedLength& w,
100  const UnsignedLength& h,
101  const Angle& rot,
102  const UnsignedLength& hole) noexcept;
103  static QString generateRotatedOctagon(const UnsignedLength& w,
104  const UnsignedLength& h,
105  const UnsignedLength& edge,
106  const Angle& rot,
107  const UnsignedLength& hole) noexcept;
108 
109  QList<QString> mApertureMacros;
110  QMap<int, QString>
112 };
113 
114 /*******************************************************************************
115  * End of File
116  ******************************************************************************/
117 
118 } // namespace librepcb
119 
120 #endif // LIBREPCB_GERBERAPERTURELIST_H
void reset() noexcept
Definition: gerberaperturelist.cpp:133
QList< QString > mApertureMacros
Definition: gerberaperturelist.h:109
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:193
static QString generateRect(const UnsignedLength &w, const UnsignedLength &h, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:171
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
static QString generateRotatedOctagon(const UnsignedLength &w, const UnsignedLength &h, const UnsignedLength &edge, const Angle &rot, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:290
int setRect(const UnsignedLength &w, const UnsignedLength &h, const Angle &rot, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:69
static QString generateRotatedOctagonMacroWithHole()
Definition: gerberaperturelist.cpp:241
int setOctagon(const UnsignedLength &w, const UnsignedLength &h, const UnsignedLength &edge, const Angle &rot, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:121
void addMacro(const QString &macro) noexcept
Definition: gerberaperturelist.cpp:152
static QString generateRotatedRect(const UnsignedLength &w, const UnsignedLength &h, const Angle &rot, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:258
static QString generateRotatedRectMacroWithHole()
Definition: gerberaperturelist.cpp:207
int setCurrentAperture(const QString &aperture) noexcept
Definition: gerberaperturelist.cpp:142
QString generateString() const noexcept
Definition: gerberaperturelist.cpp:46
static QString generateRotatedRectMacro()
Definition: gerberaperturelist.cpp:202
static QString generateRotatedObround(const UnsignedLength &w, const UnsignedLength &h, const Angle &rot, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:271
static QString generateObround(const UnsignedLength &w, const UnsignedLength &h, const UnsignedLength &hole) noexcept
Definition: gerberaperturelist.cpp:182
static QString generateRotatedOctagonMacro()
Definition: gerberaperturelist.cpp:225
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:162
QMap< int, QString > mApertures
key: aperture number (>= 10); value: aperture definition
Definition: gerberaperturelist.h:111
GerberApertureList() noexcept
Definition: gerberaperturelist.cpp:36
static QString generateRotatedObroundMacroWithHole()
Definition: gerberaperturelist.cpp:218
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:212