Mantid
Loading...
Searching...
No Matches
PeakShapeSphericalFactory.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 +
9#include "MantidJson/Json.h"
11#include "MantidKernel/VMD.h"
12#include <json/json.h>
13
14namespace Mantid::DataObjects {
15
16using namespace Mantid::Kernel;
17
24 Json::Value root;
25 Mantid::Geometry::PeakShape *product = nullptr;
26 if (Mantid::JsonHelpers::parse(source, &root)) {
27 const std::string shape = root["shape"].asString();
29
30 const std::string algorithmName(root["algorithm_name"].asString());
31 const int algorithmVersion(root["algorithm_version"].asInt());
32 const auto frame(static_cast<SpecialCoordinateSystem>(root["frame"].asInt()));
33 const double radius(root["radius"].asDouble());
34
35 if (!root["background_outer_radius"].empty() && !root["background_inner_radius"].empty()) {
36 const double backgroundOuterRadius(root["background_outer_radius"].asDouble());
37 const double backgroundInnerRadius(root["background_inner_radius"].asDouble());
38 product = new PeakShapeSpherical(radius, backgroundInnerRadius, backgroundOuterRadius, frame, algorithmName,
39 algorithmVersion);
40 }
41
42 else {
43
44 product = new PeakShapeSpherical(radius, frame, algorithmName, algorithmVersion);
45 }
46 } else {
47 if (m_successor) {
48 product = m_successor->create(source);
49 } else {
50 throw std::invalid_argument("PeakShapeSphericalFactory:: No successor "
51 "factory able to process : " +
52 source);
53 }
54 }
55
56 } else {
57 throw std::invalid_argument("PeakShapeSphericalFactory:: Source JSON for "
58 "the peak shape is not valid: " +
59 source);
60 }
61 return product;
62}
63
69 m_successor = successorFactory;
70}
71
72} // namespace Mantid::DataObjects
double radius
Definition: Rasterize.cpp:31
Mantid::Geometry::PeakShape * create(const std::string &source) const override
Make product.
PeakShapeFactory_const_sptr m_successor
Successor factory.
void setSuccessor(PeakShapeFactory_const_sptr successorFactory) override
Set a successor should this factory be unsuitable.
PeakShapeSpherical : PeakShape for a spherical peak.
static const std::string sphereShapeName()
Non-instance shape name.
PeakShape : Abstract type to describes the shape of a peak.
Definition: PeakShape.h:20
std::shared_ptr< const PeakShapeFactory > PeakShapeFactory_const_sptr
Helper typedef.
SpecialCoordinateSystem
Special coordinate systems for Q3D.