LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
boardgerberexport.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_PROJECT_BOARDGERBEREXPORT_H
21 #define LIBREPCB_PROJECT_BOARDGERBEREXPORT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
29 
30 #include <QtCore>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 class Polygon;
38 class Circle;
39 class ExcellonGenerator;
40 class GerberGenerator;
41 
42 namespace project {
43 
44 class Project;
45 class Board;
46 class BI_Via;
47 class BI_Footprint;
48 class BI_FootprintPad;
49 
50 /*******************************************************************************
51  * Class BoardGerberExport
52  ******************************************************************************/
53 
60 class BoardGerberExport final : public QObject, public AttributeProvider {
61  Q_OBJECT
62 
63 public:
64  // Constructors / Destructor
65  BoardGerberExport() = delete;
66  BoardGerberExport(const BoardGerberExport& other) = delete;
67  BoardGerberExport(const Board& board) noexcept;
68  ~BoardGerberExport() noexcept;
69 
70  // Getters
71  FilePath getOutputDirectory() const noexcept;
72  const QVector<FilePath>& getWrittenFiles() const noexcept {
73  return mWrittenFiles;
74  }
75 
76  // General Methods
77  void exportAllLayers() const;
78 
79  // Inherited from AttributeProvider
81  QString getBuiltInAttributeValue(const QString& key) const noexcept override;
83  QVector<const AttributeProvider*> getAttributeProviderParents() const
84  noexcept override;
85 
86  // Operator Overloadings
87  BoardGerberExport& operator=(const BoardGerberExport& rhs) = delete;
88 
89 signals:
90  void attributesChanged() override;
91 
92 private:
93  // Private Methods
94  void exportDrills() const;
95  void exportDrillsNpth() const;
96  void exportDrillsPth() const;
97  void exportLayerBoardOutlines() const;
98  void exportLayerTopCopper() const;
99  void exportLayerInnerCopper() const;
100  void exportLayerBottomCopper() const;
101  void exportLayerTopSolderMask() const;
102  void exportLayerBottomSolderMask() const;
103  void exportLayerTopSilkscreen() const;
104  void exportLayerBottomSilkscreen() const;
105  void exportLayerTopSolderPaste() const;
106  void exportLayerBottomSolderPaste() const;
107 
108  int drawNpthDrills(ExcellonGenerator& gen) const;
109  int drawPthDrills(ExcellonGenerator& gen) const;
110  void drawLayer(GerberGenerator& gen, const QString& layerName) const;
111  void drawVia(GerberGenerator& gen, const BI_Via& via,
112  const QString& layerName) const;
113  void drawFootprint(GerberGenerator& gen, const BI_Footprint& footprint,
114  const QString& layerName) const;
115  void drawFootprintPad(GerberGenerator& gen, const BI_FootprintPad& pad,
116  const QString& layerName) const;
117 
118  FilePath getOutputFilePath(const QString& suffix) const noexcept;
119 
120  // Static Methods
121  static UnsignedLength calcWidthOfLayer(const UnsignedLength& width,
122  const QString& name) noexcept;
123  template <typename T>
124  static QList<T*> sortedByUuid(const QList<T*>& list) noexcept {
125  // sort a list of objects by their UUID to get reproducable gerber files
126  QList<T*> copy = list;
127  qSort(copy.begin(), copy.end(), [](const T* o1, const T* o2) {
128  return o1->getUuid() < o2->getUuid();
129  });
130  return copy;
131  }
132 
133  // Private Member Variables
135  const Board& mBoard;
137  mutable QVector<FilePath> mWrittenFiles;
138 };
139 
140 /*******************************************************************************
141  * End of File
142  ******************************************************************************/
143 
144 } // namespace project
145 } // namespace librepcb
146 
147 #endif // LIBREPCB_PROJECT_BOARDGERBEREXPORT_H
void exportLayerTopSolderPaste() const
Definition: boardgerberexport.cpp:280
void exportLayerTopCopper() const
Definition: boardgerberexport.cpp:178
static UnsignedLength calcWidthOfLayer(const UnsignedLength &width, const QString &name) noexcept
Definition: boardgerberexport.cpp:611
void exportDrills() const
Definition: boardgerberexport.cpp:129
void drawFootprint(GerberGenerator &gen, const BI_Footprint &footprint, const QString &layerName) const
Definition: boardgerberexport.cpp:455
void drawLayer(GerberGenerator &gen, const QString &layerName) const
Definition: boardgerberexport.cpp:353
void drawFootprintPad(GerberGenerator &gen, const BI_FootprintPad &pad, const QString &layerName) const
Definition: boardgerberexport.cpp:517
The Project class represents a whole (opened) project with all its content.
Definition: project.h:84
static QList< T * > sortedByUuid(const QList< T * > &list) noexcept
Definition: boardgerberexport.h:124
FilePath getOutputFilePath(const QString &suffix) const noexcept
Definition: boardgerberexport.cpp:591
The ExcellonGenerator class.
Definition: excellongenerator.h:47
void exportLayerBottomSolderMask() const
Definition: boardgerberexport.cpp:230
The BI_Footprint class.
Definition: bi_footprint.h:60
void exportLayerBottomSolderPaste() const
Definition: boardgerberexport.cpp:292
The BI_FootprintPad class.
Definition: bi_footprintpad.h:56
const QVector< FilePath > & getWrittenFiles() const noexcept
Definition: boardgerberexport.h:72
void exportLayerBottomCopper() const
Definition: boardgerberexport.cpp:190
void exportLayerInnerCopper() const
Definition: boardgerberexport.cpp:202
void exportDrillsPth() const
Definition: boardgerberexport.cpp:156
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:130
FilePath getOutputDirectory() const noexcept
Definition: boardgerberexport.cpp:74
const Project & mProject
Definition: boardgerberexport.h:134
int mCurrentInnerCopperLayer
Definition: boardgerberexport.h:136
void exportLayerTopSilkscreen() const
Definition: boardgerberexport.cpp:242
const Board & mBoard
Definition: boardgerberexport.h:135
void drawVia(GerberGenerator &gen, const BI_Via &via, const QString &layerName) const
Definition: boardgerberexport.cpp:422
QVector< const AttributeProvider * > getAttributeProviderParents() const noexceptoverride
Get all parent attribute providers (fallback if attribute not found)
Definition: boardgerberexport.cpp:121
void exportAllLayers() const
Definition: boardgerberexport.cpp:82
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:82
The BoardGerberExport class.
Definition: boardgerberexport.h:60
~BoardGerberExport() noexcept
Definition: boardgerberexport.cpp:67
void exportLayerTopSolderMask() const
Definition: boardgerberexport.cpp:218
The GerberGenerator class.
Definition: gerbergenerator.h:55
void exportDrillsNpth() const
Definition: boardgerberexport.cpp:140
QVector< FilePath > mWrittenFiles
Definition: boardgerberexport.h:137
void exportLayerBottomSilkscreen() const
Definition: boardgerberexport.cpp:261
QString getBuiltInAttributeValue(const QString &key) const noexceptoverride
Get the value of a built-in attribute (if available)
Definition: boardgerberexport.cpp:111
void exportLayerBoardOutlines() const
Definition: boardgerberexport.cpp:166
int drawPthDrills(ExcellonGenerator &gen) const
Definition: boardgerberexport.cpp:325
The BI_Via class.
Definition: bi_via.h:49
The AttributeProvider class defines an interface for classes which provides some attributes which can...
Definition: attributeprovider.h:62
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:662
int drawNpthDrills(ExcellonGenerator &gen) const
Definition: boardgerberexport.cpp:304