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) {
51 return self.getPos();
52}
53
54std::string getNameDeprecated(const IComponent &self) {
63 return self.getName();
64}
65
66std::string getFullNameDeprecated(const IComponent &self) {
75 return self.getFullName();
76}
77
78std::string typeDeprecated(const IComponent &self) {
87 return self.type();
88}
89
90Mantid::Kernel::Quat getRelativeRotDeprecated(const IComponent &self) {
91 if (PyErr_Warn(PyExc_DeprecationWarning,
92 "'IComponent.getRelativeRot' is deprecated in Mantid 7.0, "
93 "use 'ComponentInfo.relativeRotation' instead. "
94 "For more information, see the instrument access layers concept page: "
95 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html") < 0)
96 throw boost::python::error_already_set();
97 return self.getRelativeRot();
98}
99} // namespace
100
102 register_ptr_to_python<std::shared_ptr<IComponent>>();
103 register_ptr_to_python<std::shared_ptr<const IComponent>>();
104
105 class_<IComponent, boost::noncopyable>("IComponent", no_init)
106 .def("getPos", &getPosDeprecated, arg("self"),
107 "Returns the absolute position of the component (deprecated, use ComponentInfo.position)")
108 .def("getDistance", &getDistance, (arg("self"), arg("other")),
109 "Returns the distance, in metres, "
110 "between this and the given component")
111 .def("getName", &getNameDeprecated, arg("self"),
112 "Returns the name of the component (deprecated, use ComponentInfo.name)")
113 .def("getFullName", &getFullNameDeprecated, arg("self"),
114 "Returns full path name of component (deprecated, use ComponentInfo.name)")
115 .def("type", &typeDeprecated, arg("self"),
116 "Returns the type of the component represented as a string "
117 "(deprecated, use ComponentInfo.componentType)")
118 .def("getRelativeRot", &getRelativeRotDeprecated, arg("self"),
119 "Returns the relative rotation as a Quat (deprecated, use ComponentInfo.relativeRotation)");
120}
#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:38
Class for 3D vectors.
Definition V3D.h:35