Make explicit that we expect co-ordinates to be finite
The various spatial-vector, line, point, region and margin types have all long taken for granted that their co-ordinates are finite and, in particular, not NaN. Make this expectation explicit in the documentation. Added assertions where (chiefly) noexcept and (where the assertion would be a simple qIsFinite() call) constexpr didn't preclude doing so. Also assert against zero divisors that would lead to non-finite results. Make minor clean-ups to docs in the process. QMarginsF had several methods whose declaration, definition and docs weren't consistent in their parameter names. Task-number: QTBUG-89010 Change-Id: I601a830959d13a73dcb17ce31a1202a1486c8f7f Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
96ef1769c1
commit
7a738daa97
@ -322,7 +322,7 @@ QDataStream &operator>>(QDataStream &stream, QLine &line)
|
||||
A QLineF describes a finite length line (or line segment) on a
|
||||
two-dimensional surface. QLineF defines the start and end points
|
||||
of the line using floating point accuracy for coordinates. Use
|
||||
the toLine() function to retrieve an integer based copy of this
|
||||
the toLine() function to retrieve an integer-based copy of this
|
||||
line.
|
||||
|
||||
\table
|
||||
@ -458,7 +458,7 @@ QDataStream &operator>>(QDataStream &stream, QLine &line)
|
||||
/*!
|
||||
\fn QLine QLineF::toLine() const
|
||||
|
||||
Returns an integer based copy of this line.
|
||||
Returns an integer-based copy of this line.
|
||||
|
||||
Note that the returned line's start and end points are rounded to
|
||||
the nearest integer.
|
||||
@ -516,12 +516,9 @@ QDataStream &operator>>(QDataStream &stream, QLine &line)
|
||||
/*!
|
||||
\fn void QLineF::setLength(qreal length)
|
||||
|
||||
Sets the length of the line to the given \a length. QLineF will
|
||||
move the end point - p2() - of the line to give the line its new
|
||||
length, unless length() was previously zero, in which case no
|
||||
scaling is attempted. For lines with very short lengths
|
||||
(represented by denormal floating-point values), results may be
|
||||
imprecise.
|
||||
Sets the length of the line to the given finite \a length. QLineF will move
|
||||
the end point - p2() - of the line to give the line its new length, unless
|
||||
length() was previously zero, in which case no scaling is attempted.
|
||||
|
||||
\sa length(), unitVector()
|
||||
*/
|
||||
@ -558,9 +555,8 @@ QDataStream &operator>>(QDataStream &stream, QLine &line)
|
||||
/*!
|
||||
\fn qreal QLineF::pointAt(qreal t) const
|
||||
|
||||
Returns the point at the parameterized position specified by \a
|
||||
t. The function returns the line's start point if t = 0, and its end
|
||||
point if t = 1.
|
||||
Returns the point at the position specified by finite parameter \a t. The
|
||||
function returns the line's start point if t = 0, and its end point if t = 1.
|
||||
|
||||
\sa dx(), dy()
|
||||
*/
|
||||
|
@ -372,7 +372,9 @@ constexpr inline QPointF QLineF::center() const
|
||||
|
||||
inline void QLineF::setLength(qreal len)
|
||||
{
|
||||
Q_ASSERT(qIsFinite(len));
|
||||
const qreal oldLength = length();
|
||||
Q_ASSERT(qIsFinite(oldLength));
|
||||
// Scale len by dx() / length() and dy() / length(), two O(1) quantities,
|
||||
// rather than scaling dx() and dy() by len / length(), which might overflow.
|
||||
if (oldLength > 0)
|
||||
|
@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
\brief The QMargins class defines the four margins of a rectangle.
|
||||
|
||||
QMargin defines a set of four margins; left, top, right and bottom,
|
||||
QMargin defines a set of four margins; left, top, right, and bottom,
|
||||
that describe the size of the borders surrounding a rectangle.
|
||||
|
||||
The isNull() function returns \c true only if all margins are set to zero.
|
||||
@ -76,7 +76,7 @@ QT_BEGIN_NAMESPACE
|
||||
/*!
|
||||
\fn QMargins::QMargins(int left, int top, int right, int bottom)
|
||||
|
||||
Constructs margins with the given \a left, \a top, \a right, \a bottom
|
||||
Constructs margins with the given \a left, \a top, \a right, and \a bottom
|
||||
|
||||
\sa setLeft(), setRight(), setTop(), setBottom()
|
||||
*/
|
||||
@ -467,8 +467,8 @@ QDebug operator<<(QDebug dbg, const QMargins &m)
|
||||
|
||||
\brief The QMarginsF class defines the four margins of a rectangle.
|
||||
|
||||
QMarginsF defines a set of four margins; left, top, right and bottom,
|
||||
that describe the size of the borders surrounding a rectangle.
|
||||
QMarginsF defines a set of four margins; left, top, right, and bottom,
|
||||
that describe the finite size of the borders surrounding a rectangle.
|
||||
|
||||
The isNull() function returns \c true only if all margins are very close to zero.
|
||||
|
||||
@ -491,7 +491,8 @@ QDebug operator<<(QDebug dbg, const QMargins &m)
|
||||
/*!
|
||||
\fn QMarginsF::QMarginsF(qreal left, qreal top, qreal right, qreal bottom)
|
||||
|
||||
Constructs margins with the given \a left, \a top, \a right, \a bottom
|
||||
Constructs margins with the given \a left, \a top, \a right, and \a bottom.
|
||||
All parameters must be finite.
|
||||
|
||||
\sa setLeft(), setRight(), setTop(), setBottom()
|
||||
*/
|
||||
@ -542,27 +543,27 @@ QDebug operator<<(QDebug dbg, const QMargins &m)
|
||||
|
||||
|
||||
/*!
|
||||
\fn void QMarginsF::setLeft(qreal left)
|
||||
\fn void QMarginsF::setLeft(qreal aleft)
|
||||
|
||||
Sets the left margin to \a left.
|
||||
Sets the left margin to \a aleft (which must be finite).
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMarginsF::setTop(qreal Top)
|
||||
\fn void QMarginsF::setTop(qreal atop)
|
||||
|
||||
Sets the Top margin to \a Top.
|
||||
Sets the top margin to \a atop (which must be finite).
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMarginsF::setRight(qreal right)
|
||||
\fn void QMarginsF::setRight(qreal aright)
|
||||
|
||||
Sets the right margin to \a right.
|
||||
Sets the right margin to \a aright (which must be finite).
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMarginsF::setBottom(qreal bottom)
|
||||
\fn void QMarginsF::setBottom(qreal abottom)
|
||||
|
||||
Sets the bottom margin to \a bottom.
|
||||
Sets the bottom margin to \a abottom (which must be finite).
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -613,8 +614,8 @@ QDebug operator<<(QDebug dbg, const QMargins &m)
|
||||
\fn const QMarginsF operator+(const QMarginsF &lhs, qreal rhs)
|
||||
\relates QMarginsF
|
||||
|
||||
Returns a QMarginsF object that is formed by adding \a rhs to
|
||||
\a lhs.
|
||||
Returns a QMarginsF object that is formed by adding \a rhs (which must be
|
||||
finite) to each component of \a lhs.
|
||||
|
||||
\sa QMarginsF::operator+=(), QMarginsF::operator-=()
|
||||
*/
|
||||
@ -623,8 +624,8 @@ QDebug operator<<(QDebug dbg, const QMargins &m)
|
||||
\fn const QMarginsF operator+(qreal lhs, const QMarginsF &rhs)
|
||||
\relates QMarginsF
|
||||
|
||||
Returns a QMarginsF object that is formed by adding \a lhs to
|
||||
\a rhs.
|
||||
Returns a QMarginsF object that is formed by adding \a lhs (which must be
|
||||
finite) to each component of \a rhs.
|
||||
|
||||
\sa QMarginsF::operator+=(), QMarginsF::operator-=()
|
||||
*/
|
||||
@ -633,8 +634,8 @@ QDebug operator<<(QDebug dbg, const QMargins &m)
|
||||
\fn const QMarginsF operator-(const QMarginsF &lhs, qreal rhs)
|
||||
\relates QMarginsF
|
||||
|
||||
Returns a QMarginsF object that is formed by subtracting \a rhs from
|
||||
\a lhs.
|
||||
Returns a QMarginsF object that is formed by subtracting \a rhs (which must
|
||||
be finite) from each component of \a lhs.
|
||||
|
||||
\sa QMarginsF::operator+=(), QMarginsF::operator-=()
|
||||
*/
|
||||
@ -645,7 +646,7 @@ QDebug operator<<(QDebug dbg, const QMargins &m)
|
||||
\overload
|
||||
|
||||
Returns a QMarginsF object that is formed by multiplying each component
|
||||
of the given \a lhs margins by \a rhs factor.
|
||||
of the given \a lhs margins by finite factor \a rhs.
|
||||
|
||||
\sa QMarginsF::operator*=(), QMarginsF::operator/=()
|
||||
*/
|
||||
@ -656,7 +657,7 @@ QDebug operator<<(QDebug dbg, const QMargins &m)
|
||||
\overload
|
||||
|
||||
Returns a QMarginsF object that is formed by multiplying each component
|
||||
of the given \a lhs margins by \a rhs factor.
|
||||
of the given \a lhs margins by finite factor \a rhs.
|
||||
|
||||
\sa QMarginsF::operator*=(), QMarginsF::operator/=()
|
||||
*/
|
||||
@ -669,6 +670,8 @@ QDebug operator<<(QDebug dbg, const QMargins &m)
|
||||
Returns a QMarginsF object that is formed by dividing the components of
|
||||
the given \a lhs margins by the given \a rhs divisor.
|
||||
|
||||
The \a divisor must not be either zero or NaN.
|
||||
|
||||
\sa QMarginsF::operator*=(), QMarginsF::operator/=()
|
||||
*/
|
||||
|
||||
@ -721,7 +724,7 @@ QDebug operator<<(QDebug dbg, const QMargins &m)
|
||||
\fn QMarginsF &QMarginsF::operator+=(qreal addend)
|
||||
\overload
|
||||
|
||||
Adds the \a addend to each component of this object
|
||||
Adds the given finite \a addend to each component of this object
|
||||
and returns a reference to it.
|
||||
|
||||
\sa operator-=()
|
||||
@ -731,7 +734,7 @@ QDebug operator<<(QDebug dbg, const QMargins &m)
|
||||
\fn QMarginsF &QMarginsF::operator-=(qreal subtrahend)
|
||||
\overload
|
||||
|
||||
Subtracts the \a subtrahend from each component of this object
|
||||
Subtracts the given finite \a subtrahend from each component of this object
|
||||
and returns a reference to it.
|
||||
|
||||
\sa operator+=()
|
||||
@ -740,8 +743,8 @@ QDebug operator<<(QDebug dbg, const QMargins &m)
|
||||
/*!
|
||||
\fn QMarginsF &QMarginsF::operator*=(qreal factor)
|
||||
|
||||
Multiplies each component of this object by \a factor
|
||||
and returns a reference to it.
|
||||
Multiplies each component of this object by the given finite \a factor
|
||||
and returns a reference to this object.
|
||||
|
||||
\sa operator/=()
|
||||
*/
|
||||
@ -749,8 +752,10 @@ QDebug operator<<(QDebug dbg, const QMargins &m)
|
||||
/*!
|
||||
\fn QMarginsF &QMarginsF::operator/=(qreal divisor)
|
||||
|
||||
Divides each component of this object by \a divisor
|
||||
and returns a reference to it.
|
||||
Divides each component of this object by \a divisor and returns a reference
|
||||
to this object.
|
||||
|
||||
The \a divisor must not be either zero or NaN.
|
||||
|
||||
\sa operator*=()
|
||||
*/
|
||||
@ -758,7 +763,7 @@ QDebug operator<<(QDebug dbg, const QMargins &m)
|
||||
/*!
|
||||
\fn QMargins QMarginsF::toMargins() const
|
||||
|
||||
Returns an integer based copy of this margins object.
|
||||
Returns an integer-based copy of this margins object.
|
||||
|
||||
Note that the components in the returned margins will be rounded to
|
||||
the nearest integer.
|
||||
|
@ -311,10 +311,10 @@ public:
|
||||
constexpr qreal right() const noexcept;
|
||||
constexpr qreal bottom() const noexcept;
|
||||
|
||||
constexpr void setLeft(qreal left) noexcept;
|
||||
constexpr void setTop(qreal top) noexcept;
|
||||
constexpr void setRight(qreal right) noexcept;
|
||||
constexpr void setBottom(qreal bottom) noexcept;
|
||||
constexpr void setLeft(qreal aleft) noexcept;
|
||||
constexpr void setTop(qreal atop) noexcept;
|
||||
constexpr void setRight(qreal aright) noexcept;
|
||||
constexpr void setBottom(qreal abottom) noexcept;
|
||||
|
||||
constexpr QMarginsF &operator+=(const QMarginsF &margins) noexcept;
|
||||
constexpr QMarginsF &operator-=(const QMarginsF &margins) noexcept;
|
||||
@ -457,6 +457,7 @@ constexpr inline QMarginsF operator*(qreal lhs, const QMarginsF &rhs) noexcept
|
||||
|
||||
constexpr inline QMarginsF operator/(const QMarginsF &lhs, qreal divisor)
|
||||
{
|
||||
Q_ASSERT(divisor < 0 || divisor > 0);
|
||||
return QMarginsF(lhs.left() / divisor, lhs.top() / divisor,
|
||||
lhs.right() / divisor, lhs.bottom() / divisor);
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ size_t qHash(QPoint key, size_t seed) noexcept
|
||||
|
||||
A point is specified by a x coordinate and an y coordinate which
|
||||
can be accessed using the x() and y() functions. The coordinates
|
||||
of the point are specified using floating point numbers for
|
||||
of the point are specified using finite floating point numbers for
|
||||
accuracy. The isNull() function returns \c true if both x and y are
|
||||
set to 0.0. The coordinates can be set (or altered) using the setX()
|
||||
and setY() functions, or alternatively the rx() and ry() functions which
|
||||
@ -581,7 +581,7 @@ size_t qHash(QPoint key, size_t seed) noexcept
|
||||
/*!
|
||||
\fn void QPointF::setX(qreal x)
|
||||
|
||||
Sets the x coordinate of this point to the given \a x coordinate.
|
||||
Sets the x coordinate of this point to the given finite \a x coordinate.
|
||||
|
||||
\sa x(), setY()
|
||||
*/
|
||||
@ -589,7 +589,7 @@ size_t qHash(QPoint key, size_t seed) noexcept
|
||||
/*!
|
||||
\fn void QPointF::setY(qreal y)
|
||||
|
||||
Sets the y coordinate of this point to the given \a y coordinate.
|
||||
Sets the y coordinate of this point to the given finite \a y coordinate.
|
||||
|
||||
\sa y(), setX()
|
||||
*/
|
||||
@ -655,7 +655,7 @@ size_t qHash(QPoint key, size_t seed) noexcept
|
||||
/*!
|
||||
\fn QPointF& QPointF::operator*=(qreal factor)
|
||||
|
||||
Multiplies this point's coordinates by the given \a factor, and
|
||||
Multiplies this point's coordinates by the given finite \a factor, and
|
||||
returns a reference to this point. For example:
|
||||
|
||||
\snippet code/src_corelib_tools_qpoint.cpp 14
|
||||
@ -671,6 +671,8 @@ size_t qHash(QPoint key, size_t seed) noexcept
|
||||
|
||||
\snippet code/src_corelib_tools_qpoint.cpp 15
|
||||
|
||||
The \a divisor must not be zero or NaN.
|
||||
|
||||
\sa operator*=()
|
||||
*/
|
||||
|
||||
@ -695,7 +697,7 @@ size_t qHash(QPoint key, size_t seed) noexcept
|
||||
/*!
|
||||
\fn QPointF QPointF::operator*(const QPointF &point, qreal factor)
|
||||
|
||||
Returns a copy of the given \a point, multiplied by the given \a factor.
|
||||
Returns a copy of the given \a point, multiplied by the given finite \a factor.
|
||||
|
||||
\sa QPointF::operator*=()
|
||||
*/
|
||||
@ -705,7 +707,7 @@ size_t qHash(QPoint key, size_t seed) noexcept
|
||||
|
||||
\overload
|
||||
|
||||
Returns a copy of the given \a point, multiplied by the given \a factor.
|
||||
Returns a copy of the given \a point, multiplied by the given finite \a factor.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -720,7 +722,7 @@ size_t qHash(QPoint key, size_t seed) noexcept
|
||||
\overload
|
||||
|
||||
Returns a QPointF object that is formed by changing the sign of
|
||||
both components of the given \a point.
|
||||
each component of the given \a point.
|
||||
|
||||
Equivalent to \c {QPointF(0,0) - point}.
|
||||
*/
|
||||
@ -728,9 +730,11 @@ size_t qHash(QPoint key, size_t seed) noexcept
|
||||
/*!
|
||||
\fn QPointF QPointF::operator/(const QPointF &point, qreal divisor)
|
||||
|
||||
Returns the QPointF object formed by dividing both components of
|
||||
Returns the QPointF object formed by dividing each component of
|
||||
the given \a point by the given \a divisor.
|
||||
|
||||
The \a divisor must not be zero or NaN.
|
||||
|
||||
\sa QPointF::operator/=()
|
||||
*/
|
||||
|
||||
|
@ -295,7 +295,10 @@ public:
|
||||
friend constexpr inline QPointF operator-(const QPointF &p)
|
||||
{ return QPointF(-p.xp, -p.yp); }
|
||||
friend constexpr inline QPointF operator/(const QPointF &p, qreal divisor)
|
||||
{ return QPointF(p.xp / divisor, p.yp / divisor); }
|
||||
{
|
||||
Q_ASSERT(divisor < 0 || divisor > 0);
|
||||
return QPointF(p.xp / divisor, p.yp / divisor);
|
||||
}
|
||||
|
||||
constexpr QPoint toPoint() const;
|
||||
|
||||
@ -406,6 +409,7 @@ constexpr inline QPointF &QPointF::operator*=(qreal c)
|
||||
|
||||
constexpr inline QPointF &QPointF::operator/=(qreal divisor)
|
||||
{
|
||||
Q_ASSERT(divisor > 0 || divisor < 0);
|
||||
xp /= divisor;
|
||||
yp /= divisor;
|
||||
return *this;
|
||||
|
@ -1303,8 +1303,8 @@ QDebug operator<<(QDebug dbg, const QRect &r)
|
||||
\ingroup painting
|
||||
\reentrant
|
||||
|
||||
\brief The QRectF class defines a rectangle in the plane using floating
|
||||
point precision.
|
||||
\brief The QRectF class defines a finite rectangle in the plane using
|
||||
floating point precision.
|
||||
|
||||
A rectangle is normally expressed as a top-left corner and a
|
||||
size. The size (width and height) of a QRectF is always equivalent
|
||||
@ -1469,8 +1469,8 @@ QDebug operator<<(QDebug dbg, const QRect &r)
|
||||
/*!
|
||||
\fn QRectF::QRectF(qreal x, qreal y, qreal width, qreal height)
|
||||
|
||||
Constructs a rectangle with (\a x, \a y) as its top-left corner
|
||||
and the given \a width and \a height.
|
||||
Constructs a rectangle with (\a x, \a y) as its top-left corner and the
|
||||
given \a width and \a height. All parameters must be finite.
|
||||
|
||||
\sa setRect()
|
||||
*/
|
||||
@ -1569,7 +1569,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
/*!
|
||||
\fn void QRectF::setLeft(qreal x)
|
||||
|
||||
Sets the left edge of the rectangle to the given \a x
|
||||
Sets the left edge of the rectangle to the given finite \a x
|
||||
coordinate. May change the width, but will never change the right
|
||||
edge of the rectangle.
|
||||
|
||||
@ -1581,7 +1581,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
/*!
|
||||
\fn void QRectF::setTop(qreal y)
|
||||
|
||||
Sets the top edge of the rectangle to the given \a y coordinate. May
|
||||
Sets the top edge of the rectangle to the given finite \a y coordinate. May
|
||||
change the height, but will never change the bottom edge of the
|
||||
rectangle.
|
||||
|
||||
@ -1593,7 +1593,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
/*!
|
||||
\fn void QRectF::setRight(qreal x)
|
||||
|
||||
Sets the right edge of the rectangle to the given \a x
|
||||
Sets the right edge of the rectangle to the given finite \a x
|
||||
coordinate. May change the width, but will never change the left
|
||||
edge of the rectangle.
|
||||
|
||||
@ -1603,7 +1603,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
/*!
|
||||
\fn void QRectF::setBottom(qreal y)
|
||||
|
||||
Sets the bottom edge of the rectangle to the given \a y
|
||||
Sets the bottom edge of the rectangle to the given finite \a y
|
||||
coordinate. May change the height, but will never change the top
|
||||
edge of the rectangle.
|
||||
|
||||
@ -1613,7 +1613,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
/*!
|
||||
\fn void QRectF::setX(qreal x)
|
||||
|
||||
Sets the left edge of the rectangle to the given \a x
|
||||
Sets the left edge of the rectangle to the given finite \a x
|
||||
coordinate. May change the width, but will never change the right
|
||||
edge of the rectangle.
|
||||
|
||||
@ -1625,7 +1625,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
/*!
|
||||
\fn void QRectF::setY(qreal y)
|
||||
|
||||
Sets the top edge of the rectangle to the given \a y
|
||||
Sets the top edge of the rectangle to the given finite \a y
|
||||
coordinate. May change the height, but will never change the
|
||||
bottom edge of the rectangle.
|
||||
|
||||
@ -1707,7 +1707,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
\fn void QRectF::moveLeft(qreal x)
|
||||
|
||||
Moves the rectangle horizontally, leaving the rectangle's left
|
||||
edge at the given \a x coordinate. The rectangle's size is
|
||||
edge at the given finite \a x coordinate. The rectangle's size is
|
||||
unchanged.
|
||||
|
||||
\sa left(), setLeft(), moveRight()
|
||||
@ -1717,7 +1717,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
\fn void QRectF::moveTop(qreal y)
|
||||
|
||||
Moves the rectangle vertically, leaving the rectangle's top line
|
||||
at the given \a y coordinate. The rectangle's size is unchanged.
|
||||
at the given finite \a y coordinate. The rectangle's size is unchanged.
|
||||
|
||||
\sa top(), setTop(), moveBottom()
|
||||
*/
|
||||
@ -1727,7 +1727,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
\fn void QRectF::moveRight(qreal x)
|
||||
|
||||
Moves the rectangle horizontally, leaving the rectangle's right
|
||||
edge at the given \a x coordinate. The rectangle's size is
|
||||
edge at the given finite \a x coordinate. The rectangle's size is
|
||||
unchanged.
|
||||
|
||||
\sa right(), setRight(), moveLeft()
|
||||
@ -1738,7 +1738,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
\fn void QRectF::moveBottom(qreal y)
|
||||
|
||||
Moves the rectangle vertically, leaving the rectangle's bottom
|
||||
edge at the given \a y coordinate. The rectangle's size is
|
||||
edge at the given finite \a y coordinate. The rectangle's size is
|
||||
unchanged.
|
||||
|
||||
\sa bottom(), setBottom(), moveTop()
|
||||
@ -1788,8 +1788,8 @@ QRectF QRectF::normalized() const noexcept
|
||||
/*!
|
||||
\fn void QRectF::moveTo(qreal x, qreal y)
|
||||
|
||||
Moves the rectangle, leaving the top-left corner at the given
|
||||
position (\a x, \a y). The rectangle's size is unchanged.
|
||||
Moves the rectangle, leaving the top-left corner at the given position (\a
|
||||
x, \a y). The rectangle's size is unchanged. Both parameters must be finite.
|
||||
|
||||
\sa translate(), moveTopLeft()
|
||||
*/
|
||||
@ -1807,7 +1807,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
|
||||
Moves the rectangle \a dx along the x-axis and \a dy along the y-axis,
|
||||
relative to the current position. Positive values move the rectangle to the
|
||||
right and downwards.
|
||||
right and downwards. Both parameters must be finite.
|
||||
|
||||
\sa moveTopLeft(), moveTo(), translated()
|
||||
*/
|
||||
@ -1829,7 +1829,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
Returns a copy of the rectangle that is translated \a dx along the
|
||||
x axis and \a dy along the y axis, relative to the current
|
||||
position. Positive values move the rectangle to the right and
|
||||
down.
|
||||
down. Both parameters must be finite.
|
||||
|
||||
\sa translate()
|
||||
*/
|
||||
@ -1860,8 +1860,8 @@ QRectF QRectF::normalized() const noexcept
|
||||
/*!
|
||||
\fn void QRectF::setRect(qreal x, qreal y, qreal width, qreal height)
|
||||
|
||||
Sets the coordinates of the rectangle's top-left corner to (\a x,
|
||||
\a y), and its size to the given \a width and \a height.
|
||||
Sets the coordinates of the rectangle's top-left corner to (\a x, \a y), and
|
||||
its size to the given \a width and \a height. All parameters must be finite.
|
||||
|
||||
\sa getRect(), setCoords()
|
||||
*/
|
||||
@ -1872,7 +1872,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
|
||||
Sets the coordinates of the rectangle's top-left corner to (\a x1,
|
||||
\a y1), and the coordinates of its bottom-right corner to (\a x2,
|
||||
\a y2).
|
||||
\a y2). All parameters must be finite.
|
||||
|
||||
\sa getCoords(), setRect()
|
||||
*/
|
||||
@ -1882,6 +1882,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
|
||||
Returns a new rectangle with \a dx1, \a dy1, \a dx2 and \a dy2
|
||||
added respectively to the existing coordinates of this rectangle.
|
||||
All parameters must be finite.
|
||||
|
||||
\sa adjust()
|
||||
*/
|
||||
@ -1889,7 +1890,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
/*! \fn void QRectF::adjust(qreal dx1, qreal dy1, qreal dx2, qreal dy2)
|
||||
|
||||
Adds \a dx1, \a dy1, \a dx2 and \a dy2 respectively to the
|
||||
existing coordinates of the rectangle.
|
||||
existing coordinates of the rectangle. All parameters must be finite.
|
||||
|
||||
\sa adjusted(), setRect()
|
||||
*/
|
||||
@ -1920,7 +1921,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
/*!
|
||||
\fn void QRectF::setWidth(qreal width)
|
||||
|
||||
Sets the width of the rectangle to the given \a width. The right
|
||||
Sets the width of the rectangle to the given finite \a width. The right
|
||||
edge is changed, but not the left one.
|
||||
|
||||
\sa width(), setSize()
|
||||
@ -1930,7 +1931,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
/*!
|
||||
\fn void QRectF::setHeight(qreal height)
|
||||
|
||||
Sets the height of the rectangle to the given \a height. The bottom
|
||||
Sets the height of the rectangle to the given finite \a height. The bottom
|
||||
edge is changed, but not the top one.
|
||||
|
||||
\sa height(), setSize()
|
||||
@ -1940,7 +1941,7 @@ QRectF QRectF::normalized() const noexcept
|
||||
/*!
|
||||
\fn void QRectF::setSize(const QSizeF &size)
|
||||
|
||||
Sets the size of the rectangle to the given \a size. The top-left
|
||||
Sets the size of the rectangle to the given finite \a size. The top-left
|
||||
corner is not moved.
|
||||
|
||||
\sa size(), setWidth(), setHeight()
|
||||
|
@ -769,7 +769,9 @@ constexpr inline void QRectF::moveTo(const QPointF &p) noexcept
|
||||
}
|
||||
|
||||
constexpr inline QRectF QRectF::translated(qreal dx, qreal dy) const noexcept
|
||||
{ return QRectF(xp + dx, yp + dy, w, h); }
|
||||
{
|
||||
return QRectF(xp + dx, yp + dy, w, h);
|
||||
}
|
||||
|
||||
constexpr inline QRectF QRectF::translated(const QPointF &p) const noexcept
|
||||
{ return QRectF(xp + p.x(), yp + p.y(), w, h); }
|
||||
@ -810,10 +812,17 @@ constexpr inline void QRectF::setCoords(qreal xp1, qreal yp1, qreal xp2, qreal y
|
||||
}
|
||||
|
||||
constexpr inline void QRectF::adjust(qreal xp1, qreal yp1, qreal xp2, qreal yp2) noexcept
|
||||
{ xp += xp1; yp += yp1; w += xp2 - xp1; h += yp2 - yp1; }
|
||||
{
|
||||
xp += xp1;
|
||||
yp += yp1;
|
||||
w += xp2 - xp1;
|
||||
h += yp2 - yp1;
|
||||
}
|
||||
|
||||
constexpr inline QRectF QRectF::adjusted(qreal xp1, qreal yp1, qreal xp2, qreal yp2) const noexcept
|
||||
{ return QRectF(xp + xp1, yp + yp1, w + xp2 - xp1, h + yp2 - yp1); }
|
||||
{
|
||||
return QRectF(xp + xp1, yp + yp1, w + xp2 - xp1, h + yp2 - yp1);
|
||||
}
|
||||
|
||||
constexpr inline void QRectF::setWidth(qreal aw) noexcept
|
||||
{ this->w = aw; }
|
||||
|
@ -526,7 +526,7 @@ QDebug operator<<(QDebug dbg, const QSize &s)
|
||||
/*!
|
||||
\fn QSizeF::QSizeF(qreal width, qreal height)
|
||||
|
||||
Constructs a size with the given \a width and \a height.
|
||||
Constructs a size with the given finite \a width and \a height.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -550,7 +550,7 @@ QDebug operator<<(QDebug dbg, const QSize &s)
|
||||
/*!
|
||||
\fn bool QSizeF::isValid() const
|
||||
|
||||
Returns \c true if both the width and height is equal to or greater
|
||||
Returns \c true if both the width and height are equal to or greater
|
||||
than 0; otherwise returns \c false.
|
||||
|
||||
\sa isNull(), isEmpty()
|
||||
@ -575,7 +575,7 @@ QDebug operator<<(QDebug dbg, const QSize &s)
|
||||
/*!
|
||||
\fn void QSizeF::setWidth(qreal width)
|
||||
|
||||
Sets the width to the given \a width.
|
||||
Sets the width to the given finite \a width.
|
||||
|
||||
\sa width(), rwidth(), setHeight()
|
||||
*/
|
||||
@ -583,7 +583,7 @@ QDebug operator<<(QDebug dbg, const QSize &s)
|
||||
/*!
|
||||
\fn void QSizeF::setHeight(qreal height)
|
||||
|
||||
Sets the height to the given \a height.
|
||||
Sets the height to the given finite \a height.
|
||||
|
||||
\sa height(), rheight(), setWidth()
|
||||
*/
|
||||
@ -734,7 +734,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const noexcept
|
||||
\fn QSizeF &QSizeF::operator*=(qreal factor)
|
||||
\overload
|
||||
|
||||
Multiplies both the width and height by the given \a factor and
|
||||
Multiplies both the width and height by the given finite \a factor and
|
||||
returns a reference to the size.
|
||||
|
||||
\sa scale()
|
||||
@ -780,7 +780,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const noexcept
|
||||
|
||||
\overload
|
||||
|
||||
Multiplies the given \a size by the given \a factor and returns
|
||||
Multiplies the given \a size by the given finite \a factor and returns
|
||||
the result.
|
||||
|
||||
\sa QSizeF::scale()
|
||||
@ -791,7 +791,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const noexcept
|
||||
|
||||
\overload
|
||||
|
||||
Multiplies the given \a size by the given \a factor and returns
|
||||
Multiplies the given \a size by the given finite \a factor and returns
|
||||
the result.
|
||||
*/
|
||||
|
||||
@ -800,8 +800,8 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const noexcept
|
||||
|
||||
\overload
|
||||
|
||||
Divides both the width and height by the given \a divisor and
|
||||
returns a reference to the size.
|
||||
Divides both the width and height by the given \a divisor and returns a
|
||||
reference to the size. The \a divisor must not be either zero or NaN.
|
||||
|
||||
\sa scale()
|
||||
*/
|
||||
@ -812,7 +812,7 @@ QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const noexcept
|
||||
\overload
|
||||
|
||||
Divides the given \a size by the given \a divisor and returns the
|
||||
result.
|
||||
result. The \a divisor must not be either zero or NaN.
|
||||
|
||||
\sa QSizeF::scale()
|
||||
*/
|
||||
|
@ -375,7 +375,7 @@ constexpr inline QSizeF &QSizeF::operator*=(qreal c) noexcept
|
||||
|
||||
inline QSizeF &QSizeF::operator/=(qreal c)
|
||||
{
|
||||
Q_ASSERT(!qFuzzyIsNull(c));
|
||||
Q_ASSERT(!qFuzzyIsNull(c) && qIsFinite(c));
|
||||
wd = wd / c;
|
||||
ht = ht / c;
|
||||
return *this;
|
||||
|
@ -56,6 +56,10 @@ QT_BEGIN_NAMESPACE
|
||||
\ingroup painting-3D
|
||||
\inmodule QtGui
|
||||
|
||||
Vectors are one of the main building blocks of 2D representation and
|
||||
drawing. They consist of two finite floating-point coordinates,
|
||||
traditionally called x and y.
|
||||
|
||||
The QVector2D class can also be used to represent vertices in 2D space.
|
||||
We therefore do not need to provide a separate vertex class.
|
||||
|
||||
@ -80,6 +84,7 @@ QT_BEGIN_NAMESPACE
|
||||
\fn QVector2D::QVector2D(float xpos, float ypos)
|
||||
|
||||
Constructs a vector with coordinates (\a xpos, \a ypos).
|
||||
Both coordinates must be finite.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -146,7 +151,7 @@ QT_BEGIN_NAMESPACE
|
||||
/*!
|
||||
\fn void QVector2D::setX(float x)
|
||||
|
||||
Sets the x coordinate of this point to the given \a x coordinate.
|
||||
Sets the x coordinate of this point to the given finite \a x coordinate.
|
||||
|
||||
\sa x(), setY()
|
||||
*/
|
||||
@ -154,7 +159,7 @@ QT_BEGIN_NAMESPACE
|
||||
/*!
|
||||
\fn void QVector2D::setY(float y)
|
||||
|
||||
Sets the y coordinate of this point to the given \a y coordinate.
|
||||
Sets the y coordinate of this point to the given finite \a y coordinate.
|
||||
|
||||
\sa y(), setX()
|
||||
*/
|
||||
@ -260,7 +265,7 @@ QT_BEGIN_NAMESPACE
|
||||
/*!
|
||||
\fn QVector2D &QVector2D::operator*=(float factor)
|
||||
|
||||
Multiplies this vector's coordinates by the given \a factor, and
|
||||
Multiplies this vector's coordinates by the given finite \a factor and
|
||||
returns a reference to this vector.
|
||||
|
||||
\sa operator/=()
|
||||
@ -276,8 +281,8 @@ QT_BEGIN_NAMESPACE
|
||||
/*!
|
||||
\fn QVector2D &QVector2D::operator/=(float divisor)
|
||||
|
||||
Divides this vector's coordinates by the given \a divisor, and
|
||||
returns a reference to this vector.
|
||||
Divides this vector's coordinates by the given \a divisor and returns a
|
||||
reference to this vector. The \a divisor must not be either zero or NaN.
|
||||
|
||||
\sa operator*=()
|
||||
*/
|
||||
@ -286,10 +291,12 @@ QT_BEGIN_NAMESPACE
|
||||
\fn QVector2D &QVector2D::operator/=(QVector2D vector)
|
||||
\since 5.5
|
||||
|
||||
Divides the components of this vector by the corresponding
|
||||
components in \a vector.
|
||||
Divides each component of this vector by the corresponding component of \a
|
||||
vector and returns a reference to this vector.
|
||||
|
||||
\sa operator*=()
|
||||
The \a vector must have no component that is either zero or NaN.
|
||||
|
||||
\sa operator*=(), operator/()
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -333,7 +340,7 @@ QT_BEGIN_NAMESPACE
|
||||
/*! //! friend
|
||||
\fn const QVector2D QVector2D::operator*(float factor, QVector2D vector)
|
||||
|
||||
Returns a copy of the given \a vector, multiplied by the given \a factor.
|
||||
Returns a copy of the given \a vector, multiplied by the given finite \a factor.
|
||||
|
||||
\sa QVector2D::operator*=()
|
||||
*/
|
||||
@ -341,7 +348,7 @@ QT_BEGIN_NAMESPACE
|
||||
/*! //! friend
|
||||
\fn const QVector2D QVector2D::operator*(QVector2D vector, float factor)
|
||||
|
||||
Returns a copy of the given \a vector, multiplied by the given \a factor.
|
||||
Returns a copy of the given \a vector, multiplied by the given finite \a factor.
|
||||
|
||||
\sa QVector2D::operator*=()
|
||||
*/
|
||||
@ -366,8 +373,10 @@ QT_BEGIN_NAMESPACE
|
||||
/*! //! friend
|
||||
\fn const QVector2D QVector2D::operator/(QVector2D vector, float divisor)
|
||||
|
||||
Returns the QVector2D object formed by dividing all three components of
|
||||
the given \a vector by the given \a divisor.
|
||||
Returns the QVector2D object formed by dividing each component of the given
|
||||
\a vector by the given \a divisor.
|
||||
|
||||
The \a divisor must not be either zero or NaN.
|
||||
|
||||
\sa QVector2D::operator/=()
|
||||
*/
|
||||
@ -376,8 +385,10 @@ QT_BEGIN_NAMESPACE
|
||||
\fn const QVector2D QVector2D::operator/(QVector2D vector, QVector2D divisor)
|
||||
\since 5.5
|
||||
|
||||
Returns the QVector2D object formed by dividing components of the given
|
||||
\a vector by a respective components of the given \a divisor.
|
||||
Returns the QVector2D object formed by dividing each component of the given
|
||||
\a vector by the corresponding component of the given \a divisor.
|
||||
|
||||
The \a divisor must have no component that is either zero or NaN.
|
||||
|
||||
\sa QVector2D::operator/=()
|
||||
*/
|
||||
@ -481,6 +492,7 @@ QDataStream &operator>>(QDataStream &stream, QVector2D &vector)
|
||||
float x, y;
|
||||
stream >> x;
|
||||
stream >> y;
|
||||
Q_ASSERT(qIsFinite(x) && qIsFinite(y));
|
||||
vector.setX(x);
|
||||
vector.setY(y);
|
||||
return stream;
|
||||
@ -502,8 +514,8 @@ QDataStream &operator>>(QDataStream &stream, QVector2D &vector)
|
||||
\inmodule QtGui
|
||||
|
||||
Vectors are one of the main building blocks of 3D representation and
|
||||
drawing. They consist of three coordinates, traditionally called
|
||||
x, y, and z.
|
||||
drawing. They consist of three finite floating-point coordinates,
|
||||
traditionally called x, y, and z.
|
||||
|
||||
The QVector3D class can also be used to represent vertices in 3D space.
|
||||
We therefore do not need to provide a separate vertex class.
|
||||
@ -529,6 +541,7 @@ QDataStream &operator>>(QDataStream &stream, QVector2D &vector)
|
||||
\fn QVector3D::QVector3D(float xpos, float ypos, float zpos)
|
||||
|
||||
Constructs a vector with coordinates (\a xpos, \a ypos, \a zpos).
|
||||
All parameters must be finite.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -560,7 +573,7 @@ QDataStream &operator>>(QDataStream &stream, QVector2D &vector)
|
||||
\fn QVector3D::QVector3D(QVector2D vector, float zpos)
|
||||
|
||||
Constructs a 3D vector from the specified 2D \a vector. The z
|
||||
coordinate is set to \a zpos.
|
||||
coordinate is set to \a zpos, which must be finite.
|
||||
|
||||
\sa toVector2D()
|
||||
*/
|
||||
@ -613,7 +626,7 @@ QDataStream &operator>>(QDataStream &stream, QVector2D &vector)
|
||||
/*!
|
||||
\fn void QVector3D::setX(float x)
|
||||
|
||||
Sets the x coordinate of this point to the given \a x coordinate.
|
||||
Sets the x coordinate of this point to the given finite \a x coordinate.
|
||||
|
||||
\sa x(), setY(), setZ()
|
||||
*/
|
||||
@ -621,7 +634,7 @@ QDataStream &operator>>(QDataStream &stream, QVector2D &vector)
|
||||
/*!
|
||||
\fn void QVector3D::setY(float y)
|
||||
|
||||
Sets the y coordinate of this point to the given \a y coordinate.
|
||||
Sets the y coordinate of this point to the given finite \a y coordinate.
|
||||
|
||||
\sa y(), setX(), setZ()
|
||||
*/
|
||||
@ -629,7 +642,7 @@ QDataStream &operator>>(QDataStream &stream, QVector2D &vector)
|
||||
/*!
|
||||
\fn void QVector3D::setZ(float z)
|
||||
|
||||
Sets the z coordinate of this point to the given \a z coordinate.
|
||||
Sets the z coordinate of this point to the given finite \a z coordinate.
|
||||
|
||||
\sa z(), setX(), setY()
|
||||
*/
|
||||
@ -695,7 +708,7 @@ QDataStream &operator>>(QDataStream &stream, QVector2D &vector)
|
||||
/*!
|
||||
\fn QVector3D &QVector3D::operator*=(float factor)
|
||||
|
||||
Multiplies this vector's coordinates by the given \a factor, and
|
||||
Multiplies this vector's coordinates by the given finite \a factor and
|
||||
returns a reference to this vector.
|
||||
|
||||
\sa operator/=()
|
||||
@ -717,8 +730,8 @@ QDataStream &operator>>(QDataStream &stream, QVector2D &vector)
|
||||
/*!
|
||||
\fn QVector3D &QVector3D::operator/=(float divisor)
|
||||
|
||||
Divides this vector's coordinates by the given \a divisor, and
|
||||
returns a reference to this vector.
|
||||
Divides this vector's coordinates by the given \a divisor, and returns a
|
||||
reference to this vector. The \a divisor must not be either zero or NaN.
|
||||
|
||||
\sa operator*=()
|
||||
*/
|
||||
@ -727,8 +740,10 @@ QDataStream &operator>>(QDataStream &stream, QVector2D &vector)
|
||||
\fn QVector3D &QVector3D::operator/=(QVector3D vector)
|
||||
\since 5.5
|
||||
|
||||
Divides the components of this vector by the corresponding
|
||||
components in \a vector.
|
||||
Divides each component of this vector by the corresponding component in \a
|
||||
vector and returns a reference to this vector.
|
||||
|
||||
The \a vector must have no component that is either zero or NaN.
|
||||
|
||||
\sa operator*=()
|
||||
*/
|
||||
@ -751,8 +766,8 @@ QDataStream &operator>>(QDataStream &stream, QVector2D &vector)
|
||||
/*!
|
||||
\fn QVector3D QVector3D::normal(QVector3D v1, QVector3D v2)
|
||||
|
||||
Returns the normal vector of a plane defined by vectors \a v1 and \a v2,
|
||||
normalized to be a unit vector.
|
||||
Returns the unit normal vector of a plane spanned by vectors \a v1 and \a
|
||||
v2, which must not be parallel to one another.
|
||||
|
||||
Use crossProduct() to compute the cross-product of \a v1 and \a v2 if you
|
||||
do not need the result to be normalized to a unit vector.
|
||||
@ -763,8 +778,8 @@ QDataStream &operator>>(QDataStream &stream, QVector2D &vector)
|
||||
/*!
|
||||
\fn QVector3D QVector3D::normal(QVector3D v1, QVector3D v2, QVector3D v3)
|
||||
|
||||
Returns the normal vector of a plane defined by vectors
|
||||
\a v2 - \a v1 and \a v3 - \a v1, normalized to be a unit vector.
|
||||
Returns the unit normal vector of a plane spanned by vectors \a v2 - \a v1
|
||||
and \a v3 - \a v1, which must not be parallel to one another.
|
||||
|
||||
Use crossProduct() to compute the cross-product of \a v2 - \a v1 and
|
||||
\a v3 - \a v1 if you do not need the result to be normalized to a
|
||||
@ -922,7 +937,7 @@ QVector3D QVector3D::unproject(const QMatrix4x4 &modelView, const QMatrix4x4 &pr
|
||||
/*! //! friend
|
||||
\fn const QVector3D QVector3D::operator*(float factor, QVector3D vector)
|
||||
|
||||
Returns a copy of the given \a vector, multiplied by the given \a factor.
|
||||
Returns a copy of the given \a vector, multiplied by the given finite \a factor.
|
||||
|
||||
\sa QVector3D::operator*=()
|
||||
*/
|
||||
@ -930,7 +945,7 @@ QVector3D QVector3D::unproject(const QMatrix4x4 &modelView, const QMatrix4x4 &pr
|
||||
/*! //! friend
|
||||
\fn const QVector3D QVector3D::operator*(QVector3D vector, float factor)
|
||||
|
||||
Returns a copy of the given \a vector, multiplied by the given \a factor.
|
||||
Returns a copy of the given \a vector, multiplied by the given finite \a factor.
|
||||
|
||||
\sa QVector3D::operator*=()
|
||||
*/
|
||||
@ -958,8 +973,10 @@ QVector3D QVector3D::unproject(const QMatrix4x4 &modelView, const QMatrix4x4 &pr
|
||||
/*! //! friend
|
||||
\fn const QVector3D QVector3D::operator/(QVector3D vector, float divisor)
|
||||
|
||||
Returns the QVector3D object formed by dividing all three components of
|
||||
the given \a vector by the given \a divisor.
|
||||
Returns the QVector3D object formed by dividing each component of the given
|
||||
\a vector by the given \a divisor.
|
||||
|
||||
The \a divisor must not be either zero or NaN.
|
||||
|
||||
\sa QVector3D::operator/=()
|
||||
*/
|
||||
@ -968,8 +985,10 @@ QVector3D QVector3D::unproject(const QMatrix4x4 &modelView, const QMatrix4x4 &pr
|
||||
\fn const QVector3D QVector3D::operator/(QVector3D vector, QVector3D divisor)
|
||||
\since 5.5
|
||||
|
||||
Returns the QVector3D object formed by dividing components of the given
|
||||
\a vector by a respective components of the given \a divisor.
|
||||
Returns the QVector3D object formed by dividing each component of the given
|
||||
\a vector by the corresponding component of the given \a divisor.
|
||||
|
||||
The \a divisor must have no component that is either zero or NaN.
|
||||
|
||||
\sa QVector3D::operator/=()
|
||||
*/
|
||||
@ -1100,6 +1119,7 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector)
|
||||
stream >> x;
|
||||
stream >> y;
|
||||
stream >> z;
|
||||
Q_ASSERT(qIsFinite(x) && qIsFinite(y) && qIsFinite(z));
|
||||
vector.setX(x);
|
||||
vector.setY(y);
|
||||
vector.setZ(z);
|
||||
@ -1121,6 +1141,10 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector)
|
||||
\ingroup painting-3D
|
||||
\inmodule QtGui
|
||||
|
||||
Vectors are one of the main building blocks of 4D affine representations of
|
||||
3D space. They consist of four finite floating-point coordinates,
|
||||
traditionally called x, y, z and w.
|
||||
|
||||
The QVector4D class can also be used to represent vertices in 4D space.
|
||||
We therefore do not need to provide a separate vertex class.
|
||||
|
||||
@ -1145,6 +1169,7 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector)
|
||||
\fn QVector4D::QVector4D(float xpos, float ypos, float zpos, float wpos)
|
||||
|
||||
Constructs a vector with coordinates (\a xpos, \a ypos, \a zpos, \a wpos).
|
||||
All parameters must be finite.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -1176,7 +1201,8 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector)
|
||||
\fn QVector4D::QVector4D(QVector2D vector, float zpos, float wpos)
|
||||
|
||||
Constructs a 4D vector from the specified 2D \a vector. The z
|
||||
and w coordinates are set to \a zpos and \a wpos respectively.
|
||||
and w coordinates are set to \a zpos and \a wpos respectively,
|
||||
each of which must be finite.
|
||||
|
||||
\sa toVector2D()
|
||||
*/
|
||||
@ -1198,7 +1224,7 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector)
|
||||
\fn QVector4D::QVector4D(QVector3D vector, float wpos)
|
||||
|
||||
Constructs a 4D vector from the specified 3D \a vector. The w
|
||||
coordinate is set to \a wpos.
|
||||
coordinate is set to \a wpos, which must be finite.
|
||||
|
||||
\sa toVector3D()
|
||||
*/
|
||||
@ -1247,7 +1273,7 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector)
|
||||
/*!
|
||||
\fn void QVector4D::setX(float x)
|
||||
|
||||
Sets the x coordinate of this point to the given \a x coordinate.
|
||||
Sets the x coordinate of this point to the given finite \a x coordinate.
|
||||
|
||||
\sa x(), setY(), setZ(), setW()
|
||||
*/
|
||||
@ -1255,7 +1281,7 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector)
|
||||
/*!
|
||||
\fn void QVector4D::setY(float y)
|
||||
|
||||
Sets the y coordinate of this point to the given \a y coordinate.
|
||||
Sets the y coordinate of this point to the given finite \a y coordinate.
|
||||
|
||||
\sa y(), setX(), setZ(), setW()
|
||||
*/
|
||||
@ -1263,7 +1289,7 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector)
|
||||
/*!
|
||||
\fn void QVector4D::setZ(float z)
|
||||
|
||||
Sets the z coordinate of this point to the given \a z coordinate.
|
||||
Sets the z coordinate of this point to the given finite \a z coordinate.
|
||||
|
||||
\sa z(), setX(), setY(), setW()
|
||||
*/
|
||||
@ -1271,7 +1297,7 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector)
|
||||
/*!
|
||||
\fn void QVector4D::setW(float w)
|
||||
|
||||
Sets the w coordinate of this point to the given \a w coordinate.
|
||||
Sets the w coordinate of this point to the given finite \a w coordinate.
|
||||
|
||||
\sa w(), setX(), setY(), setZ()
|
||||
*/
|
||||
@ -1355,7 +1381,7 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector)
|
||||
/*!
|
||||
\fn QVector4D &QVector4D::operator*=(float factor)
|
||||
|
||||
Multiplies this vector's coordinates by the given \a factor, and
|
||||
Multiplies this vector's coordinates by the given finite \a factor, and
|
||||
returns a reference to this vector.
|
||||
|
||||
\sa operator/=()
|
||||
@ -1371,8 +1397,8 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector)
|
||||
/*!
|
||||
\fn QVector4D &QVector4D::operator/=(float divisor)
|
||||
|
||||
Divides this vector's coordinates by the given \a divisor, and
|
||||
returns a reference to this vector.
|
||||
Divides this vector's coordinates by the given \a divisor, and returns a
|
||||
reference to this vector. The \a divisor must not be either zero or NaN.
|
||||
|
||||
\sa operator*=()
|
||||
*/
|
||||
@ -1381,8 +1407,10 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector)
|
||||
\fn QVector4D &QVector4D::operator/=(QVector4D vector)
|
||||
\since 5.5
|
||||
|
||||
Divides the components of this vector by the corresponding
|
||||
components in \a vector.
|
||||
Divides each component of this vector by the corresponding component of \a
|
||||
vector and returns a reference to this vector.
|
||||
|
||||
The \a vector must have no component that is either zero or NaN.
|
||||
|
||||
\sa operator*=()
|
||||
*/
|
||||
@ -1463,8 +1491,10 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector)
|
||||
/*! //! friend
|
||||
\fn const QVector4D QVector4D::operator/(QVector4D vector, float divisor)
|
||||
|
||||
Returns the QVector4D object formed by dividing all four components of
|
||||
the given \a vector by the given \a divisor.
|
||||
Returns the QVector4D object formed by dividing each component of the given
|
||||
\a vector by the given \a divisor.
|
||||
|
||||
The \a divisor must not be either zero or NaN.
|
||||
|
||||
\sa QVector4D::operator/=()
|
||||
*/
|
||||
@ -1473,8 +1503,10 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector)
|
||||
\fn const QVector4D QVector4D::operator/(QVector4D vector, QVector4D divisor)
|
||||
\since 5.5
|
||||
|
||||
Returns the QVector4D object formed by dividing components of the given
|
||||
\a vector by a respective components of the given \a divisor.
|
||||
Returns the QVector4D object formed by dividing each component of the given
|
||||
\a vector by the corresponding component of the given \a divisor.
|
||||
|
||||
The \a divisor must have no component that is either zero or NaN.
|
||||
|
||||
\sa QVector4D::operator/=()
|
||||
*/
|
||||
@ -1611,6 +1643,7 @@ QDataStream &operator>>(QDataStream &stream, QVector4D &vector)
|
||||
stream >> y;
|
||||
stream >> z;
|
||||
stream >> w;
|
||||
Q_ASSERT(qIsFinite(x) && qIsFinite(y) && qIsFinite(z) && qIsFinite(w));
|
||||
vector.setX(x);
|
||||
vector.setY(y);
|
||||
vector.setZ(z);
|
||||
|
@ -147,11 +147,14 @@ QT_WARNING_POP
|
||||
|
||||
constexpr friend inline QVector2D operator/(QVector2D vector, float divisor)
|
||||
{
|
||||
Q_ASSERT(divisor < 0 || divisor > 0);
|
||||
return QVector2D(vector.v[0] / divisor, vector.v[1] / divisor);
|
||||
}
|
||||
|
||||
constexpr friend inline QVector2D operator/(QVector2D vector, QVector2D divisor)
|
||||
{
|
||||
Q_ASSERT(divisor.v[0] < 0 || divisor.v[0] > 0);
|
||||
Q_ASSERT(divisor.v[1] < 0 || divisor.v[1] > 0);
|
||||
return QVector2D(vector.v[0] / divisor.v[0], vector.v[1] / divisor.v[1]);
|
||||
}
|
||||
|
||||
@ -288,12 +291,17 @@ QT_WARNING_POP
|
||||
|
||||
constexpr friend inline QVector3D operator/(QVector3D vector, float divisor)
|
||||
{
|
||||
Q_ASSERT(divisor < 0 || divisor > 0);
|
||||
return QVector3D(vector.v[0] / divisor, vector.v[1] / divisor, vector.v[2] / divisor);
|
||||
}
|
||||
|
||||
constexpr friend inline QVector3D operator/(QVector3D vector, QVector3D divisor)
|
||||
{
|
||||
return QVector3D(vector.v[0] / divisor.v[0], vector.v[1] / divisor.v[1], vector.v[2] / divisor.v[2]);
|
||||
Q_ASSERT(divisor.v[0] > 0 || divisor.v[0] < 0);
|
||||
Q_ASSERT(divisor.v[1] > 0 || divisor.v[1] < 0);
|
||||
Q_ASSERT(divisor.v[2] > 0 || divisor.v[2] < 0);
|
||||
return QVector3D(vector.v[0] / divisor.v[0], vector.v[1] / divisor.v[1],
|
||||
vector.v[2] / divisor.v[2]);
|
||||
}
|
||||
|
||||
friend Q_GUI_EXPORT bool qFuzzyCompare(QVector3D v1, QVector3D v2) noexcept;
|
||||
@ -422,12 +430,18 @@ QT_WARNING_POP
|
||||
|
||||
constexpr friend inline QVector4D operator/(QVector4D vector, float divisor)
|
||||
{
|
||||
Q_ASSERT(divisor < 0 || divisor > 0);
|
||||
return QVector4D(vector.v[0] / divisor, vector.v[1] / divisor, vector.v[2] / divisor, vector.v[3] / divisor);
|
||||
}
|
||||
|
||||
constexpr friend inline QVector4D operator/(QVector4D vector, QVector4D divisor)
|
||||
{
|
||||
return QVector4D(vector.v[0] / divisor.v[0], vector.v[1] / divisor.v[1], vector.v[2] / divisor.v[2], vector.v[3] / divisor.v[3]);
|
||||
Q_ASSERT(divisor.v[0] > 0 || divisor.v[0] < 0);
|
||||
Q_ASSERT(divisor.v[1] > 0 || divisor.v[1] < 0);
|
||||
Q_ASSERT(divisor.v[2] > 0 || divisor.v[2] < 0);
|
||||
Q_ASSERT(divisor.v[3] > 0 || divisor.v[3] < 0);
|
||||
return QVector4D(vector.v[0] / divisor.v[0], vector.v[1] / divisor.v[1],
|
||||
vector.v[2] / divisor.v[2], vector.v[3] / divisor.v[3]);
|
||||
}
|
||||
|
||||
friend Q_GUI_EXPORT bool qFuzzyCompare(QVector4D v1, QVector4D v2) noexcept;
|
||||
@ -576,6 +590,7 @@ constexpr inline QVector2D &QVector2D::operator*=(QVector2D vector) noexcept
|
||||
|
||||
constexpr inline QVector2D &QVector2D::operator/=(float divisor)
|
||||
{
|
||||
Q_ASSERT(divisor < 0 || divisor > 0);
|
||||
v[0] /= divisor;
|
||||
v[1] /= divisor;
|
||||
return *this;
|
||||
@ -583,6 +598,8 @@ constexpr inline QVector2D &QVector2D::operator/=(float divisor)
|
||||
|
||||
constexpr inline QVector2D &QVector2D::operator/=(QVector2D vector)
|
||||
{
|
||||
Q_ASSERT(vector.v[0] > 0 || vector.v[0] < 0);
|
||||
Q_ASSERT(vector.v[1] > 0 || vector.v[1] < 0);
|
||||
v[0] /= vector.v[0];
|
||||
v[1] /= vector.v[1];
|
||||
return *this;
|
||||
@ -736,6 +753,7 @@ constexpr inline QVector3D &QVector3D::operator*=(QVector3D vector) noexcept
|
||||
|
||||
constexpr inline QVector3D &QVector3D::operator/=(float divisor)
|
||||
{
|
||||
Q_ASSERT(divisor < 0 || divisor > 0);
|
||||
v[0] /= divisor;
|
||||
v[1] /= divisor;
|
||||
v[2] /= divisor;
|
||||
@ -744,6 +762,9 @@ constexpr inline QVector3D &QVector3D::operator/=(float divisor)
|
||||
|
||||
constexpr inline QVector3D &QVector3D::operator/=(QVector3D vector)
|
||||
{
|
||||
Q_ASSERT(vector.v[0] > 0 || vector.v[0] < 0);
|
||||
Q_ASSERT(vector.v[1] > 0 || vector.v[1] < 0);
|
||||
Q_ASSERT(vector.v[2] > 0 || vector.v[2] < 0);
|
||||
v[0] /= vector.v[0];
|
||||
v[1] /= vector.v[1];
|
||||
v[2] /= vector.v[2];
|
||||
@ -947,6 +968,7 @@ constexpr inline QVector4D &QVector4D::operator*=(QVector4D vector) noexcept
|
||||
|
||||
constexpr inline QVector4D &QVector4D::operator/=(float divisor)
|
||||
{
|
||||
Q_ASSERT(divisor < 0 || divisor > 0);
|
||||
v[0] /= divisor;
|
||||
v[1] /= divisor;
|
||||
v[2] /= divisor;
|
||||
@ -956,6 +978,10 @@ constexpr inline QVector4D &QVector4D::operator/=(float divisor)
|
||||
|
||||
constexpr inline QVector4D &QVector4D::operator/=(QVector4D vector)
|
||||
{
|
||||
Q_ASSERT(vector.v[0] > 0 || vector.v[0] < 0);
|
||||
Q_ASSERT(vector.v[1] > 0 || vector.v[1] < 0);
|
||||
Q_ASSERT(vector.v[2] > 0 || vector.v[2] < 0);
|
||||
Q_ASSERT(vector.v[3] > 0 || vector.v[3] < 0);
|
||||
v[0] /= vector.v[0];
|
||||
v[1] /= vector.v[1];
|
||||
v[2] /= vector.v[2];
|
||||
|
Loading…
x
Reference in New Issue
Block a user