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  ******************************************************************************/
39 namespace librepcb {
40 
41 class Board;
42 class Layer;
43 class NetSignal;
44 class PadGeometry;
45 
46 /*******************************************************************************
47  * Class BoardPlaneFragmentsBuilder
48  ******************************************************************************/
49 
53 class BoardPlaneFragmentsBuilder final : public QObject {
54  Q_OBJECT
55 
56 public:
57  // Constructors / Destructor
58  explicit BoardPlaneFragmentsBuilder(bool rebuildAirWires = false,
59  QObject* parent = nullptr) noexcept;
61  ~BoardPlaneFragmentsBuilder() 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 
115 signals:
116  void started();
117  void finished();
118  void boardPlanesModified();
119 
120 private: // Methods
121  struct PlaneData {
123  const Layer* layer;
124  tl::optional<Uuid> netSignal;
129  int priority;
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;
156  const Layer* endLayer;
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 
205 private: // Data
206  const bool mRebuildAirWires;
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
bool mAbort
Definition: boardplanefragmentsbuilder.h:209
int priority
Definition: boardplanefragmentsbuilder.h:129
Point position
Definition: boardplanefragmentsbuilder.h:153
tl::optional< Uuid > netSignal
Definition: boardplanefragmentsbuilder.h:168
PositiveLength diameter
Definition: boardplanefragmentsbuilder.h:154
Definition: boardplanefragmentsbuilder.h:174
Path outline
Definition: boardplanefragmentsbuilder.h:139
UnsignedLength minWidth
Definition: boardplanefragmentsbuilder.h:126
void cancel() noexcept
Cancel the current asynchronous job.
Definition: boardplanefragmentsbuilder.cpp:106
BoardPlaneFragmentsBuilder(bool rebuildAirWires=false, QObject *parent=nullptr) noexcept
Definition: boardplanefragmentsbuilder.cpp:58
Point startPos
Definition: boardplanefragmentsbuilder.h:169
Definition: occmodel.cpp:76
Definition: boardplanefragmentsbuilder.h:135
QFuture< std::shared_ptr< JobData > > mFuture
Definition: boardplanefragmentsbuilder.h:207
QFutureWatcher< std::shared_ptr< JobData > > mWatcher
Definition: boardplanefragmentsbuilder.h:208
const Layer * startLayer
Definition: boardplanefragmentsbuilder.h:155
tl::optional< Uuid > netSignal
Definition: boardplanefragmentsbuilder.h:124
The Layer class provides all supported geometry layers.
Definition: layer.h:40
Helper class to perform coordinate transformation with various types.
Definition: transform.h:59
Definition: boardplanefragmentsbuilder.h:142
QHash< Uuid, QVector< Path > > result
Definition: boardplanefragmentsbuilder.h:184
The PadGeometry class describes the shape of a pad.
Definition: padgeometry.h:46
static QVector< std::pair< Point, Angle > > determineThermalSpokes(const PadGeometry &geometry) noexcept
Definition: boardplanefragmentsbuilder.cpp:717
QList< TraceData > traces
Definition: boardplanefragmentsbuilder.h:183
Transform transform
Definition: boardplanefragmentsbuilder.h:136
Definition: boardplanefragmentsbuilder.h:151
std::shared_ptr< JobData > run(std::shared_ptr< JobData > data, bool exceptionOnError)
Definition: boardplanefragmentsbuilder.cpp:253
bool filled
Definition: boardplanefragmentsbuilder.h:148
static PositiveLength maxArcTolerance() noexcept
Definition: boardplanefragmentsbuilder.h:201
QSet< const Layer * > boardLayers
Definition: boardplanefragmentsbuilder.h:138
UnsignedLength clearance
Definition: boardplanefragmentsbuilder.h:162
QSet< const Layer * > layers
Definition: boardplanefragmentsbuilder.h:176
PositiveLength thermalGap
Definition: boardplanefragmentsbuilder.h:131
PositiveLength width
Definition: boardplanefragmentsbuilder.h:171
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
Uuid uuid
Definition: boardplanefragmentsbuilder.h:122
bool isBusy() const noexcept
Check if there is currently a build in progress.
Definition: boardplanefragmentsbuilder.cpp:101
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:73
tl::optional< Uuid > netSignal
Definition: boardplanefragmentsbuilder.h:152
QPointer< Board > board
Definition: boardplanefragmentsbuilder.h:175
QList< std::tuple< Transform, PositiveLength, NonEmptyPath > > holes
Definition: boardplanefragmentsbuilder.h:182
QHash< const Layer *, QList< PadGeometry > > geometries
Definition: boardplanefragmentsbuilder.h:163
Zone::Layers layers
Definition: boardplanefragmentsbuilder.h:137
Path path
Definition: boardplanefragmentsbuilder.h:146
void runSynchronously(Board &board, const QSet< const Layer *> *layers=nullptr)
Build and apply plane fragments synchronously (blocking)
Definition: boardplanefragmentsbuilder.cpp:77
std::shared_ptr< JobData > createJob(Board &board, const QSet< const Layer *> *filter) noexcept
Definition: boardplanefragmentsbuilder.cpp:117
const bool mRebuildAirWires
Definition: boardplanefragmentsbuilder.h:206
QList< PadData > pads
Definition: boardplanefragmentsbuilder.h:181
const Layer * endLayer
Definition: boardplanefragmentsbuilder.h:156
tl::optional< Uuid > netSignal
Definition: boardplanefragmentsbuilder.h:145
Definition: boardplanefragmentsbuilder.h:159
Definition: boardplanefragmentsbuilder.h:166
const Layer * layer
Definition: boardplanefragmentsbuilder.h:123
Transform transform
Definition: boardplanefragmentsbuilder.h:143
UnsignedLength width
Definition: boardplanefragmentsbuilder.h:147
Point endPos
Definition: boardplanefragmentsbuilder.h:170
The Path class represents a list of vertices connected by straight lines or circular arc segments...
Definition: path.h:57
Plane fragments builder working on a librepcb::Board.
Definition: boardplanefragmentsbuilder.h:53
~BoardPlaneFragmentsBuilder() noexcept
Definition: boardplanefragmentsbuilder.cpp:69
tl::optional< Uuid > netSignal
Definition: boardplanefragmentsbuilder.h:161
bool keepIslands
Definition: boardplanefragmentsbuilder.h:128
ConnectStyle
Definition: bi_plane.h:68
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:785
PositiveLength thermalSpokeWidth
Definition: boardplanefragmentsbuilder.h:132
bool applyToBoard(std::shared_ptr< JobData > data) noexcept
Definition: boardplanefragmentsbuilder.cpp:783
QList< ViaData > vias
Definition: boardplanefragmentsbuilder.h:180
QList< PolygonData > polygons
Definition: boardplanefragmentsbuilder.h:179
const Layer * layer
Definition: boardplanefragmentsbuilder.h:144
QList< PlaneData > planes
Definition: boardplanefragmentsbuilder.h:177
const Layer * layer
Definition: boardplanefragmentsbuilder.h:167
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:56
Path outline
Definition: boardplanefragmentsbuilder.h:125
UnsignedLength minClearance
Definition: boardplanefragmentsbuilder.h:127
Transform transform
Definition: boardplanefragmentsbuilder.h:160
bool startAsynchronously(Board &board, const QSet< const Layer *> *layers=nullptr) noexcept
Start building plane fragments asynchronously.
Definition: boardplanefragmentsbuilder.cpp:88
BoardPlaneFragmentsBuilder & operator=(const BoardPlaneFragmentsBuilder &rhs)=delete
Definition: boardplanefragmentsbuilder.h:121
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:670
BI_Plane::ConnectStyle connectStyle
Definition: boardplanefragmentsbuilder.h:130
QList< KeepoutZoneData > keepoutZones
Definition: boardplanefragmentsbuilder.h:178