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 #include <algorithm>
33 
34 /*******************************************************************************
35  * Namespace / Forward Declarations
36  ******************************************************************************/
37 namespace librepcb {
38 
39 class Polygon;
40 class Circle;
41 class ExcellonGenerator;
42 class GerberGenerator;
43 
44 namespace project {
45 
46 class Project;
47 class Board;
48 class BI_Via;
49 class BI_Footprint;
50 class BI_FootprintPad;
51 class BoardFabricationOutputSettings;
52 
53 /*******************************************************************************
54  * Class BoardGerberExport
55  ******************************************************************************/
56 
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,
68  const BoardFabricationOutputSettings& settings) noexcept;
69  ~BoardGerberExport() noexcept;
70 
71  // Getters
72  FilePath getOutputDirectory() const noexcept;
73  const QVector<FilePath>& getWrittenFiles() const noexcept {
74  return mWrittenFiles;
75  }
76 
77  // General Methods
78  void exportAllLayers() const;
79 
80  // Inherited from AttributeProvider
82  QString getBuiltInAttributeValue(const QString& key) const noexcept override;
84  QVector<const AttributeProvider*> getAttributeProviderParents() const
85  noexcept override;
86 
87  // Operator Overloadings
88  BoardGerberExport& operator=(const BoardGerberExport& rhs) = delete;
89 
90 signals:
91  void attributesChanged() override;
92 
93 private:
94  // Private Methods
95  void exportDrills() const;
96  void exportDrillsNpth() const;
97  void exportDrillsPth() const;
98  void exportLayerBoardOutlines() const;
99  void exportLayerTopCopper() const;
100  void exportLayerInnerCopper() const;
101  void exportLayerBottomCopper() const;
102  void exportLayerTopSolderMask() const;
103  void exportLayerBottomSolderMask() const;
104  void exportLayerTopSilkscreen() const;
105  void exportLayerBottomSilkscreen() const;
106  void exportLayerTopSolderPaste() const;
107  void exportLayerBottomSolderPaste() const;
108 
109  int drawNpthDrills(ExcellonGenerator& gen) const;
110  int drawPthDrills(ExcellonGenerator& gen) const;
111  void drawLayer(GerberGenerator& gen, const QString& layerName) const;
112  void drawVia(GerberGenerator& gen, const BI_Via& via,
113  const QString& layerName) const;
114  void drawFootprint(GerberGenerator& gen, const BI_Footprint& footprint,
115  const QString& layerName) const;
116  void drawFootprintPad(GerberGenerator& gen, const BI_FootprintPad& pad,
117  const QString& layerName) const;
118 
119  FilePath getOutputFilePath(const QString& suffix) const noexcept;
120 
121  // Static Methods
122  static UnsignedLength calcWidthOfLayer(const UnsignedLength& width,
123  const QString& name) noexcept;
124  template <typename T>
125  static QList<T*> sortedByUuid(const QList<T*>& list) noexcept {
126  // sort a list of objects by their UUID to get reproducable gerber files
127  QList<T*> copy = list;
128  std::sort(copy.begin(), copy.end(), [](const T* o1, const T* o2) {
129  return o1->getUuid() < o2->getUuid();
130  });
131  return copy;
132  }
133 
134  // Private Member Variables
136  const Board& mBoard;
137  QScopedPointer<const BoardFabricationOutputSettings> mSettings;
139  mutable QVector<FilePath> mWrittenFiles;
140 };
141 
142 /*******************************************************************************
143  * End of File
144  ******************************************************************************/
145 
146 } // namespace project
147 } // namespace librepcb
148 
149 #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:612
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:450
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:516
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:125
FilePath getOutputFilePath(const QString &suffix) const noexcept
Definition: boardgerberexport.cpp:593
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:73
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:135
QScopedPointer< const BoardFabricationOutputSettings > mSettings
Definition: boardgerberexport.h:137
int mCurrentInnerCopperLayer
Definition: boardgerberexport.h:138
void exportLayerTopSilkscreen() const
Definition: boardgerberexport.cpp:237
const Board & mBoard
Definition: boardgerberexport.h:136
void drawVia(GerberGenerator &gen, const BI_Via &via, const QString &layerName) const
Definition: boardgerberexport.cpp:417
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:83
The BoardGerberExport class.
Definition: boardgerberexport.h:60
~BoardGerberExport() noexcept
Definition: boardgerberexport.cpp:71
void exportLayerTopSolderMask() const
Definition: boardgerberexport.cpp:215
The GerberGenerator class.
Definition: gerbergenerator.h:53
void exportDrillsNpth() const
Definition: boardgerberexport.cpp:143
QVector< FilePath > mWrittenFiles
Definition: boardgerberexport.h:139
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