diff --git a/GUI/coregui/Models/GUIObjectBuilder.cpp b/GUI/coregui/Models/GUIObjectBuilder.cpp index 89dc35558e01cb588eb49aba52527627d2139a9e..4743819895671c918f6d7fd7b8a0d715ae314ce2 100644 --- a/GUI/coregui/Models/GUIObjectBuilder.cpp +++ b/GUI/coregui/Models/GUIObjectBuilder.cpp @@ -593,7 +593,7 @@ void GUIObjectBuilder::buildPositionInfo(SessionItem* p_particle_item, const IPa SetVectorItem(*p_particle_item, ParticleItem::P_POSITION, position); } -MaterialProperty GUIObjectBuilder::createMaterialFromDomain( +ExternalProperty GUIObjectBuilder::createMaterialFromDomain( const Material* material) { QString materialName = m_topSampleName + QString("_") + QString(material->getName().c_str()); diff --git a/GUI/coregui/Models/GUIObjectBuilder.h b/GUI/coregui/Models/GUIObjectBuilder.h index 76ec0c2165627d49bd1303834566dab50e606b26..d807fdbe808bdd59f5930d9fad055c7d56e7e426 100644 --- a/GUI/coregui/Models/GUIObjectBuilder.h +++ b/GUI/coregui/Models/GUIObjectBuilder.h @@ -18,7 +18,8 @@ #define GUIOBJECTBUILDER_H #include "INodeVisitor.h" -#include "MaterialProperty.h" +#include <QString> +#include <QMap> class Material; class InstrumentModel; @@ -26,6 +27,7 @@ class SampleModel; class SessionItem; class DocumentModel; class GISASSimulation; +class ExternalProperty; //! Class to build SampleModel and InstrumentModel from domain's ISample class BA_CORE_API_ GUIObjectBuilder : public INodeVisitor @@ -101,7 +103,7 @@ public: private: void buildAbundanceInfo(SessionItem* particleItem); void buildPositionInfo(SessionItem* particleItem, const IParticle* sample); - MaterialProperty createMaterialFromDomain(const Material*); + ExternalProperty createMaterialFromDomain(const Material*); SessionItem* InsertIParticle(const IParticle* p_particle, QString model_type); SampleModel* m_sampleModel; diff --git a/GUI/coregui/Models/MaterialModel.cpp b/GUI/coregui/Models/MaterialModel.cpp index 5e802d2f4b31e50514bc977cb812a2046ee2be9c..1e9354c1c6ac044adb18ffe2657aad6d11a4df07 100644 --- a/GUI/coregui/Models/MaterialModel.cpp +++ b/GUI/coregui/Models/MaterialModel.cpp @@ -69,7 +69,7 @@ MaterialItem* MaterialModel::getMaterial(const QModelIndex& index) return dynamic_cast<MaterialItem*>(itemForIndex(index)); } -MaterialItem* MaterialModel::getMaterial(const MaterialProperty& property) +MaterialItem* MaterialModel::getMaterial(const ExternalProperty& property) { QModelIndex parentIndex; for (int i_row = 0; i_row < rowCount(parentIndex); ++i_row) { diff --git a/GUI/coregui/Models/MaterialModel.h b/GUI/coregui/Models/MaterialModel.h index c7142ad980829c15b0ea82661b12c7c970634391..d450290069e0ce951f6cc3fe41239ad055499cce 100644 --- a/GUI/coregui/Models/MaterialModel.h +++ b/GUI/coregui/Models/MaterialModel.h @@ -20,7 +20,7 @@ #include "SessionModel.h" class MaterialItem; -class MaterialProperty; +class ExternalProperty; class BA_CORE_API_ MaterialModel : public SessionModel { @@ -36,7 +36,7 @@ public: void removeMaterial(MaterialItem*); MaterialItem* getMaterial(const QModelIndex& index); - MaterialItem* getMaterial(const MaterialProperty& property); + MaterialItem* getMaterial(const ExternalProperty& property); MaterialItem* cloneMaterial(const QModelIndex& index); diff --git a/GUI/coregui/Models/MaterialPropertyController.cpp b/GUI/coregui/Models/MaterialPropertyController.cpp index c675cb0bacc44a5d7922fbf61814e1b20eb22a68..923edd99af3b18ba8690c01f484fc9778bb0a19f 100644 --- a/GUI/coregui/Models/MaterialPropertyController.cpp +++ b/GUI/coregui/Models/MaterialPropertyController.cpp @@ -57,9 +57,9 @@ void MaterialPropertyController::onMaterialDataChanged(const QModelIndex& topLef QString tag = MaterialItemUtils::materialTag(*sampleItem); Q_ASSERT(!tag.isEmpty()); - MaterialProperty property = sampleItem->getItemValue(tag).value<MaterialProperty>(); + ExternalProperty property = sampleItem->getItemValue(tag).value<ExternalProperty>(); if (property.getIdentifier() == materialItem->getIdentifier()) { - MaterialProperty new_property = MaterialItemUtils::materialProperty(*materialItem); + ExternalProperty new_property = MaterialItemUtils::materialProperty(*materialItem); sampleItem->setItemValue(tag, new_property.getVariant()); } } @@ -88,9 +88,9 @@ void MaterialPropertyController::onMaterialRowsAboutToBeRemoved(const QModelInde QString tag = MaterialItemUtils::materialTag(*sampleItem); Q_ASSERT(!tag.isEmpty()); - MaterialProperty property = sampleItem->getItemValue(tag).value<MaterialProperty>(); + ExternalProperty property = sampleItem->getItemValue(tag).value<ExternalProperty>(); if (identifiersToDelete.contains(property.getIdentifier())) { - MaterialProperty undefined; + ExternalProperty undefined; sampleItem->setItemValue(tag, undefined.getVariant()); } } @@ -105,13 +105,13 @@ void MaterialPropertyController::onMaterialModelCopy() QString tag = MaterialItemUtils::materialTag(*sampleItem); Q_ASSERT(!tag.isEmpty()); - MaterialProperty property = sampleItem->getItemValue(tag).value<MaterialProperty>(); + ExternalProperty property = sampleItem->getItemValue(tag).value<ExternalProperty>(); if (MaterialItem* material = m_materialModel->materialFromIdentifier(property.getIdentifier())) { - MaterialProperty new_property = MaterialItemUtils::materialProperty(*material); + ExternalProperty new_property = MaterialItemUtils::materialProperty(*material); sampleItem->setItemValue(tag, new_property.getVariant()); } else { - MaterialProperty undefined; + ExternalProperty undefined; sampleItem->setItemValue(tag, undefined.getVariant()); } } diff --git a/GUI/coregui/Models/SessionItemUtils.cpp b/GUI/coregui/Models/SessionItemUtils.cpp index 7ca4df8b1b64d34ebd2a559edded51a4373f748e..8a3c7fa1862b3b8fcdca35bcbbd2a900a5fe22f9 100644 --- a/GUI/coregui/Models/SessionItemUtils.cpp +++ b/GUI/coregui/Models/SessionItemUtils.cpp @@ -18,8 +18,8 @@ #include "SessionItem.h" #include "VectorItem.h" #include "MaterialItem.h" -#include "MaterialProperty.h" #include "ColorProperty.h" +#include "ExternalProperty.h" #include <QColor> #include <QIcon> #include <QPixmap> @@ -87,8 +87,8 @@ QVariant SessionItemUtils::ToolTipRole(const SessionItem& item, int ncol) QVariant SessionItemUtils::DecorationRole(const SessionItem& item) { - if (item.value().canConvert<MaterialProperty>()) - return QIcon(item.value().value<MaterialProperty>().getPixmap()); + if (item.value().canConvert<ExternalProperty>()) + return QIcon(item.value().value<ExternalProperty>().getPixmap()); if (item.value().canConvert<ColorProperty>()) return QIcon(item.value().value<ColorProperty>().getPixmap()); diff --git a/GUI/coregui/Models/SessionXML.cpp b/GUI/coregui/Models/SessionXML.cpp index 90a771628e6728d04b28a50c4541b4ae486bc37e..c7e51b63926cf2c802e041ad4b9abb534a54940c 100644 --- a/GUI/coregui/Models/SessionXML.cpp +++ b/GUI/coregui/Models/SessionXML.cpp @@ -19,7 +19,7 @@ #include "GUIHelpers.h" #include "GroupItem.h" #include "ItemFactory.h" -#include "MaterialProperty.h" +#include "ExternalProperty.h" #include "SessionModel.h" #include "WarningMessageService.h" #include <QtCore/QXmlStreamWriter> @@ -99,8 +99,8 @@ void SessionWriter::writeVariant(QXmlStreamWriter *writer, QVariant variant, int writer->writeAttribute(SessionXML::ParameterValueAttribute, variant.toString()); } - else if (type_name == Constants::MaterialPropertyType) { - MaterialProperty material_property = variant.value<MaterialProperty>(); + else if (type_name == Constants::ExternalPropertyType) { + ExternalProperty material_property = variant.value<ExternalProperty>(); writer->writeAttribute(SessionXML::ParameterValueAttribute, material_property.getName()); writer->writeAttribute(SessionXML::IdentifierAttribute, @@ -277,10 +277,10 @@ QString SessionReader::readProperty(QXmlStreamReader *reader, variant = parameter_value; } - else if (parameter_type == Constants::MaterialPropertyType) { + else if (parameter_type == Constants::ExternalPropertyType) { QString identifier = reader->attributes().value(SessionXML::IdentifierAttribute).toString(); - MaterialProperty material_property(identifier); + ExternalProperty material_property(identifier); variant = material_property.getVariant(); } diff --git a/GUI/coregui/Models/TransformToDomain.cpp b/GUI/coregui/Models/TransformToDomain.cpp index fd7ff4aa7d5972cb3fa19516bc52ffe0b83f3a28..f94456537df367fae2a066cc5a8db2e40cdfab9f 100644 --- a/GUI/coregui/Models/TransformToDomain.cpp +++ b/GUI/coregui/Models/TransformToDomain.cpp @@ -60,13 +60,13 @@ using SessionItemUtils::GetVectorItem; std::unique_ptr<Material> TransformToDomain::createDomainMaterial(const SessionItem& item) { - MaterialProperty material_property; + ExternalProperty material_property; if (item.modelType() == Constants::ParticleType) { material_property - = item.getItemValue(ParticleItem::P_MATERIAL).value<MaterialProperty>(); + = item.getItemValue(ParticleItem::P_MATERIAL).value<ExternalProperty>(); } else if (item.modelType() == Constants::LayerType) { material_property - = item.getItemValue(LayerItem::P_MATERIAL).value<MaterialProperty>(); + = item.getItemValue(LayerItem::P_MATERIAL).value<ExternalProperty>(); } if (!material_property.isDefined()) throw GUIHelpers::Error( diff --git a/GUI/coregui/Models/item_constants.h b/GUI/coregui/Models/item_constants.h index 223e54d64f208e3b64daf71e1058453e4d02a156..fd37c4739ad80e4b4770fea5fb95f9abac2cc205 100644 --- a/GUI/coregui/Models/item_constants.h +++ b/GUI/coregui/Models/item_constants.h @@ -264,7 +264,7 @@ const QString MaskEditorPresentation = "Mask Editor"; // --- Custom variants ---------------------------------------------------------- -const ModelType MaterialPropertyType = "MaterialProperty"; +const ModelType ExternalPropertyType = "ExternalProperty"; const ModelType ComboPropertyType = "ComboProperty"; const ModelType ColorPropertyType = "ColorProperty"; const ModelType GroupPropertyType = "GroupProperty_t"; diff --git a/GUI/coregui/Views/MaterialEditor/MaterialProperty.cpp b/GUI/coregui/Views/MaterialEditor/ExternalProperty.cpp similarity index 66% rename from GUI/coregui/Views/MaterialEditor/MaterialProperty.cpp rename to GUI/coregui/Views/MaterialEditor/ExternalProperty.cpp index 5c780c4f3edb38e16c9d6e29f1a16b85241fecf7..f8348d58b1ea5edc0eb8d6f04f01282344f93812 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialProperty.cpp +++ b/GUI/coregui/Views/MaterialEditor/ExternalProperty.cpp @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit scattering at grazing incidence // -//! @file GUI/coregui/Views/MaterialEditor/MaterialProperty.cpp -//! @brief Implements class MaterialProperty +//! @file GUI/coregui/Views/MaterialEditor/ExternalProperty.cpp +//! @brief Implements class ExternalProperty //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -14,46 +14,46 @@ // // ************************************************************************** // -#include "MaterialProperty.h" +#include "ExternalProperty.h" #include "MaterialItem.h" #include "MaterialModel.h" -MaterialProperty::MaterialProperty(const QString& identifier) +ExternalProperty::ExternalProperty(const QString& identifier) : m_identifier(identifier) , m_name("Undefined") , m_color(Qt::red) {} -QString MaterialProperty::getName() const +QString ExternalProperty::getName() const { return m_name; } -void MaterialProperty::setName(const QString& name) +void ExternalProperty::setName(const QString& name) { m_name = name; } -QColor MaterialProperty::getColor() const +QColor ExternalProperty::getColor() const { return m_color; } -void MaterialProperty::setColor(const QColor& color) +void ExternalProperty::setColor(const QColor& color) { m_color = color; } -QPixmap MaterialProperty::getPixmap() const +QPixmap ExternalProperty::getPixmap() const { QPixmap pixmap(10,10); pixmap.fill(getColor()); return pixmap; } -bool MaterialProperty::isDefined() const +bool ExternalProperty::isDefined() const { return !m_identifier.isEmpty(); } diff --git a/GUI/coregui/Views/MaterialEditor/MaterialProperty.h b/GUI/coregui/Views/MaterialEditor/ExternalProperty.h similarity index 80% rename from GUI/coregui/Views/MaterialEditor/MaterialProperty.h rename to GUI/coregui/Views/MaterialEditor/ExternalProperty.h index 6363f17860d5badae4c3b4c7cbea7696ccae0ecf..6b09bf9e3a3cebfe393d0cfbd44aa9e6ae69190f 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialProperty.h +++ b/GUI/coregui/Views/MaterialEditor/ExternalProperty.h @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit scattering at grazing incidence // -//! @file GUI/coregui/Views/MaterialEditor/MaterialProperty.h -//! @brief Defines class MaterialProperty +//! @file GUI/coregui/Views/MaterialEditor/ExternalProperty.h +//! @brief Defines class ExternalProperty //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -14,8 +14,8 @@ // // ************************************************************************** // -#ifndef MATERIALPROPERTY_H -#define MATERIALPROPERTY_H +#ifndef EXTERNALPROPERTY_H +#define EXTERNALPROPERTY_H #include "WinDllMacros.h" #include <QColor> @@ -26,10 +26,10 @@ //! The MaterialProperty class defines unique identifier to help LayerItem, ParticleItem etc //! to access materials from MaterialEditor; -class BA_CORE_API_ MaterialProperty +class BA_CORE_API_ ExternalProperty { public: - explicit MaterialProperty(const QString &identifier=QString()); + explicit ExternalProperty(const QString &identifier=QString()); QString getIdentifier() const { return m_identifier; @@ -58,6 +58,6 @@ private: QColor m_color; }; -Q_DECLARE_METATYPE(MaterialProperty) +Q_DECLARE_METATYPE(ExternalProperty) -#endif // MATERIALPROPERTY_H +#endif // EXTERNALPROPERTY_H diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditor.cpp b/GUI/coregui/Views/MaterialEditor/MaterialEditor.cpp index 682308a5062f8c4590f6d5e685058ef09f22fb4b..52c09865cb44cd7186c27fccd8189f9baafc7cc8 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialEditor.cpp +++ b/GUI/coregui/Views/MaterialEditor/MaterialEditor.cpp @@ -67,7 +67,7 @@ MaterialItem* MaterialEditor::selectedMaterial() } //! Sets selection corresponding to initial material property -void MaterialEditor::setInitialMaterialProperty(const MaterialProperty& matProperty) +void MaterialEditor::setInitialMaterialProperty(const ExternalProperty& matProperty) { if (MaterialItem* mat = m_materialModel->getMaterial(matProperty)) { selectionModel()->clearSelection(); diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditor.h b/GUI/coregui/Views/MaterialEditor/MaterialEditor.h index a2063c507bcc1f4b52234a3a1ad82d32233c1cd1..4c27b624bd9696d616230e8f2dbb93077b967ff8 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialEditor.h +++ b/GUI/coregui/Views/MaterialEditor/MaterialEditor.h @@ -28,7 +28,7 @@ class ComponentEditor; class QItemSelection; class QItemSelectionModel; class MaterialItem; -class MaterialProperty; +class ExternalProperty; //! Main widget of MaterialEditor @@ -43,7 +43,7 @@ public: MaterialItem* selectedMaterial(); - void setInitialMaterialProperty(const MaterialProperty& matProperty); + void setInitialMaterialProperty(const ExternalProperty& matProperty); bool modelWasChanged() const; diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.cpp b/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.cpp index 923ffbb777014a549d9f644610d05bae5d360647..f637227430a10bc651ba2c460ec61817a186b5ee 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.cpp +++ b/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.cpp @@ -19,7 +19,7 @@ #include "MaterialModel.h" #include "MaterialItem.h" #include "mainwindow_constants.h" -#include "MaterialProperty.h" +#include "ExternalProperty.h" #include "MaterialItemUtils.h" #include <QAction> #include <QPushButton> @@ -117,16 +117,16 @@ void MaterialEditorDialog::writeSettings() settings.endGroup(); } -MaterialProperty MaterialEditorDialog::selectedMaterialProperty() +ExternalProperty MaterialEditorDialog::selectedMaterialProperty() { if (MaterialItem* material = m_materialEditor->selectedMaterial()) return MaterialItemUtils::materialProperty(*material); - return MaterialProperty(); + return ExternalProperty(); } //! -void MaterialEditorDialog::setMaterialProperty(const MaterialProperty& matProperty) +void MaterialEditorDialog::setMaterialProperty(const ExternalProperty& matProperty) { Q_ASSERT(m_materialEditor); diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.h b/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.h index 3bb080e93bc3058bf40515e33b363de590e68f6b..9bf6effc92c5f234f3fac07e4a6303a01289ee90 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.h +++ b/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.h @@ -23,7 +23,7 @@ class MaterialModel; class MaterialEditor; -class MaterialProperty; +class ExternalProperty; class QBoxLayout; //! Dialog to hold MaterialEditor. @@ -37,9 +37,9 @@ class BA_CORE_API_ MaterialEditorDialog : public QDialog public: MaterialEditorDialog(MaterialModel* materialModel, QWidget* parent = nullptr); - MaterialProperty selectedMaterialProperty(); + ExternalProperty selectedMaterialProperty(); - void setMaterialProperty(const MaterialProperty& matProperty); + void setMaterialProperty(const ExternalProperty& matProperty); public slots: void onOKButton(); diff --git a/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp b/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp index f558350b3973277793cf81dff0bca841c720fb24..955e2937c340aadc3f3a88ef68e5e5163a8c346c 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp +++ b/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp @@ -48,16 +48,16 @@ QColor MaterialItemUtils::suggestMaterialColor(const QString &name) } -MaterialProperty MaterialItemUtils::defaultMaterialProperty() +ExternalProperty MaterialItemUtils::defaultMaterialProperty() { auto materials = AppSvc::materialModel()->topItems(); - return materials.isEmpty() ? MaterialProperty() : + return materials.isEmpty() ? ExternalProperty() : MaterialItemUtils::materialProperty(*materials.front()); } std::unique_ptr<Material> -MaterialItemUtils::createDomainMaterial(const MaterialProperty &material_property) +MaterialItemUtils::createDomainMaterial(const ExternalProperty &material_property) { MaterialItem *materialItem = AppSvc::materialModel()->materialFromIdentifier(material_property.getIdentifier()); @@ -90,9 +90,9 @@ QStringList MaterialItemUtils::materialRelatedModelTypes() } -MaterialProperty MaterialItemUtils::materialProperty(const SessionItem& materialItem) +ExternalProperty MaterialItemUtils::materialProperty(const SessionItem& materialItem) { - MaterialProperty result(materialItem.getItemValue(MaterialItem::P_IDENTIFIER).toString()); + ExternalProperty result(materialItem.getItemValue(MaterialItem::P_IDENTIFIER).toString()); ColorProperty colorProperty = materialItem.getItemValue(MaterialItem::P_COLOR).value<ColorProperty>(); result.setColor(colorProperty.getColor()); @@ -101,7 +101,7 @@ MaterialProperty MaterialItemUtils::materialProperty(const SessionItem& material return result; } -MaterialProperty MaterialItemUtils::selectMaterialProperty(const MaterialProperty& previousMaterial) +ExternalProperty MaterialItemUtils::selectMaterialProperty(const ExternalProperty& previousMaterial) { MaterialEditorDialog dialog(AppSvc::materialModel()); dialog.setMaterialProperty(previousMaterial); @@ -109,6 +109,6 @@ MaterialProperty MaterialItemUtils::selectMaterialProperty(const MaterialPropert return dialog.selectedMaterialProperty(); } - return MaterialProperty(); + return ExternalProperty(); } diff --git a/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.h b/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.h index d7b1384e1bddae8b3adc98c24d942e7a4cdafd6c..ca05f7ac8d2c46fc254570953f4a16d430be8bcb 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.h +++ b/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.h @@ -19,7 +19,7 @@ #include "ColorProperty.h" #include "MaterialItem.h" -#include "MaterialProperty.h" +#include "ExternalProperty.h" #include <QColor> #include <QString> #include <memory> @@ -30,18 +30,18 @@ namespace MaterialItemUtils { BA_CORE_API_ QColor suggestMaterialColor(const QString &name); -BA_CORE_API_ MaterialProperty defaultMaterialProperty(); +BA_CORE_API_ ExternalProperty defaultMaterialProperty(); BA_CORE_API_ std::unique_ptr<Material> createDomainMaterial( - const MaterialProperty &material_property); + const ExternalProperty &material_property); BA_CORE_API_ QString materialTag(const SessionItem &item); BA_CORE_API_ QStringList materialRelatedModelTypes(); //! Constructs material property corresponding to given material. -BA_CORE_API_ MaterialProperty materialProperty(const SessionItem& materialItem); +BA_CORE_API_ ExternalProperty materialProperty(const SessionItem& materialItem); //! Calls material selector dialog. -BA_CORE_API_ MaterialProperty selectMaterialProperty(const MaterialProperty &previousMaterial=MaterialProperty()); +BA_CORE_API_ ExternalProperty selectMaterialProperty(const ExternalProperty &previousMaterial=ExternalProperty()); } diff --git a/GUI/coregui/Views/PropertyEditor/ComponentFlatView.cpp b/GUI/coregui/Views/PropertyEditor/ComponentFlatView.cpp index e2ba1d283dd815f5d3657dd03febcc0a11331321..4c15fcb35c426d930bbd07ee4b23a95c2ce80556 100644 --- a/GUI/coregui/Views/PropertyEditor/ComponentFlatView.cpp +++ b/GUI/coregui/Views/PropertyEditor/ComponentFlatView.cpp @@ -21,7 +21,6 @@ #include "SessionModel.h" #include "LayoutUtils.h" #include "PropertyWidgetItem.h" -#include "CustomEventFilters.h" #include <QLabel> #include <QVBoxLayout> #include <QGridLayout> @@ -35,7 +34,6 @@ ComponentFlatView::ComponentFlatView(QWidget* parent) , m_gridLayout(nullptr) , m_model(nullptr) , m_show_children(true) - , m_wheel_event_filter(new WheelEventEater) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -170,25 +168,8 @@ PropertyWidgetItem* ComponentFlatView::createWidget(const SessionItem* item) if (!editor) return nullptr; - install_custom_filters(editor); - auto result = new PropertyWidgetItem(this); result->setItemEditor(item, editor); return result; } - -void ComponentFlatView::install_custom_filters(QWidget* editor) -{ - editor->installEventFilter(m_wheel_event_filter.get()); - editor->setFocusPolicy(Qt::StrongFocus); - - for(auto w : editor->findChildren<QAbstractSpinBox *>()) { - w->installEventFilter(m_wheel_event_filter.get()); - w->setFocusPolicy(Qt::StrongFocus); - } - - for(auto w : editor->findChildren<QComboBox *>()) - w->installEventFilter(m_wheel_event_filter.get()); - -} diff --git a/GUI/coregui/Views/PropertyEditor/ComponentFlatView.h b/GUI/coregui/Views/PropertyEditor/ComponentFlatView.h index 71ad5451a7e3d6c5b860f27cbbe1add87347b330..a04017420ffa6a97625b8114379181c556ba995e 100644 --- a/GUI/coregui/Views/PropertyEditor/ComponentFlatView.h +++ b/GUI/coregui/Views/PropertyEditor/ComponentFlatView.h @@ -25,7 +25,6 @@ class SessionModel; class QGridLayout; class QBoxLayout; class PropertyWidgetItem; -class WheelEventEater; //! Component property widget for SessionItems. On the contrary to ComponentTreeView //! properties are presented as widgets in grid layout. @@ -58,14 +57,11 @@ private: void initGridLayout(); PropertyWidgetItem* createWidget(const SessionItem* item); - void install_custom_filters(QWidget* editor); - QBoxLayout* m_mainLayout; QGridLayout* m_gridLayout; QVector<PropertyWidgetItem*> m_widgetItems; SessionModel* m_model; bool m_show_children; - std::unique_ptr<WheelEventEater> m_wheel_event_filter; QVector<const SessionItem*> m_topItems; }; diff --git a/GUI/coregui/Views/PropertyEditor/CustomEditors.cpp b/GUI/coregui/Views/PropertyEditor/CustomEditors.cpp index 941b2624ab15aa798caadce954391cd8fe17f7b6..14e73e3612e66b6f4aadce6b485b87c6fd95577e 100644 --- a/GUI/coregui/Views/PropertyEditor/CustomEditors.cpp +++ b/GUI/coregui/Views/PropertyEditor/CustomEditors.cpp @@ -16,7 +16,7 @@ #include "CustomEditors.h" #include "CustomEventFilters.h" -#include "MaterialProperty.h" +#include "ExternalProperty.h" #include "GroupProperty.h" #include "ComboProperty.h" #include "ColorProperty.h" @@ -51,7 +51,7 @@ void CustomEditor::setDataIntern(const QVariant& data) // --- MaterialPropertyEditor --- -MaterialPropertyEditor::MaterialPropertyEditor(QWidget* parent) +ExternalPropertyEditor::ExternalPropertyEditor(QWidget* parent) : CustomEditor(parent) , m_textLabel(new QLabel) , m_pixmapLabel(new QLabel) @@ -63,7 +63,7 @@ MaterialPropertyEditor::MaterialPropertyEditor(QWidget* parent) auto layout = new QHBoxLayout; layout->setContentsMargins(4, 0, 0, 0); - MaterialProperty defProperty; // to get label and pixmap of undefined material + ExternalProperty defProperty; // to get label and pixmap of undefined material m_textLabel->setText(defProperty.getName()); m_pixmapLabel->setPixmap(defProperty.getPixmap()); @@ -77,27 +77,27 @@ MaterialPropertyEditor::MaterialPropertyEditor(QWidget* parent) layout->addWidget(button); setFocusPolicy(Qt::StrongFocus); setAttribute(Qt::WA_InputMethodEnabled); - connect(button, &QToolButton::clicked, this, &MaterialPropertyEditor::buttonClicked); + connect(button, &QToolButton::clicked, this, &ExternalPropertyEditor::buttonClicked); setLayout(layout); } -void MaterialPropertyEditor::buttonClicked() +void ExternalPropertyEditor::buttonClicked() { // temporarily installing filter to prevent loss of focus caused by too insistent dialog installEventFilter(m_focusFilter); - MaterialProperty materialProperty = m_data.value<MaterialProperty>(); - MaterialProperty mat = MaterialItemUtils::selectMaterialProperty(materialProperty); + ExternalProperty materialProperty = m_data.value<ExternalProperty>(); + ExternalProperty mat = MaterialItemUtils::selectMaterialProperty(materialProperty); removeEventFilter(m_focusFilter); if(mat.isDefined() ) setDataIntern(mat.getVariant()); } -void MaterialPropertyEditor::initEditor() +void ExternalPropertyEditor::initEditor() { - Q_ASSERT(m_data.canConvert<MaterialProperty>()); - MaterialProperty materialProperty = m_data.value<MaterialProperty>(); + Q_ASSERT(m_data.canConvert<ExternalProperty>()); + ExternalProperty materialProperty = m_data.value<ExternalProperty>(); m_textLabel->setText(materialProperty.getName()); m_pixmapLabel->setPixmap(materialProperty.getPixmap()); } @@ -162,6 +162,7 @@ void ColorPropertyEditor::initEditor() CustomComboEditor::CustomComboEditor(QWidget* parent) : CustomEditor(parent) , m_box(new QComboBox) + , m_wheel_event_filter(new WheelEventEater(this)) { setAutoFillBackground(true); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); @@ -171,6 +172,8 @@ CustomComboEditor::CustomComboEditor(QWidget* parent) layout->setSpacing(0); layout->addWidget(m_box); + m_box->installEventFilter(m_wheel_event_filter); + setLayout(layout); setConnected(true); } diff --git a/GUI/coregui/Views/PropertyEditor/CustomEditors.h b/GUI/coregui/Views/PropertyEditor/CustomEditors.h index 094de57239ab7457b39b1a1c4f3962e81a7cb340..13b5cea6d8abf4c6a5c207e34d5b98e73d77b18a 100644 --- a/GUI/coregui/Views/PropertyEditor/CustomEditors.h +++ b/GUI/coregui/Views/PropertyEditor/CustomEditors.h @@ -48,13 +48,13 @@ protected: QVariant m_data; }; -//! Editor for MaterialProperty variant. +//! Editor for ExternalProperty variant. -class BA_CORE_API_ MaterialPropertyEditor : public CustomEditor +class BA_CORE_API_ ExternalPropertyEditor : public CustomEditor { Q_OBJECT public: - explicit MaterialPropertyEditor(QWidget* parent = nullptr); + explicit ExternalPropertyEditor(QWidget* parent = nullptr); private slots: void buttonClicked(); @@ -68,8 +68,7 @@ private: LostFocusFilter* m_focusFilter; }; -//! Editor for ColorProperty variant (TODO Replace ColorPropertyEditor and MaterialPropertyEditor -//! with universal one). +//! Editor for ColorProperty variant. class BA_CORE_API_ ColorPropertyEditor : public CustomEditor { @@ -109,7 +108,8 @@ protected: virtual int internIndex(); void setConnected(bool isConnected); - QComboBox* m_box; + QComboBox* m_box; + class WheelEventEater* m_wheel_event_filter; }; //! Editor for GroupProperty variant. @@ -151,9 +151,6 @@ protected: //! Editor for ScientificDoubleProperty variant. -class QLineEdit; -class QDoubleValidator; - class BA_CORE_API_ ScientificDoublePropertyEditor : public CustomEditor { Q_OBJECT @@ -167,8 +164,8 @@ protected: void initEditor(); private: - QLineEdit* m_lineEdit; - QDoubleValidator* m_validator; + class QLineEdit* m_lineEdit; + class QDoubleValidator* m_validator; }; //! Editor for boolean. diff --git a/GUI/coregui/Views/PropertyEditor/ObsoletePropertyBrowserUtils.cpp b/GUI/coregui/Views/PropertyEditor/ObsoletePropertyBrowserUtils.cpp index 4bc934d237c1c13341b84c240852f796a6a51d64..c35bcadd32e7204e369db31d93db0d0a738e0b23 100644 --- a/GUI/coregui/Views/PropertyEditor/ObsoletePropertyBrowserUtils.cpp +++ b/GUI/coregui/Views/PropertyEditor/ObsoletePropertyBrowserUtils.cpp @@ -70,7 +70,7 @@ void ObsoleteMaterialPropertyEdit::buttonClicked() { // temporarily installing filter to prevent loss of focus caused by too insistent dialog installEventFilter(m_focusFilter); - MaterialProperty mat = MaterialItemUtils::selectMaterialProperty(m_materialProperty); + ExternalProperty mat = MaterialItemUtils::selectMaterialProperty(m_materialProperty); removeEventFilter(m_focusFilter); if(mat.isDefined() ) { @@ -81,7 +81,7 @@ void ObsoleteMaterialPropertyEdit::buttonClicked() void ObsoleteMaterialPropertyEdit::setMaterialProperty( - const MaterialProperty &materialProperty) + const ExternalProperty &materialProperty) { m_materialProperty = materialProperty; m_textLabel->setText(m_materialProperty.getName()); diff --git a/GUI/coregui/Views/PropertyEditor/ObsoletePropertyBrowserUtils.h b/GUI/coregui/Views/PropertyEditor/ObsoletePropertyBrowserUtils.h index e206a513e25d5c999c6eb3ab2531f470f59376fe..98563dc7c04851f0c66d8b879b3f6c18fd83a67b 100644 --- a/GUI/coregui/Views/PropertyEditor/ObsoletePropertyBrowserUtils.h +++ b/GUI/coregui/Views/PropertyEditor/ObsoletePropertyBrowserUtils.h @@ -18,7 +18,7 @@ #define OBSOLETEPROPERTYBROWSERUTILS_H #include <QWidget> -#include "MaterialProperty.h" +#include "ExternalProperty.h" #include "ColorProperty.h" #include "ObsoleteScientificDoubleProperty.h" #include "GroupProperty.h" @@ -39,16 +39,16 @@ class BA_CORE_API_ ObsoleteMaterialPropertyEdit : public QWidget public: ObsoleteMaterialPropertyEdit(QWidget *parent = 0); - void setMaterialProperty(const MaterialProperty &materialProperty); - MaterialProperty getMaterialProperty() const {return m_materialProperty; } + void setMaterialProperty(const ExternalProperty &materialProperty); + ExternalProperty getMaterialProperty() const {return m_materialProperty; } signals: - void materialPropertyChanged(const MaterialProperty &material); + void materialPropertyChanged(const ExternalProperty &material); private slots: void buttonClicked(); private: QLabel *m_textLabel; QLabel *m_pixmapLabel; - MaterialProperty m_materialProperty; + ExternalProperty m_materialProperty; LostFocusFilter* m_focusFilter; }; diff --git a/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantFactory.cpp b/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantFactory.cpp index 6f7e2f7b11b04fddff16ed627bb5b39a41ae37c8..d12232392cb2dface5a84e23e631cc75064c6b3e 100644 --- a/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantFactory.cpp +++ b/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantFactory.cpp @@ -72,14 +72,14 @@ QWidget *ObsoletePropertyVariantFactory::createEditor(QtVariantPropertyManager * ObsoletePropertyVariantManager::materialTypeId()) { ObsoleteMaterialPropertyEdit *editor = new ObsoleteMaterialPropertyEdit(parent); QVariant var = manager->value(property); - MaterialProperty mat = var.value<MaterialProperty>(); + ExternalProperty mat = var.value<ExternalProperty>(); editor->setMaterialProperty(mat); m_property_to_material_editors[property].append(editor); m_material_editor_to_property[editor] = property; - connect(editor, SIGNAL(materialPropertyChanged(const MaterialProperty &)), - this, SLOT(slotSetValue(const MaterialProperty &))); + connect(editor, SIGNAL(materialPropertyChanged(const ExternalProperty &)), + this, SLOT(slotSetValue(const ExternalProperty &))); connect(editor, SIGNAL(destroyed(QObject *)), this, SLOT(slotEditorDestroyed(QObject *))); return editor; @@ -182,7 +182,7 @@ void ObsoletePropertyVariantFactory::slotPropertyChanged(QtProperty *property, m_property_to_material_editors[property]; QListIterator<ObsoleteMaterialPropertyEdit *> itEditor(editors); while (itEditor.hasNext()) { - MaterialProperty mat = value.value<MaterialProperty>(); + ExternalProperty mat = value.value<ExternalProperty>(); itEditor.next()->setMaterialProperty(mat); } } @@ -225,7 +225,7 @@ void ObsoletePropertyVariantFactory::slotPropertyChanged(QtProperty *property, } -void ObsoletePropertyVariantFactory::slotSetValue(const MaterialProperty &value) +void ObsoletePropertyVariantFactory::slotSetValue(const ExternalProperty &value) { QObject *object = sender(); QMap<ObsoleteMaterialPropertyEdit *, QtProperty *>::ConstIterator itEditor = diff --git a/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantFactory.h b/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantFactory.h index 6a7ab81ef42e5b5f6cf486e0a7e97f76f255f431..1099133edc7a7cb5388cfbaadb867f5a85db10ed 100644 --- a/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantFactory.h +++ b/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantFactory.h @@ -23,7 +23,7 @@ #include <QtVariantEditorFactory> class ObsoleteMaterialPropertyEdit; -class MaterialProperty; +class ExternalProperty; class ObsoleteColorPropertyEdit; class ColorProperty; class ObsoleteScientificDoublePropertyEdit; @@ -51,7 +51,7 @@ protected: virtual void disconnectPropertyManager(QtVariantPropertyManager *manager); private slots: void slotPropertyChanged(QtProperty *property, const QVariant &value); - void slotSetValue(const MaterialProperty &value); + void slotSetValue(const ExternalProperty &value); void slotSetValue(const ColorProperty &value); void slotSetValue(const ObsoleteScientificDoubleProperty &value); void slotSetValue(const GroupProperty_t &value); diff --git a/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantManager.cpp b/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantManager.cpp index 38de2dec574fdb8f921f35a56b2af3d37a90166a..7e2c46fe17a0cde889630e3b6b470edd50773339 100644 --- a/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantManager.cpp +++ b/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantManager.cpp @@ -27,7 +27,7 @@ ObsoletePropertyVariantManager::ObsoletePropertyVariantManager(QObject *parent) int ObsoletePropertyVariantManager::materialTypeId() { - int result = qMetaTypeId<MaterialProperty>(); + int result = qMetaTypeId<ExternalProperty>(); return result; } @@ -156,7 +156,7 @@ void ObsoletePropertyVariantManager::setValue(QtProperty *property, const QVaria { if (m_theMaterialValues.contains(property)) { if( val.userType() != materialTypeId() ) return; - MaterialProperty mat = val.value<MaterialProperty>(); + ExternalProperty mat = val.value<ExternalProperty>(); m_theMaterialValues[property] = mat; QVariant v2; v2.setValue(mat); @@ -212,7 +212,7 @@ void ObsoletePropertyVariantManager::setValue(QtProperty *property, const QVaria void ObsoletePropertyVariantManager::initializeProperty(QtProperty *property) { if (propertyType(property) == materialTypeId()) { - MaterialProperty m; + ExternalProperty m; m_theMaterialValues[property] = m; } if (propertyType(property) == colorPropertyTypeId()) { diff --git a/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantManager.h b/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantManager.h index a9a4ce896346fcaea55975024b1656e5053a8bae..fcb0b722ba37f5cbc5885697b0d1d392ffd92750 100644 --- a/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantManager.h +++ b/GUI/coregui/Views/PropertyEditor/ObsoletePropertyVariantManager.h @@ -22,7 +22,7 @@ #include "ColorProperty.h" #include "ComboProperty.h" #include "GroupProperty.h" -#include "MaterialProperty.h" +#include "ExternalProperty.h" #include "ObsoleteScientificDoubleProperty.h" #include <QtVariantPropertyManager> @@ -56,7 +56,7 @@ protected: virtual void initializeProperty(QtProperty *property); virtual void uninitializeProperty(QtProperty *property); private: - QMap<const QtProperty *, MaterialProperty> m_theMaterialValues; + QMap<const QtProperty *, ExternalProperty> m_theMaterialValues; QMap<const QtProperty *, ColorProperty> m_theColorValues; QMap<const QtProperty *, ObsoleteScientificDoubleProperty> m_theScientificDoubleValues; QMap<const QtProperty *, GroupProperty_t> m_theFancyGroupValues; diff --git a/GUI/coregui/Views/PropertyEditor/PropertyEditorFactory.cpp b/GUI/coregui/Views/PropertyEditor/PropertyEditorFactory.cpp index 84ec2de283f59892bac9e480b290597bb93859ab..617533f39639173661d51928591d9cfd6ac6184c 100644 --- a/GUI/coregui/Views/PropertyEditor/PropertyEditorFactory.cpp +++ b/GUI/coregui/Views/PropertyEditor/PropertyEditorFactory.cpp @@ -17,11 +17,12 @@ #include "PropertyEditorFactory.h" #include "SessionItem.h" #include "RealLimits.h" -#include "MaterialProperty.h" +#include "ExternalProperty.h" #include "GroupProperty.h" #include "CustomEditors.h" #include "ComboProperty.h" #include "ColorProperty.h" +#include "CustomEventFilters.h" #include <QDoubleSpinBox> #include <QSpinBox> #include <QLineEdit> @@ -52,7 +53,7 @@ bool isIntProperty(const QVariant& variant) bool isMaterialProperty(const QVariant& variant) { - return variant.canConvert<MaterialProperty>(); + return variant.canConvert<ExternalProperty>(); } bool isColorProperty(const QVariant& variant) @@ -102,7 +103,7 @@ bool PropertyEditorFactory::IsCustomVariant(const QVariant& variant) QString PropertyEditorFactory::ToString(const QVariant& variant) { if (isMaterialProperty(variant)) - return variant.value<MaterialProperty>().getName(); + return variant.value<ExternalProperty>().getName(); if (isColorProperty(variant)) return variant.value<ColorProperty>().getText(); if (isGroupProperty(variant)) @@ -145,7 +146,7 @@ QWidget* PropertyEditorFactory::CreateEditor(const SessionItem& item, QWidget* p } else if(isMaterialProperty(item.value())) { - auto editor = new MaterialPropertyEditor; + auto editor = new ExternalPropertyEditor; editor->setData(item.value()); result = editor; } @@ -183,6 +184,9 @@ QWidget* createCustomDoubleEditor(const SessionItem& item) auto result = new QDoubleSpinBox; result->setKeyboardTracking(false); + result->setFocusPolicy(Qt::StrongFocus); + result->installEventFilter(new WheelEventEater(result)); + result->setMaximum(std::numeric_limits<double>::max()); result->setMinimum(std::numeric_limits<double>::lowest()); @@ -202,6 +206,8 @@ QWidget* createCustomDoubleEditor(const SessionItem& item) QWidget* createCustomIntEditor(const SessionItem& item) { auto result = new QSpinBox; + result->setFocusPolicy(Qt::StrongFocus); + result->installEventFilter(new WheelEventEater(result)); result->setMaximum(std::numeric_limits<int>::max()); result->setKeyboardTracking(false); diff --git a/GUI/coregui/Views/PropertyEditor/PropertyWidgetItem.cpp b/GUI/coregui/Views/PropertyEditor/PropertyWidgetItem.cpp index 28a7bdad8cf6df4b43c278152a299b3c9a5b32ee..d2f7c65837cee1fdb8ba09913ecacc82aefd46a7 100644 --- a/GUI/coregui/Views/PropertyEditor/PropertyWidgetItem.cpp +++ b/GUI/coregui/Views/PropertyEditor/PropertyWidgetItem.cpp @@ -102,6 +102,10 @@ void PropertyWidgetItem::connectEditor(QWidget* editor) connect(combo, &ComboPropertyEditor::currentIndexChanged, [=] { m_delegate->commitData(combo); }); + // TODO after merging GroupProperty and ComboProperty + // 1) cast to CustomEditor + // 2) switch to CustomEditor::dataChanged() + } else if (auto spinbox = dynamic_cast<QSpinBox*>(editor)) { // To provide update of the model on valueChanged() and not only on editingFinished() connect(spinbox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), @@ -112,5 +116,11 @@ void PropertyWidgetItem::connectEditor(QWidget* editor) connect(spinbox, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [=] { m_delegate->commitData(spinbox); }); + + } else if (auto spinbox = dynamic_cast<ScientificDoublePropertyEditor*>(editor)) { + // To provide update of the model on valueChanged() and not only on editingFinished() + connect(spinbox, &ScientificDoublePropertyEditor::dataChanged, + [=] { m_delegate->commitData(spinbox); }); } + } diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilder.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilder.cpp index 79ce296694ff6cc0b7cd59994a62b1e27e1604fd..d111447f9e5f6b3e2455e37c1dc23968146d0ed7 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilder.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilder.cpp @@ -18,7 +18,7 @@ #include "RealSpaceModel.h" #include "SessionItem.h" #include "LayerItem.h" -#include "MaterialProperty.h" +#include "ExternalProperty.h" #include "MultiLayerItem.h" #include "TransformTo3D.h" #include "ParticleLayoutItem.h" diff --git a/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.cpp b/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.cpp index 3b78af9eb0128de13b5093ba69ddfc7bcd5deb94..303e96cc0f34afd6d2d5ae043925a96a58a08ff2 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/TransformTo3D.cpp @@ -18,7 +18,7 @@ #include "SessionItem.h" #include "FormFactorItems.h" #include "ParticleItem.h" -#include "MaterialProperty.h" +#include "ExternalProperty.h" #include "VectorItem.h" #include "LayerItem.h" #include "MultiLayerItem.h" @@ -69,7 +69,7 @@ std::unique_ptr<ba3d::Layer> TransformTo3D::createLayer(const SessionItem& layer std::unique_ptr<ba3d::Layer> result = std::make_unique<ba3d::Layer>( ba3d::dxyz(ba3d::dr(-s2,+s2), ba3d::dr(-s2,+s2), ba3d::dr(ztop, zbottom))); - QColor color = layerItem.getItemValue(LayerItem::P_MATERIAL).value<MaterialProperty>().getColor(); + QColor color = layerItem.getItemValue(LayerItem::P_MATERIAL).value<ExternalProperty>().getColor(); color.setAlphaF(.3); result->color = color; @@ -103,8 +103,8 @@ TransformTo3D::createParticle(const SessionItem& particleItem) if(result) { - MaterialProperty material - = particleItem.getItemValue(ParticleItem::P_MATERIAL).value<MaterialProperty>(); + ExternalProperty material + = particleItem.getItemValue(ParticleItem::P_MATERIAL).value<ExternalProperty>(); result->color = material.getColor(); diff --git a/GUI/coregui/Views/SampleDesigner/ILayerView.cpp b/GUI/coregui/Views/SampleDesigner/ILayerView.cpp index 0bade000f3d329d0cc784300c15128fba89c1099..911cb57f872df1e67bed249bda763e6bda48716a 100644 --- a/GUI/coregui/Views/SampleDesigner/ILayerView.cpp +++ b/GUI/coregui/Views/SampleDesigner/ILayerView.cpp @@ -19,7 +19,7 @@ #include "DesignerScene.h" #include "GUIHelpers.h" #include "LayerItem.h" -#include "MaterialProperty.h" +#include "ExternalProperty.h" #include "MultiLayerView.h" #include "SampleModel.h" #include "SessionItem.h" @@ -79,7 +79,7 @@ void ILayerView::updateColor() if(m_item->isTag(LayerItem::P_MATERIAL)) { QVariant v = m_item->getItemValue(LayerItem::P_MATERIAL); if (v.isValid()) { - MaterialProperty mp = v.value<MaterialProperty>(); + ExternalProperty mp = v.value<ExternalProperty>(); setColor(mp.getColor()); update(); } else { diff --git a/GUI/coregui/Views/SampleDesigner/LayerView.cpp b/GUI/coregui/Views/SampleDesigner/LayerView.cpp index 5474f70dfbfb7a7b1120654ceebb965efd55d540..ceea644b8f43df52e3a338a4014b8986e95539ec 100644 --- a/GUI/coregui/Views/SampleDesigner/LayerView.cpp +++ b/GUI/coregui/Views/SampleDesigner/LayerView.cpp @@ -16,7 +16,6 @@ #include "LayerView.h" #include "LayerItem.h" -#include "MaterialProperty.h" #include "MultiLayerView.h" #include "ParticleLayoutView.h" #include "SessionItem.h" diff --git a/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp b/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp index a5e5d2f43a103c84aaca001a6da9b76a47b6a9d2..41b58dbf27d9406b4f560793b47944f263163567 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp +++ b/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp @@ -16,7 +16,6 @@ #include "SampleToolBar.h" #include "DesignerView.h" -#include "MaterialProperty.h" #include "MaterialItemUtils.h" #include <QAction> #include <QButtonGroup> @@ -142,5 +141,5 @@ void SampleToolBar::onScaleComboChanged(const QString &scale_string) void SampleToolBar::onMaterialEditorCall() { - MaterialProperty mp = MaterialItemUtils::selectMaterialProperty(); + ExternalProperty mp = MaterialItemUtils::selectMaterialProperty(); } diff --git a/Tests/UnitTests/GUI/TestLayerItems.h b/Tests/UnitTests/GUI/TestLayerItems.h index d448d25f68cc8d8b7dae3d213fe1ca6ad88ac6ca..19eaac821b9870d463060feb35b0da3b087cf2db 100644 --- a/Tests/UnitTests/GUI/TestLayerItems.h +++ b/Tests/UnitTests/GUI/TestLayerItems.h @@ -1,6 +1,6 @@ #include <QtTest> #include "LayerItem.h" -#include "MaterialProperty.h" +#include "ExternalProperty.h" #include "ApplicationModels.h" #include "SampleModel.h" #include "MaterialModel.h" @@ -26,7 +26,7 @@ inline void TestLayerItems::test_LayerDefaultMaterial() auto materials = models.materialModel()->topItems(); auto defMaterial = materials.front(); - MaterialProperty material = layer->getItemValue(LayerItem::P_MATERIAL).value<MaterialProperty>(); + ExternalProperty material = layer->getItemValue(LayerItem::P_MATERIAL).value<ExternalProperty>(); QCOMPARE(material.getName(), QString("Default")); QCOMPARE(material.getIdentifier(), defMaterial->getItemValue(MaterialItem::P_IDENTIFIER).toString()); } diff --git a/Tests/UnitTests/GUI/TestMaterialModel.h b/Tests/UnitTests/GUI/TestMaterialModel.h index cf5416e6e64241e5d38396ce992a5f62979f0994..eac429ca5d447a24a8b4b7ef40bbaffa8f79c323 100644 --- a/Tests/UnitTests/GUI/TestMaterialModel.h +++ b/Tests/UnitTests/GUI/TestMaterialModel.h @@ -99,7 +99,7 @@ inline void TestMaterialModel::test_materialPropertyFromMaterial() MaterialModel model; MaterialItem* mat = model.addMaterial("Something", 1.0, 2.0); - MaterialProperty property = MaterialItemUtils::materialProperty(*mat); + ExternalProperty property = MaterialItemUtils::materialProperty(*mat); QCOMPARE(property.getName(), QString("Something")); QCOMPARE(property.getColor(), mat->getColor()); QCOMPARE(property.getIdentifier(), mat->getIdentifier()); @@ -112,13 +112,13 @@ inline void TestMaterialModel::test_defaultMaterialProperty() MaterialModel model; // testing default constructed material property - MaterialProperty property; + ExternalProperty property; QCOMPARE(property.getName(), QString("Undefined")); QCOMPARE(property.getColor(), QColor(Qt::red)); QCOMPARE(property.getIdentifier(), QString("")); // testing default material property from MaterialItemUtils - MaterialProperty property2 = MaterialItemUtils::defaultMaterialProperty(); + ExternalProperty property2 = MaterialItemUtils::defaultMaterialProperty(); QCOMPARE(property2.getName(), QString("Undefined")); QCOMPARE(property2.getColor(), QColor(Qt::red)); QCOMPARE(property2.getIdentifier(), QString("")); @@ -126,7 +126,7 @@ inline void TestMaterialModel::test_defaultMaterialProperty() // adding materials to the model, default property should refer to first material in a model auto mat1 = model.addMaterial("Something1", 1.0, 2.0); model.addMaterial("Something2", 3.0, 4.0); - MaterialProperty property3 = MaterialItemUtils::defaultMaterialProperty(); + ExternalProperty property3 = MaterialItemUtils::defaultMaterialProperty(); QCOMPARE(property3.getName(), QString("Something1")); QCOMPARE(property3.getColor(), mat1->getColor()); QCOMPARE(property3.getIdentifier(), mat1->getIdentifier()); diff --git a/Tests/UnitTests/GUI/TestMaterialPropertyController.h b/Tests/UnitTests/GUI/TestMaterialPropertyController.h index bf0aff3fa968f7e0216f39a355115899c0d1c095..82327829280db8846b37f09518253848113b67d6 100644 --- a/Tests/UnitTests/GUI/TestMaterialPropertyController.h +++ b/Tests/UnitTests/GUI/TestMaterialPropertyController.h @@ -4,7 +4,7 @@ #include "SampleModel.h" #include "LayerItem.h" #include "MaterialItem.h" -#include "MaterialProperty.h" +#include "ExternalProperty.h" #include "ColorProperty.h" #include "MaterialItemUtils.h" @@ -41,7 +41,7 @@ inline void TestMaterialPropertyController::test_ControllerForLayer() // changing name of MaterialItem in MaterialModel, looking for MaterialProperty change mat1->setItemName("newname"); // QCOMPARE(property_changed, 1); - MaterialProperty property = layer->getItemValue(LayerItem::P_MATERIAL).value<MaterialProperty>(); + ExternalProperty property = layer->getItemValue(LayerItem::P_MATERIAL).value<ExternalProperty>(); QCOMPARE(property.getIdentifier(), mat1->getIdentifier()); QCOMPARE(property.getName(), mat1->itemName()); QCOMPARE(property.getColor(), mat1->getColor()); @@ -50,7 +50,7 @@ inline void TestMaterialPropertyController::test_ControllerForLayer() ColorProperty colorProperty(Qt::red); mat1->setItemValue(MaterialItem::P_COLOR, colorProperty.getVariant()); // QCOMPARE(property_changed, 2); - property = layer->getItemValue(LayerItem::P_MATERIAL).value<MaterialProperty>(); + property = layer->getItemValue(LayerItem::P_MATERIAL).value<ExternalProperty>(); QCOMPARE(property.getIdentifier(), mat1->getIdentifier()); QCOMPARE(property.getName(), mat1->itemName()); QCOMPARE(property.getColor(), mat1->getColor()); @@ -59,7 +59,7 @@ inline void TestMaterialPropertyController::test_ControllerForLayer() // removing material from the model, property should become undefined materialModel.removeRows(0, 1, QModelIndex()); // QCOMPARE(property_changed, 3); - property = layer->getItemValue(LayerItem::P_MATERIAL).value<MaterialProperty>(); + property = layer->getItemValue(LayerItem::P_MATERIAL).value<ExternalProperty>(); QCOMPARE(property.getIdentifier(), QString()); QCOMPARE(property.getName(), QString("Undefined")); QCOMPARE(property.getColor(), QColor(Qt::red)); @@ -118,12 +118,12 @@ inline void TestMaterialPropertyController::test_ControllerInEditorContext() materialModel.createdFromCopy(); // layer2 should have undefined material property - MaterialProperty property = layer2->getItemValue(LayerItem::P_MATERIAL).value<MaterialProperty>(); + ExternalProperty property = layer2->getItemValue(LayerItem::P_MATERIAL).value<ExternalProperty>(); QCOMPARE(property.getName(), QString("Undefined")); QCOMPARE(property.getIdentifier(), QString("")); QCOMPARE(property.getColor(), QColor(Qt::red)); // layer3 should have different MaterialProperty name - property = layer3->getItemValue(LayerItem::P_MATERIAL).value<MaterialProperty>(); + property = layer3->getItemValue(LayerItem::P_MATERIAL).value<ExternalProperty>(); QCOMPARE(property.getName(), QString("name3changed")); } diff --git a/auto/Wrap/libBornAgainCore_wrap.cpp b/auto/Wrap/libBornAgainCore_wrap.cpp index 4d27e4501b49740c0c77d3ede182179ab9746be1..b7758f24dafe4e72e1bac485f1375bb7e6bf0e73 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/share/swig3.0/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 182abc5541c99f92f98a78439a7f630a79c6657c..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/share/swig3.0/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>&