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 class BoardFabricationOutputSettings;
50 
51 /*******************************************************************************
52  * Class BoardGerberExport
53  ******************************************************************************/
54 
58 class BoardGerberExport final : public QObject, public AttributeProvider {
59  Q_OBJECT
60 
61 public:
62  // Constructors / Destructor
63  BoardGerberExport() = delete;
64  BoardGerberExport(const BoardGerberExport& other) = delete;
65  BoardGerberExport(const Board& board,
66  const BoardFabricationOutputSettings& settings) noexcept;
67  ~BoardGerberExport() noexcept;
68 
69  // Getters
70  FilePath getOutputDirectory() const noexcept;
71  const QVector<FilePath>& getWrittenFiles() const noexcept {
72  return mWrittenFiles;
73  }
74 
75  // General Methods
76  void exportAllLayers() const;
77 
78  // Inherited from AttributeProvider
80  QString getBuiltInAttributeValue(const QString& key) const noexcept override;
82  QVector<const AttributeProvider*> getAttributeProviderParents() const
83  noexcept override;
84 
85  // Operator Overloadings
86  BoardGerberExport& operator=(const BoardGerberExport& rhs) = delete;
87 
88 signals:
89  void attributesChanged() override;
90 
91 private:
92  // Private Methods
93  void exportDrills() const;
94  void exportDrillsNpth() const;
95  void exportDrillsPth() const;
96  void exportLayerBoardOutlines() const;
97  void exportLayerTopCopper() const;
98  void exportLayerInnerCopper() const;
99  void exportLayerBottomCopper() const;
100  void exportLayerTopSolderMask() const;
101  void exportLayerBottomSolderMask() const;
102  void exportLayerTopSilkscreen() const;
103  void exportLayerBottomSilkscreen() const;
104  void exportLayerTopSolderPaste() const;
105  void exportLayerBottomSolderPaste() const;
106 
107  int drawNpthDrills(ExcellonGenerator& gen) const;
108  int drawPthDrills(ExcellonGenerator& gen) const;
109  void drawLayer(GerberGenerator& gen, const QString& layerName) const;
110  void drawVia(GerberGenerator& gen, const BI_Via& via,
111  const QString& layerName) const;
112  void drawFootprint(GerberGenerator& gen, const BI_Footprint& footprint,
113  const QString& layerName) const;
114  void drawFootprintPad(GerberGenerator& gen, const BI_FootprintPad& pad,
115  const QString& layerName) const;
116 
117  FilePath getOutputFilePath(const QString& suffix) const noexcept;
118 
119  // Static Methods
120  static UnsignedLength calcWidthOfLayer(const UnsignedLength& width,
121  const QString& name) noexcept;
122  template <typename T>
123  static QList<T*> sortedByUuid(const QList<T*>& list) noexcept {
124  // sort a list of objects by their UUID to get reproducable gerber files
125  QList<T*> copy = list;
126  qSort(copy.begin(), copy.end(), [](const T* o1, const T* o2) {
127  return o1->getUuid() < o2->getUuid();
128  });
129  return copy;
130  }
131 
132  // Private Member Variables
134  const Board& mBoard;
135  QScopedPointer<const BoardFabricationOutputSettings> mSettings;
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:271
void exportLayerTopCopper() const
Definition: boardgerberexport.cpp:178
static UnsignedLength calcWidthOfLayer(const UnsignedLength &width, const QString &name) noexcept
Definition: boardgerberexport.cpp:599
void exportDrills() const
Definition: boardgerberexport.cpp:133
The BoardFabricationOutputSettings class.
Definition: boardfabricationoutputsettings.h:43
void drawFootprint(GerberGenerator &gen, const BI_Footprint &footprint, const QString &layerName) const
Definition: boardgerberexport.cpp:444
void drawLayer(GerberGenerator &gen, const QString &layerName) const
Definition: boardgerberexport.cpp:342
void drawFootprintPad(GerberGenerator &gen, const BI_FootprintPad &pad, const QString &layerName) const
Definition: boardgerberexport.cpp:506
The Project class represents a whole (opened) project with all its content.
Definition: project.h:79
static QList< T * > sortedByUuid(const QList< T * > &list) noexcept
Definition: boardgerberexport.h:123
FilePath getOutputFilePath(const QString &suffix) const noexcept
Definition: boardgerberexport.cpp:580
The ExcellonGenerator class.
Definition: excellongenerator.h:44
void exportLayerBottomSolderMask() const
Definition: boardgerberexport.cpp:226
The BI_Footprint class.
Definition: bi_footprint.h:57
void exportLayerBottomSolderPaste() const
Definition: boardgerberexport.cpp:282
The BI_FootprintPad class.
Definition: bi_footprintpad.h:56
const QVector< FilePath > & getWrittenFiles() const noexcept
Definition: boardgerberexport.h:71
void exportLayerBottomCopper() const
Definition: boardgerberexport.cpp:189
void exportLayerInnerCopper() const
Definition: boardgerberexport.cpp:200
void exportDrillsPth() const
Definition: boardgerberexport.cpp:158
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
FilePath getOutputDirectory() const noexcept
Definition: boardgerberexport.cpp:78
const Project & mProject
Definition: boardgerberexport.h:133
QScopedPointer< const BoardFabricationOutputSettings > mSettings
Definition: boardgerberexport.h:135
int mCurrentInnerCopperLayer
Definition: boardgerberexport.h:136
void exportLayerTopSilkscreen() const
Definition: boardgerberexport.cpp:237
const Board & mBoard
Definition: boardgerberexport.h:134
void drawVia(GerberGenerator &gen, const BI_Via &via, const QString &layerName) const
Definition: boardgerberexport.cpp:411
QVector< const AttributeProvider * > getAttributeProviderParents() const noexceptoverride
Get all parent attribute providers (fallback if attribute not found)
Definition: boardgerberexport.cpp:125
void exportAllLayers() const
Definition: boardgerberexport.cpp:86
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:58
~BoardGerberExport() noexcept
Definition: boardgerberexport.cpp:71
void exportLayerTopSolderMask() const
Definition: boardgerberexport.cpp:215
The GerberGenerator class.
Definition: gerbergenerator.h:52
void exportDrillsNpth() const
Definition: boardgerberexport.cpp:143
QVector< FilePath > mWrittenFiles
Definition: boardgerberexport.h:137
void exportLayerBottomSilkscreen() const
Definition: boardgerberexport.cpp:254
QString getBuiltInAttributeValue(const QString &key) const noexceptoverride
Get the value of a built-in attribute (if available)
Definition: boardgerberexport.cpp:115
void exportLayerBoardOutlines() const
Definition: boardgerberexport.cpp:167
int drawPthDrills(ExcellonGenerator &gen) const
Definition: boardgerberexport.cpp:314
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:59
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:659
int drawNpthDrills(ExcellonGenerator &gen) const
Definition: boardgerberexport.cpp:293