From c6c75848b72794686b497059efd95e776a2d2c6d Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@stud.unibas.ch>
Date: Wed, 14 Nov 2012 14:36:18 +0100
Subject: [PATCH] Only allow renumbering of a chain belonging to an entity
 directly associated with the requested editor. Attention: Interface of
 RenumberChain has slightly changed.

---
 modules/mol/base/src/editor_base.cc      |  4 ++--
 modules/mol/base/src/editor_base.hh      |  2 +-
 modules/mol/base/src/impl/entity_impl.cc | 12 ++++++++++++
 modules/mol/base/src/impl/entity_impl.hh |  2 ++
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/modules/mol/base/src/editor_base.cc b/modules/mol/base/src/editor_base.cc
index 2b9a3b56d..31642fee3 100644
--- a/modules/mol/base/src/editor_base.cc
+++ b/modules/mol/base/src/editor_base.cc
@@ -208,9 +208,9 @@ void EditorBase::RenumberAllResidues(int start, bool keep_spacing)
   ent_.Impl()->RenumberAllResidues(start, keep_spacing);
 }
 
-void EditorBase::RenumberChain(ChainHandle& chain, int start, bool keep_spacing)
+void EditorBase::RenumberChain(const String& name, int start, bool keep_spacing)
 {
-  chain.Impl()->RenumberAllResidues(start, keep_spacing);
+  ent_.Impl()->RenumberChain(name, start, keep_spacing);
 }
 
 void EditorBase::RenameAtom(AtomHandle atom, const String& new_name)
diff --git a/modules/mol/base/src/editor_base.hh b/modules/mol/base/src/editor_base.hh
index c081ab978..3547f22fa 100644
--- a/modules/mol/base/src/editor_base.hh
+++ b/modules/mol/base/src/editor_base.hh
@@ -293,7 +293,7 @@ public:
   /// \param keep_spacing
   ///           If set to false, residues will continously be renumbered ongoing from start.
   ///           Otherwise the spacings between the residues are kept.
-  void RenumberChain(ChainHandle& chain, int start, bool keep_spacing);
+  void RenumberChain(const String& name, int start, bool keep_spacing);
     
   /// \brief Get edit mode of editor
   EditMode GetMode() const {return mode_;}
diff --git a/modules/mol/base/src/impl/entity_impl.cc b/modules/mol/base/src/impl/entity_impl.cc
index 1fd465f23..f8fa19e32 100644
--- a/modules/mol/base/src/impl/entity_impl.cc
+++ b/modules/mol/base/src/impl/entity_impl.cc
@@ -1202,4 +1202,16 @@ void EntityImpl::RenumberAllResidues(int start, bool keep_spacing)
 
 }
 
+void EntityImpl::RenumberChain(const String& name, int start, bool keep_spacing)
+{
+  ChainImplPtr ch=this->FindChain(name);
+
+  if(!ch) {
+    throw Error("Could not find chain with name "+name);
+  }
+
+  ch->RenumberAllResidues(start, keep_spacing);
+
+}
+
 }}} // ns
diff --git a/modules/mol/base/src/impl/entity_impl.hh b/modules/mol/base/src/impl/entity_impl.hh
index c95bef408..74d8ded33 100644
--- a/modules/mol/base/src/impl/entity_impl.hh
+++ b/modules/mol/base/src/impl/entity_impl.hh
@@ -251,6 +251,8 @@ public:
 
   void RenumberAllResidues(int start, bool keep_spacing);
 
+  void RenumberChain(const String& name, int start, bool keep_spacing);
+
 private:
   void DoCopy(EntityImplPtr dest);
   
-- 
GitLab