20 #ifndef LIBREPCB_CORE_PATH_H 21 #define LIBREPCB_CORE_PATH_H 26 #include "../exceptions.h" 29 #include <type_safe/constrained_type.hpp> 58 Q_DECLARE_TR_FUNCTIONS(
Path)
64 explicit Path(
const QVector<Vertex>& vertices) noexcept
96 const Point& center =
Point(0, 0))
const noexcept;
108 bool clean() noexcept;
109 bool close() noexcept;
110 bool open() noexcept;
185 inline uint
qHash(
const Path& key, uint seed = 0) noexcept {
194 template <
typename Value,
typename Predicate>
195 static constexpr
auto verify(Value&& val,
const Predicate& p) ->
196 typename std::decay<Value>::type {
198 ? std::forward<Value>(val)
200 Path::tr(
"Path doesn't contain vertices!")),
201 std::forward<Value>(val));
207 return p.getVertices().count() > 0;
234 template <
typename Value,
typename Predicate>
235 static constexpr
auto verify(Value&& val,
const Predicate& p) ->
236 typename std::decay<Value>::type {
237 return p(val) ? std::forward<Value>(val)
240 Path::tr(
"Path is not fillable or contains arcs!")),
241 std::forward<Value>(val));
247 return (p.getVertices().count() >= 4) && p.isClosed() && (!p.isCurved());
bool operator<(const Path &rhs) const noexcept
The "<" operator to compare two librepcb::Path objects.
Definition: path.cpp:339
Path toClosedPath() const noexcept
Definition: path.cpp:109
void invalidatePainterPath() const noexcept
Definition: path.h:172
uint qHash(const StraightAreaPath &key, uint seed=0) noexcept
Definition: path.h:263
Path flattenedArcs(const PositiveLength &maxTolerance) const noexcept
Definition: path.cpp:262
NonEmptyPath makeNonEmptyPath(const Point &pos) noexcept
Definition: path.h:225
The Vertex class.
Definition: vertex.h:43
Path toOpenPath() const noexcept
Definition: path.cpp:115
static Path centeredRect(const PositiveLength &width, const PositiveLength &height, const UnsignedLength &cornerRadius=UnsignedLength(0)) noexcept
Definition: path.cpp:437
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition: path.h:195
Path & mirror(Qt::Orientation orientation, const Point ¢er=Point(0, 0)) noexcept
Definition: path.cpp:212
bool operator()(const Path &p) const noexcept
Definition: path.h:206
Definition: occmodel.cpp:76
Path() noexcept
Definition: path.h:62
QVector< Vertex > mVertices
Definition: path.h:177
Point calcNearestPointBetweenVertices(const Point &p) const noexcept
Definition: path.cpp:86
Path rotated(const Angle &angle, const Point ¢er=Point(0, 0)) const noexcept
Definition: path.cpp:208
type_safe::constrained_type< Path, NonEmptyPathConstraint, NonEmptyPathVerifier > NonEmptyPath
Definition: path.h:219
bool clean() noexcept
Definition: path.cpp:289
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:76
static Path line(const Point &p1, const Point &p2, const Angle &angle=Angle::deg0()) noexcept
Definition: path.cpp:353
type_safe::constrained_type< Path, StraightAreaPathConstraint, StraightAreaPathVerifier > StraightAreaPath
Definition: path.h:261
bool operator==(const Path &rhs) const noexcept
Definition: path.h:121
Path mirrored(Qt::Orientation orientation, const Point ¢er=Point(0, 0)) const noexcept
Definition: path.cpp:221
bool isClosed() const noexcept
Definition: path.cpp:55
bool operator!=(const Path &rhs) const noexcept
Definition: path.h:124
static Path rect(const Point &p1, const Point &p2) noexcept
Definition: path.cpp:427
Path & flattenArcs(const PositiveLength &maxTolerance) noexcept
Definition: path.cpp:242
static Path obround(const PositiveLength &width, const PositiveLength &height) noexcept
Definition: path.cpp:361
Path & reverse() noexcept
Definition: path.cpp:226
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
static Angle deg0() noexcept
0 degrees
Definition: angle.h:346
static Path arcObround(const Point &p1, const Point &p2, const Angle &angle, const PositiveLength &width) noexcept
Definition: path.cpp:396
bool close() noexcept
Definition: path.cpp:302
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: path.cpp:321
const QVector< Vertex > & getVertices() const noexcept
Definition: path.h:76
static Path circle(const PositiveLength &diameter) noexcept
Definition: path.cpp:357
Path(const QVector< Vertex > &vertices) noexcept
Definition: path.h:64
The RuntimeError class.
Definition: exceptions.h:216
Path translated(const Point &offset) const noexcept
Definition: path.cpp:184
QVector< Vertex > & getVertices() noexcept
Definition: path.h:72
static Path flatArc(const Point &p1, const Point &p2, const Angle &angle, const PositiveLength &maxTolerance) noexcept
Definition: path.cpp:518
Path & mapToGrid(const PositiveLength &gridInterval) noexcept
Definition: path.cpp:188
Path cleaned() const noexcept
Definition: path.cpp:103
QVector< Path > toOutlineStrokes(const PositiveLength &width) const noexcept
Definition: path.cpp:121
The Path class represents a list of vertices connected by straight lines or circular arc segments...
Definition: path.h:57
bool open() noexcept
Definition: path.cpp:312
bool operator()(const Path &p) const noexcept
Definition: path.h:246
~Path() noexcept
Definition: path.h:67
QPainterPath mPainterPathPx
Definition: path.h:178
UnsignedLength getTotalStraightLength() const noexcept
Definition: path.cpp:73
Path & operator=(const Path &rhs) noexcept
Definition: path.cpp:333
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:785
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition: path.h:235
Path & translate(const Point &offset) noexcept
Definition: path.cpp:176
static Path octagon(const PositiveLength &width, const PositiveLength &height, const UnsignedLength &cornerRadius=UnsignedLength(0)) noexcept
Definition: path.cpp:467
Path & rotate(const Angle &angle, const Point ¢er=Point(0, 0)) noexcept
Definition: path.cpp:200
void insertVertex(int index, const Vertex &vertex) noexcept
Definition: path.cpp:279
bool isCurved() const noexcept
Definition: path.cpp:63
The SExpression class.
Definition: sexpression.h:66
Path reversed() const noexcept
Definition: path.cpp:238
uint qHash(const AttributeKey &key, uint seed=0) noexcept
Definition: attributekey.h:118
void addVertex(const Vertex &vertex) noexcept
Definition: path.cpp:270
const QPainterPath & toQPainterPathPx() const noexcept
Definition: path.cpp:141
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:670
Path mappedToGrid(const PositiveLength &gridInterval) const noexcept
Definition: path.cpp:196