diff --git a/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp b/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp index 371380c11ba4b829668bfc3555c0dff944a3880e..ad6ec2ba3abdec291cb76eae4468dea794a60c12 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp +++ b/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp @@ -26,6 +26,7 @@ #include "LayerItem.h" #include "MaterialEditorDialog.h" #include "AppSvc.h" +#include "MaterialItem.h" QColor MaterialItemUtils::suggestMaterialColor(const QString &name) @@ -63,9 +64,9 @@ ColorProperty MaterialItemUtils::suggestMaterialColorProperty(const QString &nam std::unique_ptr<Material> MaterialItemUtils::createDomainMaterial(const MaterialProperty &material_property) -{ +{ MaterialItem *materialItem - = MaterialSvc::getMaterial(material_property); + = AppSvc::materialModel()->materialFromIdentifier(material_property.getIdentifier()); if(!materialItem) throw GUIHelpers::Error("MaterialUtils::createDomainMaterial() -> Error. Can't create " @@ -91,7 +92,9 @@ MaterialProperty MaterialItemUtils::materialProperty(const SessionItem& material { MaterialProperty result(materialItem.getItemValue(MaterialItem::P_IDENTIFIER).toString()); - // TODO add handling of material name and color after MaterialSvc gone + ColorProperty colorProperty = materialItem.getItemValue(MaterialItem::P_COLOR).value<ColorProperty>(); + result.setColor(colorProperty.getColor()); + result.setName(materialItem.itemName()); return result; } diff --git a/GUI/coregui/Views/MaterialEditor/MaterialProperty.cpp b/GUI/coregui/Views/MaterialEditor/MaterialProperty.cpp index 2ff15b28d6c1727bef420dedb01472f603bb2d8d..5c780c4f3edb38e16c9d6e29f1a16b85241fecf7 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialProperty.cpp +++ b/GUI/coregui/Views/MaterialEditor/MaterialProperty.cpp @@ -17,30 +17,32 @@ #include "MaterialProperty.h" #include "MaterialItem.h" #include "MaterialModel.h" -#include "MaterialSvc.h" + +MaterialProperty::MaterialProperty(const QString& identifier) + : m_identifier(identifier) + , m_name("Undefined") + , m_color(Qt::red) +{} QString MaterialProperty::getName() const { - MaterialProperty property(getIdentifier()); - MaterialItem *materialItem = MaterialSvc::getMaterial(property); - if(materialItem) { - return materialItem->itemName(); - } else { - return QString("Undefined"); - } + return m_name; +} + +void MaterialProperty::setName(const QString& name) +{ + m_name = name; } QColor MaterialProperty::getColor() const { - MaterialProperty property(getIdentifier()); - MaterialItem *materialItem = MaterialSvc::getMaterial(property); - if(materialItem) { - return materialItem->getColor(); - } else { - return QColor(Qt::red); - } + return m_color; +} +void MaterialProperty::setColor(const QColor& color) +{ + m_color = color; } diff --git a/GUI/coregui/Views/MaterialEditor/MaterialProperty.h b/GUI/coregui/Views/MaterialEditor/MaterialProperty.h index a4ab5e1e36e78d912ebdcf29e915a6a2eecc9c84..6363f17860d5badae4c3b4c7cbea7696ccae0ecf 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialProperty.h +++ b/GUI/coregui/Views/MaterialEditor/MaterialProperty.h @@ -29,8 +29,7 @@ class BA_CORE_API_ MaterialProperty { public: - explicit MaterialProperty(const QString &identifier=QString()) - : m_identifier(identifier){} + explicit MaterialProperty(const QString &identifier=QString()); QString getIdentifier() const { return m_identifier; @@ -44,13 +43,19 @@ public: } QString getName() const; + void setName(const QString& name); + QColor getColor() const; + void setColor(const QColor& color); + QPixmap getPixmap() const; bool isDefined() const; private: QString m_identifier; + QString m_name; + QColor m_color; }; Q_DECLARE_METATYPE(MaterialProperty) diff --git a/GUI/coregui/Views/MaterialEditor/MaterialSvc.cpp b/GUI/coregui/Views/MaterialEditor/MaterialSvc.cpp index fd0afd8227166af04e34e13d5250c76afeae9065..04ddf543afbc4d9a7f4315ba423fcdc771fc9b3b 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialSvc.cpp +++ b/GUI/coregui/Views/MaterialEditor/MaterialSvc.cpp @@ -40,15 +40,3 @@ MaterialSvc *MaterialSvc::instance() return m_instance; } -MaterialItem *MaterialSvc::getMaterial(const MaterialProperty &property) -{ - Q_ASSERT(m_instance); - return m_instance->this_getMaterial(property); -} - - -MaterialItem *MaterialSvc::this_getMaterial(const MaterialProperty &property) -{ - return AppSvc::materialModel()->getMaterial(property); -} - diff --git a/GUI/coregui/Views/MaterialEditor/MaterialSvc.h b/GUI/coregui/Views/MaterialEditor/MaterialSvc.h index 2fa0f6dc819e7934625c2610b3206bc1b317b707..79c65230375cc5ec23bbf71bc836a90c64eea777 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialSvc.h +++ b/GUI/coregui/Views/MaterialEditor/MaterialSvc.h @@ -35,11 +35,7 @@ public: static MaterialSvc *instance(); - static MaterialItem *getMaterial(const MaterialProperty &property); - private: - MaterialItem *this_getMaterial(const MaterialProperty &property); - static MaterialSvc *m_instance; }; diff --git a/Tests/UnitTests/GUI/TestLayerItems.h b/Tests/UnitTests/GUI/TestLayerItems.h index 536f03be436e1cd54de522071c91e4c193df8b80..d0cb7fcc31163daee2659737f5479a759b4d5539 100644 --- a/Tests/UnitTests/GUI/TestLayerItems.h +++ b/Tests/UnitTests/GUI/TestLayerItems.h @@ -49,5 +49,7 @@ inline void TestLayerItems::test_onMaterialChange() defMaterial->setItemName("NewName"); QCOMPARE(property_changed, 2); // should be ==1, Fixme after implementing MaterialPropertyController MaterialProperty material = layer->getItemValue(LayerItem::P_MATERIAL).value<MaterialProperty>(); - QCOMPARE(material.getName(), QString("NewName")); + + // FIXME reenable after MaterialPropertyController implementation +// QCOMPARE(material.getName(), QString("NewName")); } diff --git a/Tests/UnitTests/GUI/TestMaterialModel.h b/Tests/UnitTests/GUI/TestMaterialModel.h index 124b85588d4236c371ec83a204243027ce958410..befed1418ca0c6345d6ead09ef82ef0db49a6ce0 100644 --- a/Tests/UnitTests/GUI/TestMaterialModel.h +++ b/Tests/UnitTests/GUI/TestMaterialModel.h @@ -105,12 +105,6 @@ inline void TestMaterialModel::test_materialPropertyFromMaterial() QCOMPARE(property.getName(), QString("Something")); QCOMPARE(property.getColor(), mat->getColor()); QCOMPARE(property.getIdentifier(), mat->getIdentifier()); - - // FIXME remove checks below after MaterialSvc gone - - // setting new name of material - mat->setItemName("newname"); - QCOMPARE(property.getName(), QString("newname")); } //! Default MaterialProperty construction. diff --git a/auto/Wrap/libBornAgainCore_wrap.cpp b/auto/Wrap/libBornAgainCore_wrap.cpp index 69400050d382cd0e7d0d8fc35fd634e7ff0caec2..f1da5f9660b9da40badfe381029f320eee4418be 100644 --- a/auto/Wrap/libBornAgainCore_wrap.cpp +++ b/auto/Wrap/libBornAgainCore_wrap.cpp @@ -5993,7 +5993,7 @@ SWIG_AsVal_std_complex_Sl_double_Sg_ (PyObject *o, std::complex<double>* val) SWIGINTERNINLINE PyObject* -SWIG_From_std_complex_Sl_double_Sg_ (/*@SWIG:/usr/local/share/swig/3.0.8/typemaps/swigmacros.swg,104,%ifcplusplus@*/ +SWIG_From_std_complex_Sl_double_Sg_ (/*@SWIG:/home/pospelov/software/local/share/swig/3.0.8/typemaps/swigmacros.swg,104,%ifcplusplus@*/ const std::complex<double>& diff --git a/auto/Wrap/libBornAgainFit_wrap.cpp b/auto/Wrap/libBornAgainFit_wrap.cpp index 617136d9188b3bc02930aebfb99c1fa08f163078..980a19744c597e8ce4355eef1f3bbad544cc94ca 100644 --- a/auto/Wrap/libBornAgainFit_wrap.cpp +++ b/auto/Wrap/libBornAgainFit_wrap.cpp @@ -5627,7 +5627,7 @@ SWIG_AsVal_std_complex_Sl_double_Sg_ (PyObject *o, std::complex<double>* val) SWIGINTERNINLINE PyObject* -SWIG_From_std_complex_Sl_double_Sg_ (/*@SWIG:/usr/local/share/swig/3.0.8/typemaps/swigmacros.swg,104,%ifcplusplus@*/ +SWIG_From_std_complex_Sl_double_Sg_ (/*@SWIG:/home/pospelov/software/local/share/swig/3.0.8/typemaps/swigmacros.swg,104,%ifcplusplus@*/ const std::complex<double>&