Mantid
Loading...
Searching...
No Matches
IComponent.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 +
8#include "MantidKernel/Quat.h"
10
11#include <boost/python/class.hpp>
12#include <boost/python/copy_const_reference.hpp>
13#include <boost/python/register_ptr_to_python.hpp>
14#include <boost/python/return_value_policy.hpp>
15
17using namespace boost::python;
18
20
21namespace Mantid::Kernel {
22class V3D;
23} // namespace Mantid::Kernel
24
25namespace {
37double getDistance(const IComponent &self, const IComponent &other) { return self.getDistance(other); }
38
39// Deprecation wrappers. Legacy component-tree access is being retired in favour
40// of the index-based ComponentInfo access layer. See the 'Instrument Access via
41// SpectrumInfo, DetectorInfo, ComponentInfo' concept page.
42Mantid::Kernel::V3D getPosDeprecated(const IComponent &self) {
43 PyErr_Warn(PyExc_DeprecationWarning, "'IComponent.getPos' is deprecated in Mantid 7.0, "
44 "use 'ComponentInfo.position' instead. "
45 "For more information, see the instrument access layers concept page: "
46 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html");
47 return self.getPos();
48}
49
50std::string getNameDeprecated(const IComponent &self) {
51 PyErr_Warn(PyExc_DeprecationWarning, "'IComponent.getName' is deprecated in Mantid 7.0, "
52 "use 'ComponentInfo.name' instead. "
53 "For more information, see the instrument access layers concept page: "
54 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html");
55 return self.getName();
56}
57
58std::string getFullNameDeprecated(const IComponent &self) {
59 PyErr_Warn(PyExc_DeprecationWarning, "'IComponent.getFullName' is deprecated in Mantid 7.0, "
60 "use 'ComponentInfo.name' instead. "
61 "For more information, see the instrument access layers concept page: "
62 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html");
63 return self.getFullName();
64}
65
66std::string typeDeprecated(const IComponent &self) {
67 PyErr_Warn(PyExc_DeprecationWarning, "'IComponent.type' is deprecated in Mantid 7.0, "
68 "use 'ComponentInfo.componentType' instead. "
69 "For more information, see the instrument access layers concept page: "
70 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html");
71 return self.type();
72}
73
74Mantid::Kernel::Quat getRelativeRotDeprecated(const IComponent &self) {
75 PyErr_Warn(PyExc_DeprecationWarning, "'IComponent.getRelativeRot' is deprecated in Mantid 7.0, "
76 "use 'ComponentInfo.relativeRotation' instead. "
77 "For more information, see the instrument access layers concept page: "
78 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html");
79 return self.getRelativeRot();
80}
81} // namespace
82
84 register_ptr_to_python<std::shared_ptr<IComponent>>();
85 register_ptr_to_python<std::shared_ptr<const IComponent>>();
86
87 class_<IComponent, boost::noncopyable>("IComponent", no_init)
88 .def("getPos", &getPosDeprecated, arg("self"),
89 "Returns the absolute position of the component (deprecated, use ComponentInfo.position)")
90 .def("getDistance", &getDistance, (arg("self"), arg("other")),
91 "Returns the distance, in metres, "
92 "between this and the given component")
93 .def("getName", &getNameDeprecated, arg("self"),
94 "Returns the name of the component (deprecated, use ComponentInfo.name)")
95 .def("getFullName", &getFullNameDeprecated, arg("self"),
96 "Returns full path name of component (deprecated, use ComponentInfo.name)")
97 .def("type", &typeDeprecated, arg("self"),
98 "Returns the type of the component represented as a string "
99 "(deprecated, use ComponentInfo.componentType)")
100 .def("getRelativeRot", &getRelativeRotDeprecated, arg("self"),
101 "Returns the relative rotation as a Quat (deprecated, use ComponentInfo.relativeRotation)");
102}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition GetPointer.h:17
void export_IComponent()
base class for Geometric IComponent
Definition IComponent.h:53
virtual Kernel::V3D getPos() const =0
Get the position of the IComponent. Tree structure is traverse through the.
virtual std::string type() const
Returns a string representation of the IComponent type.
Definition IComponent.h:56
virtual double getDistance(const IComponent &) const =0
Get the distance to another IComponent.
virtual Kernel::Quat getRelativeRot() const =0
Get the relative Orientation.
virtual std::string getFullName() const =0
Get the IComponent full path name.
virtual std::string getName() const =0
Get the IComponent name.
Class for quaternions.
Definition Quat.h:39
Class for 3D vectors.
Definition V3D.h:34