diff --git a/src/Mod/Material/App/ExternalManager.cpp b/src/Mod/Material/App/ExternalManager.cpp index 07e0f23f51..d9af3c53dc 100644 --- a/src/Mod/Material/App/ExternalManager.cpp +++ b/src/Mod/Material/App/ExternalManager.cpp @@ -519,7 +519,7 @@ ExternalManager::libraryMaterials(const QString& libraryName) std::shared_ptr> ExternalManager::libraryMaterials(const QString& libraryName, - const std::shared_ptr& filter, + const MaterialFilter& filter, const MaterialFilterOptions& options) { auto materialList = std::make_shared>(); @@ -532,13 +532,7 @@ ExternalManager::libraryMaterials(const QString& libraryName, Py::Callable libraries(_managerObject.getAttr("libraryMaterials")); Py::Tuple args(3); args.setItem(0, Py::String(libraryName.toStdString())); - if (filter) { - args.setItem(1, - Py::Object(new MaterialFilterPy(new MaterialFilter(*filter)), true)); - } - else { - args.setItem(1, Py::None()); - } + args.setItem(1, Py::Object(new MaterialFilterPy(new MaterialFilter(filter)), true)); args.setItem( 2, Py::Object(new MaterialFilterOptionsPy(new MaterialFilterOptions(options)), true)); @@ -750,7 +744,7 @@ std::shared_ptr ExternalManager::getModel(const QString& uuid) void ExternalManager::addModel(const QString& libraryName, const QString& path, - const std::shared_ptr& model) + const Model& model) { connect(); @@ -761,7 +755,7 @@ void ExternalManager::addModel(const QString& libraryName, Py::Tuple args(3); args.setItem(0, Py::String(libraryName.toStdString())); args.setItem(1, Py::String(path.toStdString())); - args.setItem(2, Py::Object(new ModelPy(new Model(*model)), true)); + args.setItem(2, Py::Object(new ModelPy(new Model(model)), true)); libraries.apply(args); // No return expected } else { @@ -777,7 +771,7 @@ void ExternalManager::addModel(const QString& libraryName, void ExternalManager::migrateModel(const QString& libraryName, const QString& path, - const std::shared_ptr& model) + const Model& model) { connect(); @@ -788,7 +782,7 @@ void ExternalManager::migrateModel(const QString& libraryName, Py::Tuple args(3); args.setItem(0, Py::String(libraryName.toStdString())); args.setItem(1, Py::String(path.toStdString())); - args.setItem(2, Py::Object(new ModelPy(new Model(*model)), true)); + args.setItem(2, Py::Object(new ModelPy(new Model(model)), true)); libraries.apply(args); // No return expected } else { @@ -804,7 +798,7 @@ void ExternalManager::migrateModel(const QString& libraryName, void ExternalManager::updateModel(const QString& libraryName, const QString& path, - const std::shared_ptr& model) + const Model& model) { connect(); @@ -815,7 +809,7 @@ void ExternalManager::updateModel(const QString& libraryName, Py::Tuple args(3); args.setItem(0, Py::String(libraryName.toStdString())); args.setItem(1, Py::String(path.toStdString())); - args.setItem(2, Py::Object(new ModelPy(new Model(*model)), true)); + args.setItem(2, Py::Object(new ModelPy(new Model(model)), true)); libraries.apply(args); // No return expected } else { @@ -999,7 +993,7 @@ std::shared_ptr ExternalManager::getMaterial(const QString& uuid) void ExternalManager::addMaterial(const QString& libraryName, const QString& path, - const std::shared_ptr& material) + const Material& material) { connect(); @@ -1010,7 +1004,7 @@ void ExternalManager::addMaterial(const QString& libraryName, Py::Tuple args(3); args.setItem(0, Py::String(libraryName.toStdString())); args.setItem(1, Py::String(path.toStdString())); - args.setItem(2, Py::Object(new MaterialPy(new Material(*material)), true)); + args.setItem(2, Py::Object(new MaterialPy(new Material(material)), true)); libraries.apply(args); // No return expected } else { @@ -1026,7 +1020,7 @@ void ExternalManager::addMaterial(const QString& libraryName, void ExternalManager::migrateMaterial(const QString& libraryName, const QString& path, - const std::shared_ptr& material) + const Material& material) { connect(); @@ -1037,7 +1031,7 @@ void ExternalManager::migrateMaterial(const QString& libraryName, Py::Tuple args(3); args.setItem(0, Py::String(libraryName.toStdString())); args.setItem(1, Py::String(path.toStdString())); - auto mat = new Material(*material); + auto mat = new Material(material); args.setItem(2, Py::Object(new MaterialPy(mat), true)); libraries.apply(args); // No return expected } @@ -1054,7 +1048,7 @@ void ExternalManager::migrateMaterial(const QString& libraryName, void ExternalManager::updateMaterial(const QString& libraryName, const QString& path, - const std::shared_ptr& material) + const Material& material) { connect(); @@ -1065,7 +1059,7 @@ void ExternalManager::updateMaterial(const QString& libraryName, Py::Tuple args(3); args.setItem(0, Py::String(libraryName.toStdString())); args.setItem(1, Py::String(path.toStdString())); - args.setItem(2, Py::Object(new MaterialPy(new Material(*material)), true)); + args.setItem(2, Py::Object(new MaterialPy(new Material(material)), true)); libraries.apply(args); // No return expected } else { diff --git a/src/Mod/Material/App/ExternalManager.h b/src/Mod/Material/App/ExternalManager.h index 3f3e1a10cf..de406d4187 100644 --- a/src/Mod/Material/App/ExternalManager.h +++ b/src/Mod/Material/App/ExternalManager.h @@ -65,7 +65,7 @@ public: std::shared_ptr> libraryMaterials(const QString& libraryName); std::shared_ptr> libraryMaterials(const QString& libraryName, - const std::shared_ptr& filter, + const MaterialFilter& filter, const MaterialFilterOptions& options); std::shared_ptr> libraryFolders(const QString& libraryName); @@ -79,12 +79,12 @@ public: // Model management std::shared_ptr getModel(const QString& uuid); void - addModel(const QString& libraryName, const QString& path, const std::shared_ptr& model); + addModel(const QString& libraryName, const QString& path, const Model& model); void - migrateModel(const QString& libraryName, const QString& path, const std::shared_ptr& model); + migrateModel(const QString& libraryName, const QString& path, const Model& model); void updateModel(const QString& libraryName, const QString& path, - const std::shared_ptr& model); + const Model& model); void setModelPath(const QString& libraryName, const QString& path, const QString& uuid); void renameModel(const QString& libraryName, const QString& name, const QString& uuid); void moveModel(const QString& libraryName, const QString& path, const QString& uuid); @@ -94,13 +94,13 @@ public: std::shared_ptr getMaterial(const QString& uuid); void addMaterial(const QString& libraryName, const QString& path, - const std::shared_ptr& material); + const Material& material); void migrateMaterial(const QString& libraryName, const QString& path, - const std::shared_ptr& material); + const Material& material); void updateMaterial(const QString& libraryName, const QString& path, - const std::shared_ptr& material); + const Material& material); void setMaterialPath(const QString& libraryName, const QString& path, const QString& uuid); void renameMaterial(const QString& libraryName, const QString& name, const QString& uuid); void moveMaterial(const QString& libraryName, const QString& path, const QString& uuid); diff --git a/src/Mod/Material/App/MaterialFilter.cpp b/src/Mod/Material/App/MaterialFilter.cpp index a1284a7151..7ab64f3d81 100644 --- a/src/Mod/Material/App/MaterialFilter.cpp +++ b/src/Mod/Material/App/MaterialFilter.cpp @@ -68,25 +68,25 @@ MaterialFilter::MaterialFilter() , _requireAppearance(false) {} -bool MaterialFilter::modelIncluded(const std::shared_ptr& material) const +bool MaterialFilter::modelIncluded(const Material& material) const { if (_requirePhysical) { - if (!material->hasPhysicalProperties()) { + if (!material.hasPhysicalProperties()) { return false; } } if (_requireAppearance) { - if (!material->hasAppearanceProperties()) { + if (!material.hasAppearanceProperties()) { return false; } } for (const auto& complete : _requiredComplete) { - if (!material->isModelComplete(complete)) { + if (!material.isModelComplete(complete)) { return false; } } for (const auto& required : _required) { - if (!material->hasModel(required)) { + if (!material.hasModel(required)) { return false; } } @@ -98,7 +98,7 @@ bool MaterialFilter::modelIncluded(const QString& uuid) const { try { auto material = MaterialManager::getManager().getMaterial(uuid); - return modelIncluded(material); + return modelIncluded(*material); } catch (const MaterialNotFound&) { } diff --git a/src/Mod/Material/App/MaterialFilter.h b/src/Mod/Material/App/MaterialFilter.h index c25612bd2c..165ed1a755 100644 --- a/src/Mod/Material/App/MaterialFilter.h +++ b/src/Mod/Material/App/MaterialFilter.h @@ -164,7 +164,7 @@ public: * * Models only need to be included in one set. */ - bool modelIncluded(const std::shared_ptr& material) const; + bool modelIncluded(const Material& material) const; bool modelIncluded(const QString& uuid) const; /* Add model UUIDs for required models, or models that are both required diff --git a/src/Mod/Material/App/MaterialLibrary.cpp b/src/Mod/Material/App/MaterialLibrary.cpp index 40c0b64f6f..c15a3a97d2 100644 --- a/src/Mod/Material/App/MaterialLibrary.cpp +++ b/src/Mod/Material/App/MaterialLibrary.cpp @@ -59,7 +59,7 @@ MaterialLibrary::MaterialLibrary(const Library& library) {} std::shared_ptr>> -MaterialLibrary::getMaterialTree(const std::shared_ptr& filter, +MaterialLibrary::getMaterialTree(const Materials::MaterialFilter& filter, const Materials::MaterialFilterOptions& options) const { std::shared_ptr>> materialTree = diff --git a/src/Mod/Material/App/MaterialLibrary.h b/src/Mod/Material/App/MaterialLibrary.h index 27e78cd8b3..3ea7df00cc 100644 --- a/src/Mod/Material/App/MaterialLibrary.h +++ b/src/Mod/Material/App/MaterialLibrary.h @@ -62,7 +62,7 @@ public: ~MaterialLibrary() override = default; virtual std::shared_ptr>> - getMaterialTree(const std::shared_ptr& filter, + getMaterialTree(const Materials::MaterialFilter& filter, const Materials::MaterialFilterOptions& options) const; // Use this to get a shared_ptr for *this diff --git a/src/Mod/Material/App/MaterialManager.cpp b/src/Mod/Material/App/MaterialManager.cpp index 8bcc7c023d..10ca04ee9f 100644 --- a/src/Mod/Material/App/MaterialManager.cpp +++ b/src/Mod/Material/App/MaterialManager.cpp @@ -344,7 +344,7 @@ MaterialManager::libraryMaterials(const QString& libraryName, bool local) std::shared_ptr> MaterialManager::libraryMaterials(const QString& libraryName, - const std::shared_ptr& filter, + const MaterialFilter& filter, const MaterialFilterOptions& options, bool local) { @@ -415,7 +415,7 @@ void MaterialManager::createFolder(const std::shared_ptr& libra } #if defined(BUILD_MATERIAL_EXTERNAL) else if (_useExternal) { - _externalManager->createFolder(library, path); + _externalManager->createFolder(*library, path); } else { throw Materials::CreationError("External materials are not enabled"); @@ -435,7 +435,7 @@ void MaterialManager::renameFolder(const std::shared_ptr& libra } #if defined(BUILD_MATERIAL_EXTERNAL) else if (_useExternal) { - _externalManager->renameFolder(library, oldPath, newPath); + _externalManager->renameFolder(*library, oldPath, newPath); } else { throw Materials::RenameError("External materials are not enabled"); @@ -454,7 +454,7 @@ void MaterialManager::deleteRecursive(const std::shared_ptr& li } #if defined(BUILD_MATERIAL_EXTERNAL) else if (_useExternal) { - _externalManager->deleteRecursive(library, path); + _externalManager->deleteRecursive(*library, path); } else { throw Materials::DeleteError("External materials are not enabled"); @@ -469,27 +469,27 @@ void MaterialManager::deleteRecursive(const std::shared_ptr& li //===== std::shared_ptr>> -MaterialManager::getMaterialTree(const std::shared_ptr& library, - const std::shared_ptr& filter) const +MaterialManager::getMaterialTree(const MaterialLibrary& library, + const Materials::MaterialFilter& filter) const { MaterialFilterOptions options; - return library->getMaterialTree(filter, options); + return library.getMaterialTree(filter, options); } std::shared_ptr>> -MaterialManager::getMaterialTree(const std::shared_ptr& library, - const std::shared_ptr& filter, +MaterialManager::getMaterialTree(const MaterialLibrary& library, + const Materials::MaterialFilter& filter, const MaterialFilterOptions& options) const { - return library->getMaterialTree(filter, options); + return library.getMaterialTree(filter, options); } std::shared_ptr>> -MaterialManager::getMaterialTree(const std::shared_ptr& library) const +MaterialManager::getMaterialTree(const MaterialLibrary& library) const { - std::shared_ptr filter; + Materials::MaterialFilter filter; MaterialFilterOptions options; - return library->getMaterialTree(filter, options); + return library.getMaterialTree(filter, options); } //===== @@ -551,14 +551,11 @@ bool MaterialManager::exists(const QString& uuid) const return _localManager->exists(uuid); } -bool MaterialManager::exists(const std::shared_ptr& library, +bool MaterialManager::exists(const MaterialLibrary& library, const QString& uuid) const { - if (library->isLocal()) { - auto materialLibrary = - reinterpret_cast&>(library); - - return _localManager->exists(materialLibrary, uuid); + if (library.isLocal()) { + return _localManager->exists(library, uuid); } return false; } @@ -638,7 +635,7 @@ void MaterialManager::migrateToExternal(const std::shared_ptrgetMaterial(uuid); if (!material->isOldFormat()) { - _externalManager->migrateMaterial(library->getName(), path, material); + _externalManager->migrateMaterial(library->getName(), path, *material); } } } @@ -659,7 +656,7 @@ void MaterialManager::validateMigration(const std::shared_ptrgetMaterial(uuid); if (!material->isOldFormat()) { auto externalMaterial = _externalManager->getMaterial(uuid); - material->validate(externalMaterial); + material->validate(*externalMaterial); } } } diff --git a/src/Mod/Material/App/MaterialManager.h b/src/Mod/Material/App/MaterialManager.h index 0d2e052a4b..beeabb60a1 100644 --- a/src/Mod/Material/App/MaterialManager.h +++ b/src/Mod/Material/App/MaterialManager.h @@ -87,7 +87,7 @@ public: libraryMaterials(const QString& libraryName, bool local = false); std::shared_ptr> libraryMaterials(const QString& libraryName, - const std::shared_ptr& filter, + const MaterialFilter& filter, const MaterialFilterOptions& options, bool local = false); bool isLocalLibrary(const QString& libraryName); @@ -103,14 +103,14 @@ public: // Tree management std::shared_ptr>> - getMaterialTree(const std::shared_ptr& library, - const std::shared_ptr& filter) const; + getMaterialTree(const MaterialLibrary& library, + const Materials::MaterialFilter& filter) const; std::shared_ptr>> - getMaterialTree(const std::shared_ptr& library, - const std::shared_ptr& filter, + getMaterialTree(const MaterialLibrary& library, + const Materials::MaterialFilter& filter, const MaterialFilterOptions& options) const; std::shared_ptr>> - getMaterialTree(const std::shared_ptr& library) const; + getMaterialTree(const MaterialLibrary& library) const; // Material management std::shared_ptr>> getLocalMaterials() const; @@ -120,7 +120,7 @@ public: std::shared_ptr getMaterialByPath(const QString& path, const QString& library) const; std::shared_ptr getParent(const std::shared_ptr& material) const; bool exists(const QString& uuid) const; - bool exists(const std::shared_ptr& library, const QString& uuid) const; + bool exists(const MaterialLibrary& library, const QString& uuid) const; void remove(const QString& uuid) const; void saveMaterial(const std::shared_ptr& library, diff --git a/src/Mod/Material/App/MaterialManagerExternal.cpp b/src/Mod/Material/App/MaterialManagerExternal.cpp index 490bb84e11..8ebfdc2d08 100644 --- a/src/Mod/Material/App/MaterialManagerExternal.cpp +++ b/src/Mod/Material/App/MaterialManagerExternal.cpp @@ -159,7 +159,7 @@ MaterialManagerExternal::libraryMaterials(const QString& libraryName) std::shared_ptr> MaterialManagerExternal::libraryMaterials(const QString& libraryName, - const std::shared_ptr& filter, + const MaterialFilter& filter, const MaterialFilterOptions& options) { return ExternalManager::getManager()->libraryMaterials(libraryName, filter, options); @@ -171,23 +171,23 @@ MaterialManagerExternal::libraryMaterials(const QString& libraryName, // //===== -void MaterialManagerExternal::createFolder(const std::shared_ptr& library, +void MaterialManagerExternal::createFolder(const MaterialLibrary& library, const QString& path) { - ExternalManager::getManager()->createFolder(library->getName(), path); + ExternalManager::getManager()->createFolder(library.getName(), path); } -void MaterialManagerExternal::renameFolder(const std::shared_ptr& library, +void MaterialManagerExternal::renameFolder(const MaterialLibrary& library, const QString& oldPath, const QString& newPath) { - ExternalManager::getManager()->renameFolder(library->getName(), oldPath, newPath); + ExternalManager::getManager()->renameFolder(library.getName(), oldPath, newPath); } -void MaterialManagerExternal::deleteRecursive(const std::shared_ptr& library, +void MaterialManagerExternal::deleteRecursive(const MaterialLibrary& library, const QString& path) { - ExternalManager::getManager()->deleteRecursive(library->getName(), path); + ExternalManager::getManager()->deleteRecursive(library.getName(), path); } //===== @@ -226,17 +226,17 @@ std::shared_ptr MaterialManagerExternal::getMaterial(const QString& uu void MaterialManagerExternal::addMaterial(const QString& libraryName, const QString& path, - const std::shared_ptr& material) + const Material& material) { - _cache.erase(material->getUUID().toStdString()); + _cache.erase(material.getUUID().toStdString()); ExternalManager::getManager()->addMaterial(libraryName, path, material); } void MaterialManagerExternal::migrateMaterial(const QString& libraryName, const QString& path, - const std::shared_ptr& material) + const Material& material) { - _cache.erase(material->getUUID().toStdString()); + _cache.erase(material.getUUID().toStdString()); ExternalManager::getManager()->migrateMaterial(libraryName, path, material); } diff --git a/src/Mod/Material/App/MaterialManagerExternal.h b/src/Mod/Material/App/MaterialManagerExternal.h index 870a0f7a4b..f0824e795f 100644 --- a/src/Mod/Material/App/MaterialManagerExternal.h +++ b/src/Mod/Material/App/MaterialManagerExternal.h @@ -75,24 +75,23 @@ public: libraryMaterials(const QString& libraryName); std::shared_ptr> libraryMaterials(const QString& libraryName, - const std::shared_ptr& filter, + const MaterialFilter& filter, const MaterialFilterOptions& options); // Folder management - void createFolder(const std::shared_ptr& library, const QString& path); - void renameFolder(const std::shared_ptr& library, - const QString& oldPath, - const QString& newPath); - void deleteRecursive(const std::shared_ptr& library, const QString& path); + void createFolder(const MaterialLibrary& library, const QString& path); + void + renameFolder(const MaterialLibrary& library, const QString& oldPath, const QString& newPath); + void deleteRecursive(const MaterialLibrary& library, const QString& path); // Material management std::shared_ptr getMaterial(const QString& uuid) const; void addMaterial(const QString& libraryName, const QString& path, - const std::shared_ptr& material); + const Material& material); void migrateMaterial(const QString& libraryName, const QString& path, - const std::shared_ptr& material); + const Material& material); // Cache functions void resetCache(); diff --git a/src/Mod/Material/App/MaterialManagerLocal.cpp b/src/Mod/Material/App/MaterialManagerLocal.cpp index ad5074c511..dc5e50fbff 100644 --- a/src/Mod/Material/App/MaterialManagerLocal.cpp +++ b/src/Mod/Material/App/MaterialManagerLocal.cpp @@ -216,27 +216,22 @@ MaterialManagerLocal::libraryMaterials(const QString& libraryName) return materials; } -bool MaterialManagerLocal::passFilter(const std::shared_ptr& material, - const std::shared_ptr& filter, +bool MaterialManagerLocal::passFilter(const Material& material, + const Materials::MaterialFilter& filter, const Materials::MaterialFilterOptions& options) const { - if (!filter) { - // If there's no filter we always include - return true; - } - // filter out old format files - if (material->isOldFormat() && !options.includeLegacy()) { + if (material.isOldFormat() && !options.includeLegacy()) { return false; } // filter based on models - return filter->modelIncluded(material); + return filter.modelIncluded(material); } std::shared_ptr> MaterialManagerLocal::libraryMaterials(const QString& libraryName, - const std::shared_ptr& filter, + const MaterialFilter& filter, const MaterialFilterOptions& options) { auto materials = std::make_shared>(); @@ -245,7 +240,7 @@ MaterialManagerLocal::libraryMaterials(const QString& libraryName, // This is needed to resolve cyclic dependencies auto library = it.second->getLibrary(); if (library->isName(libraryName)) { - if (passFilter(it.second, filter, options)) { + if (passFilter(*it.second, filter, options)) { materials->push_back( LibraryObject(it.first, it.second->getDirectory(), it.second->getName())); } @@ -386,7 +381,7 @@ bool MaterialManagerLocal::exists(const QString& uuid) const return false; } -bool MaterialManagerLocal::exists(const std::shared_ptr& library, +bool MaterialManagerLocal::exists(const MaterialLibrary& library, const QString& uuid) const { try { @@ -395,7 +390,7 @@ bool MaterialManagerLocal::exists(const std::shared_ptr& librar auto materialLibrary = reinterpret_cast&>( *(material->getLibrary())); - return (*materialLibrary == *library); + return (*materialLibrary == library); } } catch (const MaterialNotFound&) { diff --git a/src/Mod/Material/App/MaterialManagerLocal.h b/src/Mod/Material/App/MaterialManagerLocal.h index 5e37dd8b4c..f3a3c14886 100644 --- a/src/Mod/Material/App/MaterialManagerLocal.h +++ b/src/Mod/Material/App/MaterialManagerLocal.h @@ -75,7 +75,7 @@ public: libraryMaterials(const QString& libraryName); std::shared_ptr> libraryMaterials(const QString& libraryName, - const std::shared_ptr& filter, + const MaterialFilter& filter, const MaterialFilterOptions& options); // Folder management @@ -93,7 +93,7 @@ public: std::shared_ptr getMaterialByPath(const QString& path) const; std::shared_ptr getMaterialByPath(const QString& path, const QString& library) const; bool exists(const QString& uuid) const; - bool exists(const std::shared_ptr& library, const QString& uuid) const; + bool exists(const MaterialLibrary& library, const QString& uuid) const; void remove(const QString& uuid); void saveMaterial(const std::shared_ptr& library, @@ -115,8 +115,8 @@ public: protected: static std::shared_ptr>> getConfiguredLibraries(); - bool passFilter(const std::shared_ptr& material, - const std::shared_ptr& filter, + bool passFilter(const Material& material, + const Materials::MaterialFilter& filter, const Materials::MaterialFilterOptions& options) const; private: diff --git a/src/Mod/Material/App/MaterialManagerPyImp.cpp b/src/Mod/Material/App/MaterialManagerPyImp.cpp index 1ae4662f5c..cb898bda1a 100644 --- a/src/Mod/Material/App/MaterialManagerPyImp.cpp +++ b/src/Mod/Material/App/MaterialManagerPyImp.cpp @@ -345,7 +345,7 @@ PyObject* MaterialManagerPy::filterMaterials(PyObject* args, PyObject* kwds) Py::List list; for (auto lib : *libraries) { - auto tree = getMaterialManagerPtr()->getMaterialTree(lib, filter, options); + auto tree = getMaterialManagerPtr()->getMaterialTree(*lib, *filter, options); if (tree->size() > 0) { addMaterials(getMaterialManagerPtr(), list, tree); } diff --git a/src/Mod/Material/App/Materials.cpp b/src/Mod/Material/App/Materials.cpp index 4d53099d3b..f2122dbf77 100644 --- a/src/Mod/Material/App/Materials.cpp +++ b/src/Mod/Material/App/Materials.cpp @@ -1344,14 +1344,14 @@ void Material::saveInherits(QTextStream& stream) const } } -bool Material::modelChanged(const std::shared_ptr& parent, - const std::shared_ptr& model) const +bool Material::modelChanged(const Material& parent, + const Model& model) const { - for (auto& it : *model) { + for (auto& it : model) { QString propertyName = it.first; auto property = getPhysicalProperty(propertyName); try { - auto parentProperty = parent->getPhysicalProperty(propertyName); + auto parentProperty = parent.getPhysicalProperty(propertyName); if (*property != *parentProperty) { return true; @@ -1365,14 +1365,14 @@ bool Material::modelChanged(const std::shared_ptr& parent, return false; } -bool Material::modelAppearanceChanged(const std::shared_ptr& parent, - const std::shared_ptr& model) const +bool Material::modelAppearanceChanged(const Material& parent, + const Model& model) const { - for (auto& it : *model) { + for (auto& it : model) { QString propertyName = it.first; auto property = getAppearanceProperty(propertyName); try { - auto parentProperty = parent->getAppearanceProperty(propertyName); + auto parentProperty = parent.getAppearanceProperty(propertyName); if (*property != *parentProperty) { return true; @@ -1409,7 +1409,7 @@ void Material::saveModels(QTextStream& stream, bool saveInherited) const bool headerPrinted = false; for (auto& itm : _physicalUuids) { auto model = modelManager.getModel(itm); - if (!inherited || modelChanged(parent, model)) { + if (!inherited || modelChanged(*parent, *model)) { if (!headerPrinted) { stream << "Models:\n"; headerPrinted = true; @@ -1463,7 +1463,7 @@ void Material::saveAppearanceModels(QTextStream& stream, bool saveInherited) con bool headerPrinted = false; for (auto& itm : _appearanceUuids) { auto model = modelManager.getModel(itm); - if (!inherited || modelAppearanceChanged(parent, model)) { + if (!inherited || modelAppearanceChanged(*parent, *model)) { if (!headerPrinted) { stream << "AppearanceModels:\n"; headerPrinted = true; @@ -1781,97 +1781,97 @@ App::Material Material::getMaterialAppearance() const return material; } -void Material::validate(const std::shared_ptr& other) const +void Material::validate(Material& other) const { try { - _library->validate(*(other->_library)); + _library->validate(*other._library); } catch (const InvalidLibrary& e) { throw InvalidMaterial(e.what()); } - if (_directory != other->_directory) { + if (_directory != other._directory) { throw InvalidMaterial("Model directories don't match"); } - if (!other->_filename.isEmpty()) { + if (!other._filename.isEmpty()) { throw InvalidMaterial("Remote filename is not empty"); } - if (_uuid != other->_uuid) { + if (_uuid != other._uuid) { throw InvalidMaterial("Model UUIDs don't match"); } - if (_name != other->_name) { + if (_name != other._name) { throw InvalidMaterial("Model names don't match"); } - if (_author != other->_author) { + if (_author != other._author) { throw InvalidMaterial("Model authors don't match"); } - if (_license != other->_license) { + if (_license != other._license) { throw InvalidMaterial("Model licenses don't match"); } - if (_parentUuid != other->_parentUuid) { + if (_parentUuid != other._parentUuid) { throw InvalidMaterial("Model parents don't match"); } - if (_description != other->_description) { + if (_description != other._description) { throw InvalidMaterial("Model descriptions don't match"); } - if (_url != other->_url) { + if (_url != other._url) { throw InvalidMaterial("Model URLs don't match"); } - if (_reference != other->_reference) { + if (_reference != other._reference) { throw InvalidMaterial("Model references don't match"); } - if (_tags.size() != other->_tags.size()) { + if (_tags.size() != other._tags.size()) { Base::Console().log("Local tags count %d\n", _tags.size()); - Base::Console().log("Remote tags count %d\n", other->_tags.size()); + Base::Console().log("Remote tags count %d\n", other._tags.size()); throw InvalidMaterial("Material tags counts don't match"); } - if (!other->_tags.contains(_tags)) { + if (!other._tags.contains(_tags)) { throw InvalidMaterial("Material tags don't match"); } - if (_physicalUuids.size() != other->_physicalUuids.size()) { + if (_physicalUuids.size() != other._physicalUuids.size()) { Base::Console().log("Local physical model count %d\n", _physicalUuids.size()); - Base::Console().log("Remote physical model count %d\n", other->_physicalUuids.size()); + Base::Console().log("Remote physical model count %d\n", other._physicalUuids.size()); throw InvalidMaterial("Material physical model counts don't match"); } - if (!other->_physicalUuids.contains(_physicalUuids)) { + if (!other._physicalUuids.contains(_physicalUuids)) { throw InvalidMaterial("Material physical models don't match"); } - if (_physicalUuids.size() != other->_physicalUuids.size()) { + if (_physicalUuids.size() != other._physicalUuids.size()) { Base::Console().log("Local appearance model count %d\n", _physicalUuids.size()); - Base::Console().log("Remote appearance model count %d\n", other->_physicalUuids.size()); + Base::Console().log("Remote appearance model count %d\n", other._physicalUuids.size()); throw InvalidMaterial("Material appearance model counts don't match"); } - if (!other->_physicalUuids.contains(_physicalUuids)) { + if (!other._physicalUuids.contains(_physicalUuids)) { throw InvalidMaterial("Material appearance models don't match"); } - if (_allUuids.size() != other->_allUuids.size()) { + if (_allUuids.size() != other._allUuids.size()) { Base::Console().log("Local model count %d\n", _allUuids.size()); - Base::Console().log("Remote model count %d\n", other->_allUuids.size()); + Base::Console().log("Remote model count %d\n", other._allUuids.size()); throw InvalidMaterial("Material model counts don't match"); } - if (!other->_allUuids.contains(_allUuids)) { + if (!other._allUuids.contains(_allUuids)) { throw InvalidMaterial("Material models don't match"); } // Need to compare properties - if (_physical.size() != other->_physical.size()) { + if (_physical.size() != other._physical.size()) { throw InvalidMaterial("Material physical property counts don't match"); } for (auto& property : _physical) { - auto& remote = other->_physical[property.first]; + auto& remote = other._physical[property.first]; property.second->validate(*remote); } - if (_appearance.size() != other->_appearance.size()) { + if (_appearance.size() != other._appearance.size()) { throw InvalidMaterial("Material appearance property counts don't match"); } for (auto& property : _appearance) { - auto& remote = other->_appearance[property.first]; + auto& remote = other._appearance[property.first]; property.second->validate(*remote); } } diff --git a/src/Mod/Material/App/Materials.h b/src/Mod/Material/App/Materials.h index 4d57c70259..31cac1986f 100644 --- a/src/Mod/Material/App/Materials.h +++ b/src/Mod/Material/App/Materials.h @@ -443,7 +443,7 @@ public: return getTypeId() == other.getTypeId() && _uuid == other._uuid; } - void validate(const std::shared_ptr& other) const; + void validate(Material& other) const; protected: void addModel(const QString& uuid); @@ -456,10 +456,10 @@ protected: getValueString(const std::map>& propertyList, const QString& name); - bool modelChanged(const std::shared_ptr& parent, - const std::shared_ptr& model) const; - bool modelAppearanceChanged(const std::shared_ptr& parent, - const std::shared_ptr& model) const; + bool modelChanged(const Material& parent, + const Model& model) const; + bool modelAppearanceChanged(const Material& parent, + const Model& model) const; void saveGeneral(QTextStream& stream) const; void saveInherits(QTextStream& stream) const; void saveModels(QTextStream& stream, bool saveInherited) const; diff --git a/src/Mod/Material/App/Model.cpp b/src/Mod/Material/App/Model.cpp index 78eeac9d7e..28a1b7ad81 100644 --- a/src/Mod/Material/App/Model.cpp +++ b/src/Mod/Material/App/Model.cpp @@ -202,10 +202,10 @@ ModelProperty& Model::operator[](const QString& key) } } -void Model::validate(const std::shared_ptr& other) const +void Model::validate(Model& other) const { try { - _library->validate(*(other->_library)); + _library->validate(*(other._library)); } catch (const InvalidLibrary& e) { @@ -213,42 +213,40 @@ void Model::validate(const std::shared_ptr& other) const } // std::map _properties; - if (_type != other->_type) { + if (_type != other._type) { throw InvalidModel("Model types don't match"); } - if (_name != other->_name) { + if (_name != other._name) { throw InvalidModel("Model names don't match"); } - if (_directory != other->_directory) { + if (_directory != other._directory) { throw InvalidModel("Model directories don't match"); } - if (!other->_filename.isEmpty()) { + if (!other._filename.isEmpty()) { throw InvalidModel("Remote filename is not empty"); } - if (_uuid != other->_uuid) { + if (_uuid != other._uuid) { throw InvalidModel("Model UUIDs don't match"); } - if (_description != other->_description) { + if (_description != other._description) { throw InvalidModel("Model descriptions don't match"); } - if (_url != other->_url) { + if (_url != other._url) { throw InvalidModel("Model URLs don't match"); } - if (_doi != other->_doi) { + if (_doi != other._doi) { throw InvalidModel("Model DOIs don't match"); } - if (_inheritedUuids != other->_inheritedUuids) { + if (_inheritedUuids != other._inheritedUuids) { throw InvalidModel("Model inherited UUIDs don't match"); } // Need to compare properties - if (_properties.size() != other->_properties.size()) { - // Base::Console().log("Local property count %d\n", _properties.size()); - // Base::Console().log("Remote property count %d\n", other->_properties.size()); + if (_properties.size() != other._properties.size()) { throw InvalidModel("Model property counts don't match"); } for (auto& property : _properties) { - auto& remote = other->_properties[property.first]; + auto& remote = other._properties[property.first]; property.second.validate(remote); } } diff --git a/src/Mod/Material/App/Model.h b/src/Mod/Material/App/Model.h index 517651e7d5..9d69a9cd4a 100644 --- a/src/Mod/Material/App/Model.h +++ b/src/Mod/Material/App/Model.h @@ -301,7 +301,7 @@ public: return _properties.cend(); } - void validate(const std::shared_ptr& other) const; + void validate(Model& other) const; private: std::shared_ptr _library; diff --git a/src/Mod/Material/App/ModelManager.cpp b/src/Mod/Material/App/ModelManager.cpp index e103c43b5f..99d3c1f561 100644 --- a/src/Mod/Material/App/ModelManager.cpp +++ b/src/Mod/Material/App/ModelManager.cpp @@ -342,7 +342,7 @@ void ModelManager::migrateToExternal(const std::shared_ptrgetModel(uuid); - _externalManager->migrateModel(library->getName(), path, model); + _externalManager->migrateModel(library->getName(), path, *model); } } @@ -360,7 +360,7 @@ void ModelManager::validateMigration(const std::shared_ptrgetModel(uuid); auto externalModel = _externalManager->getModel(uuid); - model->validate(externalModel); + model->validate(*externalModel); } } diff --git a/src/Mod/Material/App/ModelManagerExternal.cpp b/src/Mod/Material/App/ModelManagerExternal.cpp index f58d14a091..583458a83e 100644 --- a/src/Mod/Material/App/ModelManagerExternal.cpp +++ b/src/Mod/Material/App/ModelManagerExternal.cpp @@ -163,17 +163,17 @@ std::shared_ptr>> ModelManagerExternal: void ModelManagerExternal::addModel(const QString& libraryName, const QString& path, - const std::shared_ptr& model) + const Model& model) { - _cache.erase(model->getUUID().toStdString()); + _cache.erase(model.getUUID().toStdString()); ExternalManager::getManager()->addModel(libraryName, path, model); } void ModelManagerExternal::migrateModel(const QString& libraryName, const QString& path, - const std::shared_ptr& model) + const Model& model) { - _cache.erase(model->getUUID().toStdString()); + _cache.erase(model.getUUID().toStdString()); ExternalManager::getManager()->migrateModel(libraryName, path, model); } diff --git a/src/Mod/Material/App/ModelManagerExternal.h b/src/Mod/Material/App/ModelManagerExternal.h index 32514967bd..ae605e343f 100644 --- a/src/Mod/Material/App/ModelManagerExternal.h +++ b/src/Mod/Material/App/ModelManagerExternal.h @@ -63,9 +63,9 @@ public: std::shared_ptr getModel(const QString& uuid); std::shared_ptr>> getModels(); void - addModel(const QString& libraryName, const QString& path, const std::shared_ptr& model); + addModel(const QString& libraryName, const QString& path, const Model& model); void - migrateModel(const QString& libraryName, const QString& path, const std::shared_ptr& model); + migrateModel(const QString& libraryName, const QString& path, const Model& model); // Cache functions void resetCache(); diff --git a/src/Mod/Material/Gui/DlgMaterialImp.cpp b/src/Mod/Material/Gui/DlgMaterialImp.cpp index 6adc811e19..d72450a14d 100644 --- a/src/Mod/Material/Gui/DlgMaterialImp.cpp +++ b/src/Mod/Material/Gui/DlgMaterialImp.cpp @@ -85,8 +85,8 @@ DlgMaterialImp::DlgMaterialImp(bool floating, QWidget* parent, Qt::WindowFlags f // Create a filter to only include current format materials // that contain physical properties. - auto filter = std::make_shared(); - filter->requirePhysical(true); + Materials::MaterialFilter filter; + filter.requirePhysical(true); d->ui.widgetMaterial->setFilter(filter); std::vector objects = getSelectionObjects(); diff --git a/src/Mod/Material/Gui/MaterialSave.cpp b/src/Mod/Material/Gui/MaterialSave.cpp index 645b9f9679..14add39627 100644 --- a/src/Mod/Material/Gui/MaterialSave.cpp +++ b/src/Mod/Material/Gui/MaterialSave.cpp @@ -154,7 +154,7 @@ void MaterialSave::onOk(bool checked) bool saveAsCopy = false; if (Materials::MaterialManager::getManager().exists(_material->getUUID())) { // Does it already exist in this library? - if (Materials::MaterialManager::getManager().exists(library, _material->getUUID())) { + if (Materials::MaterialManager::getManager().exists(*library, _material->getUUID())) { // Confirm saving a new material auto res = confirmNewMaterial(); if (res == QMessageBox::Cancel) { @@ -371,7 +371,7 @@ void MaterialSave::showSelectedTree() lib->setFlags(Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled); addExpanded(tree, model, lib); - auto modelTree = Materials::MaterialManager::getManager().getMaterialTree(library); + auto modelTree = Materials::MaterialManager::getManager().getMaterialTree(*library); addMaterials(*lib, modelTree, folderIcon, icon); } else { diff --git a/src/Mod/Material/Gui/MaterialTreeWidget.cpp b/src/Mod/Material/Gui/MaterialTreeWidget.cpp index 59034f9e04..12599e3295 100644 --- a/src/Mod/Material/Gui/MaterialTreeWidget.cpp +++ b/src/Mod/Material/Gui/MaterialTreeWidget.cpp @@ -55,7 +55,7 @@ using namespace MatGui; TYPESYSTEM_SOURCE(MatGui::MaterialTreeWidget, Base::BaseClass) -MaterialTreeWidget::MaterialTreeWidget(const std::shared_ptr& filter, +MaterialTreeWidget::MaterialTreeWidget(const Materials::MaterialFilter& filter, QWidget* parent) : QWidget(parent) , m_expanded(false) @@ -72,7 +72,6 @@ MaterialTreeWidget::MaterialTreeWidget( : QWidget(parent) , m_expanded(false) , m_treeSizeHint(minimumTreeWidth, minimumTreeHeight) - , _filter(std::make_shared()) , _filterList(filterList) , _recentMax(defaultRecents) { @@ -83,7 +82,6 @@ MaterialTreeWidget::MaterialTreeWidget(QWidget* parent) : QWidget(parent) , m_expanded(false) , m_treeSizeHint(minimumTreeWidth, minimumTreeHeight) - , _filter(std::make_shared()) , _recentMax(defaultRecents) { setup(); @@ -170,7 +168,7 @@ void MaterialTreeWidget::createLayout() // Set the filter if using a filter list if (hasMultipleFilters()) { - _filter = _filterList->front(); + _filter = *_filterList->front(); } fillFilterCombo(); @@ -349,11 +347,8 @@ QString MaterialTreeWidget::getMaterialUUID() const return m_uuid; } -void MaterialTreeWidget::setFilter(const std::shared_ptr& filter) +void MaterialTreeWidget::setFilter(const Materials::MaterialFilter& filter) { - if (_filter) { - _filter.reset(); - } if (_filterList) { _filterList.reset(); } @@ -369,14 +364,13 @@ void MaterialTreeWidget::setFilter(const std::shared_ptr>>& filterList) { - _filter.reset(); if (_filterList) { _filterList.reset(); } _filterList = filterList; if (hasMultipleFilters()) { - _filter = _filterList->front(); + _filter = *_filterList->front(); } fillFilterCombo(); @@ -390,9 +384,7 @@ void MaterialTreeWidget::setActiveFilter(const QString& name) if (_filterList) { for (auto const& filter : *_filterList) { if (filter->name() == name) { - _filter.reset(); - - _filter = filter; + _filter = *filter; // Save the library/folder expansion state saveMaterialTree(); @@ -427,7 +419,7 @@ void MaterialTreeWidget::getFavorites() for (int i = 0; static_cast(i) < count; i++) { QString key = QStringLiteral("FAV%1").arg(i); QString uuid = QString::fromStdString(param->GetASCII(key.toStdString().c_str(), "")); - if (!_filter || _filter->modelIncluded(uuid)) { + if (_filter.modelIncluded(uuid)) { _favorites.push_back(uuid); } } @@ -444,7 +436,7 @@ void MaterialTreeWidget::getRecents() for (int i = 0; static_cast(i) < count; i++) { QString key = QStringLiteral("MRU%1").arg(i); QString uuid = QString::fromStdString(param->GetASCII(key.toStdString().c_str(), "")); - if (!_filter || _filter->modelIncluded(uuid)) { + if (_filter.modelIncluded(uuid)) { _recents.push_back(uuid); } } @@ -558,7 +550,7 @@ void MaterialTreeWidget::fillMaterialTree() auto libraries = Materials::MaterialManager::getManager().getLibraries(); for (const auto& library : *libraries) { auto materialTree = - Materials::MaterialManager::getManager().getMaterialTree(library, + Materials::MaterialManager::getManager().getMaterialTree(*library, _filter, _filterOptions); diff --git a/src/Mod/Material/Gui/MaterialTreeWidget.h b/src/Mod/Material/Gui/MaterialTreeWidget.h index 02602e9a79..ee410fbf54 100644 --- a/src/Mod/Material/Gui/MaterialTreeWidget.h +++ b/src/Mod/Material/Gui/MaterialTreeWidget.h @@ -76,7 +76,7 @@ class MatGuiExport MaterialTreeWidget: public QWidget, public Base::BaseClass TYPESYSTEM_HEADER_WITH_OVERRIDE(); public: - explicit MaterialTreeWidget(const std::shared_ptr& filter, + explicit MaterialTreeWidget(const Materials::MaterialFilter& filter, QWidget* parent = nullptr); explicit MaterialTreeWidget( const std::shared_ptr>>& filterList, @@ -92,7 +92,7 @@ public: QString getMaterialUUID() const; /** Set the material filter */ - void setFilter(const std::shared_ptr& filter); + void setFilter(const Materials::MaterialFilter& filter); void setFilter( const std::shared_ptr>>& filterList); void setActiveFilter(const QString& name); @@ -200,7 +200,7 @@ private: std::list _favorites; std::list _recents; - std::shared_ptr _filter; + Materials::MaterialFilter _filter; Materials::MaterialFilterTreeWidgetOptions _filterOptions; std::shared_ptr>> _filterList; int _recentMax; diff --git a/src/Mod/Material/Gui/MaterialTreeWidgetPyImp.cpp b/src/Mod/Material/Gui/MaterialTreeWidgetPyImp.cpp index f492212277..c985d70364 100644 --- a/src/Mod/Material/Gui/MaterialTreeWidgetPyImp.cpp +++ b/src/Mod/Material/Gui/MaterialTreeWidgetPyImp.cpp @@ -170,8 +170,7 @@ PyObject* MaterialTreeWidgetPy::setFilter(PyObject* args) } if (PyObject_TypeCheck(obj, &(Materials::MaterialFilterPy::Type))) { auto filter = static_cast(obj)->getMaterialFilterPtr(); - auto filterPtr = std::make_shared(*filter); - getMaterialTreeWidgetPtr()->setFilter(filterPtr); + getMaterialTreeWidgetPtr()->setFilter(*filter); } else if (PyList_Check(obj)) { // The argument is a list of filters diff --git a/src/Mod/Material/Gui/MaterialsEditor.cpp b/src/Mod/Material/Gui/MaterialsEditor.cpp index f384083f29..1375a308cb 100644 --- a/src/Mod/Material/Gui/MaterialsEditor.cpp +++ b/src/Mod/Material/Gui/MaterialsEditor.cpp @@ -61,7 +61,7 @@ using namespace MatGui; /* TRANSLATOR MatGui::MaterialsEditor */ -MaterialsEditor::MaterialsEditor(std::shared_ptr filter, QWidget* parent) +MaterialsEditor::MaterialsEditor(Materials::MaterialFilter filter, QWidget* parent) : QDialog(parent) , ui(new Ui_MaterialsEditor) , _material(std::make_shared()) @@ -80,7 +80,6 @@ MaterialsEditor::MaterialsEditor(QWidget* parent) , _rendered(nullptr) , _materialSelected(false) , _recentMax(0) - , _filter(nullptr) { setup(); } @@ -182,7 +181,7 @@ void MaterialsEditor::getFavorites() for (int i = 0; static_cast(i) < count; i++) { QString key = QStringLiteral("FAV%1").arg(i); QString uuid = QString::fromStdString(param->GetASCII(key.toStdString().c_str(), "")); - if (!_filter || _filter->modelIncluded(uuid)) { + if (_filter.modelIncluded(uuid)) { _favorites.push_back(uuid); } } @@ -260,7 +259,7 @@ void MaterialsEditor::getRecents() for (int i = 0; static_cast(i) < count; i++) { QString key = QStringLiteral("MRU%1").arg(i); QString uuid = QString::fromStdString(param->GetASCII(key.toStdString().c_str(), "")); - if (!_filter || _filter->modelIncluded(uuid)) { + if (_filter.modelIncluded(uuid)) { _recents.push_back(uuid); } } @@ -892,7 +891,7 @@ void MaterialsEditor::fillMaterialTree() auto libraries = getMaterialManager().getLibraries(); for (const auto& library : *libraries) { - auto materialTree = getMaterialManager().getMaterialTree(library); + auto materialTree = getMaterialManager().getMaterialTree(*library); bool showLibraries = _filterOptions.includeEmptyLibraries(); if (!_filterOptions.includeEmptyLibraries() && materialTree->size() > 0) { diff --git a/src/Mod/Material/Gui/MaterialsEditor.h b/src/Mod/Material/Gui/MaterialsEditor.h index 18e63b5b27..f28aafbbbc 100644 --- a/src/Mod/Material/Gui/MaterialsEditor.h +++ b/src/Mod/Material/Gui/MaterialsEditor.h @@ -53,7 +53,7 @@ class MaterialsEditor: public QDialog Q_OBJECT public: - explicit MaterialsEditor(std::shared_ptr filter, + explicit MaterialsEditor(Materials::MaterialFilter filter, QWidget* parent = nullptr); explicit MaterialsEditor(QWidget* parent = nullptr); ~MaterialsEditor() override = default; @@ -121,7 +121,7 @@ private: std::list _recents; int _recentMax; QIcon _warningIcon; - std::shared_ptr _filter; + Materials::MaterialFilter _filter; Materials::MaterialFilterOptions _filterOptions; void setup(); diff --git a/tests/src/Mod/Material/App/TestMaterialFilter.cpp b/tests/src/Mod/Material/App/TestMaterialFilter.cpp index c84c91d6ef..30e646dfa9 100644 --- a/tests/src/Mod/Material/App/TestMaterialFilter.cpp +++ b/tests/src/Mod/Material/App/TestMaterialFilter.cpp @@ -141,104 +141,104 @@ TEST_F(TestMaterialFilter, TestFilters) ASSERT_EQ(material->getUUID().size(), 36); // We don't know the UUID // Create an empty filter - auto filter = std::make_shared(); + Materials::MaterialFilter filter; Materials::MaterialFilterOptions options; ASSERT_TRUE(_library); - auto tree = _materialManager->getMaterialTree(_library, filter, options); + auto tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 4); options.setIncludeLegacy(true); - tree = _materialManager->getMaterialTree(_library, filter, options); + tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 5); // Create a basic rendering filter - filter->setName(QStringLiteral("Basic Appearance")); - filter->addRequiredComplete(Materials::ModelUUIDs::ModelUUID_Rendering_Basic); + filter.setName(QStringLiteral("Basic Appearance")); + filter.addRequiredComplete(Materials::ModelUUIDs::ModelUUID_Rendering_Basic); options.setIncludeLegacy(false); - tree = _materialManager->getMaterialTree(_library, filter, options); + tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 3); options.setIncludeLegacy(true); - tree = _materialManager->getMaterialTree(_library, filter, options); + tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 3); // Create an advanced rendering filter - filter->clear(); - filter->setName(QStringLiteral("Advanced Appearance")); - filter->addRequiredComplete(Materials::ModelUUIDs::ModelUUID_Rendering_Advanced); + filter.clear(); + filter.setName(QStringLiteral("Advanced Appearance")); + filter.addRequiredComplete(Materials::ModelUUIDs::ModelUUID_Rendering_Advanced); options.setIncludeLegacy(false); - tree = _materialManager->getMaterialTree(_library, filter, options); + tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 0); options.setIncludeLegacy(true); - tree = _materialManager->getMaterialTree(_library, filter, options); + tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 0); // Create a Density filter - filter->clear(); - filter->setName(QStringLiteral("Density")); - filter->addRequiredComplete(Materials::ModelUUIDs::ModelUUID_Mechanical_Density); + filter.clear(); + filter.setName(QStringLiteral("Density")); + filter.addRequiredComplete(Materials::ModelUUIDs::ModelUUID_Mechanical_Density); options.setIncludeLegacy(false); - tree = _materialManager->getMaterialTree(_library, filter, options); + tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 2); options.setIncludeLegacy(true); - tree = _materialManager->getMaterialTree(_library, filter, options); + tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 3); // Create a Hardness filter - filter->clear(); - filter->setName(QStringLiteral("Hardness")); - filter->addRequiredComplete(Materials::ModelUUIDs::ModelUUID_Mechanical_Hardness); + filter.clear(); + filter.setName(QStringLiteral("Hardness")); + filter.addRequiredComplete(Materials::ModelUUIDs::ModelUUID_Mechanical_Hardness); options.setIncludeLegacy(false); - tree = _materialManager->getMaterialTree(_library, filter, options); + tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 0); options.setIncludeLegacy(true); - tree = _materialManager->getMaterialTree(_library, filter, options); + tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 0); // Create a Density and Basic Rendering filter - filter->clear(); - filter->setName(QStringLiteral("Density and Basic Rendering")); - filter->addRequiredComplete(Materials::ModelUUIDs::ModelUUID_Rendering_Basic); - filter->addRequiredComplete(Materials::ModelUUIDs::ModelUUID_Mechanical_Density); + filter.clear(); + filter.setName(QStringLiteral("Density and Basic Rendering")); + filter.addRequiredComplete(Materials::ModelUUIDs::ModelUUID_Rendering_Basic); + filter.addRequiredComplete(Materials::ModelUUIDs::ModelUUID_Mechanical_Density); options.setIncludeLegacy(false); - tree = _materialManager->getMaterialTree(_library, filter, options); + tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 1); options.setIncludeLegacy(true); - tree = _materialManager->getMaterialTree(_library, filter, options); + tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 1); // Create a Linear Elastic filter - filter->clear(); - filter->setName(QStringLiteral("Linear Elastic")); - filter->addRequiredComplete(Materials::ModelUUIDs::ModelUUID_Mechanical_LinearElastic); + filter.clear(); + filter.setName(QStringLiteral("Linear Elastic")); + filter.addRequiredComplete(Materials::ModelUUIDs::ModelUUID_Mechanical_LinearElastic); options.setIncludeLegacy(false); - tree = _materialManager->getMaterialTree(_library, filter, options); + tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 0); options.setIncludeLegacy(true); - tree = _materialManager->getMaterialTree(_library, filter, options); + tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 0); - filter->clear(); - filter->setName(QStringLiteral("Linear Elastic")); - filter->addRequired(Materials::ModelUUIDs::ModelUUID_Mechanical_LinearElastic); + filter.clear(); + filter.setName(QStringLiteral("Linear Elastic")); + filter.addRequired(Materials::ModelUUIDs::ModelUUID_Mechanical_LinearElastic); options.setIncludeLegacy(false); - tree = _materialManager->getMaterialTree(_library, filter, options); + tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 2); options.setIncludeLegacy(true); - tree = _materialManager->getMaterialTree(_library, filter, options); + tree = _materialManager->getMaterialTree(*_library, filter, options); ASSERT_EQ(tree->size(), 2); }