Mantid
Loading...
Searching...
No Matches
Component.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
9#include <boost/python/class.hpp>
10#include <boost/python/overloads.hpp>
11
14using namespace boost::python;
15
16namespace {
17GNU_DIAG_OFF("unused-local-typedef")
18// Ignore -Wconversion warnings coming from boost::python
19// Seen with GCC 7.1.1 and Boost 1.63.0
20GNU_DIAG_OFF("conversion")
21
22// Default parameter function overloads
23BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getParameterNames, Component::getParameterNames, 0, 1)
24BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_hasParameter, Component::hasParameter, 1, 2)
25BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getNumberParameter, Component::getNumberParameter, 1, 2)
26BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getBoolParameter, Component::getBoolParameter, 1, 2)
27BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getPositionParameter, Component::getPositionParameter, 1, 2)
28BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getRotationParameter, Component::getRotationParameter, 1, 2)
29BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getStringParameter, Component::getStringParameter, 1, 2)
30BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getIntParameter, Component::getIntParameter, 1, 2)
31BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getParameterType, Component::getParameterType, 1, 2)
32BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getRotation, Component::getRotation, 0, 0)
33BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getRelativePos, Component::getRelativePos, 0, 0)
34BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getParamShortDescription, Component::getParamShortDescription, 1, 2)
35BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getParamDescription, Component::getParamDescription, 1, 2)
36
37GNU_DIAG_ON("conversion")
38GNU_DIAG_ON("unused-local-typedef")
39} // namespace
41 class_<Component, bases<IComponent>, boost::noncopyable>("Component", no_init)
42 .def("getParameterNames", &Component::getParameterNames,
43 Component_getParameterNames((arg("self"), arg("recursive") = true)))
44 .def("hasParameter", &Component::hasParameter,
45 Component_hasParameter((arg("self"), arg("name"), arg("recursive") = true)))
46 .def("getNumberParameter", &Component::getNumberParameter,
47 Component_getNumberParameter((arg("self"), arg("pname"), arg("recursive") = true)))
48 .def("getBoolParameter", &Component::getBoolParameter,
49 Component_getBoolParameter((arg("self"), arg("pname"), arg("recursive") = true)))
50 .def("getPositionParameter", &Component::getPositionParameter,
51 Component_getPositionParameter((arg("self"), arg("pname"), arg("recursive") = true)))
52 .def("getRotationParameter", &Component::getRotationParameter,
53 Component_getRotationParameter((arg("self"), arg("pname"), arg("recursive") = true)))
54 .def("getStringParameter", &Component::getStringParameter,
55 Component_getStringParameter((arg("self"), arg("pname"), arg("recursive") = true)))
56 .def("getIntParameter", &Component::getIntParameter,
57 Component_getIntParameter((arg("self"), arg("pname"), arg("recursive") = true)))
58 //
59 .def("getRotation", &Component::getRotation, Component_getRotation(arg("self")))
60 .def("getRelativePos", &Component::getRelativePos, Component_getRelativePos(arg("self")))
61 //
62 .def("getParamShortDescription", &Component::getParamShortDescription,
63 Component_getParamShortDescription((arg("self"), arg("pname"), arg("recursive") = true)))
64 .def("getParamDescription", &Component::getParamDescription,
65 Component_getParamDescription((arg("self"), arg("pname"), arg("recursive") = true)))
66
67 .def("getShortDescription", &Component::getShortDescription, arg("self"),
68 "Return the short description of current parameterized component")
69 .def("getDescription", &Component::getDescription, arg("self"),
70 "Return the description of current parameterized component")
71 .def("setDescription", &Component::setDescription, (arg("self"), arg("descr")),
72 "Set component's description, works only if the component is "
73 "parameterized component")
74
75 // HACK -- python should return parameters regardless of type. this is
76 // untill rows below do not work
77 .def("getParameterType", &Component::getParameterType,
78 Component_getParameterType((arg("self"), arg("pname"), arg("recursive") = true)))
80 //.def("getParameter", &Component::getNumberParameter,
81 // Component_getNumberParameter())
82 //.def("getParameter", &Component::getBoolParameter,
83 // Component_getBoolParameter())
84 //.def("getParameter", &Component::getStringParameter,
85 // Component_getStringParameter())
86 //.def("getParameter", &Component::getPositionParameter,
87 // Component_getPositionParameter())
88 //.def("getParameter", &Component::getRotationParameter,
89 // Component_getRotationParameter())
90
91 ;
92}
void export_Component()
Definition: Component.cpp:40
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(valueAsPrettyStrOverloader, valueAsPrettyStr, 0, 2) void export_Property()
Definition: Property.cpp:102
#define GNU_DIAG_ON(x)
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
Component is a wrapper for a Component which can modify some of its parameters, e....
Definition: Component.h:41
std::string getParamDescription(const std::string &pname, bool recursive=true) const
Get description of a parameter attached to this component
Definition: Component.cpp:585
std::string getParamShortDescription(const std::string &pname, bool recursive=true) const
Get a component's parameter short description.
Definition: Component.cpp:616
std::vector< double > getNumberParameter(const std::string &pname, bool recursive=true) const override
Get a parameter defined as a double.
Definition: Component.h:149
std::vector< Kernel::Quat > getRotationParameter(const std::string &pname, bool recursive=true) const override
Get a parameter defined as a Kernel::Quaternion.
Definition: Component.h:227
Kernel::V3D getRelativePos() const override
Get the position relative to the parent IComponent (absolute if no parent)
Definition: Component.cpp:308
std::vector< int > getIntParameter(const std::string &pname, bool recursive=true) const override
Get a parameter defined as an int.
Definition: Component.h:160
std::vector< Kernel::V3D > getPositionParameter(const std::string &pname, bool recursive=true) const override
Get a parameter defined as a Kernel::V3D.
Definition: Component.h:216
std::string getParameterType(const std::string &pname, bool recursive=true) const override
Get a parameter's type – this is HACK until Python can export property regardless of the property typ...
Definition: Component.h:173
std::set< std::string > getParameterNames(bool recursive=true) const override
Return the parameter names.
Definition: Component.cpp:436
std::vector< std::string > getStringParameter(const std::string &pname, bool recursive=true) const override
Get a parameter defined as a string.
Definition: Component.h:238
Kernel::Quat getRotation() const override
Get the absolute orientation of the IComponent.
Definition: Component.cpp:387
void setDescription(const std::string &descr)
Set components description.
Definition: Component.cpp:641
std::string getDescription() const
Get this component parameter's description – no recursive search within children.
Definition: Component.cpp:601
bool hasParameter(const std::string &name, bool recursive=true) const override
Returns a boolean indicating if the component has the named parameter.
Definition: Component.cpp:486
std::vector< bool > getBoolParameter(const std::string &pname, bool recursive=true) const override
Get a parameter defined as a bool.
Definition: Component.h:205
std::string getShortDescription() const
Get a components's short description.
Definition: Component.cpp:634
base class for Geometric IComponent
Definition: IComponent.h:51