20 #ifndef LIBREPCB_CORE_POINT_H 21 #define LIBREPCB_CORE_POINT_H 214 Q_ASSERT(length >= 0);
382 const Point& center =
Point(0, 0))
const noexcept;
408 static Point fromMm(qreal millimetersX, qreal millimetersY);
475 return (
mX == rhs.
mX) && (
mY == rhs.
mY);
478 return (
mX != rhs.
mX) || (
mY != rhs.
mY);
497 return (
mX < rhs.mX) || ((
mX == rhs.mX) && (
mY < rhs.mY));
500 return (
mX < rhs.mX) || ((
mX == rhs.mX) && (
mY <= rhs.mY));
503 return (
mX > rhs.mX) || ((
mX == rhs.mX) && (
mY > rhs.mY));
506 return (
mX > rhs.mX) || ((
mX == rhs.mX) && (
mY >= rhs.mY));
522 inline uint
qHash(
const Point& key, uint seed = 0) noexcept {
bool isOrigin() const noexcept
Check if the position represents the origin (X == 0 and Y == 0)
Definition: point.h:223
qreal toPx() const noexcept
Get the length in pixels (for QGraphics* objects)
Definition: length.h:282
const Length & getX() const noexcept
Get the X coordinate.
Definition: point.h:196
bool operator<=(const Point &rhs) const noexcept
Less/Greater comparison operator overloadings.
Definition: point.h:499
Point operator-() const
Definition: point.h:465
bool operator>(const Point &rhs) const noexcept
Less/Greater comparison operator overloadings.
Definition: point.h:502
QDataStream & operator<<(QDataStream &stream, const AttributeKey &obj)
Definition: attributekey.h:108
void setYmm(const QString &mm)
Set the Y coordinate from a string in millimeters.
Definition: point.h:145
QPointF toPxQPointF() const noexcept
Get the point as a QPointF object in pixels (for QGraphics* objects)
Definition: point.h:276
void setPointPx(const QPointF &pixels)
Definition: point.h:184
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: point.cpp:136
Point(const Point &point) noexcept
Copy Constructor.
Definition: point.h:94
Point & operator*=(LengthBase_t rhs)
Definition: point.h:447
static Point fromMil(qreal milsX, qreal milsY)
Definition: point.cpp:165
const Length & getY() const noexcept
Get the Y coordinate.
Definition: point.h:203
void setXmm(const QString &mm)
Set the X coordinate from a string in millimeters.
Definition: point.h:135
Definition: occmodel.cpp:76
bool operator==(const Point &rhs) const
Definition: point.h:474
Point operator/(LengthBase_t rhs) const
Definition: point.h:472
bool operator!=(const Point &rhs) const
Definition: point.h:477
void setLengthNm(LengthBase_t nanometers) noexcept
Set the length in nanometers.
Definition: length.h:123
Point & mapToGrid(const PositiveLength &gridInterval) noexcept
Map this Point object to a specific grid interval.
Definition: point.cpp:68
Point operator+(const Point &rhs) const
Definition: point.h:462
qint64 LengthBase_t
This type is the ONLY base type to store all lengths (always in nanometers)!
Definition: length.h:61
qreal toMm() const noexcept
Get the length in millimeters.
Definition: length.h:239
LengthBase_t toNm() const noexcept
Get the length in nanometers.
Definition: length.h:213
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:76
Length mY
the Y coordinate
Definition: point.h:512
Point & operator+=(const Point &rhs)
Definition: point.h:432
Point & mirror(Qt::Orientation orientation, const Point ¢er=Point(0, 0)) noexcept
Mirror the point horizontally or vertically around a specific center.
Definition: point.cpp:121
~Point() noexcept
Destructor.
Definition: point.h:109
Point mappedToGrid(const PositiveLength &gridInterval) const noexcept
Get a Point object which is mapped to a specific grid interval.
Definition: point.cpp:62
Point & operator=(const Point &rhs)
Definition: point.h:427
bool isOnGrid(const PositiveLength &gridInterval) const noexcept
Check whether the Point lies on the grid.
Definition: point.cpp:74
Point rotated(const Angle &angle, const Point ¢er=Point(0, 0)) const noexcept
Get the point rotated by a specific angle with respect to a specific center.
Definition: point.cpp:78
Point operator/(const Length &rhs) const
Definition: point.h:471
Point & operator-=(const Point &rhs)
Definition: point.h:437
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
qreal toMil() const noexcept
Get the length in mils (1/1000 inches)
Definition: length.h:270
Length mX
the X coordinate
Definition: point.h:511
void setLengthPx(qreal pixels)
Set the length in pixels (from QGraphics* objects)
Definition: length.h:204
void setPointNm(LengthBase_t nmX, LengthBase_t nmY) noexcept
Definition: point.h:150
void setPointInch(const QPointF &inches)
Definition: point.h:166
static Point fromInch(qreal inchesX, qreal inchesY)
Definition: point.cpp:154
QPointF toInchQPointF() const noexcept
Get the point as a QPointF object in inches.
Definition: point.h:247
void setY(const Length &y) noexcept
Set the Y coordinate.
Definition: point.h:125
Point operator%(const Length &rhs) const
Definition: point.h:473
Point operator*(LengthBase_t rhs) const
Definition: point.h:470
Point operator-(const Point &rhs) const
Definition: point.h:466
Point(const Length &x, const Length &y) noexcept
Constructor for passing two Length objects.
Definition: point.h:102
Point() noexcept
Default Constructor.
Definition: point.h:87
bool operator>=(const Point &rhs) const noexcept
Less/Greater comparison operator overloadings.
Definition: point.h:505
void setX(const Length &x) noexcept
Set the X coordinate.
Definition: point.h:118
void setPointMil(const QPointF &mils)
Definition: point.h:174
Point & operator*=(const Point &rhs)
Definition: point.h:442
Point & operator/=(const Point &rhs)
Definition: point.h:452
Point abs() const noexcept
Get a Point object with both coordinates in absolute values (X,Y >= 0)
Definition: point.cpp:50
void setLengthInch(qreal inches)
Set the length in inches.
Definition: length.h:172
Point operator*(const Length &rhs) const
Definition: point.h:469
void setPointMm(const QPointF &millimeters)
Definition: point.h:158
QPointF toMilQPointF() const noexcept
Get the point as a QPointF object in mils (1/1000 inches)
Definition: point.h:260
QPointF toMmQPointF() const noexcept
Get the point as a QPointF object in millimeters.
Definition: point.h:236
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:785
static Point fromPx(qreal pixelsX, qreal pixelsY)
Definition: point.cpp:176
Point mirrored(Qt::Orientation orientation, const Point ¢er=Point(0, 0)) const noexcept
Get the point mirrored horizontally or vertically around a specific center.
Definition: point.cpp:114
void setLengthMil(qreal mils)
Set the length in mils (1/1000 inch)
Definition: length.h:187
Point & rotate(const Angle &angle, const Point ¢er=Point(0, 0)) noexcept
Rotate the point by a specific angle with respect to a specific center.
Definition: point.cpp:84
static Point fromMm(qreal millimetersX, qreal millimetersY)
Definition: point.cpp:143
The Length class is used to represent a length (for example 12.75 millimeters)
Definition: length.h:82
uint qHash(const Point &key, uint seed=0) noexcept
Definition: point.h:522
qreal toInch() const noexcept
Get the length in inches.
Definition: length.h:261
void setLengthMm(qreal millimeters)
Set the length in millimeters.
Definition: length.h:140
Point & operator/=(LengthBase_t rhs)
Definition: point.h:457
UnsignedLength getLength() const noexcept
Get the length of the vector if X and Y represents a vector (e.g. the distance of this Point from the...
Definition: point.h:211
Point & makeAbs() noexcept
Make both coordinates absolute (X,Y >= 0)
Definition: point.cpp:56
bool operator<(const Point &rhs) const noexcept
Less/Greater comparison operator overloadings.
Definition: point.h:496
The SExpression class.
Definition: sexpression.h:66
uint qHash(const AttributeKey &key, uint seed=0) noexcept
Definition: attributekey.h:118
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:670