11#include "MantidIndexing/GlobalSpectrumIndex.h"
12#include "MantidIndexing/IndexInfo.h"
13#include "MantidIndexing/SpectrumNumber.h"
19 :
ArrayProperty(name,
"", validator), m_workspaceProp(workspaceProp), m_indexTypeProp(indexTypeProp), m_indices(0),
20 m_indicesExtracted(false) {}
34 }
catch (std::runtime_error &e) {
36 }
catch (std::out_of_range &e) {
37 error =
"Indices provided to IndexProperty are out of range: ";
38 error.append(e.what());
39 }
catch (std::logic_error &) {
40 error =
"Duplicate indices supplied to IndexProperty.";
51IndexProperty::operator Indexing::SpectrumIndexSet()
const {
return getIndices(); }
58 return indexInfo.makeIndexSet();
62 auto isRange = (max - min) ==
static_cast<int>(
m_value.size() - 1);
66 return indexInfo.makeIndexSet(
static_cast<Indexing::GlobalSpectrumIndex
>(min),
67 static_cast<Indexing::GlobalSpectrumIndex
>(max));
69 return indexInfo.makeIndexSet(
static_cast<Indexing::SpectrumNumber
>(
static_cast<int32_t
>(min)),
70 static_cast<Indexing::SpectrumNumber
>(
static_cast<int32_t
>(max)));
76 return indexInfo.makeIndexSet(std::vector<Indexing::GlobalSpectrumIndex>(
m_value.begin(),
m_value.end()));
78 std::vector<Indexing::SpectrumNumber> spectrumNumbers(
m_value.cbegin(),
m_value.cend());
79 return indexInfo.makeIndexSet(spectrumNumbers);
102 return {std::vector<Indexing::GlobalSpectrumIndex>(
m_value.begin(),
m_value.end()), indexInfo};
104 std::vector<Indexing::SpectrumNumber> spectrumNumbers(
m_value.cbegin(),
m_value.cend());
105 return {spectrumNumbers, indexInfo};
108 throw std::runtime_error(
"IndexProperty::getFilteredIndexInfo -- unsupported index type");
117 throw std::runtime_error(
"Invalid workspace type provided to "
118 "IndexProperty. Must be convertible to "
120 return wksp->indexInfo();
const std::vector< double > & rhs
An interface that is implemented by WorkspaceProperty.
virtual Workspace_sptr getWorkspace() const =0
Get a pointer to the workspace.
IndexProperty : Implementation of a property type which returns a SpectrumIndexSet provided an input ...
Indexing::SpectrumIndexSet getIndices() const
static std::string generatePropertyName(const std::string &name="")
bool isDefault() const override
Overriden function that returns if property has the same value that it was initialised with,...
const IWorkspaceProperty & m_workspaceProp
IndexProperty(const std::string &name, const IWorkspaceProperty &workspaceProp, const IndexTypeProperty &indexTypeProp, const Kernel::IValidator_sptr &validator=Kernel::IValidator_sptr(new Kernel::NullValidator))
const IndexTypeProperty & m_indexTypeProp
Indexing::SpectrumIndexSet m_indices
std::string isValid() const override
Overridden function that checks whether the property, if not overriden returns "".
Indexing::IndexInfo getFilteredIndexInfo() const
Return IndexInfo created from workspace but containing selected spectra.
IndexProperty * clone() const override
'Virtual copy constructor'
IndexProperty & operator=(const IndexProperty &)=delete
const Indexing::IndexInfo & getIndexInfoFromWorkspace() const
IndexTypeProperty : Implementation of a property which stores the type of input indices users require...
IndexType selectedType() const
Support for a property that holds an array of values.
std::string setValue(const std::string &value) override
Sets the values stored in the ArrayProperty from a string representation.
TYPE m_value
The value of the property.
const std::string & name() const
Get the property's name.
const std::string type() const
Returns the type of the property as a string.
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.