Mantid
Loading...
Searching...
No Matches
GeneralFrame.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 +
7#include <utility>
8
10
11namespace Mantid::Geometry {
12
13const std::string GeneralFrame::GeneralFrameDistance = "Distance";
14const std::string GeneralFrame::GeneralFrameTOF = "Time of Flight";
15const std::string GeneralFrame::GeneralFrameName = "General Frame";
16
17GeneralFrame::GeneralFrame(std::string frameName, std::unique_ptr<Kernel::MDUnit> unit)
18 : m_unit(unit.release()), m_frameName(std::move(frameName)) {}
19
20GeneralFrame::GeneralFrame(std::string frameName, const Kernel::UnitLabel &unit)
21 : m_unit(new Mantid::Kernel::LabelUnit(unit)), m_frameName(std::move(frameName)) {}
22
23Kernel::UnitLabel GeneralFrame::getUnitLabel() const { return m_unit->getUnitLabel(); }
24
26
28 m_unit = std::unique_ptr<Kernel::MDUnit>(newUnit.clone());
29 return true;
30}
31
32bool GeneralFrame::canConvertTo(const Kernel::MDUnit &otherUnit) const { return *this->m_unit == otherUnit; }
33
34std::string GeneralFrame::name() const { return m_frameName; }
35
37 return new GeneralFrame(m_frameName, std::unique_ptr<Kernel::MDUnit>(m_unit->clone()));
38}
39
42}
43
44bool GeneralFrame::isQ() const { return false; }
45
46bool GeneralFrame::isSameType(const MDFrame &frame) const {
47 auto isSameType = true;
48 try {
49 const auto &tmp = dynamic_cast<const GeneralFrame &>(frame);
51 } catch (std::bad_cast &) {
52 isSameType = false;
53 }
54 return isSameType;
55}
56
57} // namespace Mantid::Geometry
gsl_vector * tmp
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition: System.h:64
GeneralFrame : Any MDFrame that isn't related to momemtum transfer.
Definition: GeneralFrame.h:21
Mantid::Kernel::SpecialCoordinateSystem equivalientSpecialCoordinateSystem() const override
bool canConvertTo(const Kernel::MDUnit &otherUnit) const override
GeneralFrame * clone() const override
bool isSameType(const MDFrame &frame) const override
Kernel::UnitLabel getUnitLabel() const override
static const std::string GeneralFrameTOF
Definition: GeneralFrame.h:24
static const std::string GeneralFrameDistance
Definition: GeneralFrame.h:23
const std::string m_frameName
Frame name.
Definition: GeneralFrame.h:42
const Kernel::MDUnit & getMDUnit() const override
std::unique_ptr< Mantid::Kernel::MDUnit > m_unit
Label unit.
Definition: GeneralFrame.h:40
static const std::string GeneralFrameName
Definition: GeneralFrame.h:25
bool isQ() const override
bool setMDUnit(const Mantid::Kernel::MDUnit &newUnit) override
std::string name() const override
GeneralFrame(std::string frameName, const Kernel::UnitLabel &unit)
MDFrame : The coordinate frame for a dimension, or set of dimensions in a multidimensional workspace.
Definition: MDFrame.h:22
MDUnit : Unit type for multidimensional data types.
Definition: MDUnit.h:20
virtual MDUnit * clone() const =0
A base-class for the a class that is able to return unit labels in different representations.
Definition: UnitLabel.h:20
SpecialCoordinateSystem
Special coordinate systems for Q3D.
Helper class which provides the Collimation Length for SANS instruments.
STL namespace.