Skip to content
Snippets Groups Projects
Commit 9fcb2f6d authored by stefan's avatar stefan
Browse files

New SequenceViewer, support for seq::AlignmentHandle

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2297 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 9c49fa86
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,8 @@ void export_SequenceViewerV2()
class_<SequenceViewerV2, boost::noncopyable >("SequenceViewerV2",init<>())
.def("Show", &SequenceViewerV2::show)
.def("Hide", &SequenceViewerV2::hide)
.def("AddAlignment", &SequenceViewerV2::AddAlignment)
.def("RemoveAlignment", &SequenceViewerV2::RemoveAlignment)
.def("GetQObject",&get_py_qobject<SequenceViewerV2>)
.add_property("qobject", &get_py_qobject<SequenceViewerV2>)
;
......
......@@ -36,6 +36,7 @@ sequence_table_view.hh
sequence_viewer.hh
tick_painter.hh
title_row.hh
alignment_view_object.hh
base_view_object.hh
sequence_view_object.hh
)
......@@ -227,6 +228,7 @@ sequence/sequence_table_view.cc
sequence/sequence_viewer.cc
sequence/tick_painter.cc
sequence/title_row.cc
sequence/alignment_view_object.cc
sequence/base_view_object.cc
sequence/sequence_view_object.cc
gosty_app.cc
......@@ -360,6 +362,7 @@ sequence/sequence_table_view.hh
sequence/sequence_viewer.hh
sequence/tick_painter.hh
sequence/title_row.hh
sequence/alignment_view_object.hh
sequence/base_view_object.hh
sequence/sequence_view_object.hh
plot_viewer/plot_axis_base.hh
......
//------------------------------------------------------------------------------
// This file is part of the OpenStructure project <www.openstructure.org>
//
// Copyright (C) 2008-2010 by the OpenStructure authors
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 3.0 of the License, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
/*
Author: Stefan Scheuber
*/
#include <QtGui>
#include <ost/mol/mol.hh>
#include <ost/mol/view_op.hh>
#include "sequence_row.hh"
#include "secstr_row.hh"
#include "painter.hh"
#include "background_painter.hh"
#include "seq_secstr_painter.hh"
#include "seq_selection_painter.hh"
#include "seq_text_painter.hh"
#include "alignment_view_object.hh"
namespace ost { namespace gui {
AlignmentViewObject::AlignmentViewObject(const seq::AlignmentHandle& alignment, QObject* parent): SequenceViewObject(parent)
{
for(int i=0; i<alignment.GetCount();i++){
seq::SequenceHandle seq_handle = alignment.GetSequence(i).Copy();
this->AddSequence(seq_handle, seq_handle.GetName().c_str());
}
}
}}
//------------------------------------------------------------------------------
// This file is part of the OpenStructure project <www.openstructure.org>
//
// Copyright (C) 2008-2010 by the OpenStructure authors
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 3.0 of the License, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
#ifndef OST_SEQUENCE_VIEWER_ALIGNMENT_VIEW_OBJECT
#define OST_SEQUENCE_VIEWER_ALIGNMENT_VIEW_OBJECT
/*
Author: Stefan Scheuber
*/
#include <ost/seq/alignment_handle.hh>
#include "sequence_view_object.hh"
namespace ost { namespace gui {
class AlignmentViewObject : public SequenceViewObject
{
Q_OBJECT
public:
AlignmentViewObject(const seq::AlignmentHandle& alignment, QObject* parent = 0);
};
}}
#endif
......@@ -26,6 +26,7 @@
#include <QtGui>
#include "alignment_view_object.hh"
#include "sequence_view_object.hh"
#include "title_row.hh"
......@@ -78,6 +79,19 @@ void SequenceModel::InsertChain(QString& name, mol::ChainView& view){
this->endInsertRows();
}
void SequenceModel::InsertAlignment(const seq::AlignmentHandle& alignment){
int cols = this->columnCount();
int new_cols = alignment.GetLength();
this->beginInsertRows(QModelIndex(),this->rowCount(),this->rowCount()+alignment.GetCount()-1);
objects_.append(new AlignmentViewObject(alignment, this));
if(new_cols > cols){
this->max_columns = new_cols;
this->beginInsertColumns(QModelIndex(), cols, new_cols);
this->endInsertColumns();
}
this->endInsertRows();
}
void SequenceModel::InsertSequences(const QList<QString>& names, seq::SequenceList& list){
this->beginInsertRows(this->index(this->rowCount(),0),this->rowCount(),this->rowCount()+list.GetCount());
objects_.append(new SequenceViewObject(list, names, this));
......@@ -116,6 +130,10 @@ void SequenceModel::RemoveGfxEntity(gfx::EntityP& entity){
}
}
void SequenceModel::RemoveAlignment(const seq::AlignmentHandle& alignment){
}
int SequenceModel::GetColumnCount() const{
int cols = 0;
for(int i = 0; i<objects_.size();i++){
......
......@@ -29,6 +29,7 @@
#include <ost/mol/chain_view.hh>
#include <ost/seq/sequence_list.hh>
#include <ost/seq/alignment_handle.hh>
#include <ost/gfx/entity.hh>
......@@ -44,11 +45,13 @@ class SequenceModel : public QAbstractTableModel
public:
SequenceModel(QObject *parent = 0);
void InsertAlignment(const seq::AlignmentHandle& alignment);
void InsertGfxEntity(gfx::EntityP& entity);
void InsertChain(QString& name, mol::ChainView& view);
void InsertSequence(QString& name, seq::SequenceHandle& seq);
void InsertSequences(const QList<QString>& names, seq::SequenceList& list);
void RemoveAlignment(const seq::AlignmentHandle& alignment);
void RemoveGfxEntity(gfx::EntityP& entity);
QModelIndexList GetModelIndexes(gfx::EntityP& entity, const mol::EntityView& view);
......
......@@ -74,6 +74,9 @@ SequenceViewObject::SequenceViewObject(gfx::EntityP& entity, QObject* parent): B
}
}
SequenceViewObject::SequenceViewObject(QObject* parent): BaseViewObject(parent), entity_(gfx::EntityP())
{ }
void SequenceViewObject::AddSequence(seq::SequenceHandle& sequence, const QString& name)
{
SequenceRow* new_row = new SequenceRow(name, sequence, this);
......
......@@ -43,6 +43,7 @@ public:
SequenceViewObject(seq::SequenceHandle& sequence, const QString& name, QObject* parent = 0);
SequenceViewObject(mol::ChainView& chain, const QString& name, QObject* parent = 0);
SequenceViewObject(gfx::EntityP& entity, QObject* parent = 0);
SequenceViewObject(QObject* parent = 0);
void AddSequence(seq::SequenceHandle& sequence, const QString& name=QString());
void AddChain(mol::ChainView& chain, const QString& name=QString());
......
......@@ -128,6 +128,18 @@ void SequenceViewerV2::NodeRemoved(const gfx::GfxNodeP& node)
}
}
void SequenceViewerV2::AddAlignment(const seq::AlignmentHandle& alignment)
{
if(alignment.GetCount()>0 && alignment.GetLength()>0){
model_->InsertAlignment(alignment);
}
}
void SequenceViewerV2::RemoveAlignment(const seq::AlignmentHandle& alignment)
{
model_->RemoveAlignment(alignment);
}
void SequenceViewerV2::UpdateSearchBar()
{
QStringList sequence_names_;
......
......@@ -25,6 +25,8 @@
#include <QWidget>
#include <ost/seq/alignment_handle.hh>
#include <ost/gfx/scene.hh>
#include <ost/gfx/gfx_object.hh>
......@@ -49,6 +51,9 @@ public:
virtual void NodeRemoved(const gfx::GfxNodeP& node);
virtual void SelectionChanged(const gfx::GfxObjP& o, const mol::EntityView& view);
virtual void AddAlignment(const seq::AlignmentHandle& alignment);
virtual void RemoveAlignment(const seq::AlignmentHandle& alignment);
virtual bool Restore(const QString&){return true;};
virtual bool Save(const QString&){return true;};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment