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
64 explicit Path(
const QVector<Vertex>& vertices) noexcept {
…}
96 const
Point& center =
Point(0, 0)) const noexcept;
100 const
Point& center =
Point(0, 0)) const noexcept;
112 bool clean() noexcept;
113 bool close() noexcept;
114 bool open() noexcept;
124 Path& operator=(const
Path& rhs) noexcept;
125 bool operator==(const
Path& rhs) const noexcept {
125 bool operator==(const
Path& rhs) const noexcept {
…}
161 bool topRight,
bool bottomLeft,
162 bool bottomRight) noexcept;
165 const
Length dh) noexcept;
199inline std::size_t
qHash(
const Path& key, std::size_t seed = 0) noexcept {
199inline std::size_t
qHash(
const Path& key, std::size_t seed = 0) noexcept {
…}
208 template <
typename Value,
typename Predicate>
209 static constexpr auto verify(Value&& val,
const Predicate& p) ->
210 typename std::decay<Value>::type {
212 ? std::forward<Value>(val)
214 Path::tr(
"Path doesn't contain vertices!")),
215 std::forward<Value>(val));
209 static constexpr auto verify(Value&& val,
const Predicate& p) -> {
…}
221 return p.getVertices().count() > 0;
236 std::size_t seed = 0) noexcept {
237 return ::qHash(*key, seed);
249 template <
typename Value,
typename Predicate>
250 static constexpr auto verify(Value&& val,
const Predicate& p) ->
251 typename std::decay<Value>::type {
252 return p(val) ? std::forward<Value>(val)
255 Path::tr(
"Path is not fillable or contains arcs!")),
256 std::forward<Value>(val));
250 static constexpr auto verify(Value&& val,
const Predicate& p) -> {
…}
262 return (p.getVertices().count() >= 4) && p.isClosed() && (!p.isCurved());
279 std::size_t seed = 0) noexcept {
280 return ::qHash(*key, seed);
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
static Angle deg0() noexcept
0 degrees
Definition angle.h:349
The Length class is used to represent a length (for example 12.75 millimeters)
Definition length.h:82
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition path.h:57
Path reversed() const noexcept
Definition path.cpp:309
Path toOpenPath() const noexcept
Definition path.cpp:152
static Path trapezoid(const PositiveLength &width, const PositiveLength &height, const Length &dw, const Length dh) noexcept
Definition path.cpp:591
QVector< Path > toOutlineStrokes(const PositiveLength &width) const noexcept
Definition path.cpp:158
Path & mirror(Qt::Orientation orientation, const Point ¢er=Point(0, 0)) noexcept
Definition path.cpp:283
Path flattenedArcs(const PositiveLength &maxTolerance) const noexcept
Definition path.cpp:333
const QPainterPath & toQPainterPathPx() const noexcept
Definition path.cpp:178
static Path octagon(const PositiveLength &width, const PositiveLength &height, const UnsignedLength &cornerRadius=UnsignedLength(0)) noexcept
Definition path.cpp:611
const QVector< Vertex > & getVertices() const noexcept
Definition path.h:78
Path & reverse() noexcept
Definition path.cpp:297
static Path donut(const PositiveLength &outerDiameter, const PositiveLength &innerDiameter) noexcept
Definition path.cpp:426
QVector< Vertex > & getVertices() noexcept
Definition path.h:74
bool operator<(const Path &rhs) const noexcept
The "<" operator to compare two librepcb::Path objects.
Definition path.cpp:410
QVector< Vertex > mVertices
Definition path.h:191
static Path rect(const Point &p1, const Point &p2) noexcept
Definition path.cpp:513
Path translated(const Point &offset) const noexcept
Definition path.cpp:255
Path & flattenArcs(const PositiveLength &maxTolerance) noexcept
Definition path.cpp:313
Path mirrored(Qt::Orientation orientation, const Point ¢er=Point(0, 0)) const noexcept
Definition path.cpp:292
static Path arcObround(const Point &p1, const Point &p2, const Angle &angle, const PositiveLength &width) noexcept
Definition path.cpp:478
bool clean() noexcept
Definition path.cpp:360
bool close() noexcept
Definition path.cpp:373
Path & mapToGrid(const PositiveLength &gridInterval) noexcept
Definition path.cpp:259
static Path chamferedRect(const PositiveLength &width, const PositiveLength &height, const UnsignedLength &chamferSize, bool topLeft, bool topRight, bool bottomLeft, bool bottomRight) noexcept
Definition path.cpp:553
static Path centeredRect(const PositiveLength &width, const PositiveLength &height, const UnsignedLength &cornerRadius=UnsignedLength(0)) noexcept
Definition path.cpp:523
Path cleaned() const noexcept
Definition path.cpp:140
void insertVertex(int index, const Vertex &vertex) noexcept
Definition path.cpp:350
static Path flatArc(const Point &p1, const Point &p2, const Angle &angle, const PositiveLength &maxTolerance) noexcept
Definition path.cpp:662
Point calcNearestPointBetweenVertices(const Point &p) const noexcept
Definition path.cpp:123
bool isZeroLength() const noexcept
Definition path.cpp:73
Path mappedToGrid(const PositiveLength &gridInterval) const noexcept
Definition path.cpp:267
QString toSvgPathMm() const noexcept
Definition path.cpp:208
Path() noexcept
Definition path.h:62
static Path circle(const PositiveLength &diameter) noexcept
Definition path.cpp:422
Path(const QVector< Vertex > &vertices) noexcept
Definition path.h:64
static Path line(const Point &p1, const Point &p2, const Angle &angle=Angle::deg0()) noexcept
Definition path.cpp:418
void invalidatePainterPath() const noexcept
Definition path.h:186
qreal calcAreaOfStraightSegments() const noexcept
Definition path.cpp:108
Path & rotate(const Angle &angle, const Point ¢er=Point(0, 0)) noexcept
Definition path.cpp:271
QPainterPath mPainterPathPx
Definition path.h:192
static Path obround(const PositiveLength &width, const PositiveLength &height) noexcept
Definition path.cpp:443
void addVertex(const Vertex &vertex) noexcept
Definition path.cpp:341
~Path() noexcept
Definition path.h:67
Path rotated(const Angle &angle, const Point ¢er=Point(0, 0)) const noexcept
Definition path.cpp:279
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition path.cpp:392
bool isOnGrid(const PositiveLength &gridInterval) const noexcept
Definition path.cpp:86
Path & translate(const Point &offset) noexcept
Definition path.cpp:247
bool isCurved() const noexcept
Definition path.cpp:63
UnsignedLength getTotalStraightLength() const noexcept
Definition path.cpp:95
bool open() noexcept
Definition path.cpp:383
bool operator!=(const Path &rhs) const noexcept
Definition path.h:128
bool isClosed() const noexcept
Definition path.cpp:55
Path toClosedPath() const noexcept
Definition path.cpp:146
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The RuntimeError class.
Definition exceptions.h:218
The SExpression class.
Definition sexpression.h:69
The Vertex class.
Definition vertex.h:43
Definition occmodel.cpp:77
std::size_t qHash(const AttributeKey &key, std::size_t seed=0) noexcept
Definition attributekey.h:118
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
type_safe::constrained_type< Path, NonEmptyPathConstraint, NonEmptyPathVerifier > NonEmptyPath
Definition path.h:233
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
type_safe::constrained_type< Path, StraightAreaPathConstraint, StraightAreaPathVerifier > StraightAreaPath
Definition path.h:276
NonEmptyPath makeNonEmptyPath(const Point &pos) noexcept
Definition path.h:240
bool operator()(const Path &p) const noexcept
Definition path.h:220
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition path.h:209
bool operator()(const Path &p) const noexcept
Definition path.h:261
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition path.h:250