From 3588605c575e57bbb1b55678c9eb5ca157149b82 Mon Sep 17 00:00:00 2001 From: stefan <stefan@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Thu, 6 May 2010 14:04:16 +0000 Subject: [PATCH] New SequenceViewer, changed colors of selection and background git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2188 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- modules/gui/src/CMakeLists.txt | 3 ++ .../gui/src/sequence/background_painter.cc | 48 +++++++++++++++++++ .../gui/src/sequence/background_painter.hh | 43 +++++++++++++++++ .../gui/src/sequence/seq_selection_painter.cc | 24 +++++----- .../gui/src/sequence/seq_selection_painter.hh | 3 ++ modules/gui/src/sequence/sequence_model.cc | 2 +- modules/gui/src/sequence/sequence_model.hh | 1 + modules/gui/src/sequence/sequence_row.cc | 12 +++-- .../gui/src/sequence/sequence_table_view.cc | 5 +- modules/gui/src/sequence/view_object.cc | 13 +++-- 10 files changed, 131 insertions(+), 23 deletions(-) create mode 100644 modules/gui/src/sequence/background_painter.cc create mode 100644 modules/gui/src/sequence/background_painter.hh diff --git a/modules/gui/src/CMakeLists.txt b/modules/gui/src/CMakeLists.txt index 41e0c9901..da9df49e3 100644 --- a/modules/gui/src/CMakeLists.txt +++ b/modules/gui/src/CMakeLists.txt @@ -22,6 +22,7 @@ sequence_search_bar.hh set(OST_GUI_SEQUENCE_VIEW_HEADERS base_row.hh +background_painter.hh painter.hh secstr_row.hh seq_secstr_painter.hh @@ -211,6 +212,7 @@ sequence_viewer/sequence_viewer.cc sequence_viewer/sequence_scene.cc sequence_viewer/sequence_search_bar.cc sequence/base_row.cc +sequence/background_painter.cc sequence/secstr_row.cc sequence/seq_secstr_painter.cc sequence/seq_selection_painter.cc @@ -339,6 +341,7 @@ sequence_viewer/sequence_viewer_base.hh sequence_viewer/sequence_viewer.hh sequence_viewer/sequence_scene.hh sequence_viewer/sequence_search_bar.hh +sequence/background_painter.hh sequence/base_row.hh sequence/painter.hh sequence/secstr_row.hh diff --git a/modules/gui/src/sequence/background_painter.cc b/modules/gui/src/sequence/background_painter.cc new file mode 100644 index 000000000..adc5e6a73 --- /dev/null +++ b/modules/gui/src/sequence/background_painter.cc @@ -0,0 +1,48 @@ +//------------------------------------------------------------------------------ +// 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 "background_painter.hh" + +namespace ost { namespace gui { + +BackgroundPainter::BackgroundPainter(QObject* parent) + : Painter(parent) +{} + +void BackgroundPainter::Paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index){ + painter->save(); + if ((index.column()-1)%10 > 4){ + painter->fillRect(option.rect, QColor(240,240,240)); + + } + if(index.row()>0 && (index.column())%10 == 0){ + painter->setPen(QPen(QColor(135,135,135))); + painter->drawLine(option.rect.topRight(),option.rect.bottomRight()); + } + painter->restore(); +} + +}} diff --git a/modules/gui/src/sequence/background_painter.hh b/modules/gui/src/sequence/background_painter.hh new file mode 100644 index 000000000..942e1dde5 --- /dev/null +++ b/modules/gui/src/sequence/background_painter.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_BACKGROUND_PAINTER +#define OST_SEQUENCE_VIEWER_BACKGROUND_PAINTER + +/* + Author: Stefan Scheuber + */ + +#include <QObject> + +#include "painter.hh" + +namespace ost { namespace gui { + +class BackgroundPainter : public Painter +{ + Q_OBJECT +public: + BackgroundPainter(QObject* parent = 0); + void Paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index); +}; + +}} + +#endif diff --git a/modules/gui/src/sequence/seq_selection_painter.cc b/modules/gui/src/sequence/seq_selection_painter.cc index e9b0c4d5c..847317196 100644 --- a/modules/gui/src/sequence/seq_selection_painter.cc +++ b/modules/gui/src/sequence/seq_selection_painter.cc @@ -29,27 +29,25 @@ namespace ost { namespace gui { SeqSelectionPainter::SeqSelectionPainter(QObject* parent) - : Painter(parent) -{} + : Painter(parent), focus_color_(255,0,0,0), mouse_over_color_(240,240,240,192) +{ + +} void SeqSelectionPainter::Paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index){ painter->save(); - if ((index.column()-1)%10 > 4){ - painter->fillRect(option.rect, QColor(240,240,240)); - - } - if((index.column())%10 == 0){ - painter->setPen(QPen(QColor(135,135,135))); - painter->drawLine(option.rect.topRight(),option.rect.bottomRight()); - } + /* if (option.state & QStyle::State_HasFocus){ - painter->fillRect(option.rect, QColor(240,240,0,60)); + painter->fillRect(option.rect, focus_color_); } + */ if (option.state & QStyle::State_MouseOver){ - painter->fillRect(option.rect, QColor(240,240,240,128)); + painter->fillRect(option.rect, mouse_over_color_); } if (option.state & QStyle::State_Selected){ - painter->fillRect(option.rect, QColor(0,240,0,128)); + QColor color = option.palette.highlight().color(); + color.setAlpha(128); + painter->fillRect(option.rect, color); } painter->restore(); } diff --git a/modules/gui/src/sequence/seq_selection_painter.hh b/modules/gui/src/sequence/seq_selection_painter.hh index 416f423c0..a98d5afb6 100644 --- a/modules/gui/src/sequence/seq_selection_painter.hh +++ b/modules/gui/src/sequence/seq_selection_painter.hh @@ -36,6 +36,9 @@ public: SeqSelectionPainter(QObject* parent = 0); void Paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index); +private: + QColor focus_color_; + QColor mouse_over_color_; }; }} diff --git a/modules/gui/src/sequence/sequence_model.cc b/modules/gui/src/sequence/sequence_model.cc index 428952657..ddac0e2a8 100644 --- a/modules/gui/src/sequence/sequence_model.cc +++ b/modules/gui/src/sequence/sequence_model.cc @@ -119,7 +119,7 @@ const PainterList& SequenceModel::GetPainters(const QModelIndex& index) const{ pair.second->GetRow(pair.first); return pair.second->GetRow(pair.first)->GetPainters(); } - assert(false); + return empty_list_; } QPair<int, ViewObject*> SequenceModel::GetRowWithItem(int row) const{ diff --git a/modules/gui/src/sequence/sequence_model.hh b/modules/gui/src/sequence/sequence_model.hh index 50618db9c..1c8b27f6f 100644 --- a/modules/gui/src/sequence/sequence_model.hh +++ b/modules/gui/src/sequence/sequence_model.hh @@ -81,6 +81,7 @@ private: QList<ViewObject*> objects_; int max_columns; + PainterList empty_list_; }; diff --git a/modules/gui/src/sequence/sequence_row.cc b/modules/gui/src/sequence/sequence_row.cc index b9f758053..2c33712ac 100644 --- a/modules/gui/src/sequence/sequence_row.cc +++ b/modules/gui/src/sequence/sequence_row.cc @@ -35,10 +35,16 @@ namespace ost { namespace gui { SequenceRow::SequenceRow(const QString& name, seq::SequenceHandle& sequence, ViewObject* parent) : BaseRow(QFont("Courier",11),parent), name_(name), name_font_(QFont("Courier",11)), sequence_(sequence) -{ } +{ + name_font_.setBold(true); + name_font_.setItalic(true); +} -SequenceRow::SequenceRow(const QString& name, ViewObject* parent) : BaseRow(QFont("Courier",11),parent), name_(name) -{ } +SequenceRow::SequenceRow(const QString& name, ViewObject* parent) : BaseRow(QFont("Courier",11),parent), name_(name), name_font_(QFont("Courier",11)) +{ + name_font_.setBold(true); + name_font_.setItalic(true); +} int SequenceRow::GetColumnCount() const { diff --git a/modules/gui/src/sequence/sequence_table_view.cc b/modules/gui/src/sequence/sequence_table_view.cc index 2152c1a6b..73769705d 100644 --- a/modules/gui/src/sequence/sequence_table_view.cc +++ b/modules/gui/src/sequence/sequence_table_view.cc @@ -95,7 +95,6 @@ void SequenceTableView::InitStaticColumn() static_column_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); static_column_->show(); static_column_->setStyleSheet("QTableView { border: 0px;" - "background-color: #F6F6F6;" "selection-background-color: #EEEEEE}" "QTableView::item{ border: none;" "padding: 0px; border-width: 0px; margin: 0px;}"); @@ -130,7 +129,7 @@ void SequenceTableView::InitStaticRow() static_row_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); static_row_->show(); static_row_->setStyleSheet("QTableView { border: 0px;" - "background-color: #F6F6F6;" + "background-color: #FFFFFF;" "selection-background-color: #EEEEEE}" "QTableView::item{ border: none;" "padding: 0px; border-width: 0px; margin: 0px;}"); @@ -169,7 +168,7 @@ void SequenceTableView::InitStaticField(){ static_field_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); static_field_->show(); static_field_->setStyleSheet("QTableView { border: 0px;" - "background-color: #E0E0E0;" + "background-color: #FFFFFF;" "selection-background-color: #EEEEEE}" "QTableView::item{ border: none;" "padding: 0px; border-width: 0px; margin: 0px;}"); diff --git a/modules/gui/src/sequence/view_object.cc b/modules/gui/src/sequence/view_object.cc index e422027e7..01d80818a 100644 --- a/modules/gui/src/sequence/view_object.cc +++ b/modules/gui/src/sequence/view_object.cc @@ -32,6 +32,7 @@ #include "title_row.hh" #include "painter.hh" +#include "background_painter.hh" #include "seq_secstr_painter.hh" #include "seq_selection_painter.hh" #include "seq_text_painter.hh" @@ -78,7 +79,9 @@ ViewObject::ViewObject(gfx::EntityP& entity, QObject* parent): QObject(parent), ViewObject::ViewObject(QObject* parent): QObject(parent) { TitleRow* new_row = new TitleRow(this); - Painter* p = new TickPainter(this); + Painter* p = new BackgroundPainter(this); + new_row->InsertPainter(p); + p = new TickPainter(this); new_row->InsertPainter(p); rows_.append(new_row); } @@ -111,7 +114,9 @@ int ViewObject::GetRowCount() void ViewObject::AddSequence(seq::SequenceHandle& sequence, const QString& name) { SequenceRow* new_row = new SequenceRow(name, sequence, this); - Painter* p = new SeqSelectionPainter(this); + Painter* p = new BackgroundPainter(this); + new_row->InsertPainter(p); + p = new SeqSelectionPainter(this); new_row->InsertPainter(p); p = new SeqTextPainter(this); new_row->InsertPainter(p); @@ -121,12 +126,14 @@ void ViewObject::AddSequence(seq::SequenceHandle& sequence, const QString& name) void ViewObject::AddChain(mol::ChainView& chain, const QString& name) { SecStrRow* new_row = new SecStrRow(name, chain, this); - Painter* p = new SeqSelectionPainter(this); + Painter* p = new BackgroundPainter(this); new_row->InsertPainter(p); p = new SeqSecStrPainter(this); new_row->InsertPainter(p); p = new SeqTextPainter(this); new_row->InsertPainter(p); + p = new SeqSelectionPainter(this); + new_row->InsertPainter(p); rows_.append(new_row); } -- GitLab