New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Material: Material handling enhancements #10690
Conversation
@FEA-eng -- can you take a look at the FEM side of this to make sure I'm not missing any major flaws? |
This is obviously a big one. So we need some concentrated testing and code review. |
I have issues with compilation from source code but I'll try to test this somehow. |
There is a new dependency on lib-yaml. If you're on Linux, you'll need to install lib-yaml-dev. On windows, you'll need the latest libpack |
Well, it's a bigger issue in my case. I haven't been able to compile on Windows without crashes when creating any geometry: https://forum.freecad.org/viewtopic.php?t=73143&start=30#p703935 When it comes to Linux, my virtual Ubuntu machine is missing some dependencies and I don't know how to add them: https://forum.freecad.org/viewtopic.php?t=81204 |
macro(SetupYamlCpp) | ||
# -------------------------------- YamlCpp -------------------------------- | ||
|
||
find_package(yaml-cpp REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking this as "REQUIRED" should eliminate the need for the test code after it, right?
@davesrocketshop The only changes to FEM appear to be clang-format-based -- is that correct? |
Not quite. The material preferences have been removed from FEM. There are now separate preferences under Materials. This means the removal of the .ui file, it's corresponding .h and .cpp, CMakefiles, and the line of code that loaded it in AppFemGui.cpp. |
I don't see those changes in the current version of this PR -- can you double-check that you've |
Looking at the changed files, they're in there. They also show correctly in the PR branch. |
That's very strange, I don't see any file removals from FEM in this PR. I'll try to look closer this evening. |
The removals aren't showing in the "Files changed" section, but they're not there. Can't really explain that. The removed files are: src/Mod/Fem/Gui/DlgSettingsFemMaterial.ui The changes are showing in CMakeFiles.txt and AppFemGui.cpp |
src/Mod/Fem/Gui/AppFemGui.cpp
Outdated
@@ -25,35 +25,26 @@ | |||
#include <Base/Console.h> | |||
#include <Base/PyObjectBase.h> | |||
#include <Gui/Application.h> | |||
#include <Gui/WidgetFactory.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know who or what has modified this file but as long as Fem is not listed in the .pre-commit-config.yaml file any formatting changes should be avoided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This happened when saving the file in VSCode, which is configured to apply the clang rules on saving. The modification was the removal of the material preferences panel, in favour of moving it to a Materials preferences page.
src/Mod/Material/App/Exceptions.h
Outdated
{ | ||
this->setMessage(msg); | ||
} | ||
~Uninitialized() throw() override = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw()
is deprecated. Use noexcept
instead.
src/Mod/Material/App/FolderTree.h
Outdated
{} | ||
virtual ~FolderTreeNode() = default; | ||
|
||
NodeType getType(void) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See modernize-redundant-void-arg: In modern C++ code void
shouldn't be use any more as argument of a function.
src/Mod/Material/App/FolderTree.h
Outdated
|
||
private: | ||
NodeType _type; | ||
std::map<QString, FolderTreeNode<T>*>* _folder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the ownership of these pointers handled? If not consider using a std::shared_ptr.
MaterialConfigLoader::MaterialConfigLoader() | ||
{} | ||
|
||
bool MaterialConfigLoader::isConfigStyle(const QString& path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix const-correctness
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Static function, so already const correct
return true; | ||
} | ||
|
||
QString MaterialConfigLoader::getAuthorAndLicense(const QString& path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix const-correctness
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Static function, so already const correct
src/Mod/Material/App/AppMaterial.cpp
Outdated
* * | ||
* This file is part of the FreeCAD CAx development system. * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For new source files we should use the new copyright text:
/***************************************************************************
* 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/>. *
* *
**************************************************************************/
|
||
public: | ||
MaterialManager(); | ||
virtual ~MaterialManager() = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be ~MaterialManager() override = default;
#define MATERIAL_MATERIALVALUE_H | ||
|
||
#include <QVariant> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lacks of #include <Mod/Material/MaterialGlobal.h>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from other workbenches but I'll definitely fix
src/Mod/Material/App/Materials.cpp
Outdated
|
||
MaterialProperty::MaterialProperty() | ||
{ | ||
_valuePtr = new MaterialValue(MaterialValue::None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible memory leak! _valuePtr is a raw pointer but the destructor doesn't destroy it.
As said above consider using a std::shared_ptr or std::unique_ptr
src/Mod/Material/App/PreCompiled.h
Outdated
|
||
#include <FCConfig.h> | ||
|
||
#include <Mod/Material/MaterialGlobal.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This include shouldn't be needed here because every header that requires the export macro should include it. Only this way the clang code model will be able to correctly parse source files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments in the source code.
Good comments. I'll get to work. It should be noted however that many of your comments are for code copied closely from other workbenches, which is why it was done this way. I also appear to have skipped a few C++ "standardization" meetings, so I'm relearning :) |
What is that variable ? I built FreeCAD from your branch but I see the old editor. How can I activate the new one ? |
The problem is that I don't have "Material" in Preferences. Is there something else that I should do to activate it ? |
This is a problem I haven't figured out. If you load the workbench it shows up, but I haven't figured out how to do that automatically. There's also no option to load the workbench in the workbench preferences, it just doesn't show up. As a workaround, in the Python console, type 'import MatGui'. You'll then have the preferences available. |
485be95
to
bb83faa
Compare
I have fixed the issue and merged the changes. If you refresh your repo you will see normal workbench behaviour |
bb83faa
to
2f1fe0c
Compare
@davesrocketshop can you rebase? You're probably getting conflicts because we just added FEM to our pre-commit formatter. |
I'd want someone to walk me through that as it's not something I've done before. Every thing I read says don't do it unless you know what you're doing and I definitely don't |
Sorry, I was using "rebase" as shorthand for "using whatever strategy you like, fix the conflicts that have now appeared with the merge" -- I'd personally |
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.
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.
2f1fe0c
to
442bca8
Compare
for more information, see https://pre-commit.ci
Done |
What's left to do here ? |
I have no actionable items I'm aware of for this PR. I'm already working on the follow on. |
I was waiting for the CI to get cleaned up in the master branch (an earlier PR broke things) -- since this is going to be a big merge I didn't want to muddy the waters 😄 . |
Congrats @davesrocketshop and FreeCAD as a whole. Really exciting milestone! |
Rework of the material handling system.
This is a replacement for #10368, which will be closed in favour of this request.
This first part concentrates 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 specify whether the old or new material editors are to be used. This option will be removed before release.