| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #ifndef MATERIAL_MATERIALLIBRARY_H |
| | #define MATERIAL_MATERIALLIBRARY_H |
| |
|
| | #include <memory> |
| |
|
| | #include <QDir> |
| | #include <QString> |
| | #include <QVariant> |
| |
|
| | #include <Base/BaseClass.h> |
| | #include <Mod/Material/MaterialGlobal.h> |
| |
|
| | #include "Library.h" |
| | #include "Materials.h" |
| | #include "Model.h" |
| | #include "ModelLibrary.h" |
| |
|
| | namespace Materials |
| | { |
| |
|
| | class Material; |
| | class MaterialManager; |
| | class MaterialFilter; |
| | class MaterialFilterOptions; |
| |
|
| | class MaterialsExport MaterialLibrary |
| | : public Library, |
| | public std::enable_shared_from_this<MaterialLibrary> |
| | { |
| | TYPESYSTEM_HEADER_WITH_OVERRIDE(); |
| |
|
| | public: |
| | MaterialLibrary() = default; |
| | MaterialLibrary(const QString& libraryName, const QString& icon, bool readOnly = true); |
| | MaterialLibrary(const QString& libraryName, |
| | const QString& dir, |
| | const QString& iconPath, |
| | bool readOnly = true); |
| | MaterialLibrary(const Library& library); |
| | MaterialLibrary(const MaterialLibrary&) = delete; |
| | ~MaterialLibrary() override = default; |
| |
|
| | virtual std::shared_ptr<std::map<QString, std::shared_ptr<MaterialTreeNode>>> |
| | getMaterialTree(const Materials::MaterialFilter& filter, |
| | const Materials::MaterialFilterOptions& options) const; |
| |
|
| | |
| | std::shared_ptr<MaterialLibrary> getptr() |
| | { |
| | return shared_from_this(); |
| | } |
| | }; |
| |
|
| | class MaterialsExport MaterialLibraryLocal: public MaterialLibrary |
| | { |
| | TYPESYSTEM_HEADER_WITH_OVERRIDE(); |
| |
|
| | public: |
| | MaterialLibraryLocal() = default; |
| | MaterialLibraryLocal(const QString& libraryName, |
| | const QString& dir, |
| | const QString& iconPath, |
| | bool readOnly = true); |
| | ~MaterialLibraryLocal() override = default; |
| |
|
| | void createFolder(const QString& path); |
| | void renameFolder(const QString& oldPath, const QString& newPath); |
| | void deleteRecursive(const QString& path); |
| |
|
| | std::shared_ptr<Material> saveMaterial(const std::shared_ptr<Material>& material, |
| | const QString& path, |
| | bool overwrite, |
| | bool saveAsCopy, |
| | bool saveInherited); |
| | bool fileExists(const QString& path) const; |
| | std::shared_ptr<Material> addMaterial(const std::shared_ptr<Material>& material, |
| | const QString& path); |
| | std::shared_ptr<Material> getMaterialByPath(const QString& path) const; |
| |
|
| | bool operator==(const MaterialLibrary& library) const |
| | { |
| | return library.isLocal() ? Library::operator==(library) : false; |
| | } |
| | bool operator!=(const MaterialLibrary& library) const |
| | { |
| | return !operator==(library); |
| | } |
| |
|
| | bool operator==(const MaterialLibraryLocal& library) const |
| | { |
| | return Library::operator==(library); |
| | } |
| | bool operator!=(const MaterialLibraryLocal& library) const |
| | { |
| | return !operator==(library); |
| | } |
| |
|
| | protected: |
| | void deleteDir(MaterialManager& manager, const QString& path); |
| | void deleteFile(MaterialManager& manager, const QString& path); |
| | void updatePaths(const QString& oldPath, const QString& newPath); |
| |
|
| | QString getUUIDFromPath(const QString& path) const; |
| |
|
| | std::unique_ptr<std::map<QString, std::shared_ptr<Material>>> _materialPathMap; |
| | }; |
| |
|
| | } |
| |
|
| | Q_DECLARE_METATYPE(std::shared_ptr<Materials::MaterialLibrary>) |
| | Q_DECLARE_METATYPE(std::shared_ptr<Materials::MaterialLibraryLocal>) |
| |
|
| | #endif |
| |
|