summaryrefslogtreecommitdiffstats
path: root/src/gui/math3d/qvector3d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/math3d/qvector3d.cpp')
-rw-r--r--src/gui/math3d/qvector3d.cpp51
1 files changed, 48 insertions, 3 deletions
diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp
index 95550cde2..c1f5a3e51 100644
--- a/src/gui/math3d/qvector3d.cpp
+++ b/src/gui/math3d/qvector3d.cpp
@@ -513,7 +513,8 @@ QVector4D QVector3D::toVector4D() const
/*!
\fn QPoint QVector3D::toPoint() const
- Returns the QPoint form of this 3D vector.
+ Returns the QPoint form of this 3D vector. The z coordinate
+ is dropped.
\sa toPointF(), toVector2D()
*/
@@ -521,7 +522,8 @@ QVector4D QVector3D::toVector4D() const
/*!
\fn QPointF QVector3D::toPointF() const
- Returns the QPointF form of this 3D vector.
+ Returns the QPointF form of this 3D vector. The z coordinate
+ is dropped.
\sa toPoint(), toVector2D()
*/
@@ -558,6 +560,49 @@ QDebug operator<<(QDebug dbg, const QVector3D &vector)
#endif
-#endif
+#ifndef QT_NO_DATASTREAM
+
+/*!
+ \fn QDataStream &operator<<(QDataStream &stream, const QVector3D &vector)
+ \relates QVector3D
+
+ 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 QVector3D &vector)
+{
+ stream << double(vector.x()) << double(vector.y())
+ << double(vector.z());
+ return stream;
+}
+
+/*!
+ \fn QDataStream &operator>>(QDataStream &stream, QVector3D &vector)
+ \relates QVector3D
+
+ Reads a 3D 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, QVector3D &vector)
+{
+ double x, y, z;
+ stream >> x;
+ stream >> y;
+ stream >> z;
+ vector.setX(qreal(x));
+ vector.setY(qreal(y));
+ vector.setZ(qreal(z));
+ return stream;
+}
+
+#endif // QT_NO_DATASTREAM
+
+#endif // QT_NO_VECTOR3D
QT_END_NAMESPACE