LibrePCB Developers Documentation
boardplanefragmentsbuilder.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_BOARDPLANEFRAGMENTSBUILDER_H
21#define LIBREPCB_CORE_BOARDPLANEFRAGMENTSBUILDER_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../geometry/path.h"
27#include "../../geometry/zone.h"
28#include "../../types/uuid.h"
29#include "../../utils/transform.h"
30#include "items/bi_plane.h"
31
32#include <QtCore>
33
34#include <memory>
35
36/*******************************************************************************
37 * Namespace / Forward Declarations
38 ******************************************************************************/
39namespace librepcb {
40
41class Board;
42class Layer;
43class NetSignal;
44class PadGeometry;
45
46/*******************************************************************************
47 * Class BoardPlaneFragmentsBuilder
48 ******************************************************************************/
49
53class BoardPlaneFragmentsBuilder final : public QObject {
54 Q_OBJECT
55
56public:
57 // Constructors / Destructor
58 explicit BoardPlaneFragmentsBuilder(bool rebuildAirWires = false,
59 QObject* parent = nullptr) noexcept;
62
63 // General Methods
64
76 void runSynchronously(Board& board,
77 const QSet<const Layer*>* layers = nullptr);
78
95 bool startAsynchronously(Board& board,
96 const QSet<const Layer*>* layers = nullptr) noexcept;
97
104 bool isBusy() const noexcept;
105
109 void cancel() noexcept;
110
111 // Operator Overloadings
113 delete;
114
115signals:
116 void started();
117 void finished();
119
120private: // Methods
121 struct PlaneData {
123 const Layer* layer;
124 tl::optional<Uuid> netSignal;
133 };
134
136 Transform transform; // Applied to outline after preprocessing.
137 Zone::Layers layers; // Converted to boardLayers after preprocessing.
138 QSet<const Layer*> boardLayers;
140 };
141
142 struct PolygonData {
143 Transform transform; // Applied to path after preprocessing.
144 const Layer* layer;
145 tl::optional<Uuid> netSignal;
148 bool filled;
149 };
150
151 struct ViaData {
152 tl::optional<Uuid> netSignal;
157 };
158
159 struct PadData {
161 tl::optional<Uuid> netSignal;
163 QHash<const Layer*, QList<PadGeometry>> geometries;
164 };
165
166 struct TraceData {
167 const Layer* layer;
168 tl::optional<Uuid> netSignal;
172 };
173
174 struct JobData {
175 QPointer<Board> board;
176 QSet<const Layer*> layers;
177 QList<PlaneData> planes;
178 QList<KeepoutZoneData> keepoutZones;
179 QList<PolygonData> polygons;
180 QList<ViaData> vias;
181 QList<PadData> pads;
182 QList<std::tuple<Transform, PositiveLength, NonEmptyPath>> holes;
183 QList<TraceData> traces; // Converted to polygons after preprocessing.
184 QHash<Uuid, QVector<Path>> result;
185 bool finished = false;
186 };
187
188 std::shared_ptr<JobData> createJob(Board& board,
189 const QSet<const Layer*>* filter) noexcept;
190 std::shared_ptr<JobData> run(std::shared_ptr<JobData> data,
191 bool exceptionOnError);
192 static QVector<std::pair<Point, Angle>> determineThermalSpokes(
193 const PadGeometry& geometry) noexcept;
194 bool applyToBoard(std::shared_ptr<JobData> data) noexcept;
195
201 static PositiveLength maxArcTolerance() noexcept {
202 return PositiveLength(5000);
203 }
204
205private: // Data
207 QFuture<std::shared_ptr<JobData>> mFuture;
208 QFutureWatcher<std::shared_ptr<JobData>> mWatcher;
209 bool mAbort;
210};
211
212/*******************************************************************************
213 * End of File
214 ******************************************************************************/
215
216} // namespace librepcb
217
218#endif
ConnectStyle
Definition: bi_plane.h:68
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:73
Plane fragments builder working on a librepcb::Board.
Definition: boardplanefragmentsbuilder.h:53
std::shared_ptr< JobData > createJob(Board &board, const QSet< const Layer * > *filter) noexcept
Definition: boardplanefragmentsbuilder.cpp:123
void cancel() noexcept
Cancel the current asynchronous job.
Definition: boardplanefragmentsbuilder.cpp:112
bool isBusy() const noexcept
Check if there is currently a build in progress.
Definition: boardplanefragmentsbuilder.cpp:107
BoardPlaneFragmentsBuilder(const BoardPlaneFragmentsBuilder &other)=delete
bool mAbort
Definition: boardplanefragmentsbuilder.h:209
std::shared_ptr< JobData > run(std::shared_ptr< JobData > data, bool exceptionOnError)
Definition: boardplanefragmentsbuilder.cpp:259
static PositiveLength maxArcTolerance() noexcept
Definition: boardplanefragmentsbuilder.h:201
BoardPlaneFragmentsBuilder(bool rebuildAirWires=false, QObject *parent=nullptr) noexcept
Definition: boardplanefragmentsbuilder.cpp:58
bool startAsynchronously(Board &board, const QSet< const Layer * > *layers=nullptr) noexcept
Start building plane fragments asynchronously.
Definition: boardplanefragmentsbuilder.cpp:89
const bool mRebuildAirWires
Definition: boardplanefragmentsbuilder.h:206
bool applyToBoard(std::shared_ptr< JobData > data) noexcept
Definition: boardplanefragmentsbuilder.cpp:789
QFutureWatcher< std::shared_ptr< JobData > > mWatcher
Definition: boardplanefragmentsbuilder.h:208
void runSynchronously(Board &board, const QSet< const Layer * > *layers=nullptr)
Build and apply plane fragments synchronously (blocking)
Definition: boardplanefragmentsbuilder.cpp:78
static QVector< std::pair< Point, Angle > > determineThermalSpokes(const PadGeometry &geometry) noexcept
Definition: boardplanefragmentsbuilder.cpp:723
~BoardPlaneFragmentsBuilder() noexcept
Definition: boardplanefragmentsbuilder.cpp:70
QFuture< std::shared_ptr< JobData > > mFuture
Definition: boardplanefragmentsbuilder.h:207
The Layer class provides all supported geometry layers.
Definition: layer.h:40
The PadGeometry class describes the shape of a pad.
Definition: padgeometry.h:46
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition: path.h:58
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
Helper class to perform coordinate transformation with various types.
Definition: transform.h:59
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, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696
Definition: boardplanefragmentsbuilder.h:174
QHash< Uuid, QVector< Path > > result
Definition: boardplanefragmentsbuilder.h:184
QList< std::tuple< Transform, PositiveLength, NonEmptyPath > > holes
Definition: boardplanefragmentsbuilder.h:182
QList< PolygonData > polygons
Definition: boardplanefragmentsbuilder.h:179
QList< TraceData > traces
Definition: boardplanefragmentsbuilder.h:183
QList< KeepoutZoneData > keepoutZones
Definition: boardplanefragmentsbuilder.h:178
bool finished
Definition: boardplanefragmentsbuilder.h:185
QList< PlaneData > planes
Definition: boardplanefragmentsbuilder.h:177
QList< ViaData > vias
Definition: boardplanefragmentsbuilder.h:180
QList< PadData > pads
Definition: boardplanefragmentsbuilder.h:181
QPointer< Board > board
Definition: boardplanefragmentsbuilder.h:175
QSet< const Layer * > layers
Definition: boardplanefragmentsbuilder.h:176
Definition: boardplanefragmentsbuilder.h:135
QSet< const Layer * > boardLayers
Definition: boardplanefragmentsbuilder.h:138
Transform transform
Definition: boardplanefragmentsbuilder.h:136
Zone::Layers layers
Definition: boardplanefragmentsbuilder.h:137
Path outline
Definition: boardplanefragmentsbuilder.h:139
Definition: boardplanefragmentsbuilder.h:159
Transform transform
Definition: boardplanefragmentsbuilder.h:160
tl::optional< Uuid > netSignal
Definition: boardplanefragmentsbuilder.h:161
QHash< const Layer *, QList< PadGeometry > > geometries
Definition: boardplanefragmentsbuilder.h:163
UnsignedLength clearance
Definition: boardplanefragmentsbuilder.h:162
Definition: boardplanefragmentsbuilder.h:121
Uuid uuid
Definition: boardplanefragmentsbuilder.h:122
tl::optional< Uuid > netSignal
Definition: boardplanefragmentsbuilder.h:124
bool keepIslands
Definition: boardplanefragmentsbuilder.h:128
Path outline
Definition: boardplanefragmentsbuilder.h:125
UnsignedLength minClearance
Definition: boardplanefragmentsbuilder.h:127
UnsignedLength minWidth
Definition: boardplanefragmentsbuilder.h:126
PositiveLength thermalSpokeWidth
Definition: boardplanefragmentsbuilder.h:132
BI_Plane::ConnectStyle connectStyle
Definition: boardplanefragmentsbuilder.h:130
int priority
Definition: boardplanefragmentsbuilder.h:129
const Layer * layer
Definition: boardplanefragmentsbuilder.h:123
PositiveLength thermalGap
Definition: boardplanefragmentsbuilder.h:131
Definition: boardplanefragmentsbuilder.h:142
UnsignedLength width
Definition: boardplanefragmentsbuilder.h:147
bool filled
Definition: boardplanefragmentsbuilder.h:148
Transform transform
Definition: boardplanefragmentsbuilder.h:143
tl::optional< Uuid > netSignal
Definition: boardplanefragmentsbuilder.h:145
Path path
Definition: boardplanefragmentsbuilder.h:146
const Layer * layer
Definition: boardplanefragmentsbuilder.h:144
Definition: boardplanefragmentsbuilder.h:166
Point startPos
Definition: boardplanefragmentsbuilder.h:169
tl::optional< Uuid > netSignal
Definition: boardplanefragmentsbuilder.h:168
Point endPos
Definition: boardplanefragmentsbuilder.h:170
const Layer * layer
Definition: boardplanefragmentsbuilder.h:167
PositiveLength width
Definition: boardplanefragmentsbuilder.h:171
Definition: boardplanefragmentsbuilder.h:151
tl::optional< Uuid > netSignal
Definition: boardplanefragmentsbuilder.h:152
const Layer * endLayer
Definition: boardplanefragmentsbuilder.h:156
PositiveLength diameter
Definition: boardplanefragmentsbuilder.h:154
const Layer * startLayer
Definition: boardplanefragmentsbuilder.h:155
Point position
Definition: boardplanefragmentsbuilder.h:153