Mantid
Loading...
Searching...
No Matches
AddPeakHKL.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 +
8
10
14
15namespace Mantid::Crystal {
16
17using namespace Mantid::Kernel;
18using namespace Mantid::API;
19
20// Register the algorithm into the AlgorithmFactory
21DECLARE_ALGORITHM(AddPeakHKL)
22
23//----------------------------------------------------------------------------------------------
24
25
26const std::string AddPeakHKL::name() const { return "AddPeakHKL"; }
27
29int AddPeakHKL::version() const { return 1; }
30
32const std::string AddPeakHKL::category() const { return "Crystal\\Peaks"; }
33
35const std::string AddPeakHKL::summary() const { return "Add a peak in the hkl frame"; }
36
37//----------------------------------------------------------------------------------------------
42 "An input workspace.");
43 // clang-format off
44 declareProperty(std::make_unique<ArrayProperty<double>>("HKL", std::make_shared<ArrayLengthValidator<double> > (3)), "HKL point to add");
45 // clang-format on
46}
47
48//----------------------------------------------------------------------------------------------
52 IPeaksWorkspace_sptr peakWS = this->getProperty("Workspace");
53 const std::vector<double> hklValue = this->getProperty("HKL");
54 auto peak =
55 std::unique_ptr<Mantid::Geometry::IPeak>(peakWS->createPeakHKL(V3D(hklValue[0], hklValue[1], hklValue[2])));
56 peakWS->addPeak(*peak);
57}
58
59} // namespace Mantid::Crystal
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Definition: Algorithm.cpp:1913
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
A property class for workspaces.
AddPeakHKL : Algorithm to add a peaks to a PeaksWorkspace in the HKL frame.
Definition: AddPeakHKL.h:17
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
Definition: AddPeakHKL.cpp:35
int version() const override
Algorithm's version for identification.
Definition: AddPeakHKL.cpp:29
void exec() override
Execute the algorithm.
Definition: AddPeakHKL.cpp:51
void init() override
Initialize the algorithm's properties.
Definition: AddPeakHKL.cpp:40
const std::string category() const override
Algorithm's category for identification.
Definition: AddPeakHKL.cpp:32
ArrayLenghtValidator : Validate length of an array property.
Support for a property that holds an array of values.
Definition: ArrayProperty.h:28
Class for 3D vectors.
Definition: V3D.h:34
std::shared_ptr< IPeaksWorkspace > IPeaksWorkspace_sptr
shared pointer to Mantid::API::IPeaksWorkspace
STL namespace.
@ InOut
Both an input & output workspace.
Definition: Property.h:55