From bda3e70c95457931ca58a82d6a078fc61d2a3c3b Mon Sep 17 00:00:00 2001
From: Ansgar Philippsen <ansgar.philippsen@gmail.com>
Date: Fri, 22 Apr 2011 10:30:48 -0400
Subject: [PATCH] extended mol transform interface to accept pre-made mat4

---
 modules/mol/base/pymod/wrap_mol.cc | 11 ++++++-----
 modules/mol/base/src/transform.cc  |  7 ++++++-
 modules/mol/base/src/transform.hh  |  3 ++-
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/modules/mol/base/pymod/wrap_mol.cc b/modules/mol/base/pymod/wrap_mol.cc
index 7055b2f78..ee56770f1 100644
--- a/modules/mol/base/pymod/wrap_mol.cc
+++ b/modules/mol/base/pymod/wrap_mol.cc
@@ -72,18 +72,19 @@ BOOST_PYTHON_MODULE(_mol)
   class_<Transform>("Transform", init<>())
     .def(init<const Transform&>()) // shouldn't this be there automatically ?
     .def("GetMatrix",&Transform::GetMatrix)
-	.add_property("matrix",&Transform::GetMatrix)
+    .def("SetMatrix",&Transform::SetMatrix)
+    .add_property("matrix",&Transform::GetMatrix,&Transform::SetMatrix)
     .def("GetTransposedMatrix",&Transform::GetTransposedMatrix)
- 	.add_property("tmatrix",&Transform::GetTransposedMatrix)
+    .add_property("tmatrix",&Transform::GetTransposedMatrix)
     .def("SetTrans",&Transform::SetTrans)
     .def("GetTrans",&Transform::GetTrans)
-	.add_property("trans",&Transform::GetTrans,&Transform::SetTrans)
+    .add_property("trans",&Transform::GetTrans,&Transform::SetTrans)
     .def("SetCenter",&Transform::SetCenter)
     .def("GetCenter",&Transform::GetCenter)
-	.add_property("center",&Transform::GetCenter,&Transform::SetCenter)
+    .add_property("center",&Transform::GetCenter,&Transform::SetCenter)
     .def("SetRot",&Transform::SetRot)
     .def("GetRot",&Transform::GetRot)
-	.add_property("rot",&Transform::GetRot,&Transform::SetRot)
+    .add_property("rot",&Transform::GetRot,&Transform::SetRot)
     .def("ApplyXAxisRotation",&Transform::ApplyXAxisRotation)
     .def("ApplyYAxisRotation",&Transform::ApplyYAxisRotation)
     .def("ApplyZAxisRotation",&Transform::ApplyZAxisRotation)
diff --git a/modules/mol/base/src/transform.cc b/modules/mol/base/src/transform.cc
index 611c9111b..ffee262de 100644
--- a/modules/mol/base/src/transform.cc
+++ b/modules/mol/base/src/transform.cc
@@ -42,12 +42,17 @@ Mat4 Transform::GetMatrix() const
   return tm_;
 }
 
+void Transform::SetMatrix(const Mat4& m)
+{
+  tm_=m;
+  ttm_ = Transpose(tm_);
+}
+
 Mat4 Transform::GetTransposedMatrix() const
 {
   return ttm_;
 }
 
-
 void Transform::SetTrans(const Vec3& t) 
 {
   trans_=t;
diff --git a/modules/mol/base/src/transform.hh b/modules/mol/base/src/transform.hh
index d3ce79763..5c9acd276 100644
--- a/modules/mol/base/src/transform.hh
+++ b/modules/mol/base/src/transform.hh
@@ -41,7 +41,8 @@ public:
   void SetCenter(const geom::Vec3& c);
   geom::Vec3 GetCenter() const;
 
-
+  // directly set tm, messing up rot/trans/cen !
+  void SetMatrix(const geom::Mat4& m);
 
   /// \name rotation
   //@{
-- 
GitLab