Skip to content
Snippets Groups Projects
Commit 215f161d authored by Marco Biasini's avatar Marco Biasini
Browse files

remove entity explorer. it hasn't been used for ages

parent 82504b08
No related branches found
No related tags found
No related merge requests found
//------------------------------------------------------------------------------
// 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
//------------------------------------------------------------------------------
// 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
//------------------------------------------------------------------------------
// 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();
}
}}
//------------------------------------------------------------------------------
// 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
//------------------------------------------------------------------------------
// 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;
}
}}
//------------------------------------------------------------------------------
// 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
//------------------------------------------------------------------------------
// 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
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment