LibrePCB Developers Documentation
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_CORE_BOARDGERBEREXPORT_H
21#define LIBREPCB_CORE_BOARDGERBEREXPORT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../export/excellongenerator.h"
27#include "../../export/gerbergenerator.h"
28#include "../../fileio/filepath.h"
29#include "../../types/length.h"
30
31#include <optional/tl/optional.hpp>
32
33#include <QtCore>
34
35#include <functional>
36#include <memory>
37
38/*******************************************************************************
39 * Namespace / Forward Declarations
40 ******************************************************************************/
41namespace librepcb {
42
43class BI_Device;
44class BI_FootprintPad;
45class BI_Via;
46class Board;
47class BoardFabricationOutputSettings;
48class Circle;
49class GerberGenerator;
50class Layer;
51class Polygon;
52class Project;
53
54/*******************************************************************************
55 * Class BoardGerberExport
56 ******************************************************************************/
57
61class BoardGerberExport final : public QObject {
62 Q_OBJECT
63
64public:
65 enum class BoardSide { Top, Bottom };
66 typedef std::pair<const Layer*, const Layer*> LayerPair;
67 typedef std::function<void(const FilePath&)> BeforeWriteCallback;
68
69 // Constructors / Destructor
71 BoardGerberExport(const BoardGerberExport& other) = delete;
72 explicit BoardGerberExport(const Board& board) noexcept;
73 ~BoardGerberExport() noexcept;
74
75 // Getters
77 const BoardFabricationOutputSettings& settings) const noexcept;
78 const QVector<FilePath>& getWrittenFiles() const noexcept {
79 return mWrittenFiles;
80 }
81
82 // Setters
83 void setRemoveObsoleteFiles(bool remove);
85
86 // General Methods
87 void exportPcbLayers(const BoardFabricationOutputSettings& settings) const;
88 void exportComponentLayer(BoardSide side, const Uuid& assemblyVariant,
89 const FilePath& filePath) const;
90
91 // Operator Overloadings
93
94private:
95 // Private Methods
96 void exportDrillsMerged(const BoardFabricationOutputSettings& settings) const;
97 void exportDrillsNpth(const BoardFabricationOutputSettings& settings) const;
98 void exportDrillsPth(const BoardFabricationOutputSettings& settings) const;
100 const BoardFabricationOutputSettings& settings) const;
102 const BoardFabricationOutputSettings& settings) const;
104 const BoardFabricationOutputSettings& settings) const;
106 const BoardFabricationOutputSettings& settings) const;
108 const BoardFabricationOutputSettings& settings) const;
110 const BoardFabricationOutputSettings& settings) const;
112 const BoardFabricationOutputSettings& settings) const;
114 const BoardFabricationOutputSettings& settings) const;
116 const BoardFabricationOutputSettings& settings) const;
118 const BoardFabricationOutputSettings& settings) const;
120 const BoardFabricationOutputSettings& settings) const;
121
122 int drawNpthDrills(ExcellonGenerator& gen) const;
123 int drawPthDrills(ExcellonGenerator& gen) const;
124 QMap<LayerPair, QList<const BI_Via*> > getBlindBuriedVias() const;
125 void drawLayer(GerberGenerator& gen, const Layer& layer) const;
126 void drawVia(GerberGenerator& gen, const BI_Via& via, const Layer& layer,
127 const QString& netName) const;
128 void drawDevice(GerberGenerator& gen, const BI_Device& device,
129 const Layer& layer) const;
131 const Layer& layer) const;
132 void drawPolygon(GerberGenerator& gen, const Layer& layer,
133 const Path& outline, const UnsignedLength& lineWidth,
134 bool fill, GerberGenerator::Function function,
135 const tl::optional<QString>& net,
136 const QString& component) const;
137 QVector<Path> getComponentOutlines(const BI_Device& device,
138 const Layer& layer) const;
139
140 std::unique_ptr<ExcellonGenerator> createExcellonGenerator(
141 const BoardFabricationOutputSettings& settings,
142 ExcellonGenerator::Plating plating) const;
143 FilePath getOutputFilePath(QString path) const noexcept;
144 QString getAttributeValue(const QString& key) const noexcept;
145 void trackFileBeforeWrite(const FilePath& fp) const;
146
147 // Static Methods
149 const Layer& layer) noexcept;
150
151 // Private Member Variables
153 const Board& mBoard;
159 mutable const Layer* mCurrentStartLayer;
160 mutable const Layer* mCurrentEndLayer;
161 mutable QVector<FilePath> mWrittenFiles;
162};
163
164/*******************************************************************************
165 * End of File
166 ******************************************************************************/
167
168} // namespace librepcb
169
170#endif
The BI_Device class.
Definition: bi_device.h:57
The BI_FootprintPad class.
Definition: bi_footprintpad.h:48
The BI_Via class.
Definition: bi_via.h:44
The BoardFabricationOutputSettings class.
Definition: boardfabricationoutputsettings.h:43
The BoardGerberExport class.
Definition: boardgerberexport.h:61
int mCurrentInnerCopperLayer
Definition: boardgerberexport.h:158
void exportDrillsPth(const BoardFabricationOutputSettings &settings) const
Definition: boardgerberexport.cpp:345
const Board & mBoard
Definition: boardgerberexport.h:153
void drawVia(GerberGenerator &gen, const BI_Via &via, const Layer &layer, const QString &netName) const
Definition: boardgerberexport.cpp:749
void drawPolygon(GerberGenerator &gen, const Layer &layer, const Path &outline, const UnsignedLength &lineWidth, bool fill, GerberGenerator::Function function, const tl::optional< QString > &net, const QString &component) const
Definition: boardgerberexport.cpp:982
void exportLayerBottomSilkscreen(const BoardFabricationOutputSettings &settings) const
Definition: boardgerberexport.cpp:511
void setBeforeWriteCallback(BeforeWriteCallback cb)
Definition: boardgerberexport.cpp:110
const QVector< FilePath > & getWrittenFiles() const noexcept
Definition: boardgerberexport.h:78
BoardSide
Definition: boardgerberexport.h:65
void exportLayerTopSolderPaste(const BoardFabricationOutputSettings &settings) const
Definition: boardgerberexport.cpp:535
void exportLayerBoardOutlines(const BoardFabricationOutputSettings &settings) const
Definition: boardgerberexport.cpp:384
std::pair< const Layer *, const Layer * > LayerPair
Definition: boardgerberexport.h:66
BoardGerberExport & operator=(const BoardGerberExport &rhs)=delete
void drawLayer(GerberGenerator &gen, const Layer &layer) const
Definition: boardgerberexport.cpp:645
void exportLayerBottomSolderPaste(const BoardFabricationOutputSettings &settings) const
Definition: boardgerberexport.cpp:554
FilePath getOutputDirectory(const BoardFabricationOutputSettings &settings) const noexcept
Definition: boardgerberexport.cpp:96
const Project & mProject
Definition: boardgerberexport.h:152
void exportDrillsNpth(const BoardFabricationOutputSettings &settings) const
Definition: boardgerberexport.cpp:319
QString getAttributeValue(const QString &key) const noexcept
Definition: boardgerberexport.cpp:1063
~BoardGerberExport() noexcept
Definition: boardgerberexport.cpp:89
QDateTime mCreationDateTime
Definition: boardgerberexport.h:156
void exportLayerTopCopper(const BoardFabricationOutputSettings &settings) const
Definition: boardgerberexport.cpp:398
void exportPcbLayers(const BoardFabricationOutputSettings &settings) const
Definition: boardgerberexport.cpp:118
QMap< LayerPair, QList< const BI_Via * > > getBlindBuriedVias() const
Definition: boardgerberexport.cpp:631
void exportLayerInnerCopper(const BoardFabricationOutputSettings &settings) const
Definition: boardgerberexport.cpp:427
void exportLayerBottomCopper(const BoardFabricationOutputSettings &settings) const
Definition: boardgerberexport.cpp:412
void trackFileBeforeWrite(const FilePath &fp) const
Definition: boardgerberexport.cpp:1092
void exportComponentLayer(BoardSide side, const Uuid &assemblyVariant, const FilePath &filePath) const
Definition: boardgerberexport.cpp:138
FilePath getOutputFilePath(QString path) const noexcept
Definition: boardgerberexport.cpp:1048
void exportLayerTopSolderMask(const BoardFabricationOutputSettings &settings) const
Definition: boardgerberexport.cpp:449
const Layer * mCurrentEndLayer
Definition: boardgerberexport.h:160
std::function< void(const FilePath &)> BeforeWriteCallback
Definition: boardgerberexport.h:67
QVector< Path > getComponentOutlines(const BI_Device &device, const Layer &layer) const
Definition: boardgerberexport.cpp:1005
BoardGerberExport(const BoardGerberExport &other)=delete
bool mRemoveObsoleteFiles
Definition: boardgerberexport.h:154
void exportDrillsMerged(const BoardFabricationOutputSettings &settings) const
Definition: boardgerberexport.cpp:300
QVector< FilePath > mWrittenFiles
Definition: boardgerberexport.h:161
BeforeWriteCallback mBeforeWriteCallback
Definition: boardgerberexport.h:155
void setRemoveObsoleteFiles(bool remove)
Definition: boardgerberexport.cpp:106
int drawNpthDrills(ExcellonGenerator &gen) const
Definition: boardgerberexport.cpp:573
void exportDrillsBlindBuried(const BoardFabricationOutputSettings &settings) const
Definition: boardgerberexport.cpp:363
void exportLayerBottomSolderMask(const BoardFabricationOutputSettings &settings) const
Definition: boardgerberexport.cpp:468
void drawFootprintPad(GerberGenerator &gen, const BI_FootprintPad &pad, const Layer &layer) const
Definition: boardgerberexport.cpp:863
void drawDevice(GerberGenerator &gen, const BI_Device &device, const Layer &layer) const
Definition: boardgerberexport.cpp:773
void exportLayerTopSilkscreen(const BoardFabricationOutputSettings &settings) const
Definition: boardgerberexport.cpp:487
static UnsignedLength calcWidthOfLayer(const UnsignedLength &width, const Layer &layer) noexcept
Definition: boardgerberexport.cpp:1103
const Layer * mCurrentStartLayer
Definition: boardgerberexport.h:159
QString mProjectName
Definition: boardgerberexport.h:157
int drawPthDrills(ExcellonGenerator &gen) const
Definition: boardgerberexport.cpp:596
std::unique_ptr< ExcellonGenerator > createExcellonGenerator(const BoardFabricationOutputSettings &settings, ExcellonGenerator::Plating plating) const
Definition: boardgerberexport.cpp:1038
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:73
The ExcellonGenerator class.
Definition: excellongenerator.h:47
Plating
Definition: excellongenerator.h:52
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
The GerberGenerator class.
Definition: gerbergenerator.h:51
GerberApertureList::Function Function
Definition: gerbergenerator.h:59
The Layer class provides all supported geometry layers.
Definition: layer.h:42
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition: path.h:58
The Project class represents a whole (opened) project with all its content.
Definition: project.h:71
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696