Materials: Model Manager External Interface (#20825)

* Materials: Model Manager External Interface

Implement the ModelManagerExternal class for the external Materials
interface.

This is part of the ongoing merges of code to support external material
interfaces. In this PR the ModelManagerExternal class is implemented,
along with changes to supporting classes required for this class.

* Apply reviewer feedback
This commit is contained in:
David Carter
2025-04-28 08:29:04 -07:00
committed by GitHub
parent 1d0e6b368d
commit 827ff3eb99
14 changed files with 676 additions and 110 deletions

View File

@@ -35,6 +35,7 @@
#include "Library.h"
#include "MaterialValue.h"
#include "Model.h"
namespace Materials
{
@@ -45,12 +46,44 @@ class MaterialsExport ModelLibrary: public Library,
public:
ModelLibrary();
ModelLibrary(const Library& other);
ModelLibrary(const QString& libraryName,
const QString& dir,
const QString& icon,
bool readOnly = true);
ModelLibrary(const ModelLibrary& other) = delete;
~ModelLibrary() override = default;
bool isLocal() const;
void setLocal(bool local);
std::shared_ptr<std::map<QString, std::shared_ptr<ModelTreeNode>>>
getModelTree(ModelFilter filter) const;
// Use this to get a shared_ptr for *this
std::shared_ptr<ModelLibrary> getptr()
{
return shared_from_this();
}
private:
bool _local;
};
class MaterialsExport ModelLibraryLocal: public ModelLibrary
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
ModelLibraryLocal();
ModelLibraryLocal(const Library& other);
ModelLibraryLocal(const QString& libraryName,
const QString& dir,
const QString& icon,
bool readOnly = true);
ModelLibraryLocal(const ModelLibraryLocal& other) = delete;
~ModelLibraryLocal() override = default;
bool operator==(const ModelLibrary& library) const
{
return Library::operator==(library);
@@ -63,16 +96,7 @@ public:
std::shared_ptr<Model> addModel(const Model& model, const QString& path);
// Use this to get a shared_ptr for *this
std::shared_ptr<ModelLibrary> getptr()
{
return shared_from_this();
}
std::shared_ptr<std::map<QString, std::shared_ptr<ModelTreeNode>>>
getModelTree(ModelFilter filter) const;
private:
ModelLibrary(const ModelLibrary&);
std::unique_ptr<std::map<QString, std::shared_ptr<Model>>> _modelPathMap;
};
@@ -80,5 +104,6 @@ private:
} // namespace Materials
Q_DECLARE_METATYPE(std::shared_ptr<Materials::ModelLibrary>)
Q_DECLARE_METATYPE(std::shared_ptr<Materials::ModelLibraryLocal>)
#endif // MATERIAL_MODELLIBRARY_H