diff --git a/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp b/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp index 78b0dd3f28d3b2ff3cd48b9c7ce5a6ec17df0016..1373a042eed0e9f9e9d9623e37a70a1473c71665 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp +++ b/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.cpp @@ -24,6 +24,8 @@ #include "MaterialSvc.h" #include "ParticleItem.h" #include "LayerItem.h" +#include "MaterialEditorDialog.h" +#include "AppSvc.h" QColor MaterialItemUtils::suggestMaterialColor(const QString &name) @@ -94,3 +96,14 @@ MaterialProperty MaterialItemUtils::materialProperty(const SessionItem& material return result; } + +MaterialProperty MaterialItemUtils::selectMaterialProperty(const MaterialProperty& previousMaterial) +{ + MaterialEditorDialog dialog(AppSvc::materialModel()); + dialog.setInitialMaterialProperty(previousMaterial); + if(dialog.exec() == QDialog::Accepted) { + return dialog.getSelectedMaterialProperty(); + } + + return MaterialProperty(); +} diff --git a/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.h b/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.h index e02787c74391e604e8becf0222cfd8e707011752..88c26b92ee48b703db57fa353dfc0632412eb482 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.h +++ b/GUI/coregui/Views/MaterialEditor/MaterialItemUtils.h @@ -39,6 +39,10 @@ BA_CORE_API_ QString materialTag(const SessionItem &item); //! Constructs material property corresponding to given material. BA_CORE_API_ MaterialProperty materialProperty(const SessionItem& materialItem); + +//! Calls material selector dialog. +BA_CORE_API_ MaterialProperty selectMaterialProperty(const MaterialProperty &previousMaterial=MaterialProperty()); + } diff --git a/GUI/coregui/Views/MaterialEditor/MaterialSvc.cpp b/GUI/coregui/Views/MaterialEditor/MaterialSvc.cpp index 32bb5251a9fd6a6f845f0921afa5290d0e94189f..efd537b82c40930e3a3300832c09ebc70d7c203a 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialSvc.cpp +++ b/GUI/coregui/Views/MaterialEditor/MaterialSvc.cpp @@ -41,27 +41,6 @@ MaterialSvc *MaterialSvc::instance() } -MaterialProperty -MaterialSvc::selectMaterialProperty(const MaterialProperty &previousMaterial) -{ - Q_ASSERT(m_instance); - return m_instance->this_selectMaterialProperty(previousMaterial); -} - - -MaterialProperty -MaterialSvc::this_selectMaterialProperty(const MaterialProperty &previousMaterial) -{ - MaterialEditorDialog dialog(AppSvc::materialModel()); - dialog.setInitialMaterialProperty(previousMaterial); - if(dialog.exec() == QDialog::Accepted) { - return dialog.getSelectedMaterialProperty(); - } - - return MaterialProperty(); -} - - MaterialProperty MaterialSvc::getDefaultMaterialProperty() { Q_ASSERT(m_instance); diff --git a/GUI/coregui/Views/MaterialEditor/MaterialSvc.h b/GUI/coregui/Views/MaterialEditor/MaterialSvc.h index 7176c9feab39fb90a4340c46313981845fb68efe..f28eb293891135cfe006598ce72cb80d1252e9a6 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialSvc.h +++ b/GUI/coregui/Views/MaterialEditor/MaterialSvc.h @@ -35,13 +35,11 @@ public: static MaterialSvc *instance(); - static MaterialProperty selectMaterialProperty(const MaterialProperty &previousMaterial=MaterialProperty()); static MaterialProperty getDefaultMaterialProperty(); static MaterialItem *getMaterial(const MaterialProperty &property); private: - MaterialProperty this_selectMaterialProperty(const MaterialProperty &previousMaterial); MaterialProperty this_getDefaultMaterialProperty(); MaterialItem *this_getMaterial(const MaterialProperty &property); diff --git a/GUI/coregui/Views/PropertyEditor/CustomEditors.cpp b/GUI/coregui/Views/PropertyEditor/CustomEditors.cpp index 6b56d2c8a2f89d05794d1f989e872b8349560a39..94e402856f92136f3b41bbb91badb6c753fb5e1e 100644 --- a/GUI/coregui/Views/PropertyEditor/CustomEditors.cpp +++ b/GUI/coregui/Views/PropertyEditor/CustomEditors.cpp @@ -21,6 +21,7 @@ #include "GroupProperty.h" #include "ComboProperty.h" #include "ColorProperty.h" +#include "MaterialItemUtils.h" #include <QBoxLayout> #include <QLabel> #include <QToolButton> @@ -87,7 +88,7 @@ void MaterialPropertyEditor::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 = MaterialSvc::selectMaterialProperty(materialProperty); + MaterialProperty mat = MaterialItemUtils::selectMaterialProperty(materialProperty); removeEventFilter(m_focusFilter); if(mat.isDefined() ) diff --git a/GUI/coregui/Views/PropertyEditor/ObsoletePropertyBrowserUtils.cpp b/GUI/coregui/Views/PropertyEditor/ObsoletePropertyBrowserUtils.cpp index fc05629b6123f3f1bb42d0bd9a4ffdac45dddae6..7fcd19987a37a9c507b2888cec7b1bc05a7cbdd7 100644 --- a/GUI/coregui/Views/PropertyEditor/ObsoletePropertyBrowserUtils.cpp +++ b/GUI/coregui/Views/PropertyEditor/ObsoletePropertyBrowserUtils.cpp @@ -17,6 +17,7 @@ #include "ObsoletePropertyBrowserUtils.h" #include "MaterialSvc.h" #include "CustomEventFilters.h" +#include "MaterialItemUtils.h" #include <QColorDialog> #include <QComboBox> #include <QDoubleValidator> @@ -70,7 +71,7 @@ void ObsoleteMaterialPropertyEdit::buttonClicked() { // temporarily installing filter to prevent loss of focus caused by too insistent dialog installEventFilter(m_focusFilter); - MaterialProperty mat = MaterialSvc::selectMaterialProperty(m_materialProperty); + MaterialProperty mat = MaterialItemUtils::selectMaterialProperty(m_materialProperty); removeEventFilter(m_focusFilter); if(mat.isDefined() ) { diff --git a/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp b/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp index e3a2c48274e119a8d036aa9b09ea66842673a0ea..9ab3d304ebbc45e55833f11ba7c62bab1541588f 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp +++ b/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp @@ -18,6 +18,7 @@ #include "DesignerView.h" #include "MaterialProperty.h" #include "MaterialSvc.h" +#include "MaterialItemUtils.h" #include <QAction> #include <QButtonGroup> #include <QComboBox> @@ -142,5 +143,5 @@ void SampleToolBar::onScaleComboChanged(const QString &scale_string) void SampleToolBar::onMaterialEditorCall() { - MaterialProperty mp = MaterialSvc::selectMaterialProperty(); + MaterialProperty mp = MaterialItemUtils::selectMaterialProperty(); }