Skip to content
Snippets Groups Projects
Commit 284dafe5 authored by stefan's avatar stefan
Browse files

mol::ResidueView index problem fix

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2167 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 48c23554
Branches
Tags
No related merge requests found
...@@ -221,11 +221,15 @@ void ChainView::RemoveResidue(ResidueView view) { ...@@ -221,11 +221,15 @@ void ChainView::RemoveResidue(ResidueView view) {
if (!view.IsValid()) if (!view.IsValid())
return; return;
view.RemoveAtoms(); view.RemoveAtoms();
int index = view.GetIndex();
ResidueViewList::iterator i=data_->residues.begin(); ResidueViewList::iterator i=data_->residues.begin();
for (; i!=data_->residues.end(); ++i) { for (; i!=data_->residues.end(); ++i) {
int res_index = (*i).GetIndex();
if (*i==view) { if (*i==view) {
data_->residues.erase(i); data_->residues.erase(i);
return; }
else if(index < res_index){
(*i).SetIndex(res_index-1);
} }
} }
} }
......
...@@ -37,17 +37,17 @@ namespace ost { namespace mol { ...@@ -37,17 +37,17 @@ namespace ost { namespace mol {
class DLLEXPORT_OST_MOL ResidueViewData { class DLLEXPORT_OST_MOL ResidueViewData {
public: public:
ResidueViewData(); ResidueViewData(int residue_index): index(residue_index){}
ResidueViewData(const ChainViewDataPtr& chain_data) ResidueViewData(const ChainViewDataPtr& chain_data, int residue_index)
: chain(chain_data) { : chain(chain_data), index(residue_index) { }
}
ChainViewDataWeakPtr chain; ChainViewDataWeakPtr chain;
AtomViewList atoms; AtomViewList atoms;
int index;
}; };
ResidueView::ResidueView(const ChainView& chain, ResidueView::ResidueView(const ChainView& chain,
const ResidueHandle& residue) const ResidueHandle& residue)
: ResidueBase(residue.Impl()), data_(new ResidueViewData(chain.ViewData())) { : ResidueBase(residue.Impl()), data_(new ResidueViewData(chain.ViewData(), chain.GetResidueCount())) {
} }
ResidueView::ResidueView(const ResidueViewDataPtr& data, ResidueView::ResidueView(const ResidueViewDataPtr& data,
...@@ -185,7 +185,13 @@ bool ResidueView::operator!=(const ResidueView& rhs) const ...@@ -185,7 +185,13 @@ bool ResidueView::operator!=(const ResidueView& rhs) const
int ResidueView::GetIndex() const int ResidueView::GetIndex() const
{ {
this->CheckValidity(); this->CheckValidity();
return this->GetChain().GetResidueIndex(this->GetNumber()); return data_->index;
}
void ResidueView::SetIndex(int index)
{
this->CheckValidity();
data_->index = index;
} }
double ResidueView::GetMass() const double ResidueView::GetMass() const
......
...@@ -37,6 +37,9 @@ namespace ost { namespace mol { ...@@ -37,6 +37,9 @@ namespace ost { namespace mol {
/// affect the view and do not alter the structure and topology of the underlying /// affect the view and do not alter the structure and topology of the underlying
/// \ref ResidueHandle "residue". /// \ref ResidueHandle "residue".
class DLLEXPORT_OST_MOL ResidueView : public ResidueBase { class DLLEXPORT_OST_MOL ResidueView : public ResidueBase {
friend class ChainView;
public: public:
/// \brief Create invalid ResidueView /// \brief Create invalid ResidueView
ResidueView(); ResidueView();
...@@ -170,6 +173,12 @@ public: ...@@ -170,6 +173,12 @@ public:
bool operator==(const ResidueView& rhs) const; bool operator==(const ResidueView& rhs) const;
bool operator!=(const ResidueView& rhs) const; bool operator!=(const ResidueView& rhs) const;
protected:
/// \brief set the index of residiue view in chain
/// should be called from chainview whenever indexes change
void SetIndex(int index);
private: private:
ResidueViewDataPtr data_; ResidueViewDataPtr data_;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment