diff --git a/modules/gui/src/sequence/sequence_model.cc b/modules/gui/src/sequence/sequence_model.cc index 322ee4e45240775813672d580364328cd854ea6e..95613ac9a0d57becebc4b79e0fc37883c6e9c656 100644 --- a/modules/gui/src/sequence/sequence_model.cc +++ b/modules/gui/src/sequence/sequence_model.cc @@ -80,13 +80,19 @@ void SequenceModel::InsertGfxEntity(gfx::EntityP& ent){ this->endInsertRows(); } -void SequenceModel::RemoveSequence(gfx::EntityP& entity){ +void SequenceModel::RemoveGfxEntity(gfx::EntityP& entity){ ViewObject* obj = this->GetObject(entity); if(obj){ int index = objects_.indexOf(obj); - this->beginRemoveRows(QModelIndex(),index,index); + this->beginRemoveRows(QModelIndex(),index,index+obj->GetRowCount()-1); + int cols_before = this->columnCount(); objects_.removeAt(index); this->endRemoveRows(); + int cols = this->columnCount(); + if(cols_before>cols){ + this->beginRemoveColumns(QModelIndex(), cols, cols_before-1); + this->endRemoveColumns(); + } } } @@ -173,7 +179,7 @@ int SequenceModel::columnCount(const QModelIndex& parent) const for (int i = 0; i<objects_.size(); i++){ int max_col = objects_[i]->GetMaxColumnCount(); if(max_col >= cols) - cols = max_col+1; + cols = max_col; } return cols; } diff --git a/modules/gui/src/sequence/sequence_model.hh b/modules/gui/src/sequence/sequence_model.hh index ad94c593043c330b6933fcb23ad14a8385f29bf3..93e2f7cbab27d60a47fa6fbd1f47c4b80e455382 100644 --- a/modules/gui/src/sequence/sequence_model.hh +++ b/modules/gui/src/sequence/sequence_model.hh @@ -47,7 +47,7 @@ public: void InsertSequence(QString& name, seq::SequenceHandle& seq); void InsertSequences(const QList<QString>& names, seq::SequenceList& list); - void RemoveSequence(gfx::EntityP& entity); + void RemoveGfxEntity(gfx::EntityP& entity); ViewObject* GetObject(gfx::EntityP& entity); const PainterList& GetPainters(const QModelIndex& index) const; diff --git a/modules/gui/src/sequence/sequence_viewer.cc b/modules/gui/src/sequence/sequence_viewer.cc index 73ab0efa6aec91cfb115c9705aae6adcc2b2e97f..4496048c2d5af243a258e2f22e888dbf264a0d6e 100644 --- a/modules/gui/src/sequence/sequence_viewer.cc +++ b/modules/gui/src/sequence/sequence_viewer.cc @@ -77,7 +77,7 @@ void SequenceViewerV2::NodeAdded(const gfx::GfxNodeP& n) void SequenceViewerV2::NodeRemoved(const gfx::GfxNodeP& node) { if (gfx::EntityP o=boost::dynamic_pointer_cast<gfx::Entity>(node)) { - + model_->RemoveGfxEntity(o); } } diff --git a/modules/gui/src/sequence/view_object.cc b/modules/gui/src/sequence/view_object.cc index 1db41336f83ce62b00598089ab87a4a4f1b41257..670fad5599aacce8b066a79905400e56ecf9a605 100644 --- a/modules/gui/src/sequence/view_object.cc +++ b/modules/gui/src/sequence/view_object.cc @@ -182,14 +182,12 @@ void ViewObject::SetSelection(int row, const QSet<int>& added, const QSet<int>& QSetIterator<int> i(removed); while (i.hasNext()){ - std::cout << "REMOVED!" << std::endl; int row = i.next(); if (mol::ResidueView rv=seq.GetResidue(row-1)) { view.AddResidue(rv, mol::ViewAddFlag::INCLUDE_ATOMS); } } sel = mol::Difference(sel,view); - view = seq.GetAttachedView().GetHandle().CreateEmptyView(); i = QSetIterator<int>(added); while (i.hasNext()){ @@ -199,6 +197,7 @@ void ViewObject::SetSelection(int row, const QSet<int>& added, const QSet<int>& } } sel = mol::Union(sel,view); + sel.AddAllInclusiveBonds(); entity->SetSelection(sel); } } @@ -207,7 +206,7 @@ QVariant ViewObject::GetData(int row, int column, int role) { if(row<0 || row >= rows_.size())return QVariant(); - if(column<0 || column >= rows_[row].seq.GetLength())return QVariant(); + if(column<0 || column >= rows_[row].seq.GetLength()+1)return QVariant(); if(column == 0) { if (role == Qt::DisplayRole){ @@ -241,8 +240,8 @@ int ViewObject::GetMaxColumnCount() const int columns = 0; for(int i = 0; i < rows_.size(); i++){ int col_length = rows_[i].seq.GetLength(); - if(columns < col_length){ - columns = rows_[i].seq.GetLength() + 1; + if(columns <= col_length){ + columns = col_length+1; } } return columns;