Skip to content
Snippets Groups Projects
Commit 82481f4b authored by stefan's avatar stefan
Browse files

New Sequence Viewer, support for removing of gfx::Entities

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2165 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 9d317f04
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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;
......
......@@ -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);
}
}
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment