-
Notifications
You must be signed in to change notification settings - Fork 122
/
AddPeakHKL.cpp
65 lines (52 loc) · 2.33 KB
/
AddPeakHKL.cpp
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
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidCrystal/AddPeakHKL.h"
#include "MantidGeometry/Crystal/IPeak.h"
#include "MantidAPI/IPeaksWorkspace.h"
#include "MantidKernel/ArrayLengthValidator.h"
#include "MantidKernel/ArrayProperty.h"
namespace Mantid {
namespace Crystal {
using namespace Mantid::Kernel;
using namespace Mantid::API;
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(AddPeakHKL)
//----------------------------------------------------------------------------------------------
/// Algorithms name for identification. @see Algorithm::name
const std::string AddPeakHKL::name() const { return "AddPeakHKL"; }
/// Algorithm's version for identification. @see Algorithm::version
int AddPeakHKL::version() const { return 1; }
/// Algorithm's category for identification. @see Algorithm::category
const std::string AddPeakHKL::category() const { return "Crystal\\Peaks"; }
/// Algorithm's summary for use in the GUI and help. @see Algorithm::summary
const std::string AddPeakHKL::summary() const {
return "Add a peak in the hkl frame";
}
//----------------------------------------------------------------------------------------------
/** Initialize the algorithm's properties.
*/
void AddPeakHKL::init() {
declareProperty(
std::make_unique<WorkspaceProperty<Mantid::API::IPeaksWorkspace>>(
"Workspace", "", Direction::InOut),
"An input workspace.");
// clang-format off
declareProperty(std::make_unique<ArrayProperty<double>>("HKL", std::make_shared<ArrayLengthValidator<double> > (3)), "HKL point to add");
// clang-format on
}
//----------------------------------------------------------------------------------------------
/** Execute the algorithm.
*/
void AddPeakHKL::exec() {
IPeaksWorkspace_sptr peakWS = this->getProperty("Workspace");
const std::vector<double> hklValue = this->getProperty("HKL");
auto peak = std::unique_ptr<Mantid::Geometry::IPeak>(
peakWS->createPeakHKL(V3D(hklValue[0], hklValue[1], hklValue[2])));
peakWS->addPeak(*peak);
}
} // namespace Crystal
} // namespace Mantid