diff --git a/Fit/Param/AttLimits.cpp b/Fit/Param/AttLimits.cpp index 9a982651d92f86b18d284bc9458678fe2cb9e2a4..49d05b01fb7fa44c09313049965c96b6444e63b6 100644 --- a/Fit/Param/AttLimits.cpp +++ b/Fit/Param/AttLimits.cpp @@ -18,13 +18,13 @@ AttLimits::AttLimits() : m_limits(RealLimits::limitless()) - , m_att_fixed(Attributes::free()) + , m_fixed(false) { } -AttLimits::AttLimits(const RealLimits& limits, const Attributes& fixedAttr) +AttLimits::AttLimits(const RealLimits& limits, bool fixed) : m_limits(limits) - , m_att_fixed(fixedAttr) + , m_fixed(fixed) { } @@ -35,57 +35,57 @@ AttLimits AttLimits::limitless() AttLimits AttLimits::lowerLimited(double bound_value) { - return AttLimits(RealLimits::lowerLimited(bound_value), Attributes::free()); + return AttLimits(RealLimits::lowerLimited(bound_value), false); } AttLimits AttLimits::positive() { - return AttLimits(RealLimits::positive(), Attributes::free()); + return AttLimits(RealLimits::positive(), false); } AttLimits AttLimits::nonnegative() { - return AttLimits(RealLimits::nonnegative(), Attributes::free()); + return AttLimits(RealLimits::nonnegative(), false); } AttLimits AttLimits::upperLimited(double bound_value) { - return AttLimits(RealLimits::upperLimited(bound_value), Attributes::free()); + return AttLimits(RealLimits::upperLimited(bound_value), false); } AttLimits AttLimits::limited(double left_bound_value, double right_bound_value) { - return AttLimits(RealLimits::limited(left_bound_value, right_bound_value), Attributes::free()); + return AttLimits(RealLimits::limited(left_bound_value, right_bound_value), false); } AttLimits AttLimits::fixed() { - return AttLimits(RealLimits::limitless(), Attributes::fixed()); + return AttLimits(RealLimits::limitless(), true); } bool AttLimits::isFixed() const { - return m_att_fixed.isFixed(); + return m_fixed; } bool AttLimits::isLimited() const { - return m_att_fixed.isFree() && m_limits.isLimited(); + return !m_fixed && m_limits.isLimited(); } bool AttLimits::isUpperLimited() const { - return m_att_fixed.isFree() && !m_limits.hasLowerLimit() && m_limits.hasUpperLimit(); + return !m_fixed && !m_limits.hasLowerLimit() && m_limits.hasUpperLimit(); } bool AttLimits::isLowerLimited() const { - return m_att_fixed.isFree() && m_limits.hasLowerLimit() && !m_limits.hasUpperLimit(); + return !m_fixed && m_limits.hasLowerLimit() && !m_limits.hasUpperLimit(); } bool AttLimits::isLimitless() const { - return m_att_fixed.isFree() && !m_limits.hasLowerLimit() && !m_limits.hasUpperLimit(); + return !m_fixed && !m_limits.hasLowerLimit() && !m_limits.hasUpperLimit(); } double AttLimits::min() const @@ -100,7 +100,7 @@ double AttLimits::max() const bool AttLimits::operator==(const AttLimits& other) const { - return m_limits == other.m_limits && m_att_fixed == other.m_att_fixed; + return m_limits == other.m_limits && m_fixed == other.m_fixed; } bool AttLimits::operator!=(const AttLimits& other) const diff --git a/Fit/Param/AttLimits.h b/Fit/Param/AttLimits.h index ec90371d9abc2172c6a0e91b599939239130f134..b032c8ac55d4485892302f9031c29a48631e5535 100644 --- a/Fit/Param/AttLimits.h +++ b/Fit/Param/AttLimits.h @@ -15,7 +15,6 @@ #ifndef BORNAGAIN_FIT_PARAM_ATTLIMITS_H #define BORNAGAIN_FIT_PARAM_ATTLIMITS_H -#include "Fit/Param/Attributes.h" #include "Fit/Param/RealLimits.h" #include <string> @@ -54,10 +53,10 @@ public: } private: - AttLimits(const RealLimits& limits, const Attributes& fixedAttr); + AttLimits(const RealLimits& limits, bool fixed); RealLimits m_limits; - Attributes m_att_fixed; + bool m_fixed; }; #endif // BORNAGAIN_FIT_PARAM_ATTLIMITS_H diff --git a/Fit/Param/Attributes.h b/Fit/Param/Attributes.h deleted file mode 100644 index a2032f4de48164459ecc6b1db15239d56e444602..0000000000000000000000000000000000000000 --- a/Fit/Param/Attributes.h +++ /dev/null @@ -1,64 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Fit/Param/Attributes.h -//! @brief Defines and implements class Attributes. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -// Swig: not %include'd, but #include'd - -#ifndef BORNAGAIN_FIT_PARAM_ATTRIBUTES_H -#define BORNAGAIN_FIT_PARAM_ATTRIBUTES_H - -#include <ostream> - -//! %Attributes for a fit parameter. Currently, the only attribute is fixed/free. - -class Attributes { -public: - Attributes() = default; - //! Creates a fixed value object - static Attributes fixed() { return Attributes(true); } - static Attributes free() { return Attributes(false); } - - void setFixed(bool is_fixed) { m_is_fixed = is_fixed; } - bool isFixed() const { return m_is_fixed; } - bool isFree() const { return !isFixed(); } - - friend std::ostream& operator<<(std::ostream& ostr, const Attributes& m) - { - m.print(ostr); - return ostr; - } - - bool operator==(const Attributes& other) const { return isFixed() == other.isFixed(); } - bool operator!=(const Attributes& other) const { return !(*this == other); } - -protected: - explicit Attributes(bool is_fixed) - : m_is_fixed(is_fixed) - { - } - - bool m_is_fixed{false}; //! parameter is fixed - - void print(std::ostream& ostr) const; -}; - -//! Prints class -inline void Attributes::print(std::ostream& ostr) const -{ - if (isFixed()) - ostr << "fixed"; - else - ostr << "free"; -} - -#endif // BORNAGAIN_FIT_PARAM_ATTRIBUTES_H diff --git a/GUI/Model/Sample/CompoundItem.cpp b/GUI/Model/Sample/CompoundItem.cpp index da27f3f98febb111eefe10ebf13a920c538e269d..064e50ee10e036cc966195df91e3ced7079a90c0 100644 --- a/GUI/Model/Sample/CompoundItem.cpp +++ b/GUI/Model/Sample/CompoundItem.cpp @@ -44,11 +44,9 @@ const QString position_tooltip = "Relative position of the particle's reference } // namespace -CompoundItem::CompoundItem(const MaterialsSet* materials) +CompoundItem::CompoundItem(const MaterialsSet*) : ItemWithParticles(abundance_tooltip, position_tooltip) - , m_materials(materials) { - ASSERT(m_materials); } void CompoundItem::addItemWithParticleSelection(ItemWithParticles* particle) @@ -87,7 +85,8 @@ void CompoundItem::readFrom(QXmlStreamReader* r) if (tag == Tag::BaseData) XML::readBaseElement<ItemWithParticles>(r, tag, this); else if (tag == Tag::Particle) { - m_particles.push_back(PolyItem<ParticlesCatalog>().readItemFrom(r, m_materials)); + MaterialsSet* dummy = nullptr; + m_particles.push_back(PolyItem<ParticlesCatalog>().readItemFrom(r, dummy)); // TODO XML::gotoEndElementOfTag(r, tag); } else if (tag == Tag::ExpandCompoundGroupbox) expandCompound = XML::readTaggedBool(r, tag); diff --git a/GUI/Model/Sample/CompoundItem.h b/GUI/Model/Sample/CompoundItem.h index a14edcff50c8d0dffb32ec2cc1fe508d8fb4cec6..35444933c8e594c3cd78f64212ffe3d6d1acf1ef 100644 --- a/GUI/Model/Sample/CompoundItem.h +++ b/GUI/Model/Sample/CompoundItem.h @@ -41,7 +41,6 @@ public: private: OwningVector<ItemWithParticles> m_particles; - const MaterialsSet* m_materials; }; #endif // BORNAGAIN_GUI_MODEL_SAMPLE_COMPOUNDITEM_H diff --git a/GUI/Model/Sample/ItemWithMaterial.cpp b/GUI/Model/Sample/ItemWithMaterial.cpp index 946ffeaaf5cecc7c734922f4835b084f97584a4f..18737504502a8596db7b726bcd079e2816dc74c9 100644 --- a/GUI/Model/Sample/ItemWithMaterial.cpp +++ b/GUI/Model/Sample/ItemWithMaterial.cpp @@ -29,7 +29,6 @@ const QString MaterialId("MaterialId"); ItemWithMaterial::ItemWithMaterial(const MaterialsSet* materialModel) : m_materials(materialModel) { - ASSERT(m_materials); } void ItemWithMaterial::setMaterial(const MaterialItem* materialItem) diff --git a/GUI/Model/Sample/MesocrystalItem.cpp b/GUI/Model/Sample/MesocrystalItem.cpp index 6d830f45eec74a00889b8e1e9256bcc9b2cf753e..8769ea3d12db891135191945c68abaaa2ab92fb8 100644 --- a/GUI/Model/Sample/MesocrystalItem.cpp +++ b/GUI/Model/Sample/MesocrystalItem.cpp @@ -47,9 +47,8 @@ const QString position_tooltip = "Relative position of the mesocrystal's referen } // namespace -MesocrystalItem::MesocrystalItem(const MaterialsSet* materials) +MesocrystalItem::MesocrystalItem(const MaterialsSet*) : ItemWithParticles(abundance_tooltip, position_tooltip) - , m_materials(materials) { m_vectorA.init("First lattice vector (nm)", "Coordinates of the first lattice vector", "vectorA"); @@ -59,7 +58,7 @@ MesocrystalItem::MesocrystalItem(const MaterialsSet* materials) "vectorC"); m_outer_shape.initWithArgs("Outer Shape", "", FormfactorsCatalog::Type::Box); - m_basis_particle.initWithArgs("Basis", "", ParticlesCatalog::Type::Particle, materials); + m_basis_particle.initWithArgs("Basis", "", ParticlesCatalog::Type::Particle, nullptr); } void MesocrystalItem::writeTo(QXmlStreamWriter* w) const @@ -92,7 +91,8 @@ void MesocrystalItem::readFrom(QXmlStreamReader* r) else if (tag == Tag::OuterShape) XML::readTaggedElement(r, tag, m_outer_shape); else if (tag == Tag::BasisParticle) { - m_basis_particle.readFrom(r, m_materials); + MaterialsSet* dummy = nullptr; + m_basis_particle.readFrom(r, dummy); // TODO rm dummy arg XML::gotoEndElementOfTag(r, tag); } else if (tag == Tag::ExpandMesocrystalGroupbox) expandMesocrystal = XML::readTaggedBool(r, tag); diff --git a/GUI/Model/Sample/MesocrystalItem.h b/GUI/Model/Sample/MesocrystalItem.h index 0c0d81c5845d5ac6ec787d6bfdd54b495d4e360b..434ba543cfa5b369834afa0e748bfc88ec309ca3 100644 --- a/GUI/Model/Sample/MesocrystalItem.h +++ b/GUI/Model/Sample/MesocrystalItem.h @@ -72,7 +72,6 @@ private: VectorProperty m_vectorC; PolyItem<FormfactorsCatalog> m_outer_shape; PolyItem<ParticlesCatalog> m_basis_particle; - const MaterialsSet* m_materials; }; template <typename T> T* MesocrystalItem::setOuterShapeType() diff --git a/Wrap/Swig/libBornAgainDevice.i b/Wrap/Swig/libBornAgainDevice.i index 424753175e8d08bab658aed967b5019fd705b752..887e5c829613ea6ed49c731938a556c59e551bc7 100644 --- a/Wrap/Swig/libBornAgainDevice.i +++ b/Wrap/Swig/libBornAgainDevice.i @@ -42,7 +42,6 @@ %} %import(module="libBornAgainFit") "Fit/Param/AttLimits.h" -%import(module="libBornAgainFit") "Fit/Param/Attributes.h" %import(module="libBornAgainFit") "Fit/Param/Parameters.h" %import(module="libBornAgainFit") "Fit/Param/Parameter.h"