LibrePCB Developers Documentation
excellongenerator.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_EXCELLONGENERATOR_H
21 #define LIBREPCB_CORE_EXCELLONGENERATOR_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../fileio/filepath.h"
27 #include "../geometry/path.h"
28 #include "../types/length.h"
29 #include "gerberattribute.h"
30 
31 #include <QtCore>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 namespace librepcb {
37 
38 class Point;
39 
40 /*******************************************************************************
41  * Class ExcellonGenerator
42  ******************************************************************************/
43 
47 class ExcellonGenerator final {
48  Q_DECLARE_TR_FUNCTIONS(ExcellonGenerator)
49 
50 public:
51  // Types
52  enum class Plating { Yes, No, Mixed };
54 
55  // Constructors / Destructor
56  ExcellonGenerator() = delete;
57  ExcellonGenerator(const ExcellonGenerator& other) = delete;
58  ExcellonGenerator(const QDateTime& creationDate, const QString& projName,
59  const Uuid& projUuid, const QString& projRevision,
60  Plating plating, int fromLayer, int toLayer) noexcept;
61  ~ExcellonGenerator() noexcept;
62 
63  // Setters
64  void setUseG85Slots(bool use) noexcept { mUseG85Slots = use; }
65 
66  // Getters
67  const QString& toStr() const noexcept { return mOutput; }
68 
69  // General Methods
70  void drill(const Point& pos, const PositiveLength& dia, bool plated,
71  Function function) noexcept;
72  void drill(const NonEmptyPath& path, const PositiveLength& dia, bool plated,
73  Function function) noexcept;
74  void generate();
75  void saveToFile(const FilePath& filepath) const;
76 
77  // Operator Overloadings
78  ExcellonGenerator& operator=(const ExcellonGenerator& rhs) = delete;
79 
80 private:
81  void printHeader() noexcept;
82  void printToolList() noexcept;
83  void printDrills();
84  void printPath(const NonEmptyPath& path);
85  void printDrill(const Point& pos) noexcept;
86  void printSlot(const NonEmptyPath& path);
87  void printRout(const NonEmptyPath& path) noexcept;
88  void printMoveTo(const Point& pos) noexcept;
89  void printLinearInterpolation(const Point& pos) noexcept;
90  void printCircularInterpolation(const Point& from, const Point& to,
91  const Angle& angle) noexcept;
92  void printFooter() noexcept;
93 
94  // Types
95  typedef std::tuple<Length, bool, Function> Tool;
96 
97  // Metadata
99  QVector<GerberAttribute> mFileAttributes;
100 
101  // Configuration
103 
104  // Excellon Data
105  QString mOutput;
106  QMultiMap<Tool, NonEmptyPath> mDrillList;
107 };
108 
109 /*******************************************************************************
110  * End of File
111  ******************************************************************************/
112 
113 } // namespace librepcb
114 
115 #endif
void printHeader() noexcept
Definition: excellongenerator.cpp:117
void printDrill(const Point &pos) noexcept
Definition: excellongenerator.cpp:173
void printMoveTo(const Point &pos) noexcept
Definition: excellongenerator.cpp:228
void drill(const Point &pos, const PositiveLength &dia, bool plated, Function function) noexcept
Definition: excellongenerator.cpp:88
Definition: occmodel.cpp:77
Plating mPlating
Definition: excellongenerator.h:98
void printRout(const NonEmptyPath &path) noexcept
Definition: excellongenerator.cpp:196
void printSlot(const NonEmptyPath &path)
Definition: excellongenerator.cpp:178
void printCircularInterpolation(const Point &from, const Point &to, const Angle &angle) noexcept
Definition: excellongenerator.cpp:238
type_safe::constrained_type< Path, NonEmptyPathConstraint, NonEmptyPathVerifier > NonEmptyPath
Definition: path.h:221
QMultiMap< Tool, NonEmptyPath > mDrillList
Definition: excellongenerator.h:106
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
std::tuple< Length, bool, Function > Tool
Definition: excellongenerator.h:95
void printDrills()
Definition: excellongenerator.cpp:151
void printToolList() noexcept
Definition: excellongenerator.cpp:136
The ExcellonGenerator class.
Definition: excellongenerator.h:47
ExcellonGenerator & operator=(const ExcellonGenerator &rhs)=delete
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:79
QVector< GerberAttribute > mFileAttributes
Definition: excellongenerator.h:99
ApertureFunction
Definition: gerberattribute.h:53
bool mUseG85Slots
Definition: excellongenerator.h:102
void generate()
Definition: excellongenerator.cpp:102
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
void printPath(const NonEmptyPath &path)
Definition: excellongenerator.cpp:161
void printFooter() noexcept
Definition: excellongenerator.cpp:252
void saveToFile(const FilePath &filepath) const
Definition: excellongenerator.cpp:109
Plating
Definition: excellongenerator.h:52
const QString & toStr() const noexcept
Definition: excellongenerator.h:67
void printLinearInterpolation(const Point &pos) noexcept
Definition: excellongenerator.cpp:233
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
QString mOutput
Definition: excellongenerator.h:105
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
~ExcellonGenerator() noexcept
Definition: excellongenerator.cpp:81
void setUseG85Slots(bool use) noexcept
Definition: excellongenerator.h:64