diff options
Diffstat (limited to 'src/gui/math3d/qvector4d.cpp')
-rw-r--r-- | src/gui/math3d/qvector4d.cpp | 57 |
1 files changed, 50 insertions, 7 deletions
diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp index a28d2a1..ae03bc7 100644 --- a/src/gui/math3d/qvector4d.cpp +++ b/src/gui/math3d/qvector4d.cpp @@ -57,10 +57,6 @@ QT_BEGIN_NAMESPACE The QVector4D class can also be used to represent vertices in 4D space. We therefore do not need to provide a separate vertex class. - The coordinates are stored internally using the most efficient - representation for the GL rendering engine, which will be either - floating-point or fixed-point. - \sa QQuaternion, QVector2D, QVector3D */ @@ -488,7 +484,8 @@ QVector3D QVector4D::toVector3DAffine() const /*! \fn QPoint QVector4D::toPoint() const - Returns the QPoint form of this 4D vector. + Returns the QPoint form of this 4D vector. The z and w coordinates + are dropped. \sa toPointF(), toVector2D() */ @@ -496,7 +493,8 @@ QVector3D QVector4D::toVector3DAffine() const /*! \fn QPointF QVector4D::toPointF() const - Returns the QPointF form of this 4D vector. + Returns the QPointF form of this 4D vector. The z and w coordinates + are dropped. \sa toPoint(), toVector2D() */ @@ -513,6 +511,51 @@ QDebug operator<<(QDebug dbg, const QVector4D &vector) #endif -#endif +#ifndef QT_NO_DATASTREAM + +/*! + \fn QDataStream &operator<<(QDataStream &stream, const QVector4D &vector) + \relates QVector4D + + Writes the given \a vector to the given \a stream and returns a + reference to the stream. + + \sa {Format of the QDataStream Operators} +*/ + +QDataStream &operator<<(QDataStream &stream, const QVector4D &vector) +{ + stream << double(vector.x()) << double(vector.y()) + << double(vector.z()) << double(vector.w()); + return stream; +} + +/*! + \fn QDataStream &operator>>(QDataStream &stream, QVector4D &vector) + \relates QVector4D + + Reads a 4D vector from the given \a stream into the given \a vector + and returns a reference to the stream. + + \sa {Format of the QDataStream Operators} +*/ + +QDataStream &operator>>(QDataStream &stream, QVector4D &vector) +{ + double x, y, z, w; + stream >> x; + stream >> y; + stream >> z; + stream >> w; + vector.setX(qreal(x)); + vector.setY(qreal(y)); + vector.setZ(qreal(z)); + vector.setW(qreal(w)); + return stream; +} + +#endif // QT_NO_DATASTREAM + +#endif // QT_NO_VECTOR4D QT_END_NAMESPACE |