Skip to content
Snippets Groups Projects
Commit c808b1cc authored by Matthias Puchner's avatar Matthias Puchner
Browse files

rm obsolete MaterialModelStore

parent 90c6978b
No related branches found
No related tags found
1 merge request!490More refactoring of material handling
Pipeline #50680 passed
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "GUI/Model/Material/MaterialModel.h" #include "GUI/Model/Material/MaterialModel.h"
#include "GUI/Model/Material/MaterialItem.h" #include "GUI/Model/Material/MaterialItem.h"
#include "GUI/Model/Material/MaterialModelStore.h"
#include <QColor> #include <QColor>
#include <QUuid> #include <QUuid>
#include <random> #include <random>
...@@ -47,14 +46,6 @@ MaterialModel::MaterialModel(QObject* parent) ...@@ -47,14 +46,6 @@ MaterialModel::MaterialModel(QObject* parent)
: SessionModel(GUI::Session::XML::MaterialModelTag, parent) : SessionModel(GUI::Session::XML::MaterialModelTag, parent)
{ {
setObjectName(GUI::Session::XML::MaterialModelTag); setObjectName(GUI::Session::XML::MaterialModelTag);
if (GUI::Model::MaterialModelStore::materialModel() == nullptr)
GUI::Model::MaterialModelStore::subscribe(this);
}
MaterialModel::~MaterialModel()
{
if (GUI::Model::MaterialModelStore::materialModel() == this)
GUI::Model::MaterialModelStore::unsubscribe(this);
} }
void MaterialModel::clear() void MaterialModel::clear()
......
...@@ -24,7 +24,6 @@ class MaterialModel : public SessionModel { ...@@ -24,7 +24,6 @@ class MaterialModel : public SessionModel {
public: public:
explicit MaterialModel(QObject* parent = nullptr); explicit MaterialModel(QObject* parent = nullptr);
~MaterialModel() override;
void clear() override; void clear() override;
......
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/Model/Material/MaterialModelStore.cpp
//! @brief Implements namespace MaterialModelStore
//!
//! @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)
//
// ************************************************************************************************
#include "GUI/Model/Material/MaterialModelStore.h"
#include "GUI/Util/Error.h"
namespace {
MaterialModel* theMaterialModel = nullptr;
}
namespace GUI::Model::MaterialModelStore {
MaterialModel* materialModel()
{
return theMaterialModel;
}
void subscribe(MaterialModel* materialModel)
{
if (theMaterialModel != nullptr)
throw Error("GUI::Model::MaterialModelStore::subscribe() -> Error. Attempt to subscribe "
"MaterialModel twice.");
theMaterialModel = materialModel;
}
void unsubscribe(MaterialModel* materialModel)
{
if (theMaterialModel != materialModel)
throw Error("GUI::Model::MaterialModelStore::unsubscribe -> Error. Attempt to unsubscribe "
"MaterialModel before it was subscribed.");
theMaterialModel = nullptr;
}
} // namespace GUI::Model::MaterialModelStore
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/Model/Material/MaterialModelStore.h
//! @brief Defines namespace GUI::Model::MaterialModelStore
//!
//! @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)
//
// ************************************************************************************************
#ifndef BORNAGAIN_GUI_MODEL_MATERIAL_MATERIALMODELSTORE_H
#define BORNAGAIN_GUI_MODEL_MATERIAL_MATERIALMODELSTORE_H
class MaterialModel;
//! The MaterialModelStore holds an instance of the MaterialModel class
namespace GUI::Model::MaterialModelStore {
MaterialModel* materialModel();
void subscribe(MaterialModel* materialModel);
void unsubscribe(MaterialModel* materialModel);
} // namespace GUI::Model::MaterialModelStore
#endif // BORNAGAIN_GUI_MODEL_MATERIAL_MATERIALMODELSTORE_H
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "GUI/Model/Material/MaterialItem.h" #include "GUI/Model/Material/MaterialItem.h"
#include "GUI/Model/Material/MaterialItemContainer.h" #include "GUI/Model/Material/MaterialItemContainer.h"
#include "GUI/Model/Material/MaterialModel.h" #include "GUI/Model/Material/MaterialModel.h"
#include "GUI/Model/Material/MaterialModelStore.h"
#include <QColor> #include <QColor>
void ItemWithMaterial::setMaterial(const MaterialItem* materialItem) void ItemWithMaterial::setMaterial(const MaterialItem* materialItem)
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "GUI/Application/ApplicationSettings.h" #include "GUI/Application/ApplicationSettings.h"
#include "GUI/Model/Material/MaterialItem.h" #include "GUI/Model/Material/MaterialItem.h"
#include "GUI/Model/Material/MaterialModel.h" #include "GUI/Model/Material/MaterialModel.h"
#include "GUI/Model/Material/MaterialModelStore.h"
#include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Model/Project/ProjectDocument.h"
#include "GUI/Model/Sample/ItemWithMaterial.h" #include "GUI/Model/Sample/ItemWithMaterial.h"
#include "GUI/Model/Sample/SampleModel.h" #include "GUI/Model/Sample/SampleModel.h"
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "GUI/View/SampleDesigner/MaterialInplaceForm.h" #include "GUI/View/SampleDesigner/MaterialInplaceForm.h"
#include "GUI/Model/Material/MaterialItem.h" #include "GUI/Model/Material/MaterialItem.h"
#include "GUI/Model/Material/MaterialModel.h" #include "GUI/Model/Material/MaterialModel.h"
#include "GUI/Model/Material/MaterialModelStore.h"
#include "GUI/Model/Sample/ItemWithMaterial.h" #include "GUI/Model/Sample/ItemWithMaterial.h"
#include "GUI/Model/Session/ModelPath.h" #include "GUI/Model/Session/ModelPath.h"
#include "GUI/Model/State/SessionData.h" #include "GUI/Model/State/SessionData.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment