Mantid
Loading...
Searching...
No Matches
IComponent.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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 +
7#pragma once
8
9#include "MantidGeometry/DllConfig.h"
11#include "MantidKernel/V2D.h"
12#include "MantidKernel/V3D.h"
13
14#include <map>
15#include <optional>
16#include <set>
17#include <string>
18#include <vector>
19
20#ifndef Q_MOC_RUN
21#include <memory>
22#endif
23
24namespace Mantid {
25
26namespace Kernel {
27class Quat;
28}
29
30namespace Geometry {
31class IComponent;
32class ParameterMap;
33
36
53class MANTID_GEOMETRY_DLL IComponent {
54public:
56 virtual std::string type() const { return "LogicalComponent"; }
58 virtual IComponent *clone() const = 0;
60 virtual ~IComponent() = default;
62 virtual ComponentID getComponentID() const = 0;
64 // or pointer to itself if not. Currently is the same as getComponentID bar
65 // const cast;
66 virtual IComponent const *getBaseComponent() const = 0;
68 virtual void setParent(IComponent *) = 0;
70 virtual std::shared_ptr<const IComponent> getParent() const = 0;
72 virtual const IComponent *getBareParent() const = 0;
74 virtual std::vector<std::shared_ptr<const IComponent>> getAncestors() const = 0;
76 virtual void setName(const std::string &) = 0;
78 virtual std::string getName() const = 0;
80 virtual std::string getFullName() const = 0;
82 // otherwise absolute
83 virtual void setPos(double, double, double) = 0;
87 virtual void setPos(const Kernel::V3D &) = 0;
88 virtual void setSideBySideViewPos(const Kernel::V2D &) = 0;
90 // otherwise absolute
91 virtual void setRot(const Kernel::Quat &) = 0;
93 // virtual void copyRot(const IComponent&) = 0;
95 // present.
96 virtual void translate(const Kernel::V3D &) = 0;
98 // present.
99 virtual void translate(double, double, double) = 0;
101 virtual void rotate(const Kernel::Quat &) = 0;
103 virtual void rotate(double, const Kernel::V3D &) = 0;
105 virtual Kernel::V3D getRelativePos() const = 0;
107 // parent chain
108 virtual Kernel::V3D getPos() const = 0;
111 virtual std::optional<Kernel::V2D> getSideBySideViewPos() const = 0;
113 virtual Kernel::Quat getRelativeRot() const = 0;
115 virtual Kernel::Quat getRotation() const = 0;
117 virtual double getDistance(const IComponent &) const = 0;
119 virtual void getBoundingBox(BoundingBox &boundingBox) const = 0;
120
124 virtual Kernel::V3D getScaleFactor() const { return Kernel::V3D(1.0, 1.0, 1.0); }
125
129 virtual std::set<std::string> getParameterNames(bool recursive = true) const = 0;
131 virtual std::map<std::string, ComponentID> getParameterNamesByComponent() const = 0;
133 virtual bool hasParameter(const std::string &name, bool recursive = true) const = 0;
134 // Hack until proper python export functions are defined
135 virtual std::string getParameterType(const std::string &pname, bool recursive = true) const = 0;
136 // 06/05/2010 MG: Templated virtual functions cannot be defined so we have to
137 // resort to
138 // one for each type, luckily there won't be too many
140 virtual std::vector<double> getNumberParameter(const std::string &pname, bool recursive = true) const = 0;
142 virtual std::vector<Kernel::V3D> getPositionParameter(const std::string &pname, bool recursive = true) const = 0;
144 virtual std::vector<Kernel::Quat> getRotationParameter(const std::string &pname, bool recursive = true) const = 0;
146 virtual std::vector<std::string> getStringParameter(const std::string &pname, bool recursive = true) const = 0;
148 virtual std::vector<int> getIntParameter(const std::string &pname, bool recursive = true) const = 0;
150 virtual std::vector<bool> getBoolParameter(const std::string &pname, bool recursive = true) const = 0;
152 virtual std::string getParameterAsString(const std::string &pname, bool recursive = true) const = 0;
154 virtual bool getParameterVisible(const std::string &pname, bool recursive = true) const = 0;
156
158 virtual void printSelf(std::ostream &) const = 0;
160 virtual bool isParametrized() const = 0;
161 virtual size_t registerContents(class ComponentVisitor &component) const = 0;
162};
163
165using IComponent_sptr = std::shared_ptr<IComponent>;
167using IComponent_const_sptr = std::shared_ptr<const IComponent>;
168
169} // Namespace Geometry
170
173public:
175 void operator()(void *) {}
177 void operator()(const void *) {}
178};
179
180} // Namespace Mantid
std::string name
Definition Run.cpp:60
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
Definition BoundingBox.h:33
ComponentVisitor : Visitor for IComponents.
base class for Geometric IComponent
Definition IComponent.h:53
virtual std::vector< Kernel::Quat > getRotationParameter(const std::string &pname, bool recursive=true) const =0
Get a parameter defined as a Kernel::Quaternion.
virtual size_t registerContents(class ComponentVisitor &component) const =0
virtual std::vector< Kernel::V3D > getPositionParameter(const std::string &pname, bool recursive=true) const =0
Get a parameter defined as a Kernel::V3D.
virtual bool hasParameter(const std::string &name, bool recursive=true) const =0
Returns a boolean indicating if the component has the named parameter.
virtual Kernel::V3D getPos() const =0
Get the position of the IComponent. Tree structure is traverse through the.
virtual IComponent const * getBaseComponent() const =0
Returns const pointer to base component if this component is parametrized.
virtual std::string type() const
Returns a string representation of the IComponent type.
Definition IComponent.h:56
virtual void getBoundingBox(BoundingBox &boundingBox) const =0
Get the bounding box for this component and store it in the given argument.
virtual void setSideBySideViewPos(const Kernel::V2D &)=0
virtual std::vector< bool > getBoolParameter(const std::string &pname, bool recursive=true) const =0
Get a parameter defined as a boolean.
virtual std::optional< Kernel::V2D > getSideBySideViewPos() const =0
Get the position of the IComponent for display on the side by side instrument view.
virtual void setPos(double, double, double)=0
Set the IComponent position, x, y, z respective to parent (if present)
virtual void translate(double, double, double)=0
Translate the IComponent (x,y,z form). This is relative to parent if.
virtual void rotate(double, const Kernel::V3D &)=0
Rotate the IComponent by an angle in degrees with respect to an axis.
virtual std::shared_ptr< const IComponent > getParent() const =0
Return a pointer to the current parent.
virtual void printSelf(std::ostream &) const =0
Prints a text representation of itself.
virtual Kernel::Quat getRotation() const =0
Get the absolute orientation of the IComponent.
virtual double getDistance(const IComponent &) const =0
Get the distance to another IComponent.
virtual std::vector< std::string > getStringParameter(const std::string &pname, bool recursive=true) const =0
Get a parameter defined as a string.
virtual ~IComponent()=default
Destructor.
virtual std::vector< double > getNumberParameter(const std::string &pname, bool recursive=true) const =0
Get a parameter defined as a double.
virtual IComponent * clone() const =0
Return a clone to the current object.
virtual void setPos(const Kernel::V3D &)=0
Set the position of the component The position is with respect to the parent component.
virtual bool getParameterVisible(const std::string &pname, bool recursive=true) const =0
get visibility attribute of a parameter
virtual bool isParametrized() const =0
Returns true if the Component is parametrized (has a parameter map)
virtual std::map< std::string, ComponentID > getParameterNamesByComponent() const =0
return the parameter names and the component they are from
virtual std::string getParameterType(const std::string &pname, bool recursive=true) const =0
virtual std::vector< int > getIntParameter(const std::string &pname, bool recursive=true) const =0
Get a parameter defined as an integer.
virtual Kernel::V3D getScaleFactor() const
Gets the scaling factor of the object for the Object Component.
Definition IComponent.h:124
virtual ComponentID getComponentID() const =0
Returns the ComponentID - a unique identifier of the component.
virtual std::string getParameterAsString(const std::string &pname, bool recursive=true) const =0
get a string representation of a parameter
virtual std::set< std::string > getParameterNames(bool recursive=true) const =0
Return the names of the parameters for this component.
virtual void translate(const Kernel::V3D &)=0
Copy the Rotation from another IComponent.
virtual void setParent(IComponent *)=0
Assign a parent IComponent. Previous parent link is lost.
virtual void rotate(const Kernel::Quat &)=0
Rotate the IComponent. This is relative to parent.
virtual Kernel::Quat getRelativeRot() const =0
Get the relative Orientation.
virtual std::vector< std::shared_ptr< const IComponent > > getAncestors() const =0
Return an array of all ancestors, the nearest first.
virtual void setRot(const Kernel::Quat &)=0
Set the orientation Kernel::Quaternion relative to parent (if present)
virtual Kernel::V3D getRelativePos() const =0
Get the position relative to the parent IComponent (absolute if no parent)
virtual void setName(const std::string &)=0
Set the IComponent name.
virtual std::string getFullName() const =0
Get the IComponent full path name.
virtual const IComponent * getBareParent() const =0
Returns the bare pointer to the IComponent parent.
virtual std::string getName() const =0
Get the IComponent name.
Class for quaternions.
Definition Quat.h:39
Implements a 2-dimensional vector embedded in a 3D space, i.e.
Definition V2D.h:29
Class for 3D vectors.
Definition V3D.h:34
An object for constructing a shared_ptr that won't ever delete its pointee.
Definition IComponent.h:172
void operator()(const void *)
Does nothing.
Definition IComponent.h:177
void operator()(void *)
Does nothing.
Definition IComponent.h:175
std::shared_ptr< const IComponent > IComponent_const_sptr
Typdef of a shared pointer to a const IComponent.
Definition IComponent.h:167
std::shared_ptr< IComponent > IComponent_sptr
Typedef of a shared pointer to a IComponent.
Definition IComponent.h:165
Helper class which provides the Collimation Length for SANS instruments.