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
16// forward declare
17namespace Mantid::Kernel {
18class Quat;
19class V3D;
20} // namespace Mantid::Kernel
21
22namespace {
23// Deprecation wrappers. Absolute/relative placement is available from the
24// index-based ComponentInfo access layer. See the 'Instrument Access via
25// SpectrumInfo, DetectorInfo, ComponentInfo' concept page. (The parameter and
26// description accessors are intentionally not deprecated yet; they have no
27// ComponentInfo equivalent and await the parameter-map redesign.)
28Mantid::Kernel::Quat getRotationDeprecated(const Component &self) {
29 PyErr_Warn(PyExc_DeprecationWarning, "'Component.getRotation()' is deprecated in Mantid 7.0, "
30 "use 'ComponentInfo.rotation' instead. "
31 "For more information, see the instrument access layers concept page: "
32 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html");
33 return self.getRotation();
34}
35
36Mantid::Kernel::V3D getRelativePosDeprecated(const Component &self) {
37 PyErr_Warn(PyExc_DeprecationWarning, "'Component.getRelativePos' is deprecated in Mantid 7.0, "
38 "use 'ComponentInfo.relativePosition' instead. "
39 "For more information, see the instrument access layers concept page: "
40 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html");
41 return self.getRelativePos();
42}
43
44GNU_DIAG_OFF("unused-local-typedef")
45// Ignore -Wconversion warnings coming from boost::python
46// Seen with GCC 7.1.1 and Boost 1.63.0
47GNU_DIAG_OFF("conversion")
48
49// Default parameter function overloads
50// cppcheck-suppress unknownMacro
51BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getParameterNames, Component::getParameterNames, 0, 1)
52BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_hasParameter, Component::hasParameter, 1, 2)
53BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getNumberParameter, Component::getNumberParameter, 1, 2)
54BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getBoolParameter, Component::getBoolParameter, 1, 2)
55BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getPositionParameter, Component::getPositionParameter, 1, 2)
56BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getRotationParameter, Component::getRotationParameter, 1, 2)
57BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getStringParameter, Component::getStringParameter, 1, 2)
58BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getIntParameter, Component::getIntParameter, 1, 2)
59BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getParameterType, Component::getParameterType, 1, 2)
60BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getParamShortDescription, Component::getParamShortDescription, 1, 2)
61BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getParamDescription, Component::getParamDescription, 1, 2)
62
63GNU_DIAG_ON("conversion")
64GNU_DIAG_ON("unused-local-typedef")
65} // namespace
67 class_<Component, bases<IComponent>, boost::noncopyable>("Component", no_init)
68 .def("getParameterNames", &Component::getParameterNames,
69 Component_getParameterNames((arg("self"), arg("recursive") = true)))
70 .def("hasParameter", &Component::hasParameter,
71 Component_hasParameter((arg("self"), arg("name"), arg("recursive") = true)))
72 .def("getNumberParameter", &Component::getNumberParameter,
73 Component_getNumberParameter((arg("self"), arg("pname"), arg("recursive") = true)))
74 .def("getBoolParameter", &Component::getBoolParameter,
75 Component_getBoolParameter((arg("self"), arg("pname"), arg("recursive") = true)))
76 .def("getPositionParameter", &Component::getPositionParameter,
77 Component_getPositionParameter((arg("self"), arg("pname"), arg("recursive") = true)))
78 .def("getRotationParameter", &Component::getRotationParameter,
79 Component_getRotationParameter((arg("self"), arg("pname"), arg("recursive") = true)))
80 .def("getStringParameter", &Component::getStringParameter,
81 Component_getStringParameter((arg("self"), arg("pname"), arg("recursive") = true)))
82 .def("getIntParameter", &Component::getIntParameter,
83 Component_getIntParameter((arg("self"), arg("pname"), arg("recursive") = true)))
84 //
85 .def("getRotation", &getRotationDeprecated, arg("self"),
86 "Returns the absolute rotation as a Quat (deprecated, use ComponentInfo.rotation)")
87 .def("getRelativePos", &getRelativePosDeprecated, arg("self"),
88 "Returns the relative position as a V3D (deprecated, use ComponentInfo.relativePosition)")
89 //
90 .def("getParamShortDescription", &Component::getParamShortDescription,
91 Component_getParamShortDescription((arg("self"), arg("pname"), arg("recursive") = true)))
92 .def("getParamDescription", &Component::getParamDescription,
93 Component_getParamDescription((arg("self"), arg("pname"), arg("recursive") = true)))
94
95 .def("getShortDescription", &Component::getShortDescription, arg("self"),
96 "Return the short description of current parameterized component")
97 .def("getDescription", &Component::getDescription, arg("self"),
98 "Return the description of current parameterized component")
99 .def("setDescription", &Component::setDescription, (arg("self"), arg("descr")),
100 "Set component's description, works only if the component is "
101 "parameterized component")
102
103 // HACK -- python should return parameters regardless of type. this is
104 // untill rows below do not work
105 .def("getParameterType", &Component::getParameterType,
106 Component_getParameterType((arg("self"), arg("pname"), arg("recursive") = true)))
107 .def("getFittingParameter", &Component::getFittingParameter, (arg("self"), arg("pname"), arg("xvalue")),
108 "Get fit parameter from the parameter map."
109 " The value of the parameter is determined from a look up table or a formula")
111 //.def("getParameter", &Component::getNumberParameter,
112 // Component_getNumberParameter())
113 //.def("getParameter", &Component::getBoolParameter,
114 // Component_getBoolParameter())
115 //.def("getParameter", &Component::getStringParameter,
116 // Component_getStringParameter())
117 //.def("getParameter", &Component::getPositionParameter,
118 // Component_getPositionParameter())
119 //.def("getParameter", &Component::getRotationParameter,
120 // Component_getRotationParameter())
121 ;
122}
void export_Component()
Definition Component.cpp:66
#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:42
Kernel::V3D getRelativePos() const override
Get the position relative to the parent IComponent (absolute if no parent)
Kernel::Quat getRotation() const override
Get the absolute orientation of the IComponent.
base class for Geometric IComponent
Definition IComponent.h:53
Class for quaternions.
Definition Quat.h:39
Class for 3D vectors.
Definition V3D.h:34