LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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 <QtCore>
32
33#include <functional>
34#include <memory>
35#include <optional>
36
37/*******************************************************************************
38 * Namespace / Forward Declarations
39 ******************************************************************************/
40namespace librepcb {
41
42class BI_Device;
43class BI_Pad;
44class BI_Via;
45class Board;
46class BoardFabricationOutputSettings;
47class Circle;
48class GerberGenerator;
49class Layer;
50class Polygon;
51class Project;
52
53/*******************************************************************************
54 * Class BoardGerberExport
55 ******************************************************************************/
56
60class BoardGerberExport final : public QObject {
61 Q_OBJECT
62
63public:
64 enum class BoardSide { Top, Bottom };
65 typedef std::pair<const Layer*, const Layer*> LayerPair;
66 typedef std::function<void(const FilePath&)> BeforeWriteCallback;
67
68 // Constructors / Destructor
70 BoardGerberExport(const BoardGerberExport& other) = delete;
71 explicit BoardGerberExport(const Board& board) noexcept;
72 ~BoardGerberExport() noexcept;
73
74 // Getters
76 const BoardFabricationOutputSettings& settings) const noexcept;
77 const QVector<FilePath>& getWrittenFiles() const noexcept {
78 return mWrittenFiles;
79 }
80
81 // Setters
82 void setRemoveObsoleteFiles(bool remove);
84
85 // General Methods
86 void exportPcbLayers(const BoardFabricationOutputSettings& settings) const;
87 void exportGlueLayer(BoardSide side, const Uuid& assemblyVariant,
88 const FilePath& filePath) const;
89 void exportComponentLayer(BoardSide side, const Uuid& assemblyVariant,
90 const FilePath& filePath) const;
91
92 // Operator Overloadings
94
95private:
96 // Private Methods
97 void exportDrillsMerged(const BoardFabricationOutputSettings& settings) const;
98 void exportDrillsNpth(const BoardFabricationOutputSettings& settings) const;
99 void exportDrillsPth(const BoardFabricationOutputSettings& settings) const;
101 const BoardFabricationOutputSettings& settings) const;
103 const BoardFabricationOutputSettings& settings) const;
105 const BoardFabricationOutputSettings& settings) const;
107 const BoardFabricationOutputSettings& settings) const;
109 const BoardFabricationOutputSettings& settings) const;
111 const BoardFabricationOutputSettings& settings) const;
113 const BoardFabricationOutputSettings& settings) const;
115 const BoardFabricationOutputSettings& settings) const;
117 const BoardFabricationOutputSettings& settings) const;
119 const BoardFabricationOutputSettings& settings) const;
121 const BoardFabricationOutputSettings& settings) const;
122
123 int drawNpthDrills(ExcellonGenerator& gen) const;
124 int drawPthDrills(ExcellonGenerator& gen) const;
125 QMap<LayerPair, QList<const BI_Via*> > getBlindBuriedVias() const;
126 void drawLayer(GerberGenerator& gen, const Layer& layer) const;
127 void drawGlueLayer(GerberGenerator& gen, const Layer& layer,
128 const Uuid& assemblyVariant) const;
129 void drawLayerExceptDevices(GerberGenerator& gen, const Layer& layer) const;
130 void drawVia(GerberGenerator& gen, const BI_Via& via, const Layer& layer,
131 const QString& netName) const;
132 void drawDevice(GerberGenerator& gen, const BI_Device& device,
133 const Layer& layer) const;
134 void drawPad(GerberGenerator& gen, const BI_Pad& pad,
135 const Layer& layer) const;
136 void drawPolygon(GerberGenerator& gen, const Layer& layer,
137 const Path& outline, const UnsignedLength& lineWidth,
138 bool fill, GerberGenerator::Function function,
139 const std::optional<QString>& net,
140 const QString& component) const;
141 QVector<Path> getComponentOutlines(const BI_Device& device,
142 const Layer& layer) const;
143
144 std::unique_ptr<ExcellonGenerator> createExcellonGenerator(
145 const BoardFabricationOutputSettings& settings,
146 ExcellonGenerator::Plating plating) const;
147 FilePath getOutputFilePath(QString path) const noexcept;
148 QString getAttributeValue(const QString& key) const noexcept;
149 void trackFileBeforeWrite(const FilePath& fp) const;
150
151 // Static Methods
153 const Layer& layer) noexcept;
154
155 // Private Member Variables
157 const Board& mBoard;
163 mutable const Layer* mCurrentStartLayer;
164 mutable const Layer* mCurrentEndLayer;
165 mutable QVector<FilePath> mWrittenFiles;
166};
167
168/*******************************************************************************
169 * End of File
170 ******************************************************************************/
171
172} // namespace librepcb
173
174#endif
The BI_Device class.
Definition bi_device.h:57
A pad in a board (either standalone or from a footprint)
Definition bi_pad.h:49
The BI_Via class.
Definition bi_via.h:44
The BoardFabricationOutputSettings class.
Definition boardfabricationoutputsettings.h:43
The BoardGerberExport class.
Definition boardgerberexport.h:60
int mCurrentInnerCopperLayer
Definition boardgerberexport.h:162
void exportDrillsPth(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:376
const Board & mBoard
Definition boardgerberexport.h:157
void drawVia(GerberGenerator &gen, const BI_Via &via, const Layer &layer, const QString &netName) const
Definition boardgerberexport.cpp:817
void exportLayerBottomSilkscreen(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:548
void setBeforeWriteCallback(BeforeWriteCallback cb)
Definition boardgerberexport.cpp:110
const QVector< FilePath > & getWrittenFiles() const noexcept
Definition boardgerberexport.h:77
BoardSide
Definition boardgerberexport.h:64
void exportLayerTopSolderPaste(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:572
void exportLayerBoardOutlines(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:415
std::pair< const Layer *, const Layer * > LayerPair
Definition boardgerberexport.h:65
BoardGerberExport & operator=(const BoardGerberExport &rhs)=delete
void drawGlueLayer(GerberGenerator &gen, const Layer &layer, const Uuid &assemblyVariant) const
Definition boardgerberexport.cpp:702
void drawLayer(GerberGenerator &gen, const Layer &layer) const
Definition boardgerberexport.cpp:690
void drawLayerExceptDevices(GerberGenerator &gen, const Layer &layer) const
Definition boardgerberexport.cpp:717
void exportLayerBottomSolderPaste(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:591
FilePath getOutputDirectory(const BoardFabricationOutputSettings &settings) const noexcept
Definition boardgerberexport.cpp:96
const Project & mProject
Definition boardgerberexport.h:156
void exportDrillsNpth(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:350
QString getAttributeValue(const QString &key) const noexcept
Definition boardgerberexport.cpp:1131
~BoardGerberExport() noexcept
Definition boardgerberexport.cpp:89
QDateTime mCreationDateTime
Definition boardgerberexport.h:160
void exportLayerTopCopper(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:435
void exportPcbLayers(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:118
QMap< LayerPair, QList< const BI_Via * > > getBlindBuriedVias() const
Definition boardgerberexport.cpp:676
void exportLayerInnerCopper(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:464
void exportLayerBottomCopper(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:449
void trackFileBeforeWrite(const FilePath &fp) const
Definition boardgerberexport.cpp:1160
void exportComponentLayer(BoardSide side, const Uuid &assemblyVariant, const FilePath &filePath) const
Definition boardgerberexport.cpp:157
FilePath getOutputFilePath(QString path) const noexcept
Definition boardgerberexport.cpp:1116
void drawPad(GerberGenerator &gen, const BI_Pad &pad, const Layer &layer) const
Definition boardgerberexport.cpp:931
void exportLayerTopSolderMask(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:486
const Layer * mCurrentEndLayer
Definition boardgerberexport.h:164
std::function< void(const FilePath &)> BeforeWriteCallback
Definition boardgerberexport.h:66
QVector< Path > getComponentOutlines(const BI_Device &device, const Layer &layer) const
Definition boardgerberexport.cpp:1073
BoardGerberExport(const BoardGerberExport &other)=delete
bool mRemoveObsoleteFiles
Definition boardgerberexport.h:158
void exportDrillsMerged(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:331
QVector< FilePath > mWrittenFiles
Definition boardgerberexport.h:165
void drawPolygon(GerberGenerator &gen, const Layer &layer, const Path &outline, const UnsignedLength &lineWidth, bool fill, GerberGenerator::Function function, const std::optional< QString > &net, const QString &component) const
Definition boardgerberexport.cpp:1050
BeforeWriteCallback mBeforeWriteCallback
Definition boardgerberexport.h:159
void setRemoveObsoleteFiles(bool remove)
Definition boardgerberexport.cpp:106
int drawNpthDrills(ExcellonGenerator &gen) const
Definition boardgerberexport.cpp:610
void exportGlueLayer(BoardSide side, const Uuid &assemblyVariant, const FilePath &filePath) const
Definition boardgerberexport.cpp:138
void exportDrillsBlindBuried(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:394
void exportLayerBottomSolderMask(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:505
void drawDevice(GerberGenerator &gen, const BI_Device &device, const Layer &layer) const
Definition boardgerberexport.cpp:841
void exportLayerTopSilkscreen(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:524
static UnsignedLength calcWidthOfLayer(const UnsignedLength &width, const Layer &layer) noexcept
Definition boardgerberexport.cpp:1171
const Layer * mCurrentStartLayer
Definition boardgerberexport.h:163
QString mProjectName
Definition boardgerberexport.h:161
int drawPthDrills(ExcellonGenerator &gen) const
Definition boardgerberexport.cpp:633
std::unique_ptr< ExcellonGenerator > createExcellonGenerator(const BoardFabricationOutputSettings &settings, ExcellonGenerator::Plating plating) const
Definition boardgerberexport.cpp:1106
The Board class represents a PCB of a project and is always part of a circuit.
Definition board.h:74
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:127
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:59
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:56
Definition occmodel.cpp:77
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694