Material: Material handling enhancements

Rework of the material handling system.

This first part concntrates on a rework of the material cards.
Rather than use a fixed list of possible properties, properties can
be defined separately in their own files and mixed to provide a
complete list of possible properties. Properties can be inherited.

The cards then provide values for the properties. These can also
be inherited allowing for small changes in cards as required.

The new property definitions are more extensive than previously.
2 and 3 dimensional arrays of properties can be defined. Values
are obtained by calling an API instead of reading from a dictionary.

For compatibility, a Python dictionary of values can be obtained
similar to how it was done previously, but this is considered a
deprecated API and won't support the newer advanced features.

The editor is completely reworked. It will be able to edit older format
material cards, but can only save them in the new format.

For testing during the development phase, a system preference can
specifiy wether the old or new material editors are to be used. This
option will be removed before release.
This commit is contained in:
David Carter
2023-09-25 07:33:07 -04:00
parent 6624fa3775
commit 442bca834e
64 changed files with 1303 additions and 1235 deletions

View File

@@ -1,26 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License (LGPL) *
* as published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* for detail see the LICENCE text file. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* FreeCAD is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with FreeCAD; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -45,7 +42,7 @@ public:
Module()
: Py::ExtensionModule<Module>("Material")
{
initialize("This module is the Material module.");// register with Python
initialize("This module is the Material module."); // register with Python
}
~Module() override = default;
@@ -58,7 +55,7 @@ PyObject* initModule()
return Base::Interpreter().addModule(new Module);
}
}// namespace Materials
} // namespace Materials
PyMOD_INIT_FUNC(Material)
{

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATERIAL_EXCEPTIONS_H
#define MATERIAL_EXCEPTIONS_H
@@ -38,7 +37,7 @@ public:
{
this->setMessage(msg);
}
~Uninitialized() throw() override = default;
~Uninitialized() noexcept override = default;
};
class ModelNotFound: public Base::Exception
@@ -50,7 +49,7 @@ public:
{
this->setMessage(msg);
}
~ModelNotFound() throw() override = default;
~ModelNotFound() noexcept override = default;
};
class MaterialNotFound: public Base::Exception
@@ -62,7 +61,7 @@ public:
{
this->setMessage(msg);
}
~MaterialNotFound() throw() override = default;
~MaterialNotFound() noexcept override = default;
};
class PropertyNotFound: public Base::Exception
@@ -74,7 +73,7 @@ public:
{
this->setMessage(msg);
}
~PropertyNotFound() throw() override = default;
~PropertyNotFound() noexcept override = default;
};
class LibraryNotFound: public Base::Exception
@@ -86,7 +85,7 @@ public:
{
this->setMessage(msg);
}
~LibraryNotFound() throw() override = default;
~LibraryNotFound() noexcept override = default;
};
class InvalidModel: public Base::Exception
@@ -98,7 +97,7 @@ public:
{
this->setMessage(msg);
}
~InvalidModel() throw() override = default;
~InvalidModel() noexcept override = default;
};
class InvalidRow: public Base::Exception
@@ -110,7 +109,7 @@ public:
{
this->setMessage(msg);
}
~InvalidRow() throw() override = default;
~InvalidRow() noexcept override = default;
};
class InvalidColumn: public Base::Exception
@@ -122,7 +121,7 @@ public:
{
this->setMessage(msg);
}
~InvalidColumn() throw() override = default;
~InvalidColumn() noexcept override = default;
};
class InvalidIndex: public Base::Exception
@@ -134,7 +133,7 @@ public:
{
this->setMessage(msg);
}
~InvalidIndex() throw() override = default;
~InvalidIndex() noexcept override = default;
};
class UnknownValueType: public Base::Exception
@@ -146,9 +145,9 @@ public:
{
this->setMessage(msg);
}
~UnknownValueType() throw() override = default;
~UnknownValueType() noexcept override = default;
};
}// namespace Materials
} // namespace Materials
#endif// MATERIAL_EXCEPTIONS_H
#endif // MATERIAL_EXCEPTIONS_H

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATERIAL_FOLDERTREE_H
#define MATERIAL_FOLDERTREE_H
@@ -43,7 +42,7 @@ public:
{}
virtual ~FolderTreeNode() = default;
NodeType getType(void) const
NodeType getType() const
{
return _type;
}
@@ -52,20 +51,20 @@ public:
_type = type;
}
const std::map<QString, FolderTreeNode<T>*>* getFolder(void) const
const std::shared_ptr<std::map<QString, FolderTreeNode<T>*>> getFolder() const
{
return _folder;
}
std::map<QString, FolderTreeNode<T>*>* getFolder(void)
std::shared_ptr<std::map<QString, FolderTreeNode<T>*>> getFolder()
{
return _folder;
}
const T* getData(void) const
const T* getData() const
{
return _data;
}
void setFolder(std::map<QString, FolderTreeNode<T>*>* folder)
void setFolder(std::shared_ptr<std::map<QString, FolderTreeNode<T>*>> folder)
{
setType(FolderNode);
_folder = folder;
@@ -78,10 +77,10 @@ public:
private:
NodeType _type;
std::map<QString, FolderTreeNode<T>*>* _folder;
std::shared_ptr<std::map<QString, FolderTreeNode<T>*>> _folder;
const T* _data;
};
}// namespace Materials
} // namespace Materials
#endif// MATERIAL_FOLDERTREE_H
#endif // MATERIAL_FOLDERTREE_H

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -378,7 +377,7 @@ Material* MaterialConfigLoader::getMaterialFromPath(const MaterialLibrary& libra
// Now add the data
setPhysicalValue(finalModel, "KindOfMaterial", kindOfMaterial);
setPhysicalValue(finalModel, "MaterialNumber", materialNumber);
setPhysicalValue(finalModel, "StandardCode", norm);// Norm is the same as StandardCode
setPhysicalValue(finalModel, "StandardCode", norm); // Norm is the same as StandardCode
setPhysicalValue(finalModel, "StandardCode", standardCode);
}

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATERIAL_MATERIALCONFIGLOADER_H
#define MATERIAL_MATERIALCONFIGLOADER_H
@@ -76,6 +75,6 @@ private:
static void addVectorRendering(const QSettings& fcmat, Material* finalModel);
};
}// namespace Materials
} // namespace Materials
#endif// MATERIAL_MATERIALCONFIGLOADER_H
#endif // MATERIAL_MATERIALCONFIGLOADER_H

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -35,16 +34,13 @@ using namespace Materials;
/* TRANSLATOR Material::Materials */
std::map<QString, Material*>* MaterialLibrary::_materialPathMap = nullptr;
std::unique_ptr<std::map<QString, Material*>> MaterialLibrary::_materialPathMap =
std::make_unique<std::map<QString, Material*>>();
TYPESYSTEM_SOURCE(Materials::MaterialLibrary, LibraryBase)
MaterialLibrary::MaterialLibrary()
{
if (_materialPathMap == nullptr) {
_materialPathMap = new std::map<QString, Material*>();
}
}
{}
MaterialLibrary::MaterialLibrary(const QString& libraryName,
const QString& dir,
@@ -52,11 +48,7 @@ MaterialLibrary::MaterialLibrary(const QString& libraryName,
bool readOnly)
: LibraryBase(libraryName, dir, icon)
, _readOnly(readOnly)
{
if (_materialPathMap == nullptr) {
_materialPathMap = new std::map<QString, Material*>();
}
}
{}
void MaterialLibrary::createPath(const QString& path)
{

View File

@@ -1,28 +1,29 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATERIAL_MATERIALLIBRARY_H
#define MATERIAL_MATERIALLIBRARY_H
#include <Mod/Material/MaterialGlobal.h>
#include <Base/BaseClass.h>
#include <QDir>
#include <QString>
@@ -46,7 +47,7 @@ public:
const QString& dir,
const QString& icon,
bool readOnly = true);
virtual ~MaterialLibrary() = default;
~MaterialLibrary() override = default;
bool operator==(const MaterialLibrary& library) const
{
@@ -71,7 +72,7 @@ protected:
const QString getUUIDFromPath(const QString& path) const;
bool _readOnly;
static std::map<QString, Material*>* _materialPathMap;
static std::unique_ptr<std::map<QString, Material*>> _materialPathMap;
};
class MaterialsExport MaterialExternalLibrary: public MaterialLibrary
@@ -84,12 +85,12 @@ public:
const QString& dir,
const QString& icon,
bool readOnly = true);
virtual ~MaterialExternalLibrary();
~MaterialExternalLibrary() override;
};
}// namespace Materials
} // namespace Materials
Q_DECLARE_METATYPE(Materials::MaterialLibrary)
Q_DECLARE_METATYPE(Materials::MaterialExternalLibrary)
#endif// MATERIAL_MATERIALLIBRARY_H
#endif // MATERIAL_MATERIALLIBRARY_H

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -74,7 +73,7 @@ QString MaterialYamlEntry::yamlValue(const YAML::Node& node,
return QString::fromStdString(defaultValue);
}
void MaterialYamlEntry::addToTree(std::map<QString, Material*>* materialMap)
void MaterialYamlEntry::addToTree(std::shared_ptr<std::map<QString, Material*>> materialMap)
{
std::set<QString> exclude;
exclude.insert(QString::fromStdString("General"));
@@ -100,7 +99,7 @@ void MaterialYamlEntry::addToTree(std::map<QString, Material*>* materialMap)
std::string nodeName = it->second["UUID"].as<std::string>();
finalModel->setParentUUID(
QString::fromStdString(nodeName));// Should only be one. Need to check
QString::fromStdString(nodeName)); // Should only be one. Need to check
}
}
@@ -167,10 +166,10 @@ void MaterialYamlEntry::addToTree(std::map<QString, Material*>* materialMap)
(*materialMap)[uuid] = library.addMaterial(*finalModel, path);
}
std::map<QString, MaterialEntry*>* MaterialLoader::_materialEntryMap = nullptr;
std::unique_ptr<std::map<QString, MaterialEntry*>> MaterialLoader::_materialEntryMap = nullptr;
MaterialLoader::MaterialLoader(std::map<QString, Material*>* materialMap,
std::list<MaterialLibrary*>* libraryList)
MaterialLoader::MaterialLoader(std::shared_ptr<std::map<QString, Material*>> materialMap,
std::shared_ptr<std::list<MaterialLibrary*>> libraryList)
: _materialMap(materialMap)
, _libraryList(libraryList)
{
@@ -313,7 +312,7 @@ void MaterialLoader::dereference(Material* material)
void MaterialLoader::loadLibrary(MaterialLibrary& library)
{
if (_materialEntryMap == nullptr) {
_materialEntryMap = new std::map<QString, MaterialEntry*>();
_materialEntryMap = std::make_unique<std::map<QString, MaterialEntry*>>();
}
QDirIterator it(library.getDirectory(), QDirIterator::Subdirectories);
@@ -337,9 +336,9 @@ void MaterialLoader::loadLibrary(MaterialLibrary& library)
}
}
void MaterialLoader::loadLibraries(void)
void MaterialLoader::loadLibraries()
{
std::list<MaterialLibrary*>* _libraryList = getMaterialLibraries();
auto _libraryList = getMaterialLibraries();
if (_libraryList) {
for (auto it = _libraryList->begin(); it != _libraryList->end(); it++) {
loadLibrary(**it);
@@ -351,7 +350,7 @@ void MaterialLoader::loadLibraries(void)
}
}
std::list<MaterialLibrary*>* MaterialLoader::getMaterialLibraries()
std::shared_ptr<std::list<MaterialLibrary*>> MaterialLoader::getMaterialLibraries()
{
auto param = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Material/Resources");
@@ -426,9 +425,10 @@ std::list<MaterialLibrary*>* MaterialLoader::getMaterialLibraries()
return _libraryList;
}
std::list<QString>* MaterialLoader::getMaterialFolders(const MaterialLibrary& library)
std::shared_ptr<std::list<QString>>
MaterialLoader::getMaterialFolders(const MaterialLibrary& library)
{
std::list<QString>* pathList = new std::list<QString>();
std::shared_ptr<std::list<QString>> pathList = std::make_shared<std::list<QString>>();
QDirIterator it(library.getDirectory(), QDirIterator::Subdirectories);
while (it.hasNext()) {
auto pathname = it.next();

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATERIAL_MATERIALLOADER_H
#define MATERIAL_MATERIALLOADER_H
@@ -43,7 +42,7 @@ public:
const QString& modelUuid);
virtual ~MaterialEntry() = default;
virtual void addToTree(std::map<QString, Material*>* materialMap) = 0;
virtual void addToTree(std::shared_ptr<std::map<QString, Material*>> materialMap) = 0;
const MaterialLibrary& getLibrary() const
{
@@ -79,7 +78,7 @@ public:
const YAML::Node& modelData);
~MaterialYamlEntry() override = default;
void addToTree(std::map<QString, Material*>* materialMap) override;
void addToTree(std::shared_ptr<std::map<QString, Material*>> materialMap) override;
const YAML::Node& getModel() const
{
@@ -102,12 +101,12 @@ private:
class MaterialLoader
{
public:
explicit MaterialLoader(std::map<QString, Material*>* materialMap,
std::list<MaterialLibrary*>* libraryList);
explicit MaterialLoader(std::shared_ptr<std::map<QString, Material*>> materialMap,
std::shared_ptr<std::list<MaterialLibrary*>> libraryList);
virtual ~MaterialLoader();
std::list<MaterialLibrary*>* getMaterialLibraries();
static std::list<QString>* getMaterialFolders(const MaterialLibrary& library);
std::shared_ptr<std::list<MaterialLibrary*>> getMaterialLibraries();
static std::shared_ptr<std::list<QString>> getMaterialFolders(const MaterialLibrary& library);
static void showYaml(const YAML::Node& yaml);
private:
@@ -118,12 +117,12 @@ private:
MaterialEntry* getMaterialFromPath(MaterialLibrary& library, const QString& path) const;
void addLibrary(MaterialLibrary* model);
void loadLibrary(MaterialLibrary& library);
void loadLibraries(void);
static std::map<QString, MaterialEntry*>* _materialEntryMap;
std::map<QString, Material*>* _materialMap;
std::list<MaterialLibrary*>* _libraryList;
void loadLibraries();
static std::unique_ptr<std::map<QString, MaterialEntry*>> _materialEntryMap;
std::shared_ptr<std::map<QString, Material*>> _materialMap;
std::shared_ptr<std::list<MaterialLibrary*>> _libraryList;
};
}// namespace Materials
} // namespace Materials
#endif// MATERIAL_MATERIALLOADER_H
#endif // MATERIAL_MATERIALLOADER_H

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -38,8 +37,8 @@ using namespace Materials;
/* TRANSLATOR Material::Materials */
std::list<MaterialLibrary*>* MaterialManager::_libraryList = nullptr;
std::map<QString, Material*>* MaterialManager::_materialMap = nullptr;
std::shared_ptr<std::list<MaterialLibrary*>> MaterialManager::_libraryList = nullptr;
std::shared_ptr<std::map<QString, Material*>> MaterialManager::_materialMap = nullptr;
QMutex MaterialManager::_mutex;
TYPESYSTEM_SOURCE(Materials::MaterialManager, Base::BaseClass)
@@ -61,10 +60,10 @@ void MaterialManager::initLibraries()
delete manager;
_materialMap = new std::map<QString, Material*>();
_materialMap = std::make_shared<std::map<QString, Material*>>();
if (_libraryList == nullptr) {
_libraryList = new std::list<MaterialLibrary*>();
_libraryList = std::make_shared<std::list<MaterialLibrary*>>();
}
// Load the libraries
@@ -139,8 +138,8 @@ const Material& MaterialManager::getMaterialByPath(const QString& path) const
const Material& MaterialManager::getMaterialByPath(const QString& path, const QString& lib) const
{
auto library = getLibrary(lib); // May throw LibraryNotFound
return library->getMaterialByPath(path);// May throw MaterialNotFound
auto library = getLibrary(lib); // May throw LibraryNotFound
return library->getMaterialByPath(path); // May throw MaterialNotFound
}
MaterialLibrary* MaterialManager::getLibrary(const QString& name) const
@@ -154,13 +153,13 @@ MaterialLibrary* MaterialManager::getLibrary(const QString& name) const
throw LibraryNotFound();
}
std::list<MaterialLibrary*>* MaterialManager::getMaterialLibraries()
std::shared_ptr<std::list<MaterialLibrary*>> MaterialManager::getMaterialLibraries()
{
if (_libraryList == nullptr) {
if (_materialMap == nullptr) {
_materialMap = new std::map<QString, Material*>();
_materialMap = std::make_shared<std::map<QString, Material*>>();
}
_libraryList = new std::list<MaterialLibrary*>();
_libraryList = std::make_shared<std::list<MaterialLibrary*>>();
// Load the libraries
MaterialLoader loader(_materialMap, _libraryList);
@@ -168,10 +167,11 @@ std::list<MaterialLibrary*>* MaterialManager::getMaterialLibraries()
return _libraryList;
}
std::map<QString, MaterialTreeNode*>*
MaterialManager::getMaterialTree(const MaterialLibrary& library)
std::shared_ptr<std::map<QString, MaterialTreeNode*>>
MaterialManager::getMaterialTree(const MaterialLibrary& library) const
{
std::map<QString, MaterialTreeNode*>* materialTree = new std::map<QString, MaterialTreeNode*>();
std::shared_ptr<std::map<QString, MaterialTreeNode*>> materialTree =
std::make_shared<std::map<QString, MaterialTreeNode*>>();
for (auto it = _materialMap->begin(); it != _materialMap->end(); it++) {
auto filename = it->first;
@@ -181,7 +181,7 @@ MaterialManager::getMaterialTree(const MaterialLibrary& library)
fs::path path = material->getDirectory().toStdString();
// Start at the root
std::map<QString, MaterialTreeNode*>* node = materialTree;
auto node = materialTree;
for (auto itp = path.begin(); itp != path.end(); itp++) {
if (QString::fromStdString(itp->string())
.endsWith(QString::fromStdString(".FCMat"))) {
@@ -192,9 +192,9 @@ MaterialManager::getMaterialTree(const MaterialLibrary& library)
else {
// Add the folder only if it's not already there
QString folderName = QString::fromStdString(itp->string());
std::map<QString, MaterialTreeNode*>* mapPtr;
std::shared_ptr<std::map<QString, MaterialTreeNode*>> mapPtr;
if (node->count(folderName) == 0) {
mapPtr = new std::map<QString, MaterialTreeNode*>();
mapPtr = std::make_shared<std::map<QString, MaterialTreeNode*>>();
MaterialTreeNode* child = new MaterialTreeNode();
child->setFolder(mapPtr);
(*node)[folderName] = child;
@@ -208,18 +208,18 @@ MaterialManager::getMaterialTree(const MaterialLibrary& library)
}
}
std::list<QString>* folderList = getMaterialFolders(library);
auto folderList = getMaterialFolders(library);
for (auto folder : *folderList) {
fs::path path = folder.toStdString();
// Start at the root
std::map<QString, MaterialTreeNode*>* node = materialTree;
auto node = materialTree;
for (auto itp = path.begin(); itp != path.end(); itp++) {
// Add the folder only if it's not already there
QString folderName = QString::fromStdString(itp->string());
if (node->count(folderName) == 0) {
std::map<QString, MaterialTreeNode*>* mapPtr =
new std::map<QString, MaterialTreeNode*>();
std::shared_ptr<std::map<QString, MaterialTreeNode*>> mapPtr =
std::make_shared<std::map<QString, MaterialTreeNode*>>();
MaterialTreeNode* child = new MaterialTreeNode();
child->setFolder(mapPtr);
(*node)[folderName] = child;
@@ -230,19 +230,20 @@ MaterialManager::getMaterialTree(const MaterialLibrary& library)
}
}
}
delete folderList;
return materialTree;
}
std::list<QString>* MaterialManager::getMaterialFolders(const MaterialLibrary& library)
std::shared_ptr<std::list<QString>>
MaterialManager::getMaterialFolders(const MaterialLibrary& library) const
{
return MaterialLoader::getMaterialFolders(library);
}
std::map<QString, Material*>* MaterialManager::materialsWithModel(QString uuid)
std::shared_ptr<std::map<QString, Material*>> MaterialManager::materialsWithModel(QString uuid)
{
std::map<QString, Material*>* dict = new std::map<QString, Material*>();
std::shared_ptr<std::map<QString, Material*>> dict =
std::make_shared<std::map<QString, Material*>>();
for (auto it = _materialMap->begin(); it != _materialMap->end(); it++) {
QString key = it->first;
@@ -256,9 +257,11 @@ std::map<QString, Material*>* MaterialManager::materialsWithModel(QString uuid)
return dict;
}
std::map<QString, Material*>* MaterialManager::materialsWithModelComplete(QString uuid)
std::shared_ptr<std::map<QString, Material*>>
MaterialManager::materialsWithModelComplete(QString uuid)
{
std::map<QString, Material*>* dict = new std::map<QString, Material*>();
std::shared_ptr<std::map<QString, Material*>> dict =
std::make_shared<std::map<QString, Material*>>();
for (auto it = _materialMap->begin(); it != _materialMap->end(); it++) {
QString key = it->first;

View File

@@ -1,28 +1,29 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATERIAL_MATERIALMANAGER_H
#define MATERIAL_MATERIALMANAGER_H
#include <Mod/Material/MaterialGlobal.h>
#include <QMutex>
#include <boost/filesystem.hpp>
@@ -43,9 +44,9 @@ class MaterialsExport MaterialManager: public Base::BaseClass
public:
MaterialManager();
virtual ~MaterialManager() = default;
~MaterialManager() override = default;
std::map<QString, Material*>* getMaterials()
std::shared_ptr<std::map<QString, Material*>> getMaterials()
{
return _materialMap;
}
@@ -55,9 +56,10 @@ public:
MaterialLibrary* getLibrary(const QString& name) const;
// Library management
static std::list<MaterialLibrary*>* getMaterialLibraries();
std::map<QString, MaterialTreeNode*>* getMaterialTree(const MaterialLibrary& library);
std::list<QString>* getMaterialFolders(const MaterialLibrary& library);
static std::shared_ptr<std::list<MaterialLibrary*>> getMaterialLibraries();
std::shared_ptr<std::map<QString, MaterialTreeNode*>>
getMaterialTree(const MaterialLibrary& library) const;
std::shared_ptr<std::list<QString>> getMaterialFolders(const MaterialLibrary& library) const;
void createPath(MaterialLibrary* library, const QString& path)
{
library->createPath(path);
@@ -69,17 +71,17 @@ public:
static bool isMaterial(const fs::path& p);
std::map<QString, Material*>* materialsWithModel(QString uuid);
std::map<QString, Material*>* materialsWithModelComplete(QString uuid);
std::shared_ptr<std::map<QString, Material*>> materialsWithModel(QString uuid);
std::shared_ptr<std::map<QString, Material*>> materialsWithModelComplete(QString uuid);
private:
static std::list<MaterialLibrary*>* _libraryList;
static std::map<QString, Material*>* _materialMap;
static std::shared_ptr<std::list<MaterialLibrary*>> _libraryList;
static std::shared_ptr<std::map<QString, Material*>> _materialMap;
static QMutex _mutex;
static void initLibraries();
};
}// namespace Materials
} // namespace Materials
#endif// MATERIAL_MATERIALMANAGER_H
#endif // MATERIAL_MATERIALMANAGER_H

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
@@ -45,7 +44,7 @@ std::string MaterialManagerPy::representation() const
return str.str();
}
PyObject* MaterialManagerPy::PyMake(struct _typeobject*, PyObject*, PyObject*)// Python wrapper
PyObject* MaterialManagerPy::PyMake(struct _typeobject*, PyObject*, PyObject*) // Python wrapper
{
// never create such objects with the constructor
return new MaterialManagerPy(new MaterialManager());
@@ -113,7 +112,7 @@ PyObject* MaterialManagerPy::getMaterialByPath(PyObject* args)
Py::List MaterialManagerPy::getMaterialLibraries() const
{
std::list<MaterialLibrary*>* libraries = getMaterialManagerPtr()->getMaterialLibraries();
auto libraries = getMaterialManagerPtr()->getMaterialLibraries();
Py::List list;
for (auto it = libraries->begin(); it != libraries->end(); it++) {
@@ -133,7 +132,7 @@ Py::Dict MaterialManagerPy::getMaterials() const
{
Py::Dict dict;
std::map<QString, Material*>* materials = getMaterialManagerPtr()->getMaterials();
auto materials = getMaterialManagerPtr()->getMaterials();
for (auto it = materials->begin(); it != materials->end(); it++) {
QString key = it->first;
@@ -164,8 +163,7 @@ PyObject* MaterialManagerPy::materialsWithModel(PyObject* args)
return nullptr;
}
std::map<QString, Material*>* materials =
getMaterialManagerPtr()->materialsWithModel(QString::fromStdString(uuid));
auto materials = getMaterialManagerPtr()->materialsWithModel(QString::fromStdString(uuid));
PyObject* dict = PyDict_New();
for (auto it = materials->begin(); it != materials->end(); it++) {
@@ -175,7 +173,6 @@ PyObject* MaterialManagerPy::materialsWithModel(PyObject* args)
PyObject* materialPy = new MaterialPy(new Material(*material));
PyDict_SetItem(dict, PyUnicode_FromString(key.toStdString().c_str()), materialPy);
}
delete materials;
return dict;
}
@@ -187,7 +184,7 @@ PyObject* MaterialManagerPy::materialsWithModelComplete(PyObject* args)
return nullptr;
}
std::map<QString, Material*>* materials =
auto materials =
getMaterialManagerPtr()->materialsWithModelComplete(QString::fromStdString(uuid));
PyObject* dict = PyDict_New();
@@ -198,7 +195,6 @@ PyObject* MaterialManagerPy::materialsWithModelComplete(PyObject* args)
PyObject* materialPy = new MaterialPy(new Material(*material));
PyDict_SetItem(dict, PyUnicode_FromString(key.toStdString().c_str()), materialPy);
}
delete materials;
return dict;
}

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
@@ -80,7 +79,7 @@ std::string MaterialPy::representation() const
return str.str();
}
PyObject* MaterialPy::PyMake(struct _typeobject*, PyObject*, PyObject*)// Python wrapper
PyObject* MaterialPy::PyMake(struct _typeobject*, PyObject*, PyObject*) // Python wrapper
{
// never create such objects with the constructor
return new MaterialPy(new Material());

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -109,7 +108,7 @@ void Material2DArray::setValue(int row, int column, const QVariant& value)
}
}
const QVariant Material2DArray::getValue(int row, int column)
const QVariant Material2DArray::getValue(int row, int column) const
{
try {
auto val = getRow(row);

View File

@@ -1,28 +1,29 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATERIAL_MATERIALVALUE_H
#define MATERIAL_MATERIALVALUE_H
#include <Mod/Material/MaterialGlobal.h>
#include <QVariant>
namespace Materials
@@ -52,12 +53,12 @@ public:
explicit MaterialValue(ValueType type);
virtual ~MaterialValue() = default;
ValueType getType()
ValueType getType() const
{
return _valueType;
}
const QVariant getValue(void) const
const QVariant getValue() const
{
return _value;
}
@@ -118,7 +119,7 @@ public:
void deleteRow(int row);
void setValue(int row, int column, const QVariant& value);
const QVariant getValue(int row, int column);
const QVariant getValue(int row, int column) const;
protected:
std::vector<std::vector<QVariant>*> _rows;
@@ -178,10 +179,10 @@ protected:
bool _defaultSet;
};
}// namespace Materials
} // namespace Materials
Q_DECLARE_METATYPE(Materials::MaterialValue)
Q_DECLARE_METATYPE(Materials::Material2DArray)
Q_DECLARE_METATYPE(Materials::Material3DArray)
#endif// MATERIAL_MATERIALVALUE_H
#endif // MATERIAL_MATERIALVALUE_H

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -43,7 +42,7 @@ TYPESYSTEM_SOURCE(Materials::MaterialProperty, Materials::ModelProperty)
MaterialProperty::MaterialProperty()
{
_valuePtr = new MaterialValue(MaterialValue::None);
_valuePtr = std::make_shared<MaterialValue>(MaterialValue::None);
}
MaterialProperty::MaterialProperty(const ModelProperty& property)
@@ -59,10 +58,10 @@ MaterialProperty::MaterialProperty(const ModelProperty& property)
}
if (_valuePtr->getType() == MaterialValue::Array2D) {
reinterpret_cast<Material2DArray*>(_valuePtr)->setDefault(getColumnNull(0));
std::static_pointer_cast<Material2DArray>(_valuePtr)->setDefault(getColumnNull(0));
}
else if (_valuePtr->getType() == MaterialValue::Array3D) {
reinterpret_cast<Material3DArray*>(_valuePtr)->setDefault(getColumnNull(0));
std::static_pointer_cast<Material3DArray>(_valuePtr)->setDefault(getColumnNull(0));
}
}
@@ -71,7 +70,7 @@ MaterialProperty::MaterialProperty(const MaterialProperty& other)
{
_modelUUID = other._modelUUID;
if (other._valuePtr != nullptr) {
_valuePtr = new MaterialValue(*(other._valuePtr));
_valuePtr = std::make_shared<MaterialValue>(*(other._valuePtr));
}
else {
_valuePtr = nullptr;
@@ -82,25 +81,30 @@ MaterialProperty::MaterialProperty(const MaterialProperty& other)
}
}
MaterialProperty::~MaterialProperty()
{}
// MaterialProperty::~MaterialProperty()
// {}
void MaterialProperty::setModelUUID(const QString& uuid)
{
_modelUUID = uuid;
}
const QVariant MaterialProperty::getValue(void) const
const QVariant MaterialProperty::getValue() const
{
return _valuePtr->getValue();
}
MaterialValue* MaterialProperty::getMaterialValue(void)
std::shared_ptr<MaterialValue> MaterialProperty::getMaterialValue()
{
return _valuePtr;
}
const QString MaterialProperty::getString(void) const
const std::shared_ptr<MaterialValue> MaterialProperty::getMaterialValue() const
{
return _valuePtr;
}
const QString MaterialProperty::getString() const
{
if (getType() == MaterialValue::Quantity) {
Base::Quantity quantity = getValue().value<Base::Quantity>();
@@ -117,49 +121,45 @@ void MaterialProperty::setPropertyType(const QString& type)
void MaterialProperty::setType(const QString& type)
{
if (_valuePtr) {
delete _valuePtr;
}
if (type == QString::fromStdString("String")) {
_valuePtr = new MaterialValue(MaterialValue::String);
_valuePtr = std::make_shared<MaterialValue>(MaterialValue::String);
}
else if (type == QString::fromStdString("Boolean")) {
_valuePtr = new MaterialValue(MaterialValue::Boolean);
_valuePtr = std::make_shared<MaterialValue>(MaterialValue::Boolean);
}
else if (type == QString::fromStdString("Integer")) {
_valuePtr = new MaterialValue(MaterialValue::Integer);
_valuePtr = std::make_shared<MaterialValue>(MaterialValue::Integer);
}
else if (type == QString::fromStdString("Float")) {
_valuePtr = new MaterialValue(MaterialValue::Float);
_valuePtr = std::make_shared<MaterialValue>(MaterialValue::Float);
}
else if (type == QString::fromStdString("URL")) {
_valuePtr = new MaterialValue(MaterialValue::URL);
_valuePtr = std::make_shared<MaterialValue>(MaterialValue::URL);
}
else if (type == QString::fromStdString("Quantity")) {
_valuePtr = new MaterialValue(MaterialValue::Quantity);
_valuePtr = std::make_shared<MaterialValue>(MaterialValue::Quantity);
}
else if (type == QString::fromStdString("Color")) {
_valuePtr = new MaterialValue(MaterialValue::Color);
_valuePtr = std::make_shared<MaterialValue>(MaterialValue::Color);
}
else if (type == QString::fromStdString("File")) {
_valuePtr = new MaterialValue(MaterialValue::File);
_valuePtr = std::make_shared<MaterialValue>(MaterialValue::File);
}
else if (type == QString::fromStdString("Image")) {
_valuePtr = new MaterialValue(MaterialValue::Image);
_valuePtr = std::make_shared<MaterialValue>(MaterialValue::Image);
}
else if (type == QString::fromStdString("List")) {
_valuePtr = new MaterialValue(MaterialValue::List);
_valuePtr = std::make_shared<MaterialValue>(MaterialValue::List);
}
else if (type == QString::fromStdString("2DArray")) {
_valuePtr = new Material2DArray();
_valuePtr = std::make_shared<Material2DArray>();
}
else if (type == QString::fromStdString("3DArray")) {
_valuePtr = new Material3DArray();
_valuePtr = std::make_shared<Material3DArray>();
}
else {
// Error. Throw something
_valuePtr = new MaterialValue(MaterialValue::None);
_valuePtr = std::make_shared<MaterialValue>(MaterialValue::None);
std::string stringType = type.toStdString();
std::string name = getName().toStdString();
throw UnknownValueType();
@@ -176,6 +176,16 @@ MaterialProperty& MaterialProperty::getColumn(int column)
}
}
const MaterialProperty& MaterialProperty::getColumn(int column) const
{
try {
return _columns.at(column);
}
catch (std::out_of_range const&) {
throw InvalidColumn();
}
}
MaterialValue::ValueType MaterialProperty::getColumnType(int column) const
{
try {
@@ -337,9 +347,9 @@ MaterialProperty& MaterialProperty::operator=(const MaterialProperty& other)
ModelProperty::operator=(other);
_modelUUID = other._modelUUID;
delete _valuePtr;
if (other._valuePtr != nullptr) {
_valuePtr = new MaterialValue(*(other._valuePtr));
_valuePtr = std::make_shared<MaterialValue>(*(other._valuePtr));
}
else {
_valuePtr = nullptr;
@@ -531,7 +541,7 @@ void Material::setPhysicalValue(const QString& name, const QString& value)
{
setPhysicalEditState(name);
_physical[name].setValue(value);// may not be a string type
_physical[name].setValue(value); // may not be a string type
}
void Material::setPhysicalValue(const QString& name, int value)
@@ -559,7 +569,7 @@ void Material::setAppearanceValue(const QString& name, const QString& value)
{
setAppearanceEditState(name);
_appearance[name].setValue(value);// may not be a string type
_appearance[name].setValue(value); // may not be a string type
}
MaterialProperty& Material::getPhysicalProperty(const QString& name)

View File

@@ -1,28 +1,29 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATERIAL_MATERIALS_H
#define MATERIAL_MATERIALS_H
#include <Mod/Material/MaterialGlobal.h>
#include <Base/BaseClass.h>
#include <QDir>
#include <QString>
@@ -46,28 +47,30 @@ public:
MaterialProperty();
explicit MaterialProperty(const ModelProperty& property);
explicit MaterialProperty(const MaterialProperty& property);
virtual ~MaterialProperty();
~MaterialProperty() override = default;
MaterialValue::ValueType getType(void) const
MaterialValue::ValueType getType() const
{
return _valuePtr->getType();
}
const QString getModelUUID(void) const;
const QVariant getValue(void) const;
const QString getModelUUID() const;
const QVariant getValue() const;
bool isNull() const
{
return _valuePtr->isNull();
}
MaterialValue* getMaterialValue(void);
const QString getString(void) const;
bool getBoolean(void) const;
int getInt(void) const;
double getFloat(void) const;
const Base::Quantity& getQuantity(void) const;
const QString getURL(void) const;
std::shared_ptr<MaterialValue> getMaterialValue();
const std::shared_ptr<MaterialValue> getMaterialValue() const;
const QString getString() const;
bool getBoolean() const;
int getInt() const;
double getFloat() const;
const Base::Quantity& getQuantity() const;
const QString getURL() const;
MaterialProperty& getColumn(int column);
const MaterialProperty& getColumn(int column) const;
MaterialValue::ValueType getColumnType(int column) const;
QString getColumnUnits(int column) const;
QVariant getColumnNull(int column) const;
@@ -102,7 +105,7 @@ protected:
private:
QString _modelUUID;
MaterialValue* _valuePtr;
std::shared_ptr<MaterialValue> _valuePtr;
std::vector<MaterialProperty> _columns;
};
@@ -113,9 +116,9 @@ class MaterialsExport Material: public Base::BaseClass
public:
enum ModelEdit
{
ModelEdit_None, // No change
ModelEdit_Alter,// Existing values are changed
ModelEdit_Extend// New values added
ModelEdit_None, // No change
ModelEdit_Alter, // Existing values are changed
ModelEdit_Extend // New values added
};
Material();
@@ -320,15 +323,15 @@ private:
std::list<QString> _tags;
std::vector<QString> _physicalUuids;
std::vector<QString> _appearanceUuids;
std::vector<QString> _allUuids;// Includes inherited models
std::vector<QString> _allUuids; // Includes inherited models
std::map<QString, MaterialProperty> _physical;
std::map<QString, MaterialProperty> _appearance;
bool _dereferenced;
ModelEdit _editState;
};
}// namespace Materials
} // namespace Materials
Q_DECLARE_METATYPE(Materials::Material*)
#endif// MATERIAL_MATERIALS_H
#endif // MATERIAL_MATERIALS_H

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_

View File

@@ -1,28 +1,29 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATERIAL_MODEL_H
#define MATERIAL_MODEL_H
#include <Mod/Material/MaterialGlobal.h>
#include <Base/BaseClass.h>
#include <Base/Quantity.h>
#include <QDir>
@@ -46,7 +47,7 @@ public:
const QString& url,
const QString& description);
explicit ModelProperty(const ModelProperty& other);
virtual ~ModelProperty() = default;
~ModelProperty() override = default;
const QString getName() const
{
@@ -147,7 +148,7 @@ public:
const QString& description,
const QString& url,
const QString& doi);
virtual ~Model() = default;
~Model() override = default;
const ModelLibrary& getLibrary() const
{
@@ -292,6 +293,6 @@ private:
std::map<QString, ModelProperty> _properties;
};
}// namespace Materials
} // namespace Materials
#endif// MATERIAL_MODEL_H
#endif // MATERIAL_MODEL_H

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_

