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

Added simplistic version of new SequenceViewer (SequenceViewerV2)

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2155 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent a5747b44
Branches
Tags
No related merge requests found
......@@ -9,6 +9,7 @@ set(OST_GUI_PYMOD_SOURCES
export_remote_site_loader.cc
export_scene_win.cc
export_sequence_viewer.cc
export_sequence_viewerV2.cc
export_perspective.cc
export_sip_handler.cc
export_scene_selection.cc
......
......@@ -18,22 +18,18 @@
//------------------------------------------------------------------------------
#include <boost/python.hpp>
#include <ost/gui/sequence_viewer/sequence_viewer.hh>
#include "sip_handler.hh"
#include "sequence_viewer_proxyV2.hh"
using namespace boost::python;
using namespace ost;
using namespace ost::gui;
void export_SequenceViewer()
void export_SequenceViewerV2()
{
class_<SequenceViewer, boost::noncopyable >("SequenceViewer", no_init)
.def("Show", &SequenceViewer::show)
.def("Hide", &SequenceViewer::hide)
.def("GetQObject",&get_py_qobject<SequenceViewer>)
.add_property("qobject", &get_py_qobject<SequenceViewer>)
class_<SequenceViewerProxyV2, bases<SipHandlerBase> >("SequenceViewerV2", init<>())
.def("Show", &SequenceViewerProxyV2::Show)
.def("Hide", &SequenceViewerProxyV2::Hide)
;
}
//------------------------------------------------------------------------------
// 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
//------------------------------------------------------------------------------
#include <boost/python.hpp>
#include "sequence_viewer_proxy.hh"
using namespace boost::python;
using namespace ost;
using namespace ost::gui;
void export_SequenceViewer()
{
class_<SequenceViewerProxy, bases<SipHandlerBase> >("SequenceViewer")
.def("Show", &SequenceViewerProxy::Show)
.def("Hide", &SequenceViewerProxy::Hide)
;
}
//------------------------------------------------------------------------------
// 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_GUI_SEQUENCE_VIEWER_PROXY_V2_HH
#define OST_GUI_SEQUENCE_VIEWER_PROXY_V2_HH
#include <ost/gui/sequence/sequence_viewer.hh>
#include "sip_handler.hh"
namespace ost { namespace gui {
class SequenceViewerProxyV2 : public SipHandler<SequenceViewerV2> {
public:
SequenceViewerProxyV2(SequenceViewerV2* seq_viewer=new SequenceViewerV2()):
SipHandler<SequenceViewerV2>(seq_viewer)
{ }
void Show()
{
return Me()->show();
}
void Hide()
{
return Me()->hide();
}
};
}}
#endif
......@@ -33,6 +33,7 @@ void export_Gosty();
void export_PyShell();
void export_SceneWin();
void export_SequenceViewer();
void export_SequenceViewerV2();
void export_PanelBar();
void export_Perspective();
void export_SipHandler();
......@@ -116,6 +117,7 @@ BOOST_PYTHON_MODULE(_gui)
export_SceneWin();
export_SceneSelection();
export_SequenceViewer();
export_SequenceViewerV2();
export_RemoteSiteLoader();
export_FileLoader();
export_Widget();
......
......@@ -19,6 +19,12 @@ sequence_viewer.hh
sequence_scene.hh
sequence_search_bar.hh
)
set(OST_GUI_SEQUENCE_VIEW_HEADERS
sequence_table_view.hh
sequence_viewer.hh
)
set(OST_GUI_TOOLS_HEADERS
tool.hh
tool_option_group.hh
......@@ -192,6 +198,8 @@ sequence_viewer/sequence_viewer_base.cc
sequence_viewer/sequence_viewer.cc
sequence_viewer/sequence_scene.cc
sequence_viewer/sequence_search_bar.cc
sequence/sequence_table_view.cc
sequence/sequence_viewer.cc
gosty_app.cc
change_process_name.cc
main_area.cc
......@@ -308,6 +316,8 @@ sequence_viewer/sequence_viewer_base.hh
sequence_viewer/sequence_viewer.hh
sequence_viewer/sequence_scene.hh
sequence_viewer/sequence_search_bar.hh
sequence/sequence_table_view.hh
sequence/sequence_viewer.hh
plot_viewer/plot_axis_base.hh
plot_viewer/plot_data_graphics_item_base.hh
plot_viewer/plot_function_info.hh
......@@ -410,6 +420,7 @@ module(NAME gui SOURCES ${OST_GUI_MOCS} ${OST_GUI_SOURCES}
HEADERS ${OST_GUI_TOOLS_HEADERS} IN_DIR tools
${OST_GUI_PLOT_VIEWER_HEADERS} IN_DIR plot_viewer
${OST_GUI_SEQUENCE_VIEWER_HEADERS} IN_DIR sequence_viewer
${OST_GUI_SEQUENCE_VIEW_HEADERS} IN_DIR sequence
${OST_GUI_PYTHON_SHELL_HEADERS} IN_DIR python_shell
${OST_GUI_PANEL_BAR_HEADERS} IN_DIR panel_bar
${OST_GUI_SCENE_WIN_HEADERS} IN_DIR scene_win
......
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QApplication>
#include <QStandardItemModel>
#include <QFile>
#include "freezetablewidget.h"
int main( int argc, char** argv )
{
Q_INIT_RESOURCE(grades);
QApplication app( argc, argv );
QStandardItemModel *model=new QStandardItemModel();
QFile file(":/grades.txt");
QString line;
QStringList list;
if (file.open(QFile::ReadOnly)) {
line = file.readLine(200);
list= line.simplified().split(",");
model->setHorizontalHeaderLabels(list);
int row=0;
QStandardItem *newItem=0;
while(file.canReadLine()){
line = file.readLine(200);
if(!line.startsWith("#") && line.contains(",")){
list= line.simplified().split(",");
for(int col=0; col<list.length(); col++){
newItem = new QStandardItem(list.at(col));
model->setItem(row ,col, newItem);
}
row++;
}
}
}
file.close();
FreezeTableWidget *tableView = new FreezeTableWidget(model);
tableView->setWindowTitle(QObject::tr("Frozen Column Example"));
tableView->resize(560,680);
tableView->show();
return app.exec();
}
//------------------------------------------------------------------------------
// 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 <QHeaderView>
#include <QScrollBar>
#include "sequence_table_view.hh"
namespace ost { namespace gui {
SequenceTableView::SequenceTableView(QAbstractItemModel * model)
{
this->setModel(model);
column_not_move_ = new QTableView(this);
column_not_move_->setModel(this->model());
column_not_move_->setFocusPolicy(Qt::NoFocus);
column_not_move_->verticalHeader()->hide();
column_not_move_->horizontalHeader()->setResizeMode(QHeaderView::Fixed);
this->viewport()->stackUnder(column_not_move_);
column_not_move_->setSelectionModel(this->selectionModel());
for(int col=1; col<this->model()->columnCount(); col++)
column_not_move_->setColumnHidden(col, true);
column_not_move_->setColumnWidth(0, this->columnWidth(0) );
column_not_move_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
column_not_move_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
column_not_move_->show();
this->updateNotMoveColumn();
setHorizontalScrollMode(ScrollPerPixel);
setVerticalScrollMode(ScrollPerPixel);
column_not_move_->setVerticalScrollMode(ScrollPerPixel);
connect(this->horizontalHeader(),SIGNAL(sectionResized(int,int,int)), this, SLOT(ResizeWidth(int,int,int)));
connect(this->verticalHeader(),SIGNAL(sectionResized(int,int,int)), this, SLOT(ResizeHeight(int,int,int)));
connect(column_not_move_->verticalScrollBar(), SIGNAL(valueChanged(int)), this->verticalScrollBar(), SLOT(setValue(int)));
connect(verticalScrollBar(), SIGNAL(valueChanged(int)), column_not_move_->verticalScrollBar(), SLOT(setValue(int)));
}
void SequenceTableView::ResizeWidth(int index, int, int size)
{
if(index == 0){
column_not_move_->setColumnWidth(0,size);
updateNotMoveColumn();
}
}
void SequenceTableView::ResizeHeight(int index, int, int size)
{
column_not_move_->setRowHeight(index, size);
}
void SequenceTableView::resizeEvent(QResizeEvent * event)
{
QTableView::resizeEvent(event);
updateNotMoveColumn();
}
QModelIndex SequenceTableView::moveCursor(CursorAction action, Qt::KeyboardModifiers modifiers)
{
QModelIndex current = QTableView::moveCursor(action, modifiers);
if(action == MoveLeft && current.column()>0
&& this->visualRect(current).topLeft().x() < column_not_move_->columnWidth(0) ){
const int new_value = horizontalScrollBar()->value() + this->visualRect(current).topLeft().x() - column_not_move_->columnWidth(0);
horizontalScrollBar()->setValue(new_value);
}
return current;
}
void SequenceTableView::scrollTo(const QModelIndex & index, ScrollHint hint){
if(index.column()>0){
QTableView::scrollTo(index, hint);
}
}
void SequenceTableView::updateNotMoveColumn()
{
int x = this->verticalHeader()->width()+this->frameWidth();
int y = this->frameWidth();
int w = this->columnWidth(0);
int h = this->viewport()->height()+this->horizontalHeader()->height();
column_not_move_->setGeometry(x,y,w,h);
}
SequenceTableView::~SequenceTableView(){}
}}
//------------------------------------------------------------------------------
// 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_SEQUENCE_TABLE_VIEW
#define OST_SEQUENCE_VIEWER_SEQUENCE_TABLE_VIEW
/*
Author: Stefan Scheuber
*/
#include <QTableView>
#include <ost/gui/module_config.hh>
namespace ost { namespace gui {
/// \brief QTableView with first column not moving
class DLLEXPORT_OST_GUI SequenceTableView : public QTableView {
Q_OBJECT
public:
SequenceTableView(QAbstractItemModel * model);
~SequenceTableView();
protected:
virtual void resizeEvent(QResizeEvent *event);
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
void scrollTo (const QModelIndex & index, ScrollHint hint = EnsureVisible);
private slots:
void ResizeWidth(int index, int, int size);
void ResizeHeight(int index, int, int size);
private:
QTableView *column_not_move_;
void updateNotMoveColumn();
};
}}
#endif
//------------------------------------------------------------------------------
// 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 <QStandardItem>
#include <QVBoxLayout>
#include "sequence_viewer.hh"
#include "sequence_table_view.hh"
namespace ost { namespace gui {
SequenceViewerV2::SequenceViewerV2(QWidget* parent): Widget(NULL,parent)
{
QStandardItemModel* model=new QStandardItemModel();
QStandardItem* item = new QStandardItem("Best protein the world has ever seen");
model->setItem(0, 0, item);
item = new QStandardItem("slakdjjjjjjjjjjjjjjjjjjjjjjjjlakskdjaksdjaksldjalsdjaklsdjalskdjaskdjaksdjaksdjkasjdkasjdklasdjladjkdjfhjksgb,myxcnaiosjh3iklrjakslfjka");
model->setItem(0, 1, item);
item = new QStandardItem("Worst protein the world has ever seen");
model->setItem(1, 0, item);
item = new QStandardItem("slakdjjjjjjjjjjjjjjjjjjjjjjjjlakskdjaksdjaksldjalsdjaklsdjalskdjaskdjaksdjaksdjkasjdkasjdklasdjladjkdjfhjksgb,myxcnaiosjh3iklrjakslfjkb");
model->setItem(1, 1, item);
QVBoxLayout* layout = new QVBoxLayout(this);
seq_table_view_ = new SequenceTableView(model);
layout->addWidget(seq_table_view_);
this->setLayout(layout);
}
SequenceViewerV2::~SequenceViewerV2(){}
}}
//------------------------------------------------------------------------------
// 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_SEQUENCE_VIEWER
#define OST_SEQUENCE_VIEWER_SEQUENCE_VIEWER
/*
Author: Stefan Scheuber
*/
#include <QWidget>
#include <QTableView>
#include <ost/gui/widget.hh>
#include <ost/gui/module_config.hh>
namespace ost { namespace gui {
/// \brief QTableView with first column not moving
class DLLEXPORT_OST_GUI SequenceViewerV2 : public Widget {
Q_OBJECT
public:
SequenceViewerV2(QWidget* parent=NULL);
~SequenceViewerV2();
virtual bool Restore(const QString&){return true;};
virtual bool Save(const QString&){return true;};
private:
QTableView* seq_table_view_;
};
}}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment