From be6d6e3477b00424ade7026800cd9f3e6e1ce505 Mon Sep 17 00:00:00 2001 From: Marco Biasini <marco.biasini@unibas.ch> Date: Sun, 20 Feb 2011 11:16:12 +0100 Subject: [PATCH] added overload to Entity.selection that accepts a string: ent.selection='aname=CA' is equivalent to ent.selection=ent.view.Select('aname=CA') --- modules/gfx/pymod/export_entity.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/gfx/pymod/export_entity.cc b/modules/gfx/pymod/export_entity.cc index 83dee487c..9092a6344 100644 --- a/modules/gfx/pymod/export_entity.cc +++ b/modules/gfx/pymod/export_entity.cc @@ -185,6 +185,7 @@ void ent_apply_61(Entity* e, MapHandleColorOp& mhco, bool store){ void ent_apply_62(Entity* e, MapHandleColorOp& mhco){ e->Apply(mhco); } + #endif //OST_IMG_ENABLED RenderOptionsPtr ent_sline_opts(Entity* ent) @@ -238,6 +239,18 @@ RenderOptionsPtr ent_ltrace_opts(Entity* ent) return ent->GetOptions(RenderMode::LINE_TRACE); } +void set_selection(Entity* ent, object sel) +{ + try { + String sel_string=extract<String>(sel); + ent->SetSelection(ent->GetView().Select(sel_string)); + } catch (error_already_set& e) { + PyErr_Clear(); + mol::EntityView view=extract<mol::EntityView>(sel); + ent->SetSelection(view); + } +} + } void export_Entity() @@ -259,7 +272,7 @@ void export_Entity() .def("SetSelection",&Entity::SetSelection) .def("GetSelection",&Entity::GetSelection) .add_property("selection", &Entity::GetSelection, - &Entity::SetSelection) + &set_selection) .def("GetView", &Entity::GetView) .def("UpdateView", &Entity::UpdateView) .def("SetQuery", set_query1) -- GitLab