Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "MantidDataObjects/PeakShapeBase.h"
#include "MantidAPI/SpecialCoordinateSystem.h"
#include "MantidKernel/V3D.h"
#include <jsoncpp/json/json.h>
namespace Mantid {
namespace DataObjects {
PeakShapeBase::PeakShapeBase(const Kernel::VMD &peakCentre,
API::SpecialCoordinateSystem frame,
std::string algorithmName, int algorithmVersion)
: m_centre(peakCentre), m_frame(frame), m_algorithmName(algorithmName),
m_algorithmVersion(algorithmVersion) {}
//----------------------------------------------------------------------------------------------
/** Destructor
*/
PeakShapeBase::~PeakShapeBase() {}
/**
* @brief Copy constructor
* @param other : source of the copy
*/
PeakShapeBase::PeakShapeBase(const PeakShapeBase &other)
: m_centre(other.centre()), m_frame(other.frame()),
m_algorithmName(other.algorithmName()),
m_algorithmVersion(other.algorithmVersion()) {}
/**
* @brief Assignment operator
* @param other : source of the assignment
* @return Ref to assigned object.
*/
PeakShapeBase &PeakShapeBase::operator=(const PeakShapeBase &other) {
if (this != &other) {
m_centre = other.centre();
m_algorithmName = other.algorithmName();
m_algorithmVersion = other.algorithmVersion();
m_frame = other.frame();
}
return *this;
}
/**
* @brief PeakShapeBase::frame
* @return The coordinate frame used
*/
API::SpecialCoordinateSystem PeakShapeBase::frame() const { return m_frame; }
/**
* @brief PeakShapeBase::buildCommon. Serialize to JSON object and return the
* JSON value for further modification
* @param root : Ref to root value to write to
*/
void PeakShapeBase::buildCommon(Json::Value &root) const {
Json::Value shape(this->shapeName());
Json::Value algorithmName(this->algorithmName());
Json::Value algorithmVersion(this->algorithmVersion());
Json::Value centre;
for (size_t i = 0; i < m_centre.size(); ++i) {
centre.append(m_centre[i]);
}
Json::Value frame(this->frame());
root["shape"] = shape;
root["algorithm_name"] = algorithmName;
root["algorithm_version"] = algorithmVersion;
root["centre"] = centre;
root["frame"] = frame;
}
/**
* @brief Get the algorithm name
* @return Algorithm name
*/
std::string PeakShapeBase::algorithmName() const { return m_algorithmName; }
/**
* @brief Get the algorithmVersion
* @return Algorithm version
*/
int PeakShapeBase::algorithmVersion() const { return m_algorithmVersion; }
bool PeakShapeBase::operator==(const PeakShapeBase &other) const {
return other.centre() == this->centre() && other.frame() == this->frame();
}
/**
* @brief Get centre of sphere
* @return centre as VMD
*/
Mantid::Kernel::VMD PeakShapeBase::centre() const { return m_centre; }
} // namespace DataObjects
} // namespace Mantid