diff --git a/modules/gui/pymod/export_sequence_viewerV2.cc b/modules/gui/pymod/export_sequence_viewerV2.cc index cd010952fb9b6a32a06b85aafbeac16e08ced672..0a744dcccf75b17baf3d5445c7b0a2177cb73fd0 100644 --- a/modules/gui/pymod/export_sequence_viewerV2.cc +++ b/modules/gui/pymod/export_sequence_viewerV2.cc @@ -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>) ; diff --git a/modules/gui/src/CMakeLists.txt b/modules/gui/src/CMakeLists.txt index b4ca43ed392d7f8088acc611f71ce05dec3b5ed0..36b468e63609e895af4c01c2a6363b31502b79fe 100644 --- a/modules/gui/src/CMakeLists.txt +++ b/modules/gui/src/CMakeLists.txt @@ -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 diff --git a/modules/gui/src/sequence/alignment_view_object.cc b/modules/gui/src/sequence/alignment_view_object.cc new file mode 100644 index 0000000000000000000000000000000000000000..bee250f9ffd8fb7285e0e93cc083b0ee16e0a3a0 --- /dev/null +++ b/modules/gui/src/sequence/alignment_view_object.cc @@ -0,0 +1,51 @@ +//------------------------------------------------------------------------------ +// 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()); + } +} + +}} diff --git a/modules/gui/src/sequence/alignment_view_object.hh b/modules/gui/src/sequence/alignment_view_object.hh new file mode 100644 index 0000000000000000000000000000000000000000..a75159c229ca45583acfd5702443bc063dfdb6ad --- /dev/null +++ b/modules/gui/src/sequence/alignment_view_object.hh @@ -0,0 +1,43 @@ +//------------------------------------------------------------------------------ +// 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 diff --git a/modules/gui/src/sequence/sequence_model.cc b/modules/gui/src/sequence/sequence_model.cc index dc26ce348841621fa3d330fce38e83d1f9c7a062..e054a9046e8721e53479444851f42297dfcb1913 100644 --- a/modules/gui/src/sequence/sequence_model.cc +++ b/modules/gui/src/sequence/sequence_model.cc @@ -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++){ diff --git a/modules/gui/src/sequence/sequence_model.hh b/modules/gui/src/sequence/sequence_model.hh index 98cbe3aa4d47476f133e7cdcae9592a92246b016..218dbb4c91b730404caa19e9f2fd9d3a76085ec5 100644 --- a/modules/gui/src/sequence/sequence_model.hh +++ b/modules/gui/src/sequence/sequence_model.hh @@ -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); diff --git a/modules/gui/src/sequence/sequence_view_object.cc b/modules/gui/src/sequence/sequence_view_object.cc index d3e53093a6e06357b9c2d019e570e0c9c0518b5a..b5a44c06753a7b8670377708b7fcff4960124d19 100644 --- a/modules/gui/src/sequence/sequence_view_object.cc +++ b/modules/gui/src/sequence/sequence_view_object.cc @@ -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); diff --git a/modules/gui/src/sequence/sequence_view_object.hh b/modules/gui/src/sequence/sequence_view_object.hh index 9d85f85b839908c2ae469087e4f06cce2bd47aca..9c443095f614860ba1cb8e71b3432ab1d22a5a93 100644 --- a/modules/gui/src/sequence/sequence_view_object.hh +++ b/modules/gui/src/sequence/sequence_view_object.hh @@ -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()); diff --git a/modules/gui/src/sequence/sequence_viewer.cc b/modules/gui/src/sequence/sequence_viewer.cc index d00a1b07bbd756a59067afe1c0467605e425f0ee..c73f0a51a27f81c5281c00b4ec7af9968d9fa283 100644 --- a/modules/gui/src/sequence/sequence_viewer.cc +++ b/modules/gui/src/sequence/sequence_viewer.cc @@ -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_; diff --git a/modules/gui/src/sequence/sequence_viewer.hh b/modules/gui/src/sequence/sequence_viewer.hh index b04d242dc3c1d3befd3ffda6698e417b3322e2a2..b4134f1fe4f919380503c325f7d3bf25cae80b6b 100644 --- a/modules/gui/src/sequence/sequence_viewer.hh +++ b/modules/gui/src/sequence/sequence_viewer.hh @@ -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;};