From 0aa7425f1581b169f5d06a2818597331ad1de272 Mon Sep 17 00:00:00 2001 From: John Tytgat Date: Wed, 11 May 2011 22:31:36 +0200 Subject: [PATCH] fix bug #260: broken Qt support for Transform (transplanted from 84c8b6d5c58c8e09c53356287bdfc8bc730492a0 ) --- Eigen/src/Geometry/Transform.h | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index d8ec8236e..19d012572 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -672,7 +672,7 @@ Transform::Transform(const QMatrix& other) * * This function is available only if the token EIGEN_QT_SUPPORT is defined. */ -template +template Transform& Transform::operator=(const QMatrix& other) { EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE) @@ -718,9 +718,13 @@ Transform& Transform::operator { check_template_params(); EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE) - m_matrix << other.m11(), other.m21(), other.dx(), - other.m12(), other.m22(), other.dy(), - other.m13(), other.m23(), other.m33(); + if (Mode == int(AffineCompact)) + m_matrix << other.m11(), other.m21(), other.dx(), + other.m12(), other.m22(), other.dy(); + else + m_matrix << other.m11(), other.m21(), other.dx(), + other.m12(), other.m22(), other.dy(), + other.m13(), other.m23(), other.m33(); return *this; } @@ -732,9 +736,14 @@ template QTransform Transform::toQTransform(void) const { EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE) - return QTransform(matrix.coeff(0,0), matrix.coeff(1,0), matrix.coeff(2,0) - matrix.coeff(0,1), matrix.coeff(1,1), matrix.coeff(2,1) - matrix.coeff(0,2), matrix.coeff(1,2), matrix.coeff(2,2)); + if (Mode == int(AffineCompact)) + return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0), + m_matrix.coeff(0,1), m_matrix.coeff(1,1), + m_matrix.coeff(0,2), m_matrix.coeff(1,2)); + else + return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0), m_matrix.coeff(2,0), + m_matrix.coeff(0,1), m_matrix.coeff(1,1), m_matrix.coeff(2,1), + m_matrix.coeff(0,2), m_matrix.coeff(1,2), m_matrix.coeff(2,2)); } #endif