Material: Material handling enhancements

Rework of the material handling system.

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

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

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

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

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

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

View File

@@ -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)

View File

@@ -25,8 +25,8 @@
#include <Base/Console.h>
#include <Base/PyObjectBase.h>
#include <Gui/Application.h>
#include <Gui/Language/Translator.h>
#include <Gui/WidgetFactory.h>
#include <Gui/Language/Translator.h>
#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<FemGui::DlgSettingsFemGeneralImp>(
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<FemGui::DlgSettingsFemGeneralImp>(QT_TRANSLATE_NOOP("QObject", "FEM"));
new Gui::PrefPageProducer<FemGui::DlgSettingsFemGmshImp>(QT_TRANSLATE_NOOP("QObject", "FEM"));
new Gui::PrefPageProducer<FemGui::DlgSettingsFemCcxImp>(QT_TRANSLATE_NOOP("QObject", "FEM"));
new Gui::PrefPageProducer<FemGui::DlgSettingsFemElmerImp>(QT_TRANSLATE_NOOP("QObject", "FEM"));
new Gui::PrefPageProducer<FemGui::DlgSettingsFemMystranImp>(
QT_TRANSLATE_NOOP("QObject", "FEM"));
new Gui::PrefPageProducer<FemGui::DlgSettingsFemMystranImp>(QT_TRANSLATE_NOOP("QObject", "FEM"));
new Gui::PrefPageProducer<FemGui::DlgSettingsFemZ88Imp>(QT_TRANSLATE_NOOP("QObject", "FEM"));
// register preferences pages on Import-Export
new Gui::PrefPageProducer<FemGui::DlgSettingsFemExportAbaqusImp>(
QT_TRANSLATE_NOOP("QObject", "Import-Export"));
new Gui::PrefPageProducer<FemGui::DlgSettingsFemInOutVtkImp>(
QT_TRANSLATE_NOOP("QObject", "Import-Export"));
new Gui::PrefPageProducer<FemGui::DlgSettingsFemExportAbaqusImp>(QT_TRANSLATE_NOOP("QObject", "Import-Export"));
new Gui::PrefPageProducer<FemGui::DlgSettingsFemInOutVtkImp>(QT_TRANSLATE_NOOP("QObject", "Import-Export"));
// add resources and reloads the translators
loadFemResource();
// clang-format on
PyMOD_Return(mod);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,25 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License (LGPL) *
* as published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* for detail see the LICENCE text file. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* FreeCAD is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with FreeCAD; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
@@ -34,6 +32,7 @@
#include <Gui/WidgetFactory.h>
#include "DlgSettingsMaterial.h"
#include "Workbench.h"
// use a different name to CreateCommand()
void CreateMaterialCommands();
@@ -54,7 +53,7 @@ public:
Module()
: Py::ExtensionModule<Module>("MatGui")
{
initialize("This module is the MatGui module.");// register with Python
initialize("This module is the MatGui module."); // register with Python
}
~Module() override
@@ -68,7 +67,7 @@ PyObject* initModule()
return Base::Interpreter().addModule(new Module);
}
}// namespace MatGui
} // namespace MatGui
PyMOD_INIT_FUNC(MatGui)
{
@@ -90,6 +89,8 @@ PyMOD_INIT_FUNC(MatGui)
Base::Console().Log("Loading GUI of Material module... done\n");
MatGui::Workbench ::init();
// instantiating the commands
CreateMaterialCommands();

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -56,7 +55,8 @@ Array2D::Array2D(const QString& propertyName, Materials::Material* material, QWi
_property = nullptr;
}
if (_property) {
_value = static_cast<Materials::Material2DArray*>(_property->getMaterialValue());
_value =
std::static_pointer_cast<Materials::Material2DArray>(_property->getMaterialValue());
}
else {
_value = nullptr;
@@ -76,7 +76,7 @@ void Array2D::setupDefault()
}
try {
Materials::MaterialProperty& column1 = _property->getColumn(0);
const Materials::MaterialProperty& column1 = _property->getColumn(0);
QString label = QString::fromStdString("Default ") + column1.getName();
ui->labelDefault->setText(label);
if (column1.getPropertyType() == QString::fromStdString("Quantity")) {
@@ -118,7 +118,7 @@ void Array2D::setColumnDelegates(QTableView* table)
{
int length = _property->columns();
for (int i = 0; i < length; i++) {
Materials::MaterialProperty& column = _property->getColumn(i);
const Materials::MaterialProperty& column = _property->getColumn(i);
table->setItemDelegateForColumn(
i,
new ArrayDelegate(column.getType(), column.getUnits(), this));

View File

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

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -55,7 +54,8 @@ Array3D::Array3D(const QString& propertyName, Materials::Material* material, QWi
_property = nullptr;
}
if (_property) {
_value = static_cast<Materials::Material3DArray*>(_property->getMaterialValue());
_value =
std::static_pointer_cast<Materials::Material3DArray>(_property->getMaterialValue());
}
else {
_value = nullptr;
@@ -95,7 +95,7 @@ void Array3D::setupDefault()
}
try {
Materials::MaterialProperty& column1 = _property->getColumn(0);
auto& column1 = _property->getColumn(0);
QString label = QString::fromStdString("Default ") + column1.getName();
ui->labelDefault->setText(label);
if (column1.getPropertyType() == QString::fromStdString("Quantity")) {
@@ -122,7 +122,7 @@ void Array3D::defaultValueChanged(const Base::Quantity& value)
void Array3D::setDepthColumnDelegate(QTableView* table)
{
Materials::MaterialProperty& column = _property->getColumn(0);
auto& column = _property->getColumn(0);
table->setItemDelegateForColumn(0,
new ArrayDelegate(column.getType(), column.getUnits(), this));
}
@@ -159,7 +159,7 @@ void Array3D::setColumnDelegates(QTableView* table)
{
int length = _property->columns();
for (int i = 0; i < length; i++) {
Materials::MaterialProperty& column = _property->getColumn(i);
auto& column = _property->getColumn(i);
table->setItemDelegateForColumn(
i,
new ArrayDelegate(column.getType(), column.getUnits(), this));

View File

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

View File

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

View File

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

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -47,8 +46,8 @@ AbstractArrayModel::AbstractArrayModel(QObject* parent)
//===
Array2DModel::Array2DModel(Materials::MaterialProperty* property,
Materials::Material2DArray* value,
Array2DModel::Array2DModel(const Materials::MaterialProperty* property,
std::shared_ptr<Materials::Material2DArray> value,
QObject* parent)
: AbstractArrayModel(parent)
, _property(property)
@@ -58,10 +57,10 @@ Array2DModel::Array2DModel(Materials::MaterialProperty* property,
int Array2DModel::rowCount(const QModelIndex& parent) const
{
if (parent.isValid()) {
return 0;// No children
return 0; // No children
}
return _value->rows() + 1;// Will always have 1 empty row
return _value->rows() + 1; // Will always have 1 empty row
}
bool Array2DModel::newRow(const QModelIndex& index) const
@@ -105,7 +104,7 @@ QVariant Array2DModel::headerData(int section, Qt::Orientation orientation, int
{
if (role == Qt::DisplayRole) {
if (orientation == Qt::Horizontal) {
Materials::MaterialProperty& column = _property->getColumn(section);
const Materials::MaterialProperty& column = _property->getColumn(section);
return QVariant(column.getName());
}
else if (orientation == Qt::Vertical) {
@@ -188,8 +187,8 @@ bool Array2DModel::removeColumns(int column, int count, const QModelIndex& paren
//===
Array3DDepthModel::Array3DDepthModel(Materials::MaterialProperty* property,
Materials::Material3DArray* value,
Array3DDepthModel::Array3DDepthModel(const Materials::MaterialProperty* property,
std::shared_ptr<Materials::Material3DArray> value,
QObject* parent)
: AbstractArrayModel(parent)
, _property(property)
@@ -199,10 +198,10 @@ Array3DDepthModel::Array3DDepthModel(Materials::MaterialProperty* property,
int Array3DDepthModel::rowCount(const QModelIndex& parent) const
{
if (parent.isValid()) {
return 0;// No children
return 0; // No children
}
return _value->depth() + 1;// Will always have 1 empty row
return _value->depth() + 1; // Will always have 1 empty row
}
bool Array3DDepthModel::newRow(const QModelIndex& index) const
@@ -239,7 +238,7 @@ QVariant Array3DDepthModel::headerData(int section, Qt::Orientation orientation,
{
if (role == Qt::DisplayRole) {
if (orientation == Qt::Horizontal) {
Materials::MaterialProperty& column = _property->getColumn(section);
const Materials::MaterialProperty& column = _property->getColumn(section);
return QVariant(column.getName());
}
else if (orientation == Qt::Vertical) {
@@ -322,8 +321,8 @@ bool Array3DDepthModel::removeColumns(int column, int count, const QModelIndex&
//===
Array3DModel::Array3DModel(Materials::MaterialProperty* property,
Materials::Material3DArray* value,
Array3DModel::Array3DModel(const Materials::MaterialProperty* property,
std::shared_ptr<Materials::Material3DArray> value,
QObject* parent)
: AbstractArrayModel(parent)
, _property(property)
@@ -333,10 +332,10 @@ Array3DModel::Array3DModel(Materials::MaterialProperty* property,
int Array3DModel::rowCount(const QModelIndex& parent) const
{
if (parent.isValid()) {
return 0;// No children
return 0; // No children
}
return _value->depth() + 1;// Will always have 1 empty row
return _value->depth() + 1; // Will always have 1 empty row
}
int Array3DModel::columnCount(const QModelIndex& parent) const
@@ -384,7 +383,7 @@ QVariant Array3DModel::headerData(int section, Qt::Orientation orientation, int
{
if (role == Qt::DisplayRole) {
if (orientation == Qt::Horizontal) {
Materials::MaterialProperty& column = _property->getColumn(section + 1);
const Materials::MaterialProperty& column = _property->getColumn(section + 1);
return QVariant(column.getName());
}
else if (orientation == Qt::Vertical) {

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATGUI_ARRAYMODEL_H
#define MATGUI_ARRAYMODEL_H
@@ -46,8 +45,8 @@ public:
class Array2DModel: public AbstractArrayModel
{
public:
explicit Array2DModel(Materials::MaterialProperty* property = nullptr,
Materials::Material2DArray* value = nullptr,
explicit Array2DModel(const Materials::MaterialProperty* property = nullptr,
std::shared_ptr<Materials::Material2DArray> value = nullptr,
QObject* parent = nullptr);
~Array2DModel() override = default;
@@ -68,15 +67,15 @@ public:
bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex()) override;
private:
Materials::MaterialProperty* _property;
Materials::Material2DArray* _value;
const Materials::MaterialProperty* _property;
std::shared_ptr<Materials::Material2DArray> _value;
};
class Array3DDepthModel: public AbstractArrayModel
{
public:
explicit Array3DDepthModel(Materials::MaterialProperty* property = nullptr,
Materials::Material3DArray* value = nullptr,
explicit Array3DDepthModel(const Materials::MaterialProperty* property = nullptr,
std::shared_ptr<Materials::Material3DArray> value = nullptr,
QObject* parent = nullptr);
~Array3DDepthModel() override = default;
@@ -101,15 +100,15 @@ public:
bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex()) override;
private:
Materials::MaterialProperty* _property;
Materials::Material3DArray* _value;
const Materials::MaterialProperty* _property;
std::shared_ptr<Materials::Material3DArray> _value;
};
class Array3DModel: public AbstractArrayModel
{
public:
explicit Array3DModel(Materials::MaterialProperty* property = nullptr,
Materials::Material3DArray* value = nullptr,
explicit Array3DModel(const Materials::MaterialProperty* property = nullptr,
std::shared_ptr<Materials::Material3DArray> value = nullptr,
QObject* parent = nullptr);
~Array3DModel() override = default;
@@ -130,10 +129,10 @@ public:
bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex()) override;
private:
Materials::MaterialProperty* _property;
Materials::Material3DArray* _value;
const Materials::MaterialProperty* _property;
std::shared_ptr<Materials::Material3DArray> _value;
};
}// namespace MatGui
} // namespace MatGui
#endif// MATGUI_ARRAYMODEL_H
#endif // MATGUI_ARRAYMODEL_H

View File

@@ -30,7 +30,7 @@ list(APPEND MatGui_LIBS
${QtConcurrent_LIBRARIES}
)
set (Material_TR_QRC ${CMAKE_CURRENT_BINARY_DIR}/Resources/Material_translation.qrc)
set(Material_TR_QRC ${CMAKE_CURRENT_BINARY_DIR}/Resources/Material_translation.qrc)
qt_find_and_add_translation(QM_SRCS "Resources/translations/*_*.ts"
${CMAKE_CURRENT_BINARY_DIR}/Resources/translations)
qt_create_resource_file(${Material_TR_QRC} ${QM_SRCS})
@@ -76,6 +76,8 @@ SET(MatGui_SRCS
ModelSelect.ui
PreCompiled.cpp
PreCompiled.h
Workbench.cpp
Workbench.h
)
if(FREECAD_USE_PCH)
@@ -96,7 +98,6 @@ SET(MatGuiIcon_SVG
add_library(MatGui SHARED ${MatGui_SRCS} ${MatGuiIcon_SVG})
target_link_libraries(MatGui ${MatGui_LIBS})
SET_BIN_DIR(MatGui MatGui /Mod/Material)
SET_PYTHON_PREFIX_SUFFIX(MatGui)

View File

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

View File

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

View File

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

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -112,7 +111,7 @@ bool MaterialDelegate::editorEvent(QEvent* event,
void MaterialDelegate::showColorModal(QStandardItem* item)
{
QColor currentColor;// = d->col;
QColor currentColor; // = d->col;
currentColor.setRgba(parseColor(item->text()));
QColorDialog* dlg = new QColorDialog(currentColor);
@@ -275,7 +274,7 @@ QSize MaterialDelegate::sizeHint(const QStyleOptionViewItem& option, const QMode
std::string type = propertyType.toStdString();
if (type == "Color") {
return QSize(75, 23);// Standard QPushButton size
return QSize(75, 23); // Standard QPushButton size
}
else if (type == "2DArray" || type == "3DArray") {
return QSize(23, 23);
@@ -421,7 +420,7 @@ QWidget* MaterialDelegate::createWidget(QWidget* parent,
Gui::InputField* input = new Gui::InputField();
input->setMinimum(std::numeric_limits<double>::min());
input->setMaximum(std::numeric_limits<double>::max());
input->setUnitText(propertyUnits);// TODO: Ensure this exists
input->setUnitText(propertyUnits); // TODO: Ensure this exists
input->setPrecision(6);
input->setQuantityString(propertyValue);

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATGUI_MATERIALDELEGATE_H
#define MATGUI_MATERIALDELEGATE_H
@@ -46,7 +45,7 @@ class MaterialDelegate: public QStyledItemDelegate
Q_OBJECT
public:
explicit MaterialDelegate(QObject* parent = nullptr);
virtual ~MaterialDelegate() = default;
~MaterialDelegate() override = default;
QWidget* createEditor(QWidget* parent,
const QStyleOptionViewItem&,
@@ -82,6 +81,6 @@ private:
void showArray3DModal(const QString& propertyName, QStandardItem* item);
};
}// namespace MatGui
} // namespace MatGui
#endif// MATGUI_MATERIALDELEGATE_H
#endif // MATGUI_MATERIALDELEGATE_H

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -56,7 +55,7 @@ MaterialSave::MaterialSave(Materials::Material* material, QWidget* parent)
else {
ui->editFilename->setText(QString::fromStdString("NewMaterial.FCMat"));
}
_filename = QString(ui->editFilename->text());// No filename by default
_filename = QString(ui->editFilename->text()); // No filename by default
connect(ui->standardButtons->button(QDialogButtonBox::Ok),
&QPushButton::clicked,
@@ -97,7 +96,7 @@ void MaterialSave::onOk(bool checked)
Base::Console().Log("name '%s'\n", _filename.toStdString().c_str());
if (name != _material->getName()) {
_material->setName(name);
_material->setEditStateAlter();// ? Does a name change count?
_material->setEditStateAlter(); // ? Does a name change count?
}
auto variant = ui->comboLibrary->currentData();
@@ -132,8 +131,8 @@ void MaterialSave::reject()
void MaterialSave::setLibraries()
{
std::list<Materials::MaterialLibrary*>* libraries = _manager.getMaterialLibraries();
for (Materials::MaterialLibrary* library : *libraries) {
auto libraries = _manager.getMaterialLibraries();
for (auto library : *libraries) {
if (!library->isReadOnly()) {
QVariant libraryVariant;
libraryVariant.setValue(*library);
@@ -162,10 +161,11 @@ void MaterialSave::addExpanded(QTreeView* tree, QStandardItemModel* parent, QSta
tree->setExpanded(child->index(), true);
}
void MaterialSave::addMaterials(QStandardItem& parent,
const std::map<QString, Materials::MaterialTreeNode*>* modelTree,
const QIcon& folderIcon,
const QIcon& icon)
void MaterialSave::addMaterials(
QStandardItem& parent,
const std::shared_ptr<std::map<QString, Materials::MaterialTreeNode*>> modelTree,
const QIcon& folderIcon,
const QIcon& icon)
{
auto tree = ui->treeMaterials;
for (auto& mat : *modelTree) {
@@ -188,7 +188,7 @@ void MaterialSave::addMaterials(QStandardItem& parent,
auto node = new QStandardItem(folderIcon, mat.first);
addExpanded(tree, &parent, node);
// node->setFlags(Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
const std::map<QString, Materials::MaterialTreeNode*>* treeMap = nodePtr->getFolder();
auto treeMap = nodePtr->getFolder();
addMaterials(*node, treeMap, folderIcon, icon);
}
}
@@ -212,8 +212,7 @@ void MaterialSave::showSelectedTree()
lib->setFlags(Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
addExpanded(tree, model, lib);
std::map<QString, Materials::MaterialTreeNode*>* modelTree =
_manager.getMaterialTree(library);
auto modelTree = _manager.getMaterialTree(library);
addMaterials(*lib, modelTree, folderIcon, icon);
}
else {
@@ -241,7 +240,7 @@ void MaterialSave::onSelectModel(const QItemSelection& selected, const QItemSele
// Q_UNUSED(selected);
Q_UNUSED(deselected);
_filename = QString(ui->editFilename->text());// No filename by default
_filename = QString(ui->editFilename->text()); // No filename by default
QStandardItemModel* model = static_cast<QStandardItemModel*>(ui->treeMaterials->model());
QModelIndexList indexes = selected.indexes();
if (indexes.count() == 0) {

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATGUI_MATERIALSAVE_H
#define MATGUI_MATERIALSAVE_H
@@ -49,10 +48,11 @@ public:
void createModelTree();
void addExpanded(QTreeView* tree, QStandardItem* parent, QStandardItem* child);
void addExpanded(QTreeView* tree, QStandardItemModel* parent, QStandardItem* child);
void addMaterials(QStandardItem& parent,
const std::map<QString, Materials::MaterialTreeNode*>* modelTree,
const QIcon& folderIcon,
const QIcon& icon);
void
addMaterials(QStandardItem& parent,
const std::shared_ptr<std::map<QString, Materials::MaterialTreeNode*>> modelTree,
const QIcon& folderIcon,
const QIcon& icon);
void showSelectedTree();
void onSelectModel(const QItemSelection& selected, const QItemSelection& deselected);
@@ -76,6 +76,6 @@ private:
QString getPath(const QStandardItem* item) const;
};
}// namespace MatGui
} // namespace MatGui
#endif// MATGUI_MATERIALSAVE_H
#endif // MATGUI_MATERIALSAVE_H

View File

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -378,10 +377,11 @@ void MaterialsEditor::reject()
// auto pixmap = icon.pixmap();
// }
void MaterialsEditor::addMaterials(QStandardItem& parent,
const std::map<QString, Materials::MaterialTreeNode*>* modelTree,
const QIcon& folderIcon,
const QIcon& icon)
void MaterialsEditor::addMaterials(
QStandardItem& parent,
const std::shared_ptr<std::map<QString, Materials::MaterialTreeNode*>> modelTree,
const QIcon& folderIcon,
const QIcon& icon)
{
auto tree = ui->treeMaterials;
for (auto& mat : *modelTree) {
@@ -404,7 +404,7 @@ void MaterialsEditor::addMaterials(QStandardItem& parent,
auto node = new QStandardItem(folderIcon, mat.first);
addExpanded(tree, &parent, node);
node->setFlags(Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
const std::map<QString, Materials::MaterialTreeNode*>* treeMap = nodePtr->getFolder();
auto treeMap = nodePtr->getFolder();
addMaterials(*node, treeMap, folderIcon, icon);
}
}
@@ -549,8 +549,7 @@ void MaterialsEditor::fillMaterialTree()
QIcon icon(library->getIconPath());
QIcon folderIcon(QString::fromStdString(":/icons/folder.svg"));
std::map<QString, Materials::MaterialTreeNode*>* modelTree =
_materialManager.getMaterialTree(*library);
auto modelTree = _materialManager.getMaterialTree(*library);
addMaterials(*lib, modelTree, folderIcon, icon);
}
}
@@ -650,16 +649,16 @@ QString MaterialsEditor::getColorHash(const QString& colorString, int colorRange
std::stringstream stream(colorString.toStdString());
char c;
stream >> c;// read "("
stream >> c; // read "("
double red;
stream >> red;
stream >> c;// ","
stream >> c; // ","
double green;
stream >> green;
stream >> c;// ","
stream >> c; // ","
double blue;
stream >> blue;
stream >> c;// ","
stream >> c; // ","
double alpha = 1.0;
if (c == ',') {
stream >> alpha;
@@ -888,7 +887,7 @@ int MaterialsEditor::confirmSave(QWidget* parent)
}
int res = QMessageBox::Cancel;
box.adjustSize();// Silence warnings from Qt on Windows
box.adjustSize(); // Silence warnings from Qt on Windows
switch (box.exec()) {
case QMessageBox::Save:
saveMaterial();

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATGUI_MATERIALSEDITOR_H
#define MATGUI_MATERIALSEDITOR_H
@@ -116,16 +115,17 @@ private:
void createMaterialTree();
void fillMaterialTree();
void refreshMaterialTree();
void addMaterials(QStandardItem& parent,
const std::map<QString, Materials::MaterialTreeNode*>* modelTree,
const QIcon& folderIcon,
const QIcon& icon);
void
addMaterials(QStandardItem& parent,
const std::shared_ptr<std::map<QString, Materials::MaterialTreeNode*>> modelTree,
const QIcon& folderIcon,
const QIcon& icon);
bool isMaterial(const fs::path& p) const
{
return Materials::MaterialManager::isMaterial(p);
}
};
}// namespace MatGui
} // namespace MatGui
#endif// MATGUI_MATERIALSEDITOR_H
#endif // MATGUI_MATERIALSEDITOR_H

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
@@ -233,9 +232,10 @@ void ModelSelect::addExpanded(QTreeView* tree, QStandardItemModel* parent, QStan
tree->setExpanded(child->index(), true);
}
void ModelSelect::addModels(QStandardItem& parent,
const std::map<QString, Materials::ModelTreeNode*>* modelTree,
const QIcon& icon)
void ModelSelect::addModels(
QStandardItem& parent,
const std::shared_ptr<std::map<QString, Materials::ModelTreeNode*>> modelTree,
const QIcon& icon)
{
auto tree = ui->treeModels;
for (auto& mod : *modelTree) {
@@ -255,7 +255,7 @@ void ModelSelect::addModels(QStandardItem& parent,
auto node = new QStandardItem(mod.first);
addExpanded(tree, &parent, node);
node->setFlags(Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
const std::map<QString, Materials::ModelTreeNode*>* treeMap = nodePtr->getFolder();
auto treeMap = nodePtr->getFolder();
addModels(*node, treeMap, icon);
}
}
@@ -343,16 +343,13 @@ void ModelSelect::fillTree()
addExpanded(tree, model, lib);
addRecents(lib);
std::list<Materials::ModelLibrary*>* libraries = getModelManager().getModelLibraries();
for (Materials::ModelLibrary* library : *libraries) {
auto libraries = getModelManager().getModelLibraries();
for (auto library : *libraries) {
lib = new QStandardItem(library->getName());
lib->setFlags(Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
addExpanded(tree, model, lib);
// auto path = library->getDirectoryPath();
std::map<QString, Materials::ModelTreeNode*>* modelTree =
getModelManager().getModelTree(*library, _filter);
// delete modelTree;
auto modelTree = getModelManager().getModelTree(*library, _filter);
addModels(*lib, modelTree, QIcon(library->getIconPath()));
}
}
@@ -450,7 +447,7 @@ void ModelSelect::updateMaterialModel(const QString& uuid)
updateModelProperties(model);
}
void ModelSelect::clearMaterialModel(void)
void ModelSelect::clearMaterialModel()
{
// Update the general information
ui->editName->setText(QString::fromStdString(""));

View File

@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
**************************************************************************/
#ifndef MATGUI_MODELSELECT_H
#define MATGUI_MODELSELECT_H
@@ -78,10 +77,10 @@ private:
void addRecents(QStandardItem* parent);
void addFavorites(QStandardItem* parent);
void addModels(QStandardItem& parent,
const std::map<QString, Materials::ModelTreeNode*>* modelTree,
const std::shared_ptr<std::map<QString, Materials::ModelTreeNode*>> modelTree,
const QIcon& icon);
void updateMaterialModel(const QString& uuid);
void clearMaterialModel(void);
void clearMaterialModel();
void createModelTree();
void refreshModelTree();
void fillTree();
@@ -104,6 +103,6 @@ private:
int _recentMax;
};
}// namespace MatGui
} // namespace MatGui
#endif// MATGUI_MODELSELECT_H
#endif // MATGUI_MODELSELECT_H

View File

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

View File

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

View File

@@ -0,0 +1,34 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of FreeCAD. *
* *
* 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. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
**************************************************************************/
#include "PreCompiled.h"
#include "Workbench.h"
using namespace MatGui;
/// @namespace MatGui @class Workbench
TYPESYSTEM_SOURCE(MatGui::Workbench, Gui::StdWorkbench)
Workbench::Workbench() = default;
Workbench::~Workbench() = default;

View File

@@ -0,0 +1,47 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of FreeCAD. *
* *
* 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. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
**************************************************************************/
#ifndef MATGUI_WORKBENCH_H
#define MATGUI_WORKBENCH_H
#include <Gui/Workbench.h>
#include <Mod/Material/MaterialGlobal.h>
namespace MatGui
{
/**
* @author David Carter
*/
class MatGuiExport Workbench: public Gui::StdWorkbench
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
Workbench();
~Workbench() override;
};
} // namespace MatGui
#endif // MATGUI_WORKBENCH_H

View File

@@ -18,8 +18,30 @@
#* USA *
#* *
#***************************************************************************
"""Initialization of the Material Workbench graphical interface."""
# import FreeCADGui
import FreeCAD as App
import FreeCADGui as Gui
import os
# import Material_rc
# FreeCADGui.addPreferencePage(":/ui/preferences-material.ui","Material")
class MaterialWorkbench(Gui.Workbench):
"""Part workbench object."""
def __init__(self):
self.__class__.Icon = os.path.join(App.getResourceDir(),
"Mod", "Material",
"Resources", "icons",
"MaterialWorkbench.svg")
self.__class__.MenuText = "Material"
self.__class__.ToolTip = "Material workbench"
def Initialize(self):
# load the module
import MatGui
def GetClassName(self):
return "MatGui::Workbench"
Gui.addWorkbench(MaterialWorkbench())

View File

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

View File

@@ -1,23 +1,23 @@
# ***************************************************************************
# * Copyright (c) 2023 David Carter <dcarter@dvidcarter.ca> *
# * Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
# * *
# * 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. *
# * This file is part of FreeCAD. *
# * *
# * This program 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 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. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * 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 Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# **************************************************************************/
__title__ = "material model utilities"
__author__ = "David Carter"

View File

@@ -1,4 +1,24 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* This file is part of FreeCAD. *
* *
* 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. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
**************************************************************************/
#include "gtest/gtest.h"
@@ -90,10 +110,6 @@ TEST_F(MaterialTest, TestMaterialsWithModel)
auto mat = itp->first;
EXPECT_NO_THROW(materials->at(mat));
}
delete materials;
delete materialsComplete;
delete materialsLinearElastic;
}
TEST_F(MaterialTest, testMaterialByPath)