From 6858ce448718db1cc7c76535cac82672ad1d7664 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 20 Aug 2009 09:06:18 +1000 Subject: Remove QGraphicsTransform::project() QMatrix4x4::toTransform() now does what project() used to do. Reviewed-by: trustme --- src/gui/graphicsview/qgraphicsitem_p.h | 2 +- src/gui/graphicsview/qgraphicstransform.cpp | 31 +--------------------- src/gui/graphicsview/qgraphicstransform.h | 2 -- .../qgraphicstransform/tst_qgraphicstransform.cpp | 4 +-- 4 files changed, 4 insertions(+), 35 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 38cb757..eedc4a3 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -507,7 +507,7 @@ struct QGraphicsItemPrivate::TransformData x.rotate(rotation, 0, 0, 1); x.scale(scale); x.translate(-xOrigin, -yOrigin); - QTransform t = QGraphicsTransform::project(x); + QTransform t = x.toTransform(); // project the 3D matrix back to 2D. if (postmultiplyTransform) t *= *postmultiplyTransform; return t; diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp index b486438..585e0f9 100644 --- a/src/gui/graphicsview/qgraphicstransform.cpp +++ b/src/gui/graphicsview/qgraphicstransform.cpp @@ -149,38 +149,9 @@ QGraphicsTransform::QGraphicsTransform(QGraphicsTransformPrivate &p, QObject *pa It applies this transformation to \a matrix. - \sa QGraphicsItem::transform(), project() + \sa QGraphicsItem::transform(), QMatrix4x4::toTransform() */ -static const qreal inv_dist_to_plane = 1. / 1024.; - -/*! - Projects \a matrix into a 2D transformation that has the same - effect as applying \a matrix and then projecting the co-ordinates - to two dimensions. - - \sa applyTo() -*/ -QTransform QGraphicsTransform::project(const QMatrix4x4& matrix) -{ - // The following projection matrix is pre-multiplied with "matrix": - // | 1 0 0 0 | - // | 0 1 0 0 | - // | 0 0 1 0 | - // | 0 0 d 1 | - // where d = -1 / 1024. This projection is consistent with the - // Qt::XAxis and Qt::YAxis rotations of QTransform::rotate(). - // After projection, row 3 and column 3 are dropped to form - // the final QTransform. - return QTransform - (matrix(0, 0), matrix(1, 0), - matrix(3, 0) - matrix(2, 0) * inv_dist_to_plane, - matrix(0, 1), matrix(1, 1), - matrix(3, 1) - matrix(2, 1) * inv_dist_to_plane, - matrix(0, 3), matrix(1, 3), - matrix(3, 3) - matrix(2, 3) * inv_dist_to_plane); -} - /*! Notifies that this transform operation has changed its parameters in such a way that applyTo() will return a different result than before. diff --git a/src/gui/graphicsview/qgraphicstransform.h b/src/gui/graphicsview/qgraphicstransform.h index 8ffcbbb..d6d5b79 100644 --- a/src/gui/graphicsview/qgraphicstransform.h +++ b/src/gui/graphicsview/qgraphicstransform.h @@ -65,8 +65,6 @@ public: virtual void applyTo(QMatrix4x4 *matrix) const = 0; - static QTransform project(const QMatrix4x4& matrix); - protected Q_SLOTS: void update(); diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp index 029c182..d3d511a 100644 --- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp +++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp @@ -88,7 +88,7 @@ static QTransform transform2D(const QGraphicsTransform& t) { QMatrix4x4 m; t.applyTo(&m); - return QGraphicsTransform::project(m); + return m.toTransform(); } void tst_QGraphicsTransform::scale() @@ -148,7 +148,7 @@ void tst_QGraphicsTransform::scale() // Because the origin has a non-zero z, mapping (4, 5) in 2D // will introduce a projective component into the result. - QTransform t3 = QGraphicsTransform::project(t2); + QTransform t3 = t2.toTransform(); QCOMPARE(t3.map(QPointF(4, 5)), QPointF(31 / t3.m33(), 8 / t3.m33())); } -- cgit v0.12