Ignore:
Timestamp:
Apr 23, 2021, 8:43:45 PM (5 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Candidate_v1.7.0, stable
Children:
51d384a
Parents:
38bcbe
git-author:
Frederik Heber <frederik.heber@…> (10/07/20 19:05:19)
git-committer:
Frederik Heber <frederik.heber@…> (04/23/21 20:43:45)
Message:

Added python getters for selected atom ids and elements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Python/PythonScripting_impl.hpp

    r38bcbe rea30e6  
    100100      "returns the volume of the simulation domain."
    101101  );
     102  boost::python::def< MoleCuilder::detail::elementVec() >(
     103      "getSelectedAtomElements",
     104      MoleCuilder::detail::module_getSelectedAtomElements,
     105      "returns the element numbers of all currently selected atoms."
     106  );
     107  boost::python::def< MoleCuilder::detail::atomIdVec() >(
     108      "getSelectedAtomIds",
     109      MoleCuilder::detail::module_getSelectedAtomIds,
     110      "returns the ids of all currently selected atoms."
     111  );
    102112  boost::python::def< double() >(
    103113      "getSelectedMolarMass",
     
    107117
    108118  // STL Vectors:
     119  // unsignedIntVec
     120  boost::python::class_< std::vector< atomId_t > >("PythonType_unsignedIntVec")
     121      .def("__len__", &std::vector< unsigned int >::size)
     122      .def("clear", &std::vector< unsigned int >::clear)
     123      .def("append", &MoleCuilder::PythonTypes::vec_item< std::vector< unsigned int > >::add,
     124            boost::python::with_custodian_and_ward<1, 2>()) // let container keep value
     125      .def("__getitem__", &MoleCuilder::PythonTypes::vec_item< std::vector< unsigned int > >::get,
     126           boost::python::return_value_policy<boost::python::copy_non_const_reference>())
     127      .def("__setitem__", &MoleCuilder::PythonTypes::vec_item< std::vector< unsigned int > >::set,
     128           boost::python::with_custodian_and_ward<1,2>()) // to let container keep value
     129      .def("__delitem__", &MoleCuilder::PythonTypes::vec_item< std::vector< unsigned int > >::del)
     130      .def("__iter__", boost::python::iterator< std::vector< unsigned int > >())
     131  ;
    109132  // doubleVec
    110133  boost::python::class_< std::vector< double > >("PythonType_doubleVec")
Note: See TracChangeset for help on using the changeset viewer.