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_FootprintPad;
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 exportComponentLayer(BoardSide side, const Uuid& assemblyVariant,
88 const FilePath& filePath) const;
89
90 // Operator Overloadings
92
93private:
94 // Private Methods
95 void exportDrillsMerged(const BoardFabricationOutputSettings& settings) const;
96 void exportDrillsNpth(const BoardFabricationOutputSettings& settings) const;
97 void exportDrillsPth(const BoardFabricationOutputSettings& settings) const;
99 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;
120
121 int drawNpthDrills(ExcellonGenerator& gen) const;
122 int drawPthDrills(ExcellonGenerator& gen) const;
123 QMap<LayerPair, QList<const BI_Via*> > getBlindBuriedVias() const;
124 void drawLayer(GerberGenerator& gen, const Layer& layer) const;
125 void drawVia(GerberGenerator& gen, const BI_Via& via, const Layer& layer,
126 const QString& netName) const;
127 void drawDevice(GerberGenerator& gen, const BI_Device& device,
128 const Layer& layer) const;
130 const Layer& layer) const;
131 void drawPolygon(GerberGenerator& gen, const Layer& layer,
132 const Path& outline, const UnsignedLength& lineWidth,
133 bool fill, GerberGenerator::Function function,
134 const std::optional<QString>& net,
135 const QString& component) const;
136 QVector<Path> getComponentOutlines(const BI_Device& device,
137 const Layer& layer) const;
138
139 std::unique_ptr<ExcellonGenerator> createExcellonGenerator(
140 const BoardFabricationOutputSettings& settings,
141 ExcellonGenerator::Plating plating) const;
142 FilePath getOutputFilePath(QString path) const noexcept;
143 QString getAttributeValue(const QString& key) const noexcept;
144 void trackFileBeforeWrite(const FilePath& fp) const;
145
146 // Static Methods
148 const Layer& layer) noexcept;
149
150 // Private Member Variables
152 const Board& mBoard;
158 mutable const Layer* mCurrentStartLayer;
159 mutable const Layer* mCurrentEndLayer;
160 mutable QVector<FilePath> mWrittenFiles;
161};
162
163/*******************************************************************************
164 * End of File
165 ******************************************************************************/
166
167} // namespace librepcb
168
169#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:60
int mCurrentInnerCopperLayer
Definition boardgerberexport.h:157
void exportDrillsPth(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:345
const Board & mBoard
Definition boardgerberexport.h:152
void drawVia(GerberGenerator &gen, const BI_Via &via, const Layer &layer, const QString &netName) const
Definition boardgerberexport.cpp:749
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:77
BoardSide
Definition boardgerberexport.h:64
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:65
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:151
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:155
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:159
std::function< void(const FilePath &)> BeforeWriteCallback
Definition boardgerberexport.h:66
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:153
void exportDrillsMerged(const BoardFabricationOutputSettings &settings) const
Definition boardgerberexport.cpp:300
QVector< FilePath > mWrittenFiles
Definition boardgerberexport.h:160
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:982
BeforeWriteCallback mBeforeWriteCallback
Definition boardgerberexport.h:154
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:158
QString mProjectName
Definition boardgerberexport.h:156
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: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:57
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:76
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694