Skip to content
Snippets Groups Projects
Commit 43bafdb8 authored by tobias's avatar tobias
Browse files

additional selection options for right click menu

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2688 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent abceb8d8
No related branches found
No related tags found
No related merge requests found
...@@ -29,8 +29,14 @@ namespace ost { namespace gui { ...@@ -29,8 +29,14 @@ namespace ost { namespace gui {
SceneMenu::SceneMenu() { SceneMenu::SceneMenu() {
context_menu_=new QMenu(); context_menu_=new QMenu();
select_menu_=context_menu_->addMenu("Select"); select_menu_=context_menu_->addMenu("Select");
QAction* a=select_menu_->addAction("Around Atom"); QAction* a=select_menu_->addAction("Atom");
connect(a, SIGNAL(triggered()), this, SLOT(SelectAtom()));
a=select_menu_->addAction("Residue");
connect(a, SIGNAL(triggered()), this, SLOT(SelectResidue()));
a=select_menu_->addAction("Around Atom");
connect(a, SIGNAL(triggered()), this, SLOT(SelectAroundAtom())); connect(a, SIGNAL(triggered()), this, SLOT(SelectAroundAtom()));
a=select_menu_->addAction("Around Residue");
connect(a, SIGNAL(triggered()), this, SLOT(SelectAroundResidue()));
a=select_menu_->addAction("Backbone"); a=select_menu_->addAction("Backbone");
connect(a, SIGNAL(triggered()), this, SLOT(SelectBackbone())); connect(a, SIGNAL(triggered()), this, SLOT(SelectBackbone()));
a=select_menu_->addAction("Sidechains"); a=select_menu_->addAction("Sidechains");
...@@ -76,6 +82,32 @@ void SceneMenu::SelectAroundAtom() ...@@ -76,6 +82,32 @@ void SceneMenu::SelectAroundAtom()
e->SetSelection(v); e->SetSelection(v);
} }
void SceneMenu::SelectAroundResidue()
{
gfx::EntityP e=dyn_cast<gfx::Entity>(picked_.first);
mol::EntityView v=e->GetView().CreateEmptyView();
v.AddAtom(picked_.second);
v=v.ExtendViewToResidues();
v=v.ExtendViewToSurrounding(0.5);
e->SetSelection(v.ExtendViewToResidues());
}
void SceneMenu::SelectAtom()
{
gfx::EntityP e=dyn_cast<gfx::Entity>(picked_.first);
mol::EntityView v=e->GetView().CreateEmptyView();
v.AddAtom(picked_.second);
e->SetSelection(v);
}
void SceneMenu::SelectResidue()
{
gfx::EntityP e=dyn_cast<gfx::Entity>(picked_.first);
mol::EntityView v=e->GetView().CreateEmptyView();
v.AddAtom(picked_.second);
e->SetSelection(v.ExtendViewToResidues());
}
void SceneMenu::Select(const String& str) void SceneMenu::Select(const String& str)
{ {
gfx::EntityP e=dyn_cast<gfx::Entity>(picked_.first); gfx::EntityP e=dyn_cast<gfx::Entity>(picked_.first);
......
...@@ -43,6 +43,9 @@ public slots: ...@@ -43,6 +43,9 @@ public slots:
void SelectSidechains(); void SelectSidechains();
void SelectLigands(); void SelectLigands();
void SelectAroundAtom(); void SelectAroundAtom();
void SelectAroundResidue();
void SelectAtom();
void SelectResidue();
void Select(const String& str); void Select(const String& str);
void UnSelect(); void UnSelect();
void CenterOnAtom(); void CenterOnAtom();
......
...@@ -86,6 +86,8 @@ void export_EntityView() ...@@ -86,6 +86,8 @@ void export_EntityView()
class_<EntityView, bases<EntityBase> >("EntityView", init<>()) class_<EntityView, bases<EntityBase> >("EntityView", init<>())
.def("Copy", &EntityView::Copy) .def("Copy", &EntityView::Copy)
.def("ExtendViewToResidues", &EntityView::ExtendViewToResidues)
.def("ExtendViewToSurrounding", &EntityView::ExtendViewToSurrounding)
.def("FindChain", find_chain_str) .def("FindChain", find_chain_str)
.def("FindResidue", &EntityView::FindResidue) .def("FindResidue", &EntityView::FindResidue)
.def("FindAtom", find_atom_a) .def("FindAtom", find_atom_a)
......
...@@ -773,6 +773,42 @@ void EntityView::RemoveAtomInternal(const AtomView& av) ...@@ -773,6 +773,42 @@ void EntityView::RemoveAtomInternal(const AtomView& av)
data_->handle_to_view.erase(av.GetHandle().GetHashCode()); data_->handle_to_view.erase(av.GetHandle().GetHashCode());
} }
EntityView EntityView::ExtendViewToResidues() const
{
this->CheckValidity();
EntityView view=this->CreateEmptyView();
ResidueViewList residues=this->GetResidueList();
ResidueViewList::const_iterator res_it;
for (res_it=residues.begin(); res_it!=residues.end(); ++res_it) {
view.AddResidue((*res_it).GetHandle(),
mol::ViewAddFlag::INCLUDE_ALL|mol::ViewAddFlag::CHECK_DUPLICATES);
}
view.AddAllInclusiveBonds();
return view;
}
EntityView EntityView::ExtendViewToSurrounding(Real gap) const
{
this->CheckValidity();
EntityView view=this->CreateEmptyView();
AtomViewList atoms=this->GetAtomList();
AtomViewList::const_iterator atm_it;
Real max_dist=5+gap;
for (atm_it=atoms.begin(); atm_it!=atoms.end(); ++atm_it) {
view.AddAtom((*atm_it),mol::ViewAddFlag::INCLUDE_ALL|mol::ViewAddFlag::CHECK_DUPLICATES);
AtomHandleList prot_atoms=this->GetHandle().FindWithin((*atm_it).GetPos(),max_dist);
AtomHandleList::const_iterator protatm_it;
for (protatm_it=prot_atoms.begin(); protatm_it!=prot_atoms.end(); ++protatm_it){
Real dist=geom::Distance((*atm_it).GetPos(), (*protatm_it).GetPos());
if (dist <= (*atm_it).GetRadius() + (*protatm_it).GetRadius() + gap) {
view.AddAtom((*protatm_it),mol::ViewAddFlag::INCLUDE_ALL|mol::ViewAddFlag::CHECK_DUPLICATES);
}
}
}
view.AddAllInclusiveBonds();
return view;
}
namespace { namespace {
class EntityViewDumper : public EntityVisitor { class EntityViewDumper : public EntityVisitor {
......
...@@ -286,6 +286,16 @@ public: ...@@ -286,6 +286,16 @@ public:
Real GetAngle(const AtomView& a1, const AtomView& a2, Real GetAngle(const AtomView& a1, const AtomView& a2,
const AtomView& a3) const; const AtomView& a3) const;
/// \brief Extend current view to include all atoms of each residue where
/// at least one atom is selected currently
EntityView ExtendViewToResidues() const;
/// \brief Extend current view to include all atoms that are within the sum
/// of their vdw radii + gap
///
/// Include all atoms within: at1.GetRadius() + at2.GetRadius() + gap
EntityView ExtendViewToSurrounding(Real gap) const;
/// \brief returns a string containing a human-readable summary of the /// \brief returns a string containing a human-readable summary of the
/// entity view /// entity view
String Dump() const; String Dump() const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment