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 
48 class GerberApertureList final {
49  Q_DECLARE_TR_FUNCTIONS(GerberApertureList)
50 
51 public:
52  // Constructors / Destructor
53  // GerberApertureList() = delete;
54  GerberApertureList(const GerberApertureList& other) = delete;
55  GerberApertureList() noexcept;
56  ~GerberApertureList() noexcept;
57 
58  // Getters
59  QString generateString() const noexcept;
60 
61  // General Methods
62  int setCircle(const UnsignedLength& dia, const UnsignedLength& hole);
63  int setRect(const UnsignedLength& w, const UnsignedLength& h,
64  const Angle& rot, const UnsignedLength& hole) noexcept;
65  int setObround(const UnsignedLength& w, const UnsignedLength& h,
66  const Angle& rot, const UnsignedLength& hole) noexcept;
67  int setRegularPolygon(const UnsignedLength& dia, int n, 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 generateRotatedRect(const UnsignedLength& w,
95  const UnsignedLength& h, const Angle& rot,
96  const UnsignedLength& hole) noexcept;
97  static QString generateRotatedObround(const UnsignedLength& w,
98  const UnsignedLength& h,
99  const Angle& rot,
100  const UnsignedLength& hole) noexcept;
101 
102  QList<QString> mApertureMacros;
103  QMap<int, QString>
105 };
106 
107 /*******************************************************************************
108  * End of File
109  ******************************************************************************/
110 
111 } // namespace librepcb
112 
113 #endif // LIBREPCB_GERBERAPERTURELIST_H
void reset() noexcept
Definition: gerberaperturelist.cpp:121
QList< QString > mApertureMacros
Definition: gerberaperturelist.h:102
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:81
~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:104
GerberApertureList() noexcept
Definition: gerberaperturelist.cpp:36
static QString generateRotatedObroundMacroWithHole()
Definition: gerberaperturelist.cpp:206
The GerberApertureList class.
Definition: gerberaperturelist.h:48
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:662
static QString generateRotatedObroundMacro()
Definition: gerberaperturelist.cpp:200