diff --git a/GUI/Model/FromCore/ItemizeSample.cpp b/GUI/Model/FromCore/ItemizeSample.cpp index c8eb6d376a3c19f3f8b842934c895299c5ad70cc..1386bb6e306fed64d3918dc81f98ca3ee551454b 100644 --- a/GUI/Model/FromCore/ItemizeSample.cpp +++ b/GUI/Model/FromCore/ItemizeSample.cpp @@ -525,7 +525,7 @@ void set_FormFactor(std::variant<ParticleItem*, MesocrystalItem*> parent, const throw std::runtime_error("Formfactor not supported by GUI importer"); } -MaterialItem* findMaterialItem(MaterialModel& matItems, const ISampleNode* node) +MaterialItem* findMaterialItem(MaterialsSet& matItems, const ISampleNode* node) { const Material* material = node->material(); @@ -550,7 +550,7 @@ MaterialItem* findMaterialItem(MaterialModel& matItems, const ISampleNode* node) return result; } -void copyParticleItem(ParticleItem* parent, MaterialModel& matItems, const Particle* particle) +void copyParticleItem(ParticleItem* parent, MaterialsSet& matItems, const Particle* particle) { parent->setAbundance(particle->abundance()); parent->setPosition(particle->particlePosition()); @@ -559,7 +559,7 @@ void copyParticleItem(ParticleItem* parent, MaterialModel& matItems, const Parti set_FormFactor(parent, particle->pFormfactor()); } -void copyParticle(const IParticle* iparticle, MaterialModel& matItems, +void copyParticle(const IParticle* iparticle, MaterialsSet& matItems, std::function<void(ItemWithParticles*)> addToParent) { if (const auto* particle = dynamic_cast<const Particle*>(iparticle)) { @@ -630,7 +630,7 @@ SampleItem* itemizeSample(const MultiLayer& sample, const QString& nodeName) result->setCrossCorLength(sample.crossCorrLength()); result->setExternalField(sample.externalField()); - MaterialModel& matItems = result->materialModel(); + MaterialsSet& matItems = result->materialModel(); // iterate over layers for (size_t layerIndex = 0; layerIndex < sample.numberOfLayers(); layerIndex++) { diff --git a/GUI/Model/Material/MaterialModel.cpp b/GUI/Model/Material/MaterialsSet.cpp similarity index 77% rename from GUI/Model/Material/MaterialModel.cpp rename to GUI/Model/Material/MaterialsSet.cpp index 69719c37e8bbda7b449e34090e99be4ef8e43d0a..afdd1819120bc6a93419037541d90386c6e3bb22 100644 --- a/GUI/Model/Material/MaterialModel.cpp +++ b/GUI/Model/Material/MaterialsSet.cpp @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/Model/Material/MaterialModel.cpp -//! @brief Implements class MaterialModel. +//! @file GUI/Model/Material/MaterialsSet.cpp +//! @brief Implements class MaterialsSet. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,7 +12,7 @@ // // ************************************************************************************************ -#include "GUI/Model/Material/MaterialModel.h" +#include "GUI/Model/Material/MaterialsSet.h" #include "Base/Util/Assert.h" #include "GUI/Model/Material/MaterialItem.h" #include "GUI/Support/XML/UtilXML.h" @@ -58,30 +58,30 @@ const QMap<QString, DefaultMaterials> materialMap = {{"Default", DefaultMaterial {"Core", DefaultMaterials::Core}, {"Substrate", DefaultMaterials::Substrate}}; -MaterialModel::MaterialModel() = default; +MaterialsSet::MaterialsSet() = default; -MaterialModel::~MaterialModel() +MaterialsSet::~MaterialsSet() { clear(); } -void MaterialModel::clear() +void MaterialsSet::clear() { qDeleteAll(m_materials); m_materials.clear(); } -MaterialItem* MaterialModel::addMaterialItem(MaterialItem* materialItem) +MaterialItem* MaterialsSet::addMaterialItem(MaterialItem* materialItem) { return addMaterialItem(materialItem, true); } -MaterialItem* MaterialModel::addMaterialItem() +MaterialItem* MaterialsSet::addMaterialItem() { return addMaterialItem(new MaterialItem(), false); } -MaterialItem* MaterialModel::addMaterialItem(MaterialItem* materialItem, bool signalAdding) +MaterialItem* MaterialsSet::addMaterialItem(MaterialItem* materialItem, bool signalAdding) { ASSERT(materialItem); materialItem->disconnect(this); @@ -94,8 +94,8 @@ MaterialItem* MaterialModel::addMaterialItem(MaterialItem* materialItem, bool si return materialItem; } -MaterialItem* MaterialModel::addRefractiveMaterialItem(const QString& name, double delta, - double beta) +MaterialItem* MaterialsSet::addRefractiveMaterialItem(const QString& name, double delta, + double beta) { auto* materialItem = new MaterialItem(); materialItem->setMatItemName(name); @@ -106,7 +106,7 @@ MaterialItem* MaterialModel::addRefractiveMaterialItem(const QString& name, doub return materialItem; } -MaterialItem* MaterialModel::addSLDMaterialItem(const QString& name, double sld, double abs_term) +MaterialItem* MaterialsSet::addSLDMaterialItem(const QString& name, double sld, double abs_term) { auto* materialItem = new MaterialItem(); materialItem->setMatItemName(name); @@ -117,7 +117,7 @@ MaterialItem* MaterialModel::addSLDMaterialItem(const QString& name, double sld, return materialItem; } -MaterialItem* MaterialModel::materialItemFromName(const QString& name) const +MaterialItem* MaterialsSet::materialItemFromName(const QString& name) const { for (auto* materialItem : m_materials) if (materialItem->matItemName() == name) @@ -126,7 +126,7 @@ MaterialItem* MaterialModel::materialItemFromName(const QString& name) const return nullptr; } -MaterialItem* MaterialModel::materialItemFromIdentifier(const QString& identifier) const +MaterialItem* MaterialsSet::materialItemFromIdentifier(const QString& identifier) const { for (auto* materialItem : m_materials) if (materialItem->identifier() == identifier) @@ -135,18 +135,18 @@ MaterialItem* MaterialModel::materialItemFromIdentifier(const QString& identifie return nullptr; } -const QVector<MaterialItem*>& MaterialModel::materialItems() const +const QVector<MaterialItem*>& MaterialsSet::materialItems() const { return m_materials; } -MaterialItem* MaterialModel::defaultMaterialItem() const +MaterialItem* MaterialsSet::defaultMaterialItem() const { ASSERT(!materialItems().isEmpty()); return materialItems().front(); } -MaterialItem* MaterialModel::defaultCoreMaterialItem() const +MaterialItem* MaterialsSet::defaultCoreMaterialItem() const { for (auto* material : materialItems()) if (material->matItemName() == materialMap.key(DefaultMaterials::Core)) @@ -155,7 +155,7 @@ MaterialItem* MaterialModel::defaultCoreMaterialItem() const return defaultMaterialItem(); } -MaterialItem* MaterialModel::defaultParticleMaterialItem() const +MaterialItem* MaterialsSet::defaultParticleMaterialItem() const { for (auto* material : materialItems()) if (material->matItemName() == materialMap.key(DefaultMaterials::Particle)) @@ -164,14 +164,14 @@ MaterialItem* MaterialModel::defaultParticleMaterialItem() const return defaultMaterialItem(); } -void MaterialModel::removeMaterialItem(MaterialItem* materialItem) +void MaterialsSet::removeMaterialItem(MaterialItem* materialItem) { m_materials.removeAll(materialItem); delete materialItem; emit materialAddedOrRemoved(); } -void MaterialModel::writeTo(QXmlStreamWriter* w) const +void MaterialsSet::writeTo(QXmlStreamWriter* w) const { XML::writeAttribute(w, XML::Attrib::version, uint(1)); @@ -183,7 +183,7 @@ void MaterialModel::writeTo(QXmlStreamWriter* w) const } } -void MaterialModel::readFrom(QXmlStreamReader* r) +void MaterialsSet::readFrom(QXmlStreamReader* r) { clear(); diff --git a/GUI/Model/Material/MaterialModel.h b/GUI/Model/Material/MaterialsSet.h similarity index 86% rename from GUI/Model/Material/MaterialModel.h rename to GUI/Model/Material/MaterialsSet.h index c8a190751d34c79cc60772a60514363ac8171320..df367419825ca761ecd7ccadccc566a6a9ad0505 100644 --- a/GUI/Model/Material/MaterialModel.h +++ b/GUI/Model/Material/MaterialsSet.h @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/Model/Material/MaterialModel.h -//! @brief Defines class MaterialModel. +//! @file GUI/Model/Material/MaterialsSet.h +//! @brief Defines class MaterialsSet. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,8 +12,8 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_GUI_MODEL_MATERIAL_MATERIALMODEL_H -#define BORNAGAIN_GUI_MODEL_MATERIAL_MATERIALMODEL_H +#ifndef BORNAGAIN_GUI_MODEL_MATERIAL_MATERIALSSET_H +#define BORNAGAIN_GUI_MODEL_MATERIAL_MATERIALSSET_H #include <QMap> #include <QObject> @@ -27,11 +27,11 @@ extern const QMap<QString, DefaultMaterials> materialMap; class MaterialItem; -class MaterialModel : public QObject { +class MaterialsSet : public QObject { Q_OBJECT public: - MaterialModel(); - ~MaterialModel(); + MaterialsSet(); + ~MaterialsSet(); //! Add the material and take ownership of it. MaterialItem* addMaterialItem(MaterialItem* materialItem); @@ -71,4 +71,4 @@ private: QVector<MaterialItem*> m_materials; //!< all materials (owned by this class) }; -#endif // BORNAGAIN_GUI_MODEL_MATERIAL_MATERIALMODEL_H +#endif // BORNAGAIN_GUI_MODEL_MATERIAL_MATERIALSSET_H diff --git a/GUI/Model/Sample/CompoundItem.cpp b/GUI/Model/Sample/CompoundItem.cpp index 06a300be3c8e71d0e84708ea637b926b3edde421..c984c1396c30fadef0f5d599c160a0f99326c30d 100644 --- a/GUI/Model/Sample/CompoundItem.cpp +++ b/GUI/Model/Sample/CompoundItem.cpp @@ -40,7 +40,7 @@ const QString position_tooltip = "Relative position of the particle's reference } // namespace -CompoundItem::CompoundItem(const MaterialModel* materials) +CompoundItem::CompoundItem(const MaterialsSet* materials) : ItemWithParticles(abundance_tooltip, position_tooltip) , m_material_model(materials) { diff --git a/GUI/Model/Sample/CompoundItem.h b/GUI/Model/Sample/CompoundItem.h index bbeed7cea344606080892c3bb144b38f38c3e61b..c82c64760296f561e9f93048c1cc29ace17aab0b 100644 --- a/GUI/Model/Sample/CompoundItem.h +++ b/GUI/Model/Sample/CompoundItem.h @@ -20,11 +20,11 @@ #include "Sample/Particle/Compound.h" #include <memory> -class MaterialModel; +class MaterialsSet; class CompoundItem : public ItemWithParticles { public: - CompoundItem(const MaterialModel* materials); + CompoundItem(const MaterialsSet* materials); void writeTo(QXmlStreamWriter* w) const override; void readFrom(QXmlStreamReader* r) override; @@ -42,7 +42,7 @@ public: private: SelectionVector<ItemWithParticlesCatalog> m_particles; - const MaterialModel* m_material_model; + const MaterialsSet* m_material_model; }; #endif // BORNAGAIN_GUI_MODEL_SAMPLE_COMPOUNDITEM_H diff --git a/GUI/Model/Sample/CoreAndShellItem.cpp b/GUI/Model/Sample/CoreAndShellItem.cpp index b4578da1a34090d322ef625b58a635e3a0ee445e..bdee755428b89241f0930c4e1fa4fefa48f42f7f 100644 --- a/GUI/Model/Sample/CoreAndShellItem.cpp +++ b/GUI/Model/Sample/CoreAndShellItem.cpp @@ -14,7 +14,7 @@ #include "GUI/Model/Sample/CoreAndShellItem.h" #include "Base/Util/Assert.h" -#include "GUI/Model/Material/MaterialModel.h" +#include "GUI/Model/Material/MaterialsSet.h" #include "GUI/Model/Sample/ParticleItem.h" #include "Sample/Particle/CoreAndShell.h" #include "Sample/Particle/Particle.h" @@ -40,7 +40,7 @@ const QString position_tooltip = "Relative position of the particle's reference } // namespace -CoreAndShellItem::CoreAndShellItem(const MaterialModel* materials) +CoreAndShellItem::CoreAndShellItem(const MaterialsSet* materials) : ItemWithParticles(abundance_tooltip, position_tooltip) , m_material_model(materials) { @@ -152,7 +152,7 @@ ParticleItem* CoreAndShellItem::coreItem() const return m_core.get(); } -ParticleItem* CoreAndShellItem::createCoreItem(const MaterialModel* materials) +ParticleItem* CoreAndShellItem::createCoreItem(const MaterialsSet* materials) { m_core = std::make_unique<ParticleItem>(materials); m_core->setMaterial(materials->defaultCoreMaterialItem()); @@ -164,7 +164,7 @@ ParticleItem* CoreAndShellItem::shellItem() const return m_shell.get(); } -ParticleItem* CoreAndShellItem::createShellItem(const MaterialModel* materials) +ParticleItem* CoreAndShellItem::createShellItem(const MaterialsSet* materials) { m_shell = std::make_unique<ParticleItem>(materials); m_shell->setMaterial(materials->defaultParticleMaterialItem()); diff --git a/GUI/Model/Sample/CoreAndShellItem.h b/GUI/Model/Sample/CoreAndShellItem.h index 2694311c1e0605a91b4df07483929ea5eb302c4b..9dea73817cbe3f8ed220ca89e88b65ee845eaf09 100644 --- a/GUI/Model/Sample/CoreAndShellItem.h +++ b/GUI/Model/Sample/CoreAndShellItem.h @@ -19,12 +19,12 @@ #include <memory> class CoreAndShell; -class MaterialModel; +class MaterialsSet; class ParticleItem; class CoreAndShellItem : public ItemWithParticles { public: - CoreAndShellItem(const MaterialModel* materials); + CoreAndShellItem(const MaterialsSet* materials); void writeTo(QXmlStreamWriter* w) const override; void readFrom(QXmlStreamReader* r) override; @@ -32,10 +32,10 @@ public: std::unique_ptr<CoreAndShell> createCoreAndShell() const; ParticleItem* coreItem() const; - ParticleItem* createCoreItem(const MaterialModel* materials); + ParticleItem* createCoreItem(const MaterialsSet* materials); ParticleItem* shellItem() const; - ParticleItem* createShellItem(const MaterialModel* materials); + ParticleItem* createShellItem(const MaterialsSet* materials); QVector<ItemWithParticles*> containedItemsWithParticles() const override; @@ -46,7 +46,7 @@ public: private: std::unique_ptr<ParticleItem> m_core; std::unique_ptr<ParticleItem> m_shell; - const MaterialModel* m_material_model; + const MaterialsSet* m_material_model; }; #endif // BORNAGAIN_GUI_MODEL_SAMPLE_COREANDSHELLITEM_H diff --git a/GUI/Model/Sample/ItemWithMaterial.cpp b/GUI/Model/Sample/ItemWithMaterial.cpp index d5a3daabd8c0e5ad54352d07741cb272da038f34..df9e6b9c5f9a349d291ea73a89074c9f91d68abd 100644 --- a/GUI/Model/Sample/ItemWithMaterial.cpp +++ b/GUI/Model/Sample/ItemWithMaterial.cpp @@ -15,7 +15,7 @@ #include "GUI/Model/Sample/ItemWithMaterial.h" #include "Base/Util/Assert.h" #include "GUI/Model/Material/MaterialItem.h" -#include "GUI/Model/Material/MaterialModel.h" +#include "GUI/Model/Material/MaterialsSet.h" #include "GUI/Support/XML/UtilXML.h" namespace { @@ -26,7 +26,7 @@ const QString MaterialId("MaterialId"); } // namespace Tag } // namespace -ItemWithMaterial::ItemWithMaterial(const MaterialModel* materialModel) +ItemWithMaterial::ItemWithMaterial(const MaterialsSet* materialModel) : m_material_model(materialModel) { ASSERT(m_material_model); diff --git a/GUI/Model/Sample/ItemWithMaterial.h b/GUI/Model/Sample/ItemWithMaterial.h index 405bbdbab541fbcfea82acc3894a7a8b75f1dd3e..d6db6a452842ececdda7b219e1c5db886ac609e9 100644 --- a/GUI/Model/Sample/ItemWithMaterial.h +++ b/GUI/Model/Sample/ItemWithMaterial.h @@ -21,14 +21,14 @@ #include <functional> class MaterialItem; -class MaterialModel; +class MaterialsSet; //! Base class for all sample components made of some material. class ItemWithMaterial { public: //! Overhand the material list where the current material has to be searched for. - explicit ItemWithMaterial(const MaterialModel* materialModel); + explicit ItemWithMaterial(const MaterialsSet* materialModel); //! Set the material this item shall use. //! Stores the identifier, not the pointer! @@ -49,7 +49,7 @@ public: virtual void readFrom(QXmlStreamReader* r); protected: - const MaterialModel* m_material_model; + const MaterialsSet* m_material_model; QString m_material_identifier; }; diff --git a/GUI/Model/Sample/ItemWithParticlesCatalog.cpp b/GUI/Model/Sample/ItemWithParticlesCatalog.cpp index 78ac6f206fd1889f67bbd46be25767e8e90f1843..16594dd518447d080da2baf3fc7dd64a522c03f5 100644 --- a/GUI/Model/Sample/ItemWithParticlesCatalog.cpp +++ b/GUI/Model/Sample/ItemWithParticlesCatalog.cpp @@ -19,7 +19,7 @@ #include "GUI/Model/Sample/MesocrystalItem.h" #include "GUI/Model/Sample/ParticleItem.h" -ItemWithParticles* ItemWithParticlesCatalog::create(Type type, const MaterialModel* materials) +ItemWithParticles* ItemWithParticlesCatalog::create(Type type, const MaterialsSet* materials) { switch (type) { case Type::Particle: diff --git a/GUI/Model/Sample/ItemWithParticlesCatalog.h b/GUI/Model/Sample/ItemWithParticlesCatalog.h index ca22f9f76efa2ea221feaa1a320b87b1e848114f..0549f478e68300444c7fd1e19b607a19e70f682a 100644 --- a/GUI/Model/Sample/ItemWithParticlesCatalog.h +++ b/GUI/Model/Sample/ItemWithParticlesCatalog.h @@ -19,7 +19,7 @@ #include <QVector> class ItemWithParticles; -class MaterialModel; +class MaterialsSet; class ItemWithParticlesCatalog { public: @@ -30,7 +30,7 @@ public: enum class Type : uint8_t { Particle = 1, Composition = 2, CoreShell = 3, Mesocrystal = 4 }; //! Creates the item of the given type. - static ItemWithParticles* create(Type type, const MaterialModel* materials); + static ItemWithParticles* create(Type type, const MaterialsSet* materials); //! List of available types, sorted as expected in the UI. static QVector<Type> types(); diff --git a/GUI/Model/Sample/LayerItem.cpp b/GUI/Model/Sample/LayerItem.cpp index ed163978b571b663ba740c1e4c8c755663258f90..f5e44193b6690b1ec1150de1b0d98b98889d2d89 100644 --- a/GUI/Model/Sample/LayerItem.cpp +++ b/GUI/Model/Sample/LayerItem.cpp @@ -66,7 +66,7 @@ QVector<ItemWithMaterial*> layoutItemsWithMaterial(ParticleLayoutItem* layout) } // namespace -LayerItem::LayerItem(const MaterialModel* materials) +LayerItem::LayerItem(const MaterialsSet* materials) : ItemWithMaterial(materials) , m_name("Layer") { diff --git a/GUI/Model/Sample/LayerItem.h b/GUI/Model/Sample/LayerItem.h index a6abf2dfa6a51807d8a62ed64aafe9df5fa1fc98..38373a10d001224a4c0248e87637e77792441421 100644 --- a/GUI/Model/Sample/LayerItem.h +++ b/GUI/Model/Sample/LayerItem.h @@ -29,7 +29,7 @@ class ParticleLayoutItem; class LayerItem : public virtual ItemWithMaterial, public virtual Item3D { public: - explicit LayerItem(const MaterialModel* materials); + explicit LayerItem(const MaterialsSet* materials); ~LayerItem(); QString layerName() const { return m_name; } diff --git a/GUI/Model/Sample/MesocrystalItem.cpp b/GUI/Model/Sample/MesocrystalItem.cpp index 349b9624dbc8e92383e3db9945655f8dc069913d..d8afbfa0ac102232b527a62ec776d4df6a0e7f96 100644 --- a/GUI/Model/Sample/MesocrystalItem.cpp +++ b/GUI/Model/Sample/MesocrystalItem.cpp @@ -45,7 +45,7 @@ const QString position_tooltip = "Relative position of the mesocrystal's referen } // namespace -MesocrystalItem::MesocrystalItem(const MaterialModel* materials) +MesocrystalItem::MesocrystalItem(const MaterialsSet* materials) : ItemWithParticles(abundance_tooltip, position_tooltip) , m_material_model(materials) { diff --git a/GUI/Model/Sample/MesocrystalItem.h b/GUI/Model/Sample/MesocrystalItem.h index 00eee99b3b34e30f0a184e332dcbad832bf58f55..8659292ad03af47f69cc6d168aa2037094b376b3 100644 --- a/GUI/Model/Sample/MesocrystalItem.h +++ b/GUI/Model/Sample/MesocrystalItem.h @@ -26,12 +26,12 @@ class IFormFactor; class IParticle; -class MaterialModel; +class MaterialsSet; class Mesocrystal; class MesocrystalItem : public ItemWithParticles { public: - explicit MesocrystalItem(const MaterialModel* materials); + explicit MesocrystalItem(const MaterialsSet* materials); void writeTo(QXmlStreamWriter* w) const override; void readFrom(QXmlStreamReader* r) override; @@ -72,7 +72,7 @@ private: VectorProperty m_vectorC; SelectionProperty<FormFactorItemCatalog> m_outer_shape; SelectionProperty<ItemWithParticlesCatalog> m_basis_particle; - const MaterialModel* m_material_model; + const MaterialsSet* m_material_model; }; template <typename T> T* MesocrystalItem::setOuterShapeType() diff --git a/GUI/Model/Sample/ParticleItem.cpp b/GUI/Model/Sample/ParticleItem.cpp index 5d929a6feab499efdd87ad3f35f2274b227f778d..05dd008e703d2988d8422e2e5545a06a16a7ef96 100644 --- a/GUI/Model/Sample/ParticleItem.cpp +++ b/GUI/Model/Sample/ParticleItem.cpp @@ -36,7 +36,7 @@ const QString position_tooltip = "Relative position of the particle's reference } // namespace -ParticleItem::ParticleItem(const MaterialModel* materials) +ParticleItem::ParticleItem(const MaterialsSet* materials) : ItemWithMaterial(materials) , ItemWithParticles(abundance_tooltip, position_tooltip) { diff --git a/GUI/Model/Sample/ParticleItem.h b/GUI/Model/Sample/ParticleItem.h index d406bdf0f87862ab9c6a4758cb954cb5d89cdb9d..76f1660af3c7af5b2173a75df85a97041b32f457 100644 --- a/GUI/Model/Sample/ParticleItem.h +++ b/GUI/Model/Sample/ParticleItem.h @@ -26,7 +26,7 @@ class Particle; class ParticleItem : public ItemWithMaterial, public ItemWithParticles { public: - ParticleItem(const MaterialModel* materials); + ParticleItem(const MaterialsSet* materials); void writeTo(QXmlStreamWriter* w) const override; void readFrom(QXmlStreamReader* r) override; diff --git a/GUI/Model/Sample/ParticleLayoutItem.cpp b/GUI/Model/Sample/ParticleLayoutItem.cpp index 4ab69bd73cbb966ee9cc3e0ec03aaae620210bdd..46041f8fad5de44ffd4f36cd41ef4b56e5e406cf 100644 --- a/GUI/Model/Sample/ParticleLayoutItem.cpp +++ b/GUI/Model/Sample/ParticleLayoutItem.cpp @@ -31,7 +31,7 @@ const QString ExpandInterferenceGroupbox("ExpandInterferenceGroupbox"); } // namespace Tag } // namespace -ParticleLayoutItem::ParticleLayoutItem(const MaterialModel* materials) +ParticleLayoutItem::ParticleLayoutItem(const MaterialsSet* materials) : m_material_model(materials) { m_own_density.init("Total particle density (nm^-2)", diff --git a/GUI/Model/Sample/ParticleLayoutItem.h b/GUI/Model/Sample/ParticleLayoutItem.h index d6663f959288a1831f1bde1b3158fe3db767a85f..2c6aa7a23a4207a1f9a4a0e59e0d5c32bbd6f62d 100644 --- a/GUI/Model/Sample/ParticleLayoutItem.h +++ b/GUI/Model/Sample/ParticleLayoutItem.h @@ -25,11 +25,11 @@ #include <memory> class ItemWithParticles; -class MaterialModel; +class MaterialsSet; class ParticleLayoutItem : public Item3D { public: - ParticleLayoutItem(const MaterialModel* materials); + ParticleLayoutItem(const MaterialsSet* materials); //! The density value which belonging only to the layout. //! @@ -81,7 +81,7 @@ private: DoubleProperty m_own_density; SelectionProperty<InterferenceItemCatalog> m_interference; SelectionVector<ItemWithParticlesCatalog> m_particles; - const MaterialModel* m_material_model; + const MaterialsSet* m_material_model; }; #endif // BORNAGAIN_GUI_MODEL_SAMPLE_PARTICLELAYOUTITEM_H diff --git a/GUI/Model/Sample/SampleItem.cpp b/GUI/Model/Sample/SampleItem.cpp index 787e3bab3e5ab2fb4b55abdf37a93c609f8f33d5..b19bc31187b00052f85eaaaf7c91f24de446f99c 100644 --- a/GUI/Model/Sample/SampleItem.cpp +++ b/GUI/Model/Sample/SampleItem.cpp @@ -24,7 +24,7 @@ namespace Tag { const QString Name("Name"); const QString Description("Description"); const QString CrossCorrelationLength("CrossCorrelationLength"); -const QString MaterialModel("MaterialModel"); +const QString MaterialsSet("MaterialsSet"); const QString Layer("Layer"); const QString ExternalField("ExternalField"); const QString ExpandInfoGroupbox("ExpandInfoGroupbox"); @@ -152,7 +152,7 @@ void SampleItem::writeTo(QXmlStreamWriter* w) const w->writeEndElement(); // materials - w->writeStartElement(Tag::MaterialModel); + w->writeStartElement(Tag::MaterialsSet); m_materials.writeTo(w); w->writeEndElement(); @@ -200,7 +200,7 @@ void SampleItem::readFrom(QXmlStreamReader* r) XML::gotoEndElementOfTag(r, tag); // materials - } else if (tag == Tag::MaterialModel) { + } else if (tag == Tag::MaterialsSet) { m_materials.readFrom(r); XML::gotoEndElementOfTag(r, tag); diff --git a/GUI/Model/Sample/SampleItem.h b/GUI/Model/Sample/SampleItem.h index 8043bbe14dc27b4e91ff67ac2aef441984708a6b..af5a44e619119eeeec023475593c1732904e0bf4 100644 --- a/GUI/Model/Sample/SampleItem.h +++ b/GUI/Model/Sample/SampleItem.h @@ -17,7 +17,7 @@ #include "Base/Types/OwningVector.h" #include "GUI/Model/Descriptor/VectorProperty.h" -#include "GUI/Model/Material/MaterialModel.h" +#include "GUI/Model/Material/MaterialsSet.h" #include "GUI/Model/Sample/Item3D.h" #include <QString> #include <QVector> @@ -66,8 +66,8 @@ public: void writeTo(QXmlStreamWriter* w) const; void readFrom(QXmlStreamReader* r); - MaterialModel& materialModel() { return m_materials; } - const MaterialModel& materialModel() const { return m_materials; } + MaterialsSet& materialModel() { return m_materials; } + const MaterialsSet& materialModel() const { return m_materials; } bool expandInfo = true; @@ -77,7 +77,7 @@ private: DoubleProperty m_cross_correlation_length; VectorProperty m_external_field; OwningVector<LayerItem> m_layers; - MaterialModel m_materials; + MaterialsSet m_materials; }; #endif // BORNAGAIN_GUI_MODEL_SAMPLE_SAMPLEITEM_H diff --git a/GUI/View/Material/MaterialEditorDialog.cpp b/GUI/View/Material/MaterialEditorDialog.cpp index 38099f4a2d31e0e450038bea140446cdfebce2d1..e46ccfcde7fabde6dde089132638f488487b954b 100644 --- a/GUI/View/Material/MaterialEditorDialog.cpp +++ b/GUI/View/Material/MaterialEditorDialog.cpp @@ -14,7 +14,7 @@ #include "GUI/View/Material/MaterialEditorDialog.h" #include "GUI/Model/Material/MaterialItem.h" -#include "GUI/Model/Material/MaterialModel.h" +#include "GUI/Model/Material/MaterialsSet.h" #include "GUI/Model/Sample/ItemWithMaterial.h" #include "GUI/Model/Sample/SampleItem.h" #include "GUI/Support/Style/Style.h" diff --git a/GUI/View/Material/MaterialTableModel.cpp b/GUI/View/Material/MaterialTableModel.cpp index a8f6f140dd71ea470729749faa6960bc35269318..fc534e8e7f91e2d2f191f028d5e4f2f7ae60b0d7 100644 --- a/GUI/View/Material/MaterialTableModel.cpp +++ b/GUI/View/Material/MaterialTableModel.cpp @@ -14,12 +14,12 @@ #include "GUI/View/Material/MaterialTableModel.h" #include "GUI/Model/Material/MaterialItem.h" -#include "GUI/Model/Material/MaterialModel.h" +#include "GUI/Model/Material/MaterialsSet.h" #include <QApplication> #include <QFontMetrics> #include <QPixmap> -MaterialTableModel::MaterialTableModel(MaterialModel& model) +MaterialTableModel::MaterialTableModel(MaterialsSet& model) : m_model(model) { } diff --git a/GUI/View/Material/MaterialTableModel.h b/GUI/View/Material/MaterialTableModel.h index 958014ec4bf808dfa27bf9fe511ddd0718bf9948..6a2e84ad52ece53d5a496bb4565e4f34dd327cd7 100644 --- a/GUI/View/Material/MaterialTableModel.h +++ b/GUI/View/Material/MaterialTableModel.h @@ -18,7 +18,7 @@ #include <QAbstractItemModel> class MaterialItem; -class MaterialModel; +class MaterialsSet; //! Model for list of materials, used in MaterialEditorDialog. //! @@ -27,7 +27,7 @@ class MaterialModel; class MaterialTableModel : public QAbstractTableModel { Q_OBJECT public: - MaterialTableModel(MaterialModel& model); + MaterialTableModel(MaterialsSet& model); int rowCount(const QModelIndex& parent = QModelIndex()) const override; int columnCount(const QModelIndex& parent = QModelIndex()) const override; @@ -59,7 +59,7 @@ private: //! The columns in the header. PARAMETERS contains delta/beta or Re/Im. enum Column { NAME, TYPE, PARAMETERS, MAGNETIZATION, NUM_COLUMNS }; - MaterialModel& m_model; + MaterialsSet& m_model; }; diff --git a/GUI/View/Sample/LayerForm.cpp b/GUI/View/Sample/LayerForm.cpp index d164f0088f22ca26366fd8733b255a4e85d4ce98..c4e05ed0955a41320e4e94c0b9a01da386df8e2c 100644 --- a/GUI/View/Sample/LayerForm.cpp +++ b/GUI/View/Sample/LayerForm.cpp @@ -15,7 +15,7 @@ #include "GUI/View/Sample/LayerForm.h" #include "Base/Util/Assert.h" #include "GUI/Model/Material/MaterialItem.h" -#include "GUI/Model/Material/MaterialModel.h" +#include "GUI/Model/Material/MaterialsSet.h" #include "GUI/Model/Sample/LayerItem.h" #include "GUI/Model/Sample/SampleItem.h" #include "GUI/View/Numeric/NumWidgetUtil.h" @@ -122,7 +122,7 @@ LayerForm::LayerForm(QWidget* parent, LayerItem* layerItem, SampleEditorControll // listen to changes in materials to update the title (contains the material name). Necessary // to reflect e.g. a name change done in the material editor. - connect(ec->materialModel(), &MaterialModel::materialChanged, this, &LayerForm::updateTitle); + connect(ec->materialModel(), &MaterialsSet::materialChanged, this, &LayerForm::updateTitle); updateLayerPositionDependentElements(); } diff --git a/GUI/View/Sample/MaterialInplaceForm.cpp b/GUI/View/Sample/MaterialInplaceForm.cpp index e0b5067deca03bc093285d2e982a13e410467fc6..63a2a3e5a341203a57c979c3207f9cb74ff79800 100644 --- a/GUI/View/Sample/MaterialInplaceForm.cpp +++ b/GUI/View/Sample/MaterialInplaceForm.cpp @@ -15,7 +15,7 @@ #include "GUI/View/Sample/MaterialInplaceForm.h" #include "Base/Util/Assert.h" #include "GUI/Model/Material/MaterialItem.h" -#include "GUI/Model/Material/MaterialModel.h" +#include "GUI/Model/Material/MaterialsSet.h" #include "GUI/Model/Sample/ItemWithMaterial.h" #include "GUI/Model/Sample/LayerItem.h" #include "GUI/Model/Sample/SampleItem.h" diff --git a/GUI/View/Sample/SampleEditorController.cpp b/GUI/View/Sample/SampleEditorController.cpp index faaa25d721384a40c9ef3eff012095266f209330..88c2de3e9d7e753c6cde3e8dc1b6f9e19980525a 100644 --- a/GUI/View/Sample/SampleEditorController.cpp +++ b/GUI/View/Sample/SampleEditorController.cpp @@ -14,7 +14,7 @@ #include "GUI/View/Sample/SampleEditorController.h" #include "Base/Util/Assert.h" -#include "GUI/Model/Material/MaterialModel.h" +#include "GUI/Model/Material/MaterialsSet.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Model/Sample/CompoundItem.h" #include "GUI/Model/Sample/CoreAndShellItem.h" @@ -346,7 +346,7 @@ void SampleEditorController::setCurrentIndex(ISelectionContainerForm* widget, in emit modified(); } -MaterialModel* SampleEditorController::materialModel() const +MaterialsSet* SampleEditorController::materialModel() const { return &m_sample_item->materialModel(); } diff --git a/GUI/View/Sample/SampleEditorController.h b/GUI/View/Sample/SampleEditorController.h index 9515180cbdc626ad7725feb1393a77372f936a69..1a70a6d6a3e2e62557297e5fb279d5bcee11c609 100644 --- a/GUI/View/Sample/SampleEditorController.h +++ b/GUI/View/Sample/SampleEditorController.h @@ -32,7 +32,7 @@ class ItemWithParticles; class LatticeTypeSelectionForm; class LayerForm; class LayerItem; -class MaterialModel; +class MaterialsSet; class MesocrystalForm; class ParticleLayoutItem; class SampleForm; @@ -61,7 +61,7 @@ public: SampleItem* sampleItem() const { return m_sample_item; } //! The materials of the current document - MaterialModel* materialModel() const; + MaterialsSet* materialModel() const; void addLayerItem(LayerItem* before); QColor findColor(int atIndex); diff --git a/Tests/Unit/GUI/TestMaterialItems.cpp b/Tests/Unit/GUI/TestMaterialItems.cpp index e7ea1c1b19974da4990c1d21eb4877c6b5bf6a14..f84488df781b4c842fef18242abd764faedad86d 100644 --- a/Tests/Unit/GUI/TestMaterialItems.cpp +++ b/Tests/Unit/GUI/TestMaterialItems.cpp @@ -1,13 +1,13 @@ #include "GUI/Model/Material/MaterialItem.h" -#include "GUI/Model/Material/MaterialModel.h" +#include "GUI/Model/Material/MaterialsSet.h" #include "GUI/Support/XML/Backup.h" #include "Tests/GTestWrapper/google_test.h" #include <memory> -TEST(TestMaterialModel, addRefractiveMaterial) +TEST(TestMaterialsSet, addRefractiveMaterial) { - std::unique_ptr<MaterialModel> model(new MaterialModel); + std::unique_ptr<MaterialsSet> model(new MaterialsSet); EXPECT_TRUE(model->materialItems().isEmpty()); @@ -23,9 +23,9 @@ TEST(TestMaterialModel, addRefractiveMaterial) EXPECT_EQ(material->beta(), beta); } -TEST(TestMaterialModel, addSLDMaterial) +TEST(TestMaterialsSet, addSLDMaterial) { - std::unique_ptr<MaterialModel> model(new MaterialModel); + std::unique_ptr<MaterialsSet> model(new MaterialsSet); EXPECT_TRUE(model->materialItems().isEmpty()); @@ -43,9 +43,9 @@ TEST(TestMaterialModel, addSLDMaterial) //! Checks the method which returns MaterialItem from known identifier. -TEST(TestMaterialModel, materialFromIdentifier) +TEST(TestMaterialsSet, materialFromIdentifier) { - MaterialModel model; + MaterialsSet model; MaterialItem* material1 = model.addRefractiveMaterialItem("aaa", 1.0, 2.0); MaterialItem* material2 = model.addRefractiveMaterialItem("bbb", 3.0, 4.0); EXPECT_EQ(material1, model.materialItemFromIdentifier(material1->identifier())); @@ -55,9 +55,9 @@ TEST(TestMaterialModel, materialFromIdentifier) //! Checks the method which returns MaterialItem from material name. -TEST(TestMaterialModel, materialFromName) +TEST(TestMaterialsSet, materialFromName) { - MaterialModel model; + MaterialsSet model; MaterialItem* material1 = model.addRefractiveMaterialItem("aaa", 1.0, 2.0); MaterialItem* material2 = model.addRefractiveMaterialItem("bbb", 3.0, 4.0); EXPECT_EQ(material1, model.materialItemFromName(material1->matItemName())); @@ -67,9 +67,9 @@ TEST(TestMaterialModel, materialFromName) //! Default MaterialProperty construction. -TEST(TestMaterialModel, defaultMaterialProperty) +TEST(TestMaterialsSet, defaultMaterialProperty) { - MaterialModel model; + MaterialsSet model; // should throw in the absence of any materials // EXPECT_FAILED_ASSERT(model.defaultMaterialItem()); <--- TODO: restore @@ -80,7 +80,7 @@ TEST(TestMaterialModel, defaultMaterialProperty) EXPECT_EQ(model.defaultMaterialItem(), mat1); } -TEST(TestMaterialModel, serializeRefractiveMaterial) +TEST(TestMaterialsSet, serializeRefractiveMaterial) { MaterialItem material; material.setRefractiveIndex(11, 12); @@ -103,7 +103,7 @@ TEST(TestMaterialModel, serializeRefractiveMaterial) EXPECT_EQ(target.magnetization().r3(), R3(1, 2, 3)); } -TEST(TestMaterialModel, serializeSLDMaterial) +TEST(TestMaterialsSet, serializeSLDMaterial) { MaterialItem material; material.setScatteringLengthDensity(complex_t(11, 12));