View File

@@ -1,28 +1,29 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATERIAL_MODELLIBRARY_H
#define MATERIAL_MODELLIBRARY_H
#include <Mod/Material/MaterialGlobal.h>
#include <Base/BaseClass.h>
#include <Base/Quantity.h>
#include <QDir>
@@ -42,7 +43,7 @@ class MaterialsExport LibraryBase: public Base::BaseClass
public:
LibraryBase();
explicit LibraryBase(const QString& libraryName, const QString& dir, const QString& icon);
virtual ~LibraryBase() = default;
~LibraryBase() override = default;
const QString getName() const
{
@@ -81,7 +82,7 @@ class MaterialsExport ModelLibrary: public LibraryBase
public:
ModelLibrary();
explicit ModelLibrary(const QString& libraryName, const QString& dir, const QString& icon);
virtual ~ModelLibrary() = default;
~ModelLibrary() override = default;
bool operator==(const ModelLibrary& library) const
{
@@ -95,6 +96,6 @@ public:
Model* addModel(const Model& model, const QString& path);
};
}// namespace Materials
} // namespace Materials
#endif// MATERIAL_MODELLIBRARY_H
#endif // MATERIAL_MODELLIBRARY_H

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -53,9 +52,10 @@ ModelEntry::ModelEntry(const ModelLibrary& library,
, _dereferenced(false)
{}
std::map<QString, ModelEntry*>* ModelLoader::_modelEntryMap = nullptr;
std::unique_ptr<std::map<QString, ModelEntry*>> ModelLoader::_modelEntryMap = nullptr;
ModelLoader::ModelLoader(std::map<QString, Model*>* modelMap, std::list<ModelLibrary*>* libraryList)
ModelLoader::ModelLoader(std::shared_ptr<std::map<QString, Model*>> modelMap,
std::shared_ptr<std::list<ModelLibrary*>> libraryList)
: _modelMap(modelMap)
, _libraryList(libraryList)
{
@@ -305,7 +305,7 @@ void ModelLoader::addToTree(ModelEntry* model,
void ModelLoader::loadLibrary(const ModelLibrary& library)
{
if (_modelEntryMap == nullptr) {
_modelEntryMap = new std::map<QString, ModelEntry*>();
_modelEntryMap = std::make_unique<std::map<QString, ModelEntry*>>();
}
QDirIterator it(library.getDirectory(), QDirIterator::Subdirectories);
@@ -340,7 +340,7 @@ void ModelLoader::loadLibrary(const ModelLibrary& library)
// delete inheritances;
}
void ModelLoader::loadLibraries(void)
void ModelLoader::loadLibraries()
{
getModelLibraries();
if (_libraryList) {

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATERIAL_MODELLOADER_H
#define MATERIAL_MODELLOADER_H
@@ -96,8 +95,8 @@ private:
class ModelLoader
{
public:
explicit ModelLoader(std::map<QString, Model*>* modelMap,
std::list<ModelLibrary*>* libraryList);
explicit ModelLoader(std::shared_ptr<std::map<QString, Model*>> modelMap,
std::shared_ptr<std::list<ModelLibrary*>> libraryList);
virtual ~ModelLoader() = default;
static const QString getUUIDFromPath(const QString& path);
@@ -119,12 +118,12 @@ private:
ModelEntry* getModelFromPath(const ModelLibrary& library, const QString& path) const;
void addLibrary(ModelLibrary* model);
void loadLibrary(const ModelLibrary& library);
void loadLibraries(void);
static std::map<QString, ModelEntry*>* _modelEntryMap;
std::map<QString, Model*>* _modelMap;
std::list<ModelLibrary*>* _libraryList;
void loadLibraries();
static std::unique_ptr<std::map<QString, ModelEntry*>> _modelEntryMap;
std::shared_ptr<std::map<QString, Model*>> _modelMap;
std::shared_ptr<std::list<ModelLibrary*>> _libraryList;
};
}// namespace Materials
} // namespace Materials
#endif// MATERIAL_MODELLOADER_H
#endif // MATERIAL_MODELLOADER_H

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -35,8 +34,8 @@
using namespace Materials;
std::list<ModelLibrary*>* ModelManager::_libraryList = nullptr;
std::map<QString, Model*>* ModelManager::_modelMap = nullptr;
std::shared_ptr<std::list<ModelLibrary*>> ModelManager::_libraryList = nullptr;
std::shared_ptr<std::map<QString, Model*>> ModelManager::_modelMap = nullptr;
QMutex ModelManager::_mutex;
TYPESYSTEM_SOURCE(Materials::ModelManager, Base::BaseClass)
@@ -51,9 +50,9 @@ void ModelManager::initLibraries()
QMutexLocker locker(&_mutex);
if (_modelMap == nullptr) {
_modelMap = new std::map<QString, Model*>();
_modelMap = std::make_shared<std::map<QString, Model*>>();
if (_libraryList == nullptr) {
_libraryList = new std::list<ModelLibrary*>();
_libraryList = std::make_shared<std::list<ModelLibrary*>>();
}
// Load the libraries
@@ -126,10 +125,11 @@ bool ModelManager::passFilter(ModelFilter filter, Model::ModelType modelType) co
return false;
}
std::map<QString, ModelTreeNode*>* ModelManager::getModelTree(const ModelLibrary& library,
ModelFilter filter)
std::shared_ptr<std::map<QString, ModelTreeNode*>>
ModelManager::getModelTree(const ModelLibrary& library, ModelFilter filter) const
{
std::map<QString, ModelTreeNode*>* modelTree = new std::map<QString, ModelTreeNode*>();
std::shared_ptr<std::map<QString, ModelTreeNode*>> modelTree =
std::make_shared<std::map<QString, ModelTreeNode*>>();
for (auto it = _modelMap->begin(); it != _modelMap->end(); it++) {
auto filename = it->first;
@@ -140,7 +140,7 @@ std::map<QString, ModelTreeNode*>* ModelManager::getModelTree(const ModelLibrary
Base::Console().Log("Relative path '%s'\n\t", path.string().c_str());
// Start at the root
std::map<QString, ModelTreeNode*>* node = modelTree;
std::shared_ptr<std::map<QString, ModelTreeNode*>> node = modelTree;
for (auto itp = path.begin(); itp != path.end(); itp++) {
if (isModel(itp->string())) {
ModelTreeNode* child = new ModelTreeNode();
@@ -150,9 +150,9 @@ std::map<QString, ModelTreeNode*>* ModelManager::getModelTree(const ModelLibrary
else {
// Add the folder only if it's not already there
QString folderName = QString::fromStdString(itp->string());
std::map<QString, ModelTreeNode*>* mapPtr;
std::shared_ptr<std::map<QString, ModelTreeNode*>> mapPtr;
if (node->count(QString::fromStdString(itp->string())) == 0) {
mapPtr = new std::map<QString, ModelTreeNode*>();
mapPtr = std::make_shared<std::map<QString, ModelTreeNode*>>();
ModelTreeNode* child = new ModelTreeNode();
child->setFolder(mapPtr);
(*node)[QString::fromStdString(itp->string())] = child;

View File

@@ -1,28 +1,29 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATERIAL_MODELMANAGER_H
#define MATERIAL_MODELMANAGER_H
#include <Mod/Material/MaterialGlobal.h>
#include <QMutex>
#include <boost/filesystem.hpp>
@@ -51,20 +52,20 @@ public:
};
ModelManager();
virtual ~ModelManager() = default;
~ModelManager() override = default;
void refresh();
std::list<ModelLibrary*>* getModelLibraries()
std::shared_ptr<std::list<ModelLibrary*>> getModelLibraries()
{
return _libraryList;
}
std::map<QString, Model*>* getModels()
std::shared_ptr<std::map<QString, Model*>> getModels()
{
return _modelMap;
}
std::map<QString, ModelTreeNode*>* getModelTree(const ModelLibrary& library,
ModelFilter filter = ModelFilter_None);
std::shared_ptr<std::map<QString, ModelTreeNode*>>
getModelTree(const ModelLibrary& library, ModelFilter filter = ModelFilter_None) const;
const Model& getModel(const QString& uuid) const;
const Model& getModelByPath(const QString& path) const;
const Model& getModelByPath(const QString& path, const QString& libraryPath) const;
@@ -75,11 +76,11 @@ public:
private:
static void initLibraries();
static std::list<ModelLibrary*>* _libraryList;
static std::map<QString, Model*>* _modelMap;
static std::shared_ptr<std::list<ModelLibrary*>> _libraryList;
static std::shared_ptr<std::map<QString, Model*>> _modelMap;
static QMutex _mutex;
};
}// namespace Materials
} // namespace Materials
#endif// MATERIAL_MODELMANAGER_H
#endif // MATERIAL_MODELMANAGER_H

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
@@ -43,7 +42,7 @@ std::string ModelManagerPy::representation() const
return str.str();
}
PyObject* ModelManagerPy::PyMake(struct _typeobject*, PyObject*, PyObject*)// Python wrapper
PyObject* ModelManagerPy::PyMake(struct _typeobject*, PyObject*, PyObject*) // Python wrapper
{
// never create such objects with the constructor
return new ModelManagerPy(new ModelManager());
@@ -68,7 +67,7 @@ PyObject* ModelManagerPy::getModel(PyObject* args)
}
catch (ModelNotFound const&) {
QString error = QString::fromStdString("Model not found:\n");
std::map<QString, Model*>* _modelMap = getModelManagerPtr()->getModels();
auto _modelMap = getModelManagerPtr()->getModels();
error += QString::fromStdString("ModelMap:\n");
for (auto itp = _modelMap->begin(); itp != _modelMap->end(); itp++) {
error += QString::fromStdString("\t_modelMap[") + itp->first
@@ -120,7 +119,7 @@ PyObject* ModelManagerPy::getModelByPath(PyObject* args)
Py::List ModelManagerPy::getModelLibraries() const
{
std::list<ModelLibrary*>* libraries = getModelManagerPtr()->getModelLibraries();
std::shared_ptr<std::list<ModelLibrary*>> libraries = getModelManagerPtr()->getModelLibraries();
Py::List list;
for (auto it = libraries->begin(); it != libraries->end(); it++) {
@@ -138,7 +137,7 @@ Py::List ModelManagerPy::getModelLibraries() const
Py::Dict ModelManagerPy::getModels() const
{
std::map<QString, Model*>* models = getModelManagerPtr()->getModels();
auto models = getModelManagerPtr()->getModels();
Py::Dict dict;
for (auto it = models->begin(); it != models->end(); it++) {

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
@@ -53,7 +52,7 @@ std::string ModelPropertyPy::representation() const
return str.str();
}
PyObject* ModelPropertyPy::PyMake(struct _typeobject*, PyObject*, PyObject*)// Python wrapper
PyObject* ModelPropertyPy::PyMake(struct _typeobject*, PyObject*, PyObject*) // Python wrapper
{
// never create such objects with the constructor
return new ModelPropertyPy(new ModelProperty());

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
@@ -74,7 +73,7 @@ std::string ModelPy::representation() const
return str.str();
}
PyObject* ModelPy::PyMake(struct _typeobject*, PyObject*, PyObject*)// Python wrapper
PyObject* ModelPy::PyMake(struct _typeobject*, PyObject*, PyObject*) // Python wrapper
{
// never create such objects with the constructor
return new ModelPy(new Model());

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATERIAL_MODELUUIDS_H
#define MATERIAL_MODELUUIDS_H
@@ -68,6 +67,6 @@ static const QString ModelUUID_Rendering_Advanced =
static const QString ModelUUID_Rendering_Vector =
QString::fromStdString("fdf5a80e-de50-4157-b2e5-b6e5f88b680e");
}// namespace Materials
} // namespace Materials
#endif// MATERIAL_MODELUUIDS_H
#endif // MATERIAL_MODELUUIDS_H

View File

@@ -1,24 +1,22 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"

View File

@@ -1,45 +1,42 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATGUI_PRECOMPILED_H
#define MATGUI_PRECOMPILED_H
#ifndef MATERIAL_PRECOMPILED_H
#define MATERIAL_PRECOMPILED_H
#include <FCConfig.h>
#include <Mod/Material/MaterialGlobal.h>
// point at which warnings of overly long specifiers disabled (needed for VC6)
#ifdef _MSC_VER
# pragma warning( disable : 4251 )
# pragma warning( disable : 4503 )
# pragma warning( disable : 4786 ) // specifier longer then 255 chars
# pragma warning( disable : 4273 )
#pragma warning(disable : 4251)
#pragma warning(disable : 4503)
#pragma warning(disable : 4786) // specifier longer then 255 chars
#pragma warning(disable : 4273)
#endif
#ifdef FC_OS_WIN32
# ifndef NOMINMAX
# define NOMINMAX
# endif
# include <windows.h>
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
#endif
#ifdef _PreComp_
@@ -59,9 +56,9 @@
#include <QtGlobal>
// Boost
#include <boost/regex.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/regex.hpp>
#endif //_PreComp_
#endif // MATGUI_PRECOMPILED_H
#endif // MATERIAL_PRECOMPILED_H

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATERIAL_TRIM_H
#define MATERIAL_TRIM_H
@@ -76,6 +75,6 @@ static inline std::string trim_copy(std::string s)
return s;
}
}// namespace Materials
} // namespace Materials
#endif// MATERIAL_TRIM_H
#endif // MATERIAL_TRIM_H