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/V3D.h"
12
13#include <map>
14#include <set>
15#include <string>
16#include <vector>
17
18#ifndef Q_MOC_RUN
19#include <memory>
20#endif
21
22namespace Mantid {
23
24namespace Kernel {
25class Quat;
26}
27
28namespace Geometry {
29class IComponent;
30class ParameterMap;
31
34
51class MANTID_GEOMETRY_DLL IComponent {
52public:
54 virtual std::string type() const { return "LogicalComponent"; }
56 virtual IComponent *clone() const = 0;
58 virtual ~IComponent() = default;
60 virtual ComponentID getComponentID() const = 0;
62 // or pointer to itself if not. Currently is the same as getComponentID bar
63 // const cast;
64 virtual IComponent const *getBaseComponent() const = 0;
66 virtual void setParent(IComponent *) = 0;
68 virtual std::shared_ptr<const IComponent> getParent() const = 0;
70 virtual const IComponent *getBareParent() const = 0;
72 virtual std::vector<std::shared_ptr<const IComponent>> getAncestors() const = 0;
74 virtual void setName(const std::string &) = 0;
76 virtual std::string getName() const = 0;
78 virtual std::string getFullName() const = 0;
80 // otherwise absolute
81 virtual void setPos(double, double, double) = 0;
85 virtual void setPos(const Kernel::V3D &) = 0;
87 // otherwise absolute
88 virtual void setRot(const Kernel::Quat &) = 0;
90 // virtual void copyRot(const IComponent&) = 0;
92 // present.
93 virtual void translate(const Kernel::V3D &) = 0;
95 // present.
96 virtual void translate(double, double, double) = 0;
98 virtual void rotate(const Kernel::Quat &) = 0;
100 virtual void rotate(double, const Kernel::V3D &) = 0;
102 virtual Kernel::V3D getRelativePos() const = 0;
104 // parent chain
105 virtual Kernel::V3D getPos() const = 0;
107 virtual Kernel::Quat getRelativeRot() const = 0;
109 virtual Kernel::Quat getRotation() const = 0;
111 virtual double getDistance(const IComponent &) const = 0;
113 virtual void getBoundingBox(BoundingBox &boundingBox) const = 0;
114
118 virtual Kernel::V3D getScaleFactor() const { return Kernel::V3D(1.0, 1.0, 1.0); }
119
123 virtual std::set<std::string> getParameterNames(bool recursive = true) const = 0;
125 virtual std::map<std::string, ComponentID> getParameterNamesByComponent() const = 0;
127 virtual bool hasParameter(const std::string &name, bool recursive = true) const = 0;
128 // Hack until proper python export functions are defined
129 virtual std::string getParameterType(const std::string &pname, bool recursive = true) const = 0;
130 // 06/05/2010 MG: Templated virtual functions cannot be defined so we have to
131 // resort to
132 // one for each type, luckily there won't be too many
134 virtual std::vector<double> getNumberParameter(const std::string &pname, bool recursive = true) const = 0;
136 virtual std::vector<Kernel::V3D> getPositionParameter(const std::string &pname, bool recursive = true) const = 0;
138 virtual std::vector<Kernel::Quat> getRotationParameter(const std::string &pname, bool recursive = true) const = 0;
140 virtual std::vector<std::string> getStringParameter(const std::string &pname, bool recursive = true) const = 0;
142 virtual std::vector<int> getIntParameter(const std::string &pname, bool recursive = true) const = 0;
144 virtual std::vector<bool> getBoolParameter(const std::string &pname, bool recursive = true) const = 0;
146 virtual std::string getParameterAsString(const std::string &pname, bool recursive = true) const = 0;
148 virtual bool getParameterVisible(const std::string &pname, bool recursive = true) const = 0;
150
152 virtual void printSelf(std::ostream &) const = 0;
154 virtual bool isParametrized() const = 0;
155 virtual size_t registerContents(class ComponentVisitor &component) const = 0;
156};
157
159using IComponent_sptr = std::shared_ptr<IComponent>;
161using IComponent_const_sptr = std::shared_ptr<const IComponent>;
162
163} // Namespace Geometry
164
167public:
169 void operator()(void *) {}
171 void operator()(const void *) {}
172};
173
174} // Namespace Mantid
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
Definition: BoundingBox.h:34
ComponentVisitor : Visitor for IComponents.
base class for Geometric IComponent
Definition: IComponent.h:51
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:54
virtual void getBoundingBox(BoundingBox &boundingBox) const =0
Get the bounding box for this component and store it in the given argument.
virtual std::vector< bool > getBoolParameter(const std::string &pname, bool recursive=true) const =0
Get a parameter defined as a boolean.
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:118
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
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:166
void operator()(const void *)
Does nothing.
Definition: IComponent.h:171
void operator()(void *)
Does nothing.
Definition: IComponent.h:169
std::shared_ptr< const IComponent > IComponent_const_sptr
Typdef of a shared pointer to a const IComponent.
Definition: IComponent.h:161
std::shared_ptr< IComponent > IComponent_sptr
Typedef of a shared pointer to a IComponent.
Definition: IComponent.h:159
Helper class which provides the Collimation Length for SANS instruments.