From b3be5ccac71ddca7b79ba86bdbce460c5d6c5dbc Mon Sep 17 00:00:00 2001 From: Ansgar Philippsen <ansgar.philippsen@gmail.com> Date: Wed, 7 Nov 2012 10:20:48 -0500 Subject: [PATCH] added fix transform interface to entity and xcs editor --- modules/mol/base/pymod/export_entity.cc | 1 + modules/mol/base/src/entity_handle.cc | 6 ++++++ modules/mol/base/src/entity_handle.hh | 2 ++ modules/mol/base/src/impl/entity_impl.cc | 14 +++++++++++++- modules/mol/base/src/impl/entity_impl.hh | 1 + modules/mol/base/src/xcs_editor.cc | 5 +++++ modules/mol/base/src/xcs_editor.hh | 3 +++ 7 files changed, 31 insertions(+), 1 deletion(-) diff --git a/modules/mol/base/pymod/export_entity.cc b/modules/mol/base/pymod/export_entity.cc index bb55d9bd6..0373b2590 100644 --- a/modules/mol/base/pymod/export_entity.cc +++ b/modules/mol/base/pymod/export_entity.cc @@ -197,6 +197,7 @@ void export_Entity() .add_property("transform",&EntityHandle::GetTransform,&EntityHandle::SetTransform) .def("HasTransform",&EntityHandle::HasTransform) .def("ClearTransform",&EntityHandle::ClearTransform) + .def("FixTransform",&EntityHandle::FixTransform) .def("EditXCS", &EntityHandle::EditXCS, arg("mode")=UNBUFFERED_EDIT) .def("EditICS", &EntityHandle::EditICS, arg("mode")=UNBUFFERED_EDIT) .def("RequestXCSEditor", &depr_request_xcs_editor, arg("mode")=UNBUFFERED_EDIT) diff --git a/modules/mol/base/src/entity_handle.cc b/modules/mol/base/src/entity_handle.cc index e34e11d2e..eaa348914 100644 --- a/modules/mol/base/src/entity_handle.cc +++ b/modules/mol/base/src/entity_handle.cc @@ -295,6 +295,12 @@ void EntityHandle::ClearTransform() Impl()->ClearTransform(); } +void EntityHandle::FixTransform() +{ + this->CheckValidity(); + Impl()->FixTransform(); +} + ResidueHandle EntityHandle::FindResidue(const String& chain_name, const ResNum& residue) const { this->CheckValidity(); diff --git a/modules/mol/base/src/entity_handle.hh b/modules/mol/base/src/entity_handle.hh index fe2a43913..63a2bc6be 100644 --- a/modules/mol/base/src/entity_handle.hh +++ b/modules/mol/base/src/entity_handle.hh @@ -279,6 +279,8 @@ public: bool HasTransform() const; /// \brief remove transform void ClearTransform(); + /// \brief write transformed pos to orig, and the clear tf + void FixTransform(); /// \brief get complete list of residues /// \sa #ResiduesBegin, #ResiduesEnd diff --git a/modules/mol/base/src/impl/entity_impl.cc b/modules/mol/base/src/impl/entity_impl.cc index f8fa19e32..852b9bebb 100644 --- a/modules/mol/base/src/impl/entity_impl.cc +++ b/modules/mol/base/src/impl/entity_impl.cc @@ -748,8 +748,20 @@ void EntityImpl::SetTransform(const geom::Transform& tf) void EntityImpl::ClearTransform() { - has_transform_=false; SetTransform(geom::Transform()); + has_transform_=false; +} + +void EntityImpl::FixTransform() +{ + if(!has_transform_) return; + for(AtomImplMap::iterator it = atom_map_.begin();it!=atom_map_.end();++it) { + it->second->OriginalPos()=it->second->TransformedPos(); + } + transform_=geom::Transform(); + has_transform_=false; + this->UpdateTransformedPos(); + this->MarkOrganizerDirty(); } void EntityImpl::AttachObserver(const EntityObserverPtr& o) diff --git a/modules/mol/base/src/impl/entity_impl.hh b/modules/mol/base/src/impl/entity_impl.hh index 74d8ded33..6862e5e27 100644 --- a/modules/mol/base/src/impl/entity_impl.hh +++ b/modules/mol/base/src/impl/entity_impl.hh @@ -151,6 +151,7 @@ public: const geom::Transform& GetTransform() const {return transform_;} bool HasTransform() const {return has_transform_;} void ClearTransform(); + void FixTransform(); void AttachObserver(const EntityObserverPtr& o); void DetachObserver(const EntityObserverPtr& o); diff --git a/modules/mol/base/src/xcs_editor.cc b/modules/mol/base/src/xcs_editor.cc index 5596e3962..7bf68701d 100644 --- a/modules/mol/base/src/xcs_editor.cc +++ b/modules/mol/base/src/xcs_editor.cc @@ -205,6 +205,11 @@ void XCSEditor::SetTransform(const geom::Transform& transform) this->Update(); } +void XCSEditor::FixTransform() +{ + ent_.Impl()->FixTransform(); +} + void XCSEditor::Update() { if (GetMode()==UNBUFFERED_EDIT) { diff --git a/modules/mol/base/src/xcs_editor.hh b/modules/mol/base/src/xcs_editor.hh index a7cc317b2..e52d9e4c5 100644 --- a/modules/mol/base/src/xcs_editor.hh +++ b/modules/mol/base/src/xcs_editor.hh @@ -104,6 +104,9 @@ public: void SetTransform(const geom::Mat4& transform); void SetTransform(const geom::Transform& transform); + /// \brief set transformed pos to new original pos + void FixTransform(); + /// \brief immediately update internal coordinate system void UpdateICS(); -- GitLab