|
Mantid
|
Collects the position and rotation an instrument definition specifies piecemeal, so that each can be applied once, complete. More...
#include <PositionAndRotationAccumulator.h>
Classes | |
| struct | Position |
| struct | Rotation |
Public Member Functions | |
| std::map< size_t, Kernel::V3D > | positions () const |
| The accumulated position for each component that had any coordinate set. | |
| std::map< size_t, Kernel::Quat > | rotations () const |
| The composed rotation for each component that had any angle set. | |
| void | setCoordinate (const size_t componentIndex, const std::string &axis, const double value, const Kernel::V3D ¤tPosition) |
| Set one coordinate. | |
| void | setPosition (const size_t componentIndex, const Kernel::V3D &position) |
| Set the whole position at once, discarding any coordinates accumulated so far. | |
| bool | setRotationAngle (const size_t componentIndex, const std::string &axis, const double degrees) |
| Set one rotation angle, in degrees. | |
Private Attributes | |
| std::map< size_t, Position > | m_positions |
| std::map< size_t, Rotation > | m_rotations |
Collects the position and rotation an instrument definition specifies piecemeal, so that each can be applied once, complete.
An instrument definition may set a position one coordinate at a time ("x", "y", "z"), or in spherical form, and a rotation one angle at a time ("rotx", "roty", "rotz"). Neither can be pushed straight into ComponentInfo as it arrives: a partial position would move the component to a nonsense place, and the order the rotation angles arrive in is not guaranteed, while the composition order of the resulting quaternion must be fixed.
This replaces the temporary ParameterMap that used to serve the same purpose via ParameterMap::addPositionCoordinate()/addRotationParam(). The behaviour it reproduces:
Both stores are keyed by component index and are deliberately sparse: an instrument definition names a handful of components out of an instrument that may hold hundreds of thousands. They are kept separate rather than combined into one entry so that a component which was moved but never rotated does not come back carrying a default rotation, which would overwrite the rotation it already has.
Definition at line 43 of file PositionAndRotationAccumulator.h.
| std::map< size_t, Kernel::V3D > Mantid::Geometry::PositionAndRotationAccumulator::positions | ( | ) | const |
The accumulated position for each component that had any coordinate set.
Definition at line 47 of file PositionAndRotationAccumulator.cpp.
References m_positions.
Referenced by Mantid::API::ExperimentInfo::populateInstrumentParameters().
| std::map< size_t, Kernel::Quat > Mantid::Geometry::PositionAndRotationAccumulator::rotations | ( | ) | const |
The composed rotation for each component that had any angle set.
Definition at line 55 of file PositionAndRotationAccumulator.cpp.
References m_rotations.
Referenced by Mantid::API::ExperimentInfo::populateInstrumentParameters().
| void Mantid::Geometry::PositionAndRotationAccumulator::setCoordinate | ( | const size_t | componentIndex, |
| const std::string & | axis, | ||
| const double | value, | ||
| const Kernel::V3D & | currentPosition | ||
| ) |
Set one coordinate.
currentPosition seeds the value the first time this component is touched, and is ignored afterwards. An unrecognised axis is ignored.
Definition at line 11 of file PositionAndRotationAccumulator.cpp.
References m_positions, Mantid::Kernel::V3D::setX(), and value.
Referenced by Mantid::API::ExperimentInfo::populateWithParameter().
| void Mantid::Geometry::PositionAndRotationAccumulator::setPosition | ( | const size_t | componentIndex, |
| const Kernel::V3D & | position | ||
| ) |
Set the whole position at once, discarding any coordinates accumulated so far.
Definition at line 27 of file PositionAndRotationAccumulator.cpp.
References m_positions, and position.
Referenced by Mantid::API::ExperimentInfo::populateInstrumentParameters().
| bool Mantid::Geometry::PositionAndRotationAccumulator::setRotationAngle | ( | const size_t | componentIndex, |
| const std::string & | axis, | ||
| const double | degrees | ||
| ) |
Set one rotation angle, in degrees.
Returns false for an unrecognised axis, which the caller reports – notably "rot" itself, which is deliberately dropped.
Definition at line 31 of file PositionAndRotationAccumulator.cpp.
References m_rotations.
Referenced by Mantid::API::ExperimentInfo::populateWithParameter().
|
private |
Definition at line 73 of file PositionAndRotationAccumulator.h.
Referenced by positions(), setCoordinate(), and setPosition().
|
private |
Definition at line 74 of file PositionAndRotationAccumulator.h.
Referenced by rotations(), and setRotationAngle().