![]() |
LibrePCB Developers Documentation
|
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5.6mm) for X=1.2mm and Y=5.6mm. More...
#include <point.h>
Public Member Functions | |
Point () noexcept | |
Default Constructor. | |
Point (const Point &point) noexcept | |
Copy Constructor. | |
Point (const Length &x, const Length &y) noexcept | |
Constructor for passing two Length objects. | |
Point (const SExpression &node) | |
~Point () noexcept | |
Destructor. | |
void | setX (const Length &x) noexcept |
Set the X coordinate. | |
void | setY (const Length &y) noexcept |
Set the Y coordinate. | |
void | setXmm (const QString &mm) |
Set the X coordinate from a string in millimeters. | |
void | setYmm (const QString &mm) |
Set the Y coordinate from a string in millimeters. | |
void | setPointNm (LengthBase_t nmX, LengthBase_t nmY) noexcept |
void | setPointMm (const QPointF &millimeters) |
void | setPointInch (const QPointF &inches) |
void | setPointMil (const QPointF &mils) |
void | setPointPx (const QPointF &pixels) |
const Length & | getX () const noexcept |
Get the X coordinate. | |
const Length & | getY () const noexcept |
Get the Y coordinate. | |
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 origin) | |
bool | isOrigin () const noexcept |
Check if the position represents the origin (X == 0 and Y == 0) | |
QPointF | toMmQPointF () const noexcept |
Get the point as a QPointF object in millimeters. | |
QPointF | toInchQPointF () const noexcept |
Get the point as a QPointF object in inches. | |
QPointF | toMilQPointF () const noexcept |
Get the point as a QPointF object in mils (1/1000 inches) | |
QPointF | toPxQPointF () const noexcept |
Get the point as a QPointF object in pixels (for QGraphics* objects) | |
Point | abs () const noexcept |
Get a Point object with both coordinates in absolute values (X,Y >= 0) | |
Point & | makeAbs () noexcept |
Make both coordinates absolute (X,Y >= 0) | |
Point | mappedToGrid (const PositiveLength &gridInterval) const noexcept |
Get a Point object which is mapped to a specific grid interval. | |
Point & | mapToGrid (const PositiveLength &gridInterval) noexcept |
Map this Point object to a specific grid interval. | |
bool | isOnGrid (const PositiveLength &gridInterval) const noexcept |
Check whether the Point lies on the grid. | |
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. | |
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. | |
Point | mirrored (Qt::Orientation orientation, const Point ¢er=Point(0, 0)) const noexcept |
Get the point mirrored horizontally or vertically around a specific center. | |
Point & | mirror (Qt::Orientation orientation, const Point ¢er=Point(0, 0)) noexcept |
Mirror the point horizontally or vertically around a specific center. | |
void | serialize (SExpression &root) const |
Serialize into librepcb::SExpression node. | |
Point & | operator= (const Point &rhs) |
Point & | operator+= (const Point &rhs) |
Point & | operator-= (const Point &rhs) |
Point & | operator*= (const Point &rhs) |
Point & | operator*= (LengthBase_t rhs) |
Point & | operator/= (const Point &rhs) |
Point & | operator/= (LengthBase_t rhs) |
Point | operator+ (const Point &rhs) const |
Point | operator- () const |
Point | operator- (const Point &rhs) const |
Point | operator* (const Length &rhs) const |
Point | operator* (LengthBase_t rhs) const |
Point | operator/ (const Length &rhs) const |
Point | operator/ (LengthBase_t rhs) const |
Point | operator% (const Length &rhs) const |
bool | operator== (const Point &rhs) const |
bool | operator!= (const Point &rhs) const |
bool | operator< (const Point &rhs) const noexcept |
Less/Greater comparison operator overloadings. | |
bool | operator<= (const Point &rhs) const noexcept |
bool | operator> (const Point &rhs) const noexcept |
bool | operator>= (const Point &rhs) const noexcept |
Static Public Member Functions | |
static Point | fromMm (qreal millimetersX, qreal millimetersY) |
static Point | fromMm (const QPointF &millimeters) |
static Point | fromInch (qreal inchesX, qreal inchesY) |
static Point | fromInch (const QPointF &inches) |
static Point | fromMil (qreal milsX, qreal milsY) |
static Point | fromMil (const QPointF &mils) |
static Point | fromPx (qreal pixelsX, qreal pixelsY) |
static Point | fromPx (const QPointF &pixels) |
Private Attributes | |
Length | mX |
the X coordinate | |
Length | mY |
the Y coordinate | |
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5.6mm) for X=1.2mm and Y=5.6mm.
This class is used to represent ALL coordinates in Symbols, Schematics, Footprints, Layouts and so on. You should never use another coordinate type, like QPoint or QPointF! It's very important to have a consistent coordinate type over the whole project.
A Point object consists always of two Length objects. Basically, this is the only goal of this class, but it will provide also some useful addidional methods.
|
inlinenoexcept |
Default Constructor.
The object will be initialized with X=Length(0) and Y=Length(0).
|
explicit |
|
inlinenoexcept |
Destructor.
|
inlinenoexcept |
Set the X coordinate.
x | The new X coordinate as a Length object |
|
inlinenoexcept |
Set the Y coordinate.
y | The new Y coordinate as a Length object |
|
inline |
Set the X coordinate from a string in millimeters.
mm | A string with the new X coordinate in millimeters |
Exception | If the string is not valid, an exception will be thrown. |
|
inline |
Set the Y coordinate from a string in millimeters.
mm | A string with the new Y coordinate in millimeters |
Exception | If the string is not valid, an exception will be thrown. |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
Get the X coordinate.
|
inlinenoexcept |
Get the Y coordinate.
|
inlinenoexcept |
|
inlinenoexcept |
Check if the position represents the origin (X == 0 and Y == 0)
|
inlinenoexcept |
Get the point as a QPointF object in millimeters.
|
inlinenoexcept |
Get the point as a QPointF object in inches.
|
inlinenoexcept |
Get the point as a QPointF object in mils (1/1000 inches)
|
inlinenoexcept |
Get the point as a QPointF object in pixels (for QGraphics* objects)
|
noexcept |
|
noexcept |
Make both coordinates absolute (X,Y >= 0)
|
noexcept |
Get a Point object which is mapped to a specific grid interval.
gridInterval | See Length::mappedToGrid() |
|
noexcept |
Map this Point object to a specific grid interval.
gridInterval | See Length::mapToGrid() |
|
noexcept |
Check whether the Point lies on the grid.
gridInterval | See Length::mappedToGrid() |
Get the point rotated by a specific angle with respect to a specific center.
angle | The angle to rotate (CCW) |
center | The center of the rotation |
Rotate the point by a specific angle with respect to a specific center.
angle | The angle to rotate (CCW) |
center | The center of the rotation |
Get the point mirrored horizontally or vertically around a specific center.
orientation | Qt::Horizontal = mirror X axis; Qt::Vertical = mirror Y axis |
center | The center of the mirror operation |
Mirror the point horizontally or vertically around a specific center.
orientation | Qt::Horizontal = mirror X axis; Qt::Vertical = mirror Y axis |
center | The center of the mirror operation |
void serialize | ( | SExpression & | root | ) | const |
Serialize into librepcb::SExpression node.
root | Root node to serialize into. |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
Less/Greater comparison operator overloadings.
This comparison operator doesn't make much sense, but it's useful to to sort librepcb::Point objects, e.g. for using them as a key in a sorted map. The comparison is first done on the X coordinate, and only if they are equal, the Y coordinate is also taken into account. So the "smallest" point is at (-infinity, -infinity) and the "greatest" point at (infinity, infinity).
rhs | The other object to compare |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
private |
the X coordinate
|
private |
the Y coordinate