From 215f161d4c4794f6b7edf881177a942dd20928ef Mon Sep 17 00:00:00 2001 From: Marco Biasini <marco.biasini@unibas.ch> Date: Thu, 24 Feb 2011 08:40:38 +0100 Subject: [PATCH] remove entity explorer. it hasn't been used for ages --- .../src/entity_explorer/entity_explorer.cc | 61 ------ .../src/entity_explorer/entity_explorer.hh | 47 ----- .../entity_explorer/entity_explorer_model.cc | 128 ------------ .../entity_explorer/entity_explorer_model.hh | 68 ------ modules/gui/src/entity_explorer/info_panel.cc | 34 --- modules/gui/src/entity_explorer/info_panel.hh | 49 ----- modules/gui/src/entity_explorer/menu_item.cc | 18 -- modules/gui/src/entity_explorer/menu_item.hh | 196 ------------------ 8 files changed, 601 deletions(-) delete mode 100644 modules/gui/src/entity_explorer/entity_explorer.cc delete mode 100644 modules/gui/src/entity_explorer/entity_explorer.hh delete mode 100644 modules/gui/src/entity_explorer/entity_explorer_model.cc delete mode 100644 modules/gui/src/entity_explorer/entity_explorer_model.hh delete mode 100644 modules/gui/src/entity_explorer/info_panel.cc delete mode 100644 modules/gui/src/entity_explorer/info_panel.hh delete mode 100644 modules/gui/src/entity_explorer/menu_item.cc delete mode 100644 modules/gui/src/entity_explorer/menu_item.hh diff --git a/modules/gui/src/entity_explorer/entity_explorer.cc b/modules/gui/src/entity_explorer/entity_explorer.cc deleted file mode 100644 index b05d1765d..000000000 --- a/modules/gui/src/entity_explorer/entity_explorer.cc +++ /dev/null @@ -1,61 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2011 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 <ost/gui/gl_canvas.hh> - -#include <ost/gfx/scene.hh> - - -#include "entity_explorer_model.hh" -#include "entity_explorer.hh" -#include "menu_item.hh" - -// Qt includes must come last -#include <QDebug> -#include <QMetaProperty> -#include <QLayout> - -namespace ost { namespace gui { - -class MenuItem; - -EntityExplorer::EntityExplorer(QWidget* p) - : QTreeView(p) { - this->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, - QSizePolicy::MinimumExpanding)); - EntityExplorerModel* model=new EntityExplorerModel(this); - this->setModel(model); - QObject::connect(this, SIGNAL(doubleClicked(const QModelIndex&)), - this, SLOT(DoubleClicked(const QModelIndex&))); -} - -void EntityExplorer::OnAction(QAction* action) { - -} - -void EntityExplorer::DoubleClicked(const QModelIndex& index) { - MenuItem* item=static_cast<MenuItem*>(index.internalPointer()); - if (AtomViewMenuItem* atom_item=dynamic_cast<AtomViewMenuItem*>(item)) { - gfx::Scene& scene=gfx::Scene::Instance(); - scene.SetCenter(atom_item->Atom().GetPos()); - scene.RequestRedraw(); - } -} - - -}} // ns diff --git a/modules/gui/src/entity_explorer/entity_explorer.hh b/modules/gui/src/entity_explorer/entity_explorer.hh deleted file mode 100644 index ea5c9f503..000000000 --- a/modules/gui/src/entity_explorer/entity_explorer.hh +++ /dev/null @@ -1,47 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2011 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_ENTITY_EXPLORER_HH -#define OST_GUI_ENTITY_EXPLORER_HH - -//#include <ost/signals.hh> -#include <ost/gui/module_config.hh> - -// Qt includes must come last -#include <QTreeView> -#include <QMainWindow> - -namespace ost { namespace gui { - -class GLWin; - -/// \brief Interactive scene menu -class DLLEXPORT_OST_GUI EntityExplorer: public QTreeView -{ - Q_OBJECT; -public: - EntityExplorer(QWidget* p); - -public slots: - void OnAction(QAction* action); - void DoubleClicked(const QModelIndex& index); -}; - -}} // ns - -#endif diff --git a/modules/gui/src/entity_explorer/entity_explorer_model.cc b/modules/gui/src/entity_explorer/entity_explorer_model.cc deleted file mode 100644 index bfe115c1f..000000000 --- a/modules/gui/src/entity_explorer/entity_explorer_model.cc +++ /dev/null @@ -1,128 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2011 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 <ost/gfx/scene.hh> -#include <ost/gfx/entity.hh> - -#include "entity_explorer_model.hh" -#include "menu_item.hh" - - -#include <QDebug> - -namespace ost { namespace gui { - -EntityExplorerModel::EntityExplorerModel(QObject* parent) - : QAbstractItemModel(parent), root_(new MenuItem(NULL)) { - gfx::Scene::Instance().AttachObserver(this); -} - -EntityExplorerModel::~EntityExplorerModel() -{ - gfx::Scene::Instance().DetachObserver(this); - delete root_; -} - -QVariant EntityExplorerModel::data(const QModelIndex& index, int role) const { - if (role==Qt::DisplayRole) { - MenuItem* item=static_cast<MenuItem*>(index.internalPointer()); - if (item) - return item->Data(); - } - return QVariant(); -} - -Qt::ItemFlags EntityExplorerModel::flags(const QModelIndex& index) const { - if (index.isValid()) - return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsUserCheckable; - return Qt::ItemIsEnabled; -} - -QVariant EntityExplorerModel::headerData(int section, Qt::Orientation orientation, - int role) const { - return QVariant(QString("Name")); -} - - -QModelIndex EntityExplorerModel::index(int row, int column, - const QModelIndex& parent) const { - MenuItem* item=root_; - if (parent.isValid()) - item=static_cast<MenuItem*>(parent.internalPointer()); - assert(item); - return createIndex(row, column, (item->Children())[row]); -} - -QModelIndex EntityExplorerModel::parent(const QModelIndex& index) const { - if (!index.isValid()) - return QModelIndex(); - MenuItem* item=static_cast<MenuItem*>(index.internalPointer()); - assert(item!=NULL); - if (item->Parent()==root_) { - return QModelIndex(); - } - return createIndex(item->Parent()->Row(), 0, item->Parent()); -} - -int EntityExplorerModel::rowCount(const QModelIndex& parent) const { - MenuItem* item=root_; - if (parent.isValid()) - item=static_cast<MenuItem*>(parent.internalPointer()); - assert(item!=NULL); - return item->Children().size(); -} - -int EntityExplorerModel::columnCount(const QModelIndex& parent) const { - return 1; -} - -void EntityExplorerModel::ObjectAdded(const gfx::GfxObjP& object) { -#if 0 - // needs new GfxNodeVisitor implementation - gfx::Scene& scene=gfx::Scene::Instance(); - this->beginInsertRows(QModelIndex(),scene.SceneObjects().size()-1, - scene.SceneObjects().size()-1); - root_->Children().push_back(new GfxObjMenuItem(root_, object)); - this->endInsertRows(); -#endif -} - -mol::EntityView EntityExplorerModel::GetEntity(const QModelIndex& index) const { -#if 0 - // needs new GfxNodeVisitor implementation - gfx::GfxObjList& ol=gfx::Scene::Instance().SceneObjects(); - gfx::EntityP e=dyn_cast<gfx::Entity>(ol[index.row()]); - if (e) - return e->GetView(); - else -#endif - return mol::EntityView(); -} - -mol::ChainView EntityExplorerModel::GetChain(const QModelIndex& index) const { - return (this->GetEntity(index.parent()).GetChainList())[index.row()]; -} - -mol::ResidueView EntityExplorerModel::GetResidue(const QModelIndex& index) const { - return mol::ResidueView(); -} - - -}} - - diff --git a/modules/gui/src/entity_explorer/entity_explorer_model.hh b/modules/gui/src/entity_explorer/entity_explorer_model.hh deleted file mode 100644 index 23af90cea..000000000 --- a/modules/gui/src/entity_explorer/entity_explorer_model.hh +++ /dev/null @@ -1,68 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2011 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_ENTITY_EXPLORER_MODEL_HH -#define OST_GUI_ENTITY_EXPLORER_MODEL_HH - - -#include <ost/mol/mol.hh> - -#include <ost/gfx/scene_observer.hh> -#include <ost/gfx/gfx_object.hh> -#include <ost/gui/module_config.hh> - -// Qt includes must come last -#include <QAbstractItemModel> - - -namespace ost { namespace gui { - -class MenuItem; - -namespace lvl { - typedef enum { Root=0, Entity, Chain, Residue, Atom } Level; -} - -/// \brief data model for the scene menu tree view -class DLLEXPORT_OST_GUI EntityExplorerModel : public QAbstractItemModel, - public gfx::SceneObserver { - Q_OBJECT -public: - EntityExplorerModel(QObject* parent); - ~EntityExplorerModel(); - QVariant data(const QModelIndex& index, int role) const; - Qt::ItemFlags flags(const QModelIndex& index) const; - QVariant headerData(int section, Qt::Orientation orientation, - int role=Qt::DisplayRole) const; - QModelIndex index(int row, int column, - const QModelIndex& parent=QModelIndex()) const; - QModelIndex parent(const QModelIndex& index) const; - int rowCount(const QModelIndex& parent=QModelIndex()) const; - int columnCount(const QModelIndex& parent=QModelIndex()) const; -public: - virtual void ObjectAdded(const gfx::GfxObjP& object); -private: - mol::EntityView GetEntity(const QModelIndex& index) const; - mol::ChainView GetChain(const QModelIndex& index) const; - mol::ResidueView GetResidue(const QModelIndex& index) const; - MenuItem* root_; -}; - -}} - -#endif diff --git a/modules/gui/src/entity_explorer/info_panel.cc b/modules/gui/src/entity_explorer/info_panel.cc deleted file mode 100644 index 55f7a0160..000000000 --- a/modules/gui/src/entity_explorer/info_panel.cc +++ /dev/null @@ -1,34 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2011 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 "info_panel.hh" - -namespace ost { namespace gui { - -InfoPanel::InfoPanel(QWidget* parent) - : QWidget(parent), menu_item_(NULL) { -} - -void InfoPanel::Update() { - if (!menu_item_) - return; - -} - -}} - diff --git a/modules/gui/src/entity_explorer/info_panel.hh b/modules/gui/src/entity_explorer/info_panel.hh deleted file mode 100644 index 6f687c5b7..000000000 --- a/modules/gui/src/entity_explorer/info_panel.hh +++ /dev/null @@ -1,49 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2011 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_INFO_PANEL_HH -#define OST_GUI_INFO_PANEL_HH - -#include <ost/gui/module_config.hh> - -#include <QWidget> -#include <QTableWidget> - -namespace ost { namespace gui { - -class MenuItem; - -/// \brief info panel -class DLLEXPORT_OST_GUI InfoPanel : public QWidget { - Q_OBJECT; -public: - InfoPanel(QWidget* parent); - - void SetData(MenuItem* menu_item) { - menu_item_=menu_item; - this->Update(); - } -private: - void Update(); - MenuItem* menu_item_; - QTableWidget* table_; -}; - -}} - -#endif diff --git a/modules/gui/src/entity_explorer/menu_item.cc b/modules/gui/src/entity_explorer/menu_item.cc deleted file mode 100644 index 09f17e3e9..000000000 --- a/modules/gui/src/entity_explorer/menu_item.cc +++ /dev/null @@ -1,18 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2011 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 -//------------------------------------------------------------------------------ diff --git a/modules/gui/src/entity_explorer/menu_item.hh b/modules/gui/src/entity_explorer/menu_item.hh deleted file mode 100644 index 28ac6ebf5..000000000 --- a/modules/gui/src/entity_explorer/menu_item.hh +++ /dev/null @@ -1,196 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2011 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_MENU_ITEM_HH -#define OST_GUI_MENU_ITEM_HH - -#include <boost/checked_delete.hpp> - -#include <ost/dyn_cast.hh> -#include <ost/mol/mol.hh> - -#include <ost/gfx/gfx_object.hh> -#include <ost/gfx/scene.hh> -#include <ost/gfx/entity.hh> - -// Qt includes must come last -#include <QVariant> - -namespace ost { namespace gui { - -class DLLEXPORT_OST_GUI MenuItem { -public: - MenuItem(MenuItem* parent) - :parent_(parent) { - } - - MenuItem* Parent() { - return parent_; - } - - std::vector<MenuItem*>& Children() { - return children_; - } - - virtual ~MenuItem() { - std::for_each(children_.begin(), children_.end(), - boost::checked_deleter<MenuItem>()); - } - virtual int Row() const { - return 0; - } - virtual QVariant Data() {return QVariant();}; -private: - MenuItem* parent_; - std::vector<MenuItem*> children_; -}; - -class DLLEXPORT_OST_GUI AtomViewMenuItem : public MenuItem { -public: - AtomViewMenuItem(MenuItem* parent, const mol::AtomView& atom) - : MenuItem(parent), atom_(atom) { - } - - mol::AtomView& Atom() { - return atom_; - } - - virtual QVariant Data() { - return QVariant(QString(atom_.GetName().c_str())); - } - - virtual int Row() const { - mol::ResidueView r=atom_.GetResidue(); - mol::AtomViewList::const_iterator i=std::find(r.GetAtomList().begin(), - r.GetAtomList().end(), - atom_); - assert(i!=r.GetAtomList().end()); - return std::distance(r.GetAtomList().begin(), i); - } - -private: - mol::AtomView atom_; -}; - -class DLLEXPORT_OST_GUI ResidueViewMenuItem : public MenuItem { -public: - ResidueViewMenuItem(MenuItem* parent, const mol::ResidueView& residue) - : MenuItem(parent), residue_(residue) { - mol::AtomViewList::const_iterator i=residue.GetAtomList().begin(); - for (; i!= residue.GetAtomList().end(); ++i) { - Children().push_back(new AtomViewMenuItem(this, *i)); - } - } - - mol::ResidueView& Residue() { - return residue_; - } - - virtual QVariant Data() { - String text=residue_.GetKey()+residue_.GetNumber().AsString(); - return QVariant(QString(text.c_str())); - } - - virtual int Row() const { - mol::ChainView c=residue_.GetChain(); - mol::ResidueViewList::const_iterator i=std::find(c.GetResidueList().begin(), - c.GetResidueList().end(), - residue_); - assert(i!=c.GetResidueList().end()); - return std::distance(c.GetResidueList().begin(), i); - } - -private: - mol::ResidueView residue_; -}; - -class DLLEXPORT_OST_GUI ChainViewMenuItem : public MenuItem { -public: - ChainViewMenuItem(MenuItem* parent, const mol::ChainView& chain) - : MenuItem(parent), chain_(chain) { - mol::ResidueViewList::const_iterator i=chain.GetResidueList().begin(); - for (; i!= chain.GetResidueList().end(); ++i) { - Children().push_back(new ResidueViewMenuItem(this, *i)); - } - } - - mol::ChainView& Chain() { - return chain_; - } - virtual QVariant Data() { - return QVariant(QString(chain_.GetName().c_str())); - } - virtual int Row() const { - mol::EntityView e=chain_.GetEntity(); - mol::ChainViewList::const_iterator i=std::find(e.GetChainList().begin(), - e.GetChainList().end(), - chain_); - assert(i!=e.GetChainList().end()); - return std::distance(e.GetChainList().begin(), i); - } -private: - mol::ChainView chain_; -}; - -class DLLEXPORT_OST_GUI GfxObjMenuItem : public MenuItem { -public: - GfxObjMenuItem(MenuItem* parent, const gfx::GfxObjP& p): - MenuItem(parent), object_(p) { - mol::EntityView ev; - gfx::EntityP ecp = dyn_cast<gfx::Entity>(p); - if(ecp) { - ev=ecp->GetView(); - } - - if(!ev) return; - - mol::ChainViewList::const_iterator i=ev.GetChainList().begin(); - for (; i!= ev.GetChainList().end(); ++i) { - Children().push_back(new ChainViewMenuItem(this, *i)); - } - } - - gfx::GfxObjP Object() { - return object_; - } - - virtual QVariant Data() { - return QVariant(object_->GetName().c_str()); - } - - virtual int Row() const { -#if 0 - // needs new GfxNodeVisitor implementation - gfx::Scene& sc=gfx::Scene::Instance(); - gfx::GfxObjList::iterator i=std::find(sc.SceneObjects().begin(), - sc.SceneObjects().begin(), - object_); - assert(i!=sc.SceneObjects().end()); - return std::distance(sc.SceneObjects().begin(), i); -#else - return 0; -#endif - } - -private: - gfx::GfxObjP object_; -}; - -}} - -#endif -- GitLab