From 9a659bca1e6374aff1427b9479de051bbabebdc3 Mon Sep 17 00:00:00 2001 From: stefan <stefan@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Fri, 28 May 2010 15:40:44 +0000 Subject: [PATCH] New SequenceViewer, colors for Aligments git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2302 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- modules/gui/src/CMakeLists.txt | 3 + .../src/sequence/align_properties_painter.cc | 78 +++++++++++++++++++ .../src/sequence/align_properties_painter.hh | 46 +++++++++++ .../gui/src/sequence/sequence_view_object.cc | 3 + 4 files changed, 130 insertions(+) create mode 100644 modules/gui/src/sequence/align_properties_painter.cc create mode 100644 modules/gui/src/sequence/align_properties_painter.hh diff --git a/modules/gui/src/CMakeLists.txt b/modules/gui/src/CMakeLists.txt index 36b468e63..decd467a8 100644 --- a/modules/gui/src/CMakeLists.txt +++ b/modules/gui/src/CMakeLists.txt @@ -21,6 +21,7 @@ sequence_search_bar.hh ) set(OST_GUI_SEQUENCE_VIEW_HEADERS +align_properties_painter.hh base_row.hh background_painter.hh painter.hh @@ -214,6 +215,7 @@ sequence_viewer/sequence_viewer_base.cc sequence_viewer/sequence_viewer.cc sequence_viewer/sequence_scene.cc sequence_viewer/sequence_search_bar.cc +sequence/align_properties_painter.cc sequence/base_row.cc sequence/background_painter.cc sequence/secstr_row.cc @@ -347,6 +349,7 @@ sequence_viewer/sequence_viewer_base.hh sequence_viewer/sequence_viewer.hh sequence_viewer/sequence_scene.hh sequence_viewer/sequence_search_bar.hh +sequence/align_properties_painter.hh sequence/background_painter.hh sequence/base_row.hh sequence/painter.hh diff --git a/modules/gui/src/sequence/align_properties_painter.cc b/modules/gui/src/sequence/align_properties_painter.cc new file mode 100644 index 000000000..795e8febd --- /dev/null +++ b/modules/gui/src/sequence/align_properties_painter.cc @@ -0,0 +1,78 @@ +//------------------------------------------------------------------------------ +// 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 "align_properties_painter.hh" + +namespace ost { namespace gui { + +namespace { + +QMap<QString,QColor> GetColorMap(){ + QMap<QString,QColor> map; + map["G"]=QColor(Qt::gray); + map["A"]=QColor(Qt::gray); + map["V"]=QColor(Qt::gray); + map["L"]=QColor(Qt::gray); + map["I"]=QColor(Qt::gray); + map["F"]=QColor(255,165,0); + map["Y"]=QColor(255,165,0); + map["W"]=QColor(255,165,0); + map["C"]=QColor(Qt::yellow); + map["M"]=QColor(Qt::yellow); + map["S"]=QColor(Qt::green); + map["T"]=QColor(Qt::green); + map["K"]=QColor(Qt::red); + map["R"]=QColor(Qt::red); + map["H"]=QColor(Qt::red); + map["D"]=QColor(Qt::blue); + map["E"]=QColor(Qt::blue); + map["N"]=QColor(Qt::blue); + map["Q"]=QColor(Qt::blue); + map["P"]=QColor(Qt::magenta); + return map; +} + +} + +QMap<QString,QColor> AlignPropertiesPainter::color_map_ = GetColorMap(); + + +AlignPropertiesPainter::AlignPropertiesPainter(QObject* parent) + : Painter(parent) +{} + +void AlignPropertiesPainter::Paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index){ + painter->save(); + if (index.column()>0){ + QString text = index.data(Qt::DisplayRole).toString(); + if(color_map_.contains(text)){ + painter->fillRect(option.rect, color_map_[text]); + } + } + painter->restore(); +} + +}} diff --git a/modules/gui/src/sequence/align_properties_painter.hh b/modules/gui/src/sequence/align_properties_painter.hh new file mode 100644 index 000000000..d33331cc6 --- /dev/null +++ b/modules/gui/src/sequence/align_properties_painter.hh @@ -0,0 +1,46 @@ +//------------------------------------------------------------------------------ +// 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_ALIGN_PROPERTIES_PAINTER +#define OST_SEQUENCE_VIEWER_ALIGN_PROPERTIES_PAINTER + +/* + Author: Stefan Scheuber + */ + +#include <QObject> + +#include "painter.hh" + +namespace ost { namespace gui { + + + +class AlignPropertiesPainter : public Painter +{ + Q_OBJECT +public: + AlignPropertiesPainter(QObject* parent = 0); + void Paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index); +private: + static QMap<QString,QColor> color_map_; +}; + +}} + +#endif diff --git a/modules/gui/src/sequence/sequence_view_object.cc b/modules/gui/src/sequence/sequence_view_object.cc index b5a44c067..daf0bbf65 100644 --- a/modules/gui/src/sequence/sequence_view_object.cc +++ b/modules/gui/src/sequence/sequence_view_object.cc @@ -30,6 +30,7 @@ #include "sequence_row.hh" #include "secstr_row.hh" +#include "align_properties_painter.hh" #include "painter.hh" #include "background_painter.hh" #include "seq_secstr_painter.hh" @@ -82,6 +83,8 @@ void SequenceViewObject::AddSequence(seq::SequenceHandle& sequence, const QStrin SequenceRow* new_row = new SequenceRow(name, sequence, this); Painter* p = new BackgroundPainter(this); new_row->InsertPainter(p); + p = new AlignPropertiesPainter(this); + new_row->InsertPainter(p); p = new SeqSelectionPainter(this); new_row->InsertPainter(p); p = new SeqTextPainter(this); -- GitLab