13using namespace Kernel;
22 compositeScatterer->initialize();
24 return compositeScatterer;
32 collection->setScatterers(scatterers);
61 for (
const auto &scatterer : scatterers) {
74 throw std::out_of_range(
"Index is out of range.");
91 throw std::out_of_range(
"Index is out of range.");
109 return std::accumulate(
111 [&hkl](
const auto &sum,
const auto &scatterer) {
return sum + scatterer->calculateStructureFactor(hkl); });
130 const std::string &propertyName,
131 const std::string &propertyValue) {
133 scatterer->setPropertyValue(propertyName, propertyValue);
142 throw std::invalid_argument(
"Cannot process null-scatterer.");
163 for (
auto &prop : propertyUseCount) {
164 if (scatterer->existsProperty(prop.first)) {
174 for (
auto &property : properties) {
175 const std::string &propertyName =
property->name();
183 for (
auto &property : propertyUseCount) {
184 if (property.second == 0) {
192 std::map<std::string, size_t> propertyUseCount;
194 std::vector<Property *> compositeProperties =
getProperties();
195 for (
auto &compositeProperty : compositeProperties) {
196 propertyUseCount.emplace(compositeProperty->name(), 0);
198 return propertyUseCount;
#define DECLARE_BRAGGSCATTERER(classname)
BraggScatterer is a general interface for representing scatterers in the unit cell of a periodic stru...
const std::string & getPropagatingGroupName() const
Returns the group name that is used to mark properties that are propagated.
CompositeBraggScatterer accumulates scatterers, for easier calculation of structure factors.
std::map< std::string, size_t > getPropertyCountMap() const
Returns a map with all declared property names and 0.
void removeScatterer(size_t i)
Removes the i-th scatterer from the composite or throws an std::out_of_range exception.
StructureFactor calculateStructureFactor(const Kernel::V3D &hkl) const override
Calculates the structure factor for the given HKL by summing all contributions from contained scatter...
virtual void addScatterer(const BraggScatterer_sptr &scatterer)
Clones the supplied scatterer, assigns the internal space group and unit cell to the clone and adds i...
size_t nScatterers() const
Returns the number of scatterers contained in the composite.
std::vector< BraggScatterer_sptr > m_scatterers
CompositeBraggScatterer()
Default constructor.
void afterPropertySet(const std::string &propertyName) override
Makes sure that space group and unit cell are propagated to all stored scatterers.
BraggScatterer_sptr clone() const override
Recursively clones all contained scatterers and returns the resulting composite.
void redeclareProperties()
Synchronize properties with scatterer members.
void setScatterers(const std::vector< BraggScatterer_sptr > &scatterers)
Clears all scatterers and assigns clones of the supplied ones.
void addScattererImplementation(const BraggScatterer_sptr &scatterer)
This method performs the actual cloning and adding of a new scatterer.
BraggScatterer_sptr getScatterer(size_t i) const
Returns the i-th scatterer or throws an std::out_of_range exception.
void propagatePropertyToScatterer(BraggScatterer_sptr &scatterer, const std::string &propertyName, const std::string &propertyValue)
void propagateProperty(const std::string &propertyName)
Propagates the given property to all contained scatterers that have this property.
static CompositeBraggScatterer_sptr create()
Static method that creates a new instance of CompositeBraggScatterer and returns it (wrapped by a sma...
void removeAllScatterers()
Removes all scatterers.
void removeScattererImplementation(size_t i)
This method performs the actual removal of the i-th scatterer.
Exception for when an item is not found in a collection.
void removeProperty(const std::string &name, const bool delproperty=true) override
removes the property from properties map
bool existsProperty(const std::string &name) const override
Checks whether the named property is already in the list of managed property.
std::string asString(bool withDefaultValues=false) const override
Return the property manager serialized as a string.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
void declareProperty(std::unique_ptr< Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
const std::vector< Property * > & getProperties() const override
Get the list of managed properties.
std::shared_ptr< BraggScatterer > BraggScatterer_sptr
std::shared_ptr< CompositeBraggScatterer > CompositeBraggScatterer_sptr
std::complex< double > StructureFactor