diff --git a/cMake/FreeCAD_Helpers/SetupLibYaml.cmake b/cMake/FreeCAD_Helpers/SetupLibYaml.cmake
index 3b6d1a37af..dcbc6439c7 100644
--- a/cMake/FreeCAD_Helpers/SetupLibYaml.cmake
+++ b/cMake/FreeCAD_Helpers/SetupLibYaml.cmake
@@ -1,11 +1,4 @@
macro(SetupYamlCpp)
-# -------------------------------- YamlCpp --------------------------------
-
+ # -------------------------------- YamlCpp --------------------------------
find_package(yaml-cpp REQUIRED)
- if(NOT yaml-cpp_FOUND)
- message(FATAL_ERROR "==================\n"
- "YamlCpp not found.\n"
- "==================\n")
- endif(NOT yaml-cpp_FOUND)
-
endmacro(SetupYamlCpp)
diff --git a/src/Mod/Fem/Gui/AppFemGui.cpp b/src/Mod/Fem/Gui/AppFemGui.cpp
index 1dd5e7a730..82e3f3441a 100644
--- a/src/Mod/Fem/Gui/AppFemGui.cpp
+++ b/src/Mod/Fem/Gui/AppFemGui.cpp
@@ -25,8 +25,8 @@
#include
#include
#include
-#include
#include
+#include
#include "DlgSettingsFemCcxImp.h"
#include "DlgSettingsFemElmerImp.h"
@@ -38,13 +38,21 @@
#include "DlgSettingsFemZ88Imp.h"
#include "PropertyFemMeshItem.h"
#include "ViewProviderAnalysis.h"
+#include "ViewProviderFemMesh.h"
+#include "ViewProviderFemMeshShape.h"
+#include "ViewProviderFemMeshShapeNetgen.h"
+#include "ViewProviderSetElements.h"
+#include "ViewProviderSetFaces.h"
+#include "ViewProviderSetGeometry.h"
+#include "ViewProviderSetNodes.h"
+#include "ViewProviderSolver.h"
#include "ViewProviderFemConstraint.h"
#include "ViewProviderFemConstraintBearing.h"
#include "ViewProviderFemConstraintContact.h"
#include "ViewProviderFemConstraintDisplacement.h"
#include "ViewProviderFemConstraintFixed.h"
-#include "ViewProviderFemConstraintFluidBoundary.h"
#include "ViewProviderFemConstraintForce.h"
+#include "ViewProviderFemConstraintFluidBoundary.h"
#include "ViewProviderFemConstraintGear.h"
#include "ViewProviderFemConstraintHeatflux.h"
#include "ViewProviderFemConstraintInitialTemperature.h"
@@ -55,15 +63,7 @@
#include "ViewProviderFemConstraintSpring.h"
#include "ViewProviderFemConstraintTemperature.h"
#include "ViewProviderFemConstraintTransform.h"
-#include "ViewProviderFemMesh.h"
-#include "ViewProviderFemMeshShape.h"
-#include "ViewProviderFemMeshShapeNetgen.h"
#include "ViewProviderResult.h"
-#include "ViewProviderSetElements.h"
-#include "ViewProviderSetFaces.h"
-#include "ViewProviderSetGeometry.h"
-#include "ViewProviderSetNodes.h"
-#include "ViewProviderSolver.h"
#include "Workbench.h"
#ifdef FC_USE_VTK
@@ -74,7 +74,7 @@
#endif
-// use a different name to CreateCommand()
+ // use a different name to CreateCommand()
void CreateFemCommands();
void loadFemResource()
@@ -85,9 +85,8 @@ void loadFemResource()
Gui::Translator::instance()->refresh();
}
-namespace FemGui
-{
-extern PyObject* initModule();
+namespace FemGui {
+ extern PyObject* initModule();
}
@@ -107,89 +106,84 @@ PyMOD_INIT_FUNC(FemGui)
// clang-format off
// addition objects
- FemGui::Workbench ::init();
+ FemGui::Workbench ::init();
- FemGui::ViewProviderFemAnalysis ::init();
- FemGui::ViewProviderFemAnalysisPython ::init();
+ FemGui::ViewProviderFemAnalysis ::init();
+ FemGui::ViewProviderFemAnalysisPython ::init();
- FemGui::ViewProviderFemConstraint ::init();
- FemGui::ViewProviderFemConstraintPython ::init();
+ FemGui::ViewProviderFemConstraint ::init();
+ FemGui::ViewProviderFemConstraintPython ::init();
- FemGui::ViewProviderFemConstraintOnBoundary ::init();
- FemGui::ViewProviderFemConstraintBearing ::init();
- FemGui::ViewProviderFemConstraintContact ::init();
- FemGui::ViewProviderFemConstraintDisplacement ::init();
- FemGui::ViewProviderFemConstraintFixed ::init();
- FemGui::ViewProviderFemConstraintFluidBoundary ::init();
- FemGui::ViewProviderFemConstraintForce ::init();
- FemGui::ViewProviderFemConstraintGear ::init();
- FemGui::ViewProviderFemConstraintHeatflux ::init();
- FemGui::ViewProviderFemConstraintInitialTemperature ::init();
- FemGui::ViewProviderFemConstraintPlaneRotation ::init();
- FemGui::ViewProviderFemConstraintPressure ::init();
- FemGui::ViewProviderFemConstraintPulley ::init();
- FemGui::ViewProviderFemConstraintTemperature ::init();
- FemGui::ViewProviderFemConstraintTransform ::init();
- FemGui::ViewProviderFemConstraintSpring ::init();
+ FemGui::ViewProviderFemConstraintOnBoundary ::init();
+ FemGui::ViewProviderFemConstraintBearing ::init();
+ FemGui::ViewProviderFemConstraintContact ::init();
+ FemGui::ViewProviderFemConstraintDisplacement ::init();
+ FemGui::ViewProviderFemConstraintFixed ::init();
+ FemGui::ViewProviderFemConstraintFluidBoundary ::init();
+ FemGui::ViewProviderFemConstraintForce ::init();
+ FemGui::ViewProviderFemConstraintGear ::init();
+ FemGui::ViewProviderFemConstraintHeatflux ::init();
+ FemGui::ViewProviderFemConstraintInitialTemperature ::init();
+ FemGui::ViewProviderFemConstraintPlaneRotation ::init();
+ FemGui::ViewProviderFemConstraintPressure ::init();
+ FemGui::ViewProviderFemConstraintPulley ::init();
+ FemGui::ViewProviderFemConstraintTemperature ::init();
+ FemGui::ViewProviderFemConstraintTransform ::init();
+ FemGui::ViewProviderFemConstraintSpring ::init();
- FemGui::ViewProviderFemMesh ::init();
- FemGui::ViewProviderFemMeshPython ::init();
- FemGui::ViewProviderFemMeshShape ::init();
- FemGui::ViewProviderFemMeshShapeNetgen ::init();
- FemGui::PropertyFemMeshItem ::init();
+ FemGui::ViewProviderFemMesh ::init();
+ FemGui::ViewProviderFemMeshPython ::init();
+ FemGui::ViewProviderFemMeshShape ::init();
+ FemGui::ViewProviderFemMeshShapeNetgen ::init();
+ FemGui::PropertyFemMeshItem ::init();
- FemGui::ViewProviderSetElements ::init();
- FemGui::ViewProviderSetFaces ::init();
- FemGui::ViewProviderSetGeometry ::init();
- FemGui::ViewProviderSetNodes ::init();
+ FemGui::ViewProviderSetElements ::init();
+ FemGui::ViewProviderSetFaces ::init();
+ FemGui::ViewProviderSetGeometry ::init();
+ FemGui::ViewProviderSetNodes ::init();
- FemGui::ViewProviderSolver ::init();
- FemGui::ViewProviderSolverPython ::init();
+ FemGui::ViewProviderSolver ::init();
+ FemGui::ViewProviderSolverPython ::init();
- FemGui::ViewProviderResult ::init();
- FemGui::ViewProviderResultPython ::init();
+ FemGui::ViewProviderResult ::init();
+ FemGui::ViewProviderResultPython ::init();
#ifdef FC_USE_VTK
- FemGui::ViewProviderFemPostObject ::init();
- FemGui::ViewProviderFemPostPipeline ::init();
- FemGui::ViewProviderFemPostClip ::init();
- FemGui::ViewProviderFemPostContours ::init();
- FemGui::ViewProviderFemPostCut ::init();
- FemGui::ViewProviderFemPostDataAlongLine ::init();
- FemGui::ViewProviderFemPostDataAtPoint ::init();
- FemGui::ViewProviderFemPostScalarClip ::init();
- FemGui::ViewProviderFemPostWarpVector ::init();
+ FemGui::ViewProviderFemPostObject ::init();
+ FemGui::ViewProviderFemPostPipeline ::init();
+ FemGui::ViewProviderFemPostClip ::init();
+ FemGui::ViewProviderFemPostContours ::init();
+ FemGui::ViewProviderFemPostCut ::init();
+ FemGui::ViewProviderFemPostDataAlongLine ::init();
+ FemGui::ViewProviderFemPostDataAtPoint ::init();
+ FemGui::ViewProviderFemPostScalarClip ::init();
+ FemGui::ViewProviderFemPostWarpVector ::init();
- FemGui::ViewProviderFemPostFunction ::init();
- FemGui::ViewProviderFemPostFunctionProvider ::init();
- FemGui::ViewProviderFemPostBoxFunction ::init();
- FemGui::ViewProviderFemPostCylinderFunction ::init();
- FemGui::ViewProviderFemPostPlaneFunction ::init();
- FemGui::ViewProviderFemPostSphereFunction ::init();
+ FemGui::ViewProviderFemPostFunction ::init();
+ FemGui::ViewProviderFemPostFunctionProvider ::init();
+ FemGui::ViewProviderFemPostBoxFunction ::init();
+ FemGui::ViewProviderFemPostCylinderFunction ::init();
+ FemGui::ViewProviderFemPostPlaneFunction ::init();
+ FemGui::ViewProviderFemPostSphereFunction ::init();
#endif
- // register preferences pages on FEM, the order here will be the order of the tabs in pref
- // widget
- new Gui::PrefPageProducer(
- QT_TRANSLATE_NOOP("QObject", "FEM"));
+ // register preferences pages on FEM, the order here will be the order of the tabs in pref widget
+ new Gui::PrefPageProducer(QT_TRANSLATE_NOOP("QObject", "FEM"));
new Gui::PrefPageProducer(QT_TRANSLATE_NOOP("QObject", "FEM"));
new Gui::PrefPageProducer(QT_TRANSLATE_NOOP("QObject", "FEM"));
new Gui::PrefPageProducer(QT_TRANSLATE_NOOP("QObject", "FEM"));
- new Gui::PrefPageProducer(
- QT_TRANSLATE_NOOP("QObject", "FEM"));
+ new Gui::PrefPageProducer(QT_TRANSLATE_NOOP("QObject", "FEM"));
new Gui::PrefPageProducer(QT_TRANSLATE_NOOP("QObject", "FEM"));
// register preferences pages on Import-Export
- new Gui::PrefPageProducer(
- QT_TRANSLATE_NOOP("QObject", "Import-Export"));
- new Gui::PrefPageProducer(
- QT_TRANSLATE_NOOP("QObject", "Import-Export"));
+ new Gui::PrefPageProducer(QT_TRANSLATE_NOOP("QObject", "Import-Export"));
+ new Gui::PrefPageProducer(QT_TRANSLATE_NOOP("QObject", "Import-Export"));
// add resources and reloads the translators
loadFemResource();
// clang-format on
PyMOD_Return(mod);
-}
+}
\ No newline at end of file
diff --git a/src/Mod/Material/App/AppMaterial.cpp b/src/Mod/Material/App/AppMaterial.cpp
index 2f0ed8a40f..ced297ec95 100644
--- a/src/Mod/Material/App/AppMaterial.cpp
+++ b/src/Mod/Material/App/AppMaterial.cpp
@@ -1,26 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
-
+ **************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -45,7 +42,7 @@ public:
Module()
: Py::ExtensionModule("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)
{
diff --git a/src/Mod/Material/App/Exceptions.h b/src/Mod/Material/App/Exceptions.h
index 3a70f7260e..c67e9df4eb 100644
--- a/src/Mod/Material/App/Exceptions.h
+++ b/src/Mod/Material/App/Exceptions.h
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#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
diff --git a/src/Mod/Material/App/FolderTree.h b/src/Mod/Material/App/FolderTree.h
index 779f1ee0ec..75dd3dfcc7 100644
--- a/src/Mod/Material/App/FolderTree.h
+++ b/src/Mod/Material/App/FolderTree.h
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#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*>* getFolder(void) const
+ const std::shared_ptr*>> getFolder() const
{
return _folder;
}
- std::map*>* getFolder(void)
+ std::shared_ptr*>> getFolder()
{
return _folder;
}
- const T* getData(void) const
+ const T* getData() const
{
return _data;
}
- void setFolder(std::map*>* folder)
+ void setFolder(std::shared_ptr*>> folder)
{
setType(FolderNode);
_folder = folder;
@@ -78,10 +77,10 @@ public:
private:
NodeType _type;
- std::map*>* _folder;
+ std::shared_ptr*>> _folder;
const T* _data;
};
-}// namespace Materials
+} // namespace Materials
-#endif// MATERIAL_FOLDERTREE_H
+#endif // MATERIAL_FOLDERTREE_H
diff --git a/src/Mod/Material/App/MaterialConfigLoader.cpp b/src/Mod/Material/App/MaterialConfigLoader.cpp
index 4796c83100..6e5e287600 100644
--- a/src/Mod/Material/App/MaterialConfigLoader.cpp
+++ b/src/Mod/Material/App/MaterialConfigLoader.cpp
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#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);
}
diff --git a/src/Mod/Material/App/MaterialConfigLoader.h b/src/Mod/Material/App/MaterialConfigLoader.h
index 06a923c175..f2337cd04f 100644
--- a/src/Mod/Material/App/MaterialConfigLoader.h
+++ b/src/Mod/Material/App/MaterialConfigLoader.h
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#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
diff --git a/src/Mod/Material/App/MaterialLibrary.cpp b/src/Mod/Material/App/MaterialLibrary.cpp
index 224202d266..1233752be4 100644
--- a/src/Mod/Material/App/MaterialLibrary.cpp
+++ b/src/Mod/Material/App/MaterialLibrary.cpp
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -35,16 +34,13 @@ using namespace Materials;
/* TRANSLATOR Material::Materials */
-std::map* MaterialLibrary::_materialPathMap = nullptr;
+std::unique_ptr> MaterialLibrary::_materialPathMap =
+ std::make_unique>();
TYPESYSTEM_SOURCE(Materials::MaterialLibrary, LibraryBase)
MaterialLibrary::MaterialLibrary()
-{
- if (_materialPathMap == nullptr) {
- _materialPathMap = new std::map();
- }
-}
+{}
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();
- }
-}
+{}
void MaterialLibrary::createPath(const QString& path)
{
diff --git a/src/Mod/Material/App/MaterialLibrary.h b/src/Mod/Material/App/MaterialLibrary.h
index a247ce6828..a217bbec13 100644
--- a/src/Mod/Material/App/MaterialLibrary.h
+++ b/src/Mod/Material/App/MaterialLibrary.h
@@ -1,28 +1,29 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#ifndef MATERIAL_MATERIALLIBRARY_H
#define MATERIAL_MATERIALLIBRARY_H
+#include
+
#include
#include
#include
@@ -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* _materialPathMap;
+ static std::unique_ptr> _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
diff --git a/src/Mod/Material/App/MaterialLoader.cpp b/src/Mod/Material/App/MaterialLoader.cpp
index fd87c4d40c..0756753de0 100644
--- a/src/Mod/Material/App/MaterialLoader.cpp
+++ b/src/Mod/Material/App/MaterialLoader.cpp
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#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* materialMap)
+void MaterialYamlEntry::addToTree(std::shared_ptr> materialMap)
{
std::set exclude;
exclude.insert(QString::fromStdString("General"));
@@ -100,7 +99,7 @@ void MaterialYamlEntry::addToTree(std::map* materialMap)
std::string nodeName = it->second["UUID"].as();
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* materialMap)
(*materialMap)[uuid] = library.addMaterial(*finalModel, path);
}
-std::map* MaterialLoader::_materialEntryMap = nullptr;
+std::unique_ptr> MaterialLoader::_materialEntryMap = nullptr;
-MaterialLoader::MaterialLoader(std::map* materialMap,
- std::list* libraryList)
+MaterialLoader::MaterialLoader(std::shared_ptr> materialMap,
+ std::shared_ptr> 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();
+ _materialEntryMap = std::make_unique>();
}
QDirIterator it(library.getDirectory(), QDirIterator::Subdirectories);
@@ -337,9 +336,9 @@ void MaterialLoader::loadLibrary(MaterialLibrary& library)
}
}
-void MaterialLoader::loadLibraries(void)
+void MaterialLoader::loadLibraries()
{
- std::list* _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* MaterialLoader::getMaterialLibraries()
+std::shared_ptr> MaterialLoader::getMaterialLibraries()
{
auto param = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Material/Resources");
@@ -426,9 +425,10 @@ std::list* MaterialLoader::getMaterialLibraries()
return _libraryList;
}
-std::list* MaterialLoader::getMaterialFolders(const MaterialLibrary& library)
+std::shared_ptr>
+MaterialLoader::getMaterialFolders(const MaterialLibrary& library)
{
- std::list* pathList = new std::list();
+ std::shared_ptr> pathList = std::make_shared>();
QDirIterator it(library.getDirectory(), QDirIterator::Subdirectories);
while (it.hasNext()) {
auto pathname = it.next();
diff --git a/src/Mod/Material/App/MaterialLoader.h b/src/Mod/Material/App/MaterialLoader.h
index 3bcaf673d1..f4bac08939 100644
--- a/src/Mod/Material/App/MaterialLoader.h
+++ b/src/Mod/Material/App/MaterialLoader.h
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#ifndef MATERIAL_MATERIALLOADER_H
#define MATERIAL_MATERIALLOADER_H
@@ -43,7 +42,7 @@ public:
const QString& modelUuid);
virtual ~MaterialEntry() = default;
- virtual void addToTree(std::map* materialMap) = 0;
+ virtual void addToTree(std::shared_ptr> materialMap) = 0;
const MaterialLibrary& getLibrary() const
{
@@ -79,7 +78,7 @@ public:
const YAML::Node& modelData);
~MaterialYamlEntry() override = default;
- void addToTree(std::map* materialMap) override;
+ void addToTree(std::shared_ptr> materialMap) override;
const YAML::Node& getModel() const
{
@@ -102,12 +101,12 @@ private:
class MaterialLoader
{
public:
- explicit MaterialLoader(std::map* materialMap,
- std::list* libraryList);
+ explicit MaterialLoader(std::shared_ptr> materialMap,
+ std::shared_ptr> libraryList);
virtual ~MaterialLoader();
- std::list* getMaterialLibraries();
- static std::list* getMaterialFolders(const MaterialLibrary& library);
+ std::shared_ptr> getMaterialLibraries();
+ static std::shared_ptr> 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* _materialEntryMap;
- std::map* _materialMap;
- std::list* _libraryList;
+ void loadLibraries();
+ static std::unique_ptr> _materialEntryMap;
+ std::shared_ptr> _materialMap;
+ std::shared_ptr> _libraryList;
};
-}// namespace Materials
+} // namespace Materials
-#endif// MATERIAL_MATERIALLOADER_H
+#endif // MATERIAL_MATERIALLOADER_H
diff --git a/src/Mod/Material/App/MaterialManager.cpp b/src/Mod/Material/App/MaterialManager.cpp
index 2415a53ae4..717a273cff 100644
--- a/src/Mod/Material/App/MaterialManager.cpp
+++ b/src/Mod/Material/App/MaterialManager.cpp
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -38,8 +37,8 @@ using namespace Materials;
/* TRANSLATOR Material::Materials */
-std::list* MaterialManager::_libraryList = nullptr;
-std::map* MaterialManager::_materialMap = nullptr;
+std::shared_ptr> MaterialManager::_libraryList = nullptr;
+std::shared_ptr> 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();
+ _materialMap = std::make_shared>();
if (_libraryList == nullptr) {
- _libraryList = new std::list();
+ _libraryList = std::make_shared>();
}
// 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* MaterialManager::getMaterialLibraries()
+std::shared_ptr> MaterialManager::getMaterialLibraries()
{
if (_libraryList == nullptr) {
if (_materialMap == nullptr) {
- _materialMap = new std::map();
+ _materialMap = std::make_shared>();
}
- _libraryList = new std::list();
+ _libraryList = std::make_shared>();
// Load the libraries
MaterialLoader loader(_materialMap, _libraryList);
@@ -168,10 +167,11 @@ std::list* MaterialManager::getMaterialLibraries()
return _libraryList;
}
-std::map*
-MaterialManager::getMaterialTree(const MaterialLibrary& library)
+std::shared_ptr>
+MaterialManager::getMaterialTree(const MaterialLibrary& library) const
{
- std::map* materialTree = new std::map();
+ std::shared_ptr> materialTree =
+ std::make_shared>();
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* 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* mapPtr;
+ std::shared_ptr> mapPtr;
if (node->count(folderName) == 0) {
- mapPtr = new std::map();
+ mapPtr = std::make_shared>();
MaterialTreeNode* child = new MaterialTreeNode();
child->setFolder(mapPtr);
(*node)[folderName] = child;
@@ -208,18 +208,18 @@ MaterialManager::getMaterialTree(const MaterialLibrary& library)
}
}
- std::list* folderList = getMaterialFolders(library);
+ auto folderList = getMaterialFolders(library);
for (auto folder : *folderList) {
fs::path path = folder.toStdString();
// Start at the root
- std::map* 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* mapPtr =
- new std::map();
+ std::shared_ptr> mapPtr =
+ std::make_shared>();
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* MaterialManager::getMaterialFolders(const MaterialLibrary& library)
+std::shared_ptr>
+MaterialManager::getMaterialFolders(const MaterialLibrary& library) const
{
return MaterialLoader::getMaterialFolders(library);
}
-std::map* MaterialManager::materialsWithModel(QString uuid)
+std::shared_ptr> MaterialManager::materialsWithModel(QString uuid)
{
- std::map* dict = new std::map();
+ std::shared_ptr> dict =
+ std::make_shared>();
for (auto it = _materialMap->begin(); it != _materialMap->end(); it++) {
QString key = it->first;
@@ -256,9 +257,11 @@ std::map* MaterialManager::materialsWithModel(QString uuid)
return dict;
}
-std::map* MaterialManager::materialsWithModelComplete(QString uuid)
+std::shared_ptr>
+MaterialManager::materialsWithModelComplete(QString uuid)
{
- std::map* dict = new std::map();
+ std::shared_ptr> dict =
+ std::make_shared>();
for (auto it = _materialMap->begin(); it != _materialMap->end(); it++) {
QString key = it->first;
diff --git a/src/Mod/Material/App/MaterialManager.h b/src/Mod/Material/App/MaterialManager.h
index eacebabca7..200bdf6d76 100644
--- a/src/Mod/Material/App/MaterialManager.h
+++ b/src/Mod/Material/App/MaterialManager.h
@@ -1,28 +1,29 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#ifndef MATERIAL_MATERIALMANAGER_H
#define MATERIAL_MATERIALMANAGER_H
+#include
+
#include
#include
@@ -43,9 +44,9 @@ class MaterialsExport MaterialManager: public Base::BaseClass
public:
MaterialManager();
- virtual ~MaterialManager() = default;
+ ~MaterialManager() override = default;
- std::map* getMaterials()
+ std::shared_ptr> getMaterials()
{
return _materialMap;
}
@@ -55,9 +56,10 @@ public:
MaterialLibrary* getLibrary(const QString& name) const;
// Library management
- static std::list* getMaterialLibraries();
- std::map* getMaterialTree(const MaterialLibrary& library);
- std::list* getMaterialFolders(const MaterialLibrary& library);
+ static std::shared_ptr> getMaterialLibraries();
+ std::shared_ptr>
+ getMaterialTree(const MaterialLibrary& library) const;
+ std::shared_ptr> 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* materialsWithModel(QString uuid);
- std::map* materialsWithModelComplete(QString uuid);
+ std::shared_ptr> materialsWithModel(QString uuid);
+ std::shared_ptr> materialsWithModelComplete(QString uuid);
private:
- static std::list* _libraryList;
- static std::map* _materialMap;
+ static std::shared_ptr> _libraryList;
+ static std::shared_ptr> _materialMap;
static QMutex _mutex;
static void initLibraries();
};
-}// namespace Materials
+} // namespace Materials
-#endif// MATERIAL_MATERIALMANAGER_H
+#endif // MATERIAL_MATERIALMANAGER_H
diff --git a/src/Mod/Material/App/MaterialManagerPyImpl.cpp b/src/Mod/Material/App/MaterialManagerPyImpl.cpp
index 0f37e603f6..733b2cba2c 100644
--- a/src/Mod/Material/App/MaterialManagerPyImpl.cpp
+++ b/src/Mod/Material/App/MaterialManagerPyImpl.cpp
@@ -1,24 +1,23 @@
/***************************************************************************
- * Copyright (c) 2008 Werner Mayer *
+ * Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#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* 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* 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* 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* 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;
}
diff --git a/src/Mod/Material/App/MaterialPyImpl.cpp b/src/Mod/Material/App/MaterialPyImpl.cpp
index 4d54aab955..0120b66b00 100644
--- a/src/Mod/Material/App/MaterialPyImpl.cpp
+++ b/src/Mod/Material/App/MaterialPyImpl.cpp
@@ -1,24 +1,23 @@
/***************************************************************************
- * Copyright (c) 2008 Werner Mayer *
+ * Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#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());
diff --git a/src/Mod/Material/App/MaterialValue.cpp b/src/Mod/Material/App/MaterialValue.cpp
index d9f27fa24c..76805d369b 100644
--- a/src/Mod/Material/App/MaterialValue.cpp
+++ b/src/Mod/Material/App/MaterialValue.cpp
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#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);
diff --git a/src/Mod/Material/App/MaterialValue.h b/src/Mod/Material/App/MaterialValue.h
index d6df062623..a39ff4578b 100644
--- a/src/Mod/Material/App/MaterialValue.h
+++ b/src/Mod/Material/App/MaterialValue.h
@@ -1,28 +1,29 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#ifndef MATERIAL_MATERIALVALUE_H
#define MATERIAL_MATERIALVALUE_H
+#include
+
#include
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*> _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
diff --git a/src/Mod/Material/App/Materials.cpp b/src/Mod/Material/App/Materials.cpp
index 01d25de872..a2c3b23add 100644
--- a/src/Mod/Material/App/Materials.cpp
+++ b/src/Mod/Material/App/Materials.cpp
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#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::None);
}
MaterialProperty::MaterialProperty(const ModelProperty& property)
@@ -59,10 +58,10 @@ MaterialProperty::MaterialProperty(const ModelProperty& property)
}
if (_valuePtr->getType() == MaterialValue::Array2D) {
- reinterpret_cast(_valuePtr)->setDefault(getColumnNull(0));
+ std::static_pointer_cast(_valuePtr)->setDefault(getColumnNull(0));
}
else if (_valuePtr->getType() == MaterialValue::Array3D) {
- reinterpret_cast(_valuePtr)->setDefault(getColumnNull(0));
+ std::static_pointer_cast(_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(*(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 MaterialProperty::getMaterialValue()
{
return _valuePtr;
}
-const QString MaterialProperty::getString(void) const
+const std::shared_ptr MaterialProperty::getMaterialValue() const
+{
+ return _valuePtr;
+}
+
+const QString MaterialProperty::getString() const
{
if (getType() == MaterialValue::Quantity) {
Base::Quantity quantity = getValue().value();
@@ -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::String);
}
else if (type == QString::fromStdString("Boolean")) {
- _valuePtr = new MaterialValue(MaterialValue::Boolean);
+ _valuePtr = std::make_shared(MaterialValue::Boolean);
}
else if (type == QString::fromStdString("Integer")) {
- _valuePtr = new MaterialValue(MaterialValue::Integer);
+ _valuePtr = std::make_shared(MaterialValue::Integer);
}
else if (type == QString::fromStdString("Float")) {
- _valuePtr = new MaterialValue(MaterialValue::Float);
+ _valuePtr = std::make_shared(MaterialValue::Float);
}
else if (type == QString::fromStdString("URL")) {
- _valuePtr = new MaterialValue(MaterialValue::URL);
+ _valuePtr = std::make_shared(MaterialValue::URL);
}
else if (type == QString::fromStdString("Quantity")) {
- _valuePtr = new MaterialValue(MaterialValue::Quantity);
+ _valuePtr = std::make_shared(MaterialValue::Quantity);
}
else if (type == QString::fromStdString("Color")) {
- _valuePtr = new MaterialValue(MaterialValue::Color);
+ _valuePtr = std::make_shared(MaterialValue::Color);
}
else if (type == QString::fromStdString("File")) {
- _valuePtr = new MaterialValue(MaterialValue::File);
+ _valuePtr = std::make_shared(MaterialValue::File);
}
else if (type == QString::fromStdString("Image")) {
- _valuePtr = new MaterialValue(MaterialValue::Image);
+ _valuePtr = std::make_shared(MaterialValue::Image);
}
else if (type == QString::fromStdString("List")) {
- _valuePtr = new MaterialValue(MaterialValue::List);
+ _valuePtr = std::make_shared(MaterialValue::List);
}
else if (type == QString::fromStdString("2DArray")) {
- _valuePtr = new Material2DArray();
+ _valuePtr = std::make_shared();
}
else if (type == QString::fromStdString("3DArray")) {
- _valuePtr = new Material3DArray();
+ _valuePtr = std::make_shared();
}
else {
// Error. Throw something
- _valuePtr = new MaterialValue(MaterialValue::None);
+ _valuePtr = std::make_shared(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(*(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)
diff --git a/src/Mod/Material/App/Materials.h b/src/Mod/Material/App/Materials.h
index b8a950459f..a4ff89cd44 100644
--- a/src/Mod/Material/App/Materials.h
+++ b/src/Mod/Material/App/Materials.h
@@ -1,28 +1,29 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#ifndef MATERIAL_MATERIALS_H
#define MATERIAL_MATERIALS_H
+#include
+
#include
#include
#include
@@ -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 getMaterialValue();
+ const std::shared_ptr 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 _valuePtr;
std::vector _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 _tags;
std::vector _physicalUuids;
std::vector _appearanceUuids;
- std::vector _allUuids;// Includes inherited models
+ std::vector _allUuids; // Includes inherited models
std::map _physical;
std::map _appearance;
bool _dereferenced;
ModelEdit _editState;
};
-}// namespace Materials
+} // namespace Materials
Q_DECLARE_METATYPE(Materials::Material*)
-#endif// MATERIAL_MATERIALS_H
+#endif // MATERIAL_MATERIALS_H
diff --git a/src/Mod/Material/App/Model.cpp b/src/Mod/Material/App/Model.cpp
index a6b8990db6..87020a96fa 100644
--- a/src/Mod/Material/App/Model.cpp
+++ b/src/Mod/Material/App/Model.cpp
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
diff --git a/src/Mod/Material/App/Model.h b/src/Mod/Material/App/Model.h
index 5284e0042e..5202e4d9c6 100644
--- a/src/Mod/Material/App/Model.h
+++ b/src/Mod/Material/App/Model.h
@@ -1,28 +1,29 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#ifndef MATERIAL_MODEL_H
#define MATERIAL_MODEL_H
+#include
+
#include
#include
#include
@@ -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 _properties;
};
-}// namespace Materials
+} // namespace Materials
-#endif// MATERIAL_MODEL_H
+#endif // MATERIAL_MODEL_H
diff --git a/src/Mod/Material/App/ModelLibrary.cpp b/src/Mod/Material/App/ModelLibrary.cpp
index d42676b8ec..901795bd30 100644
--- a/src/Mod/Material/App/ModelLibrary.cpp
+++ b/src/Mod/Material/App/ModelLibrary.cpp
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
diff --git a/src/Mod/Material/App/ModelLibrary.h b/src/Mod/Material/App/ModelLibrary.h
index bca16e1180..1dfa04cbb1 100644
--- a/src/Mod/Material/App/ModelLibrary.h
+++ b/src/Mod/Material/App/ModelLibrary.h
@@ -1,28 +1,29 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#ifndef MATERIAL_MODELLIBRARY_H
#define MATERIAL_MODELLIBRARY_H
+#include
+
#include
#include
#include
@@ -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
diff --git a/src/Mod/Material/App/ModelLoader.cpp b/src/Mod/Material/App/ModelLoader.cpp
index 7d7e65c7fd..81c33c2253 100644
--- a/src/Mod/Material/App/ModelLoader.cpp
+++ b/src/Mod/Material/App/ModelLoader.cpp
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -53,9 +52,10 @@ ModelEntry::ModelEntry(const ModelLibrary& library,
, _dereferenced(false)
{}
-std::map* ModelLoader::_modelEntryMap = nullptr;
+std::unique_ptr> ModelLoader::_modelEntryMap = nullptr;
-ModelLoader::ModelLoader(std::map* modelMap, std::list* libraryList)
+ModelLoader::ModelLoader(std::shared_ptr> modelMap,
+ std::shared_ptr> 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();
+ _modelEntryMap = std::make_unique>();
}
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) {
diff --git a/src/Mod/Material/App/ModelLoader.h b/src/Mod/Material/App/ModelLoader.h
index 410fb74d18..b843b9e1fb 100644
--- a/src/Mod/Material/App/ModelLoader.h
+++ b/src/Mod/Material/App/ModelLoader.h
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#ifndef MATERIAL_MODELLOADER_H
#define MATERIAL_MODELLOADER_H
@@ -96,8 +95,8 @@ private:
class ModelLoader
{
public:
- explicit ModelLoader(std::map* modelMap,
- std::list* libraryList);
+ explicit ModelLoader(std::shared_ptr> modelMap,
+ std::shared_ptr> 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* _modelEntryMap;
- std::map* _modelMap;
- std::list* _libraryList;
+ void loadLibraries();
+ static std::unique_ptr> _modelEntryMap;
+ std::shared_ptr> _modelMap;
+ std::shared_ptr> _libraryList;
};
-}// namespace Materials
+} // namespace Materials
-#endif// MATERIAL_MODELLOADER_H
+#endif // MATERIAL_MODELLOADER_H
diff --git a/src/Mod/Material/App/ModelManager.cpp b/src/Mod/Material/App/ModelManager.cpp
index 63f303d7f4..2900fdde55 100644
--- a/src/Mod/Material/App/ModelManager.cpp
+++ b/src/Mod/Material/App/ModelManager.cpp
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter *
* *
- * 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 *
+ * . *
* *
- ***************************************************************************/
+ **************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -35,8 +34,8 @@
using namespace Materials;
-std::list* ModelManager::_libraryList = nullptr;
-std::map* ModelManager::_modelMap = nullptr;
+std::shared_ptr> ModelManager::_libraryList = nullptr;
+std::shared_ptr> 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();
+ _modelMap = std::make_shared>();
if (_libraryList == nullptr) {
- _libraryList = new std::list();
+ _libraryList = std::make_shared>();
}
// Load the libraries
@@ -126,10 +125,11 @@ bool ModelManager::passFilter(ModelFilter filter, Model::ModelType modelType) co
return false;
}
-std::map* ModelManager::getModelTree(const ModelLibrary& library,
- ModelFilter filter)
+std::shared_ptr>
+ModelManager::getModelTree(const ModelLibrary& library, ModelFilter filter) const
{
- std::map* modelTree = new std::map();
+ std::shared_ptr> modelTree =
+ std::make_shared>();
for (auto it = _modelMap->begin(); it != _modelMap->end(); it++) {
auto filename = it->first;
@@ -140,7 +140,7 @@ std::map* ModelManager::getModelTree(const ModelLibrary
Base::Console().Log("Relative path '%s'\n\t", path.string().c_str());
// Start at the root
- std::map* node = modelTree;
+ std::shared_ptr> 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* ModelManager::getModelTree(const ModelLibrary
else {
// Add the folder only if it's not already there
QString folderName = QString::fromStdString(itp->string());
- std::map