Improves the use of the ShapeAppearance property for the Part workbench.
removes DiffuseColor property
adds Python compatibility using custom attributes
transitions DiffuseColor to ShapeAppearance on open
Improved UI elements for setting object appearance, and appearance per face
Lays the foundation for future texture support
In v0.22 a version number -1 is added to the material files to distinguish between old and new project file.
But v0.21 doesn't know about this version number and interprets it as number of elements instead.
Because this value is assigned to an unsigned type the value becomes 2**32 - 1. Now trying to create a container of this size requires > 280 GB
of RAM. On most systems FreeCAD new handler will jump in and raises a memory exception to stop the allocation. But an other systems with
plenty of RAM it's tried to allocate the memory and then may crash at some point.
This PR fixes this regression. It puts the version number to the MaterialList XML element as an optional attribute.
With this change FreeCAD v0.22 is still able to load projects that have been created prior to this change.
Additionally FreeCAD v0.21 can again load project files without crashing.
For more details see: https://forum.freecad.org/viewtopic.php?t=87268
When synchronizing the Transparency property with the transparency value of the ShapeAppearance property then do not convert between float and
double as otherwise some strange rounding issues can occur.
Example: Set the Transparency property of an object to 35 in the Property Editor. After leaving the editor the value may switch to 34.
Uses new material system for appearance
Each feature object now has a property called ShapeMaterial that
describes its physical properties. If it has a shape, it has a
material.
The ShapeColor attribute is replaced by a ShapeAppearance attribute.
This is a material list that describes all appearance properties, not
just diffuse color. As a list in can be used for all elements of a
shape, such as edges and faces.
A new widget is provided to allow the user to select materials in a
consistent fashion. It can also launch the material editor with its
more advanced capabilities.
This patch substitutes by isAttachedToDocument() (almost) everywhere where
getNameInDocument() is used for this purpose.
The very few places not touched by this patch demand a (just a little) less trivial change.
When we change the returning type of getNameInDocument() to std::string,
those places will be easily found, because they shall generate a compiler error
(converting std::string to bool).
Rationale:
The fact that getNameInDocument() return nullptr to indicate
that the object is not attached to a document is responsible for lots of bugs
where the developer does not check for "nullptr".
The idea is to eliminate all those uses of getNameInDocument() and, in the near future,
make getNameInDocument() return always a valid std::string.
=====================================================================
Issue #11183
- The message is not useful for the user in terms of content.
- The user can do nothing about it, but move on.
To compare if two property contains the same content. The default
implementation in Property uses the persistense interface to save both
properties to string and compares the content. This may not work at the
moment if the property saves content in separate file or in binary.
Various properties have cheaper implementation to direct compare their
internal values.
The enumeration items are exposed through sub path '.Enum'. When
'ShowAll' is enabled in property view, this sub path is exposed as a
sub property item named 'Enum', and can be either manually edited or
bound with an expression.
‣ Make countersink and counterbore on metric holes freely definable by user.
‣ Fixed the Naming of M1.6, M2, M2.5 and M3.5
‣ Added constructor for custom enums from Enums to PropertyEnumeration
‣ Put definitions of cut-types (counterbore/countersink) for
screwtypes into json-files for easy modification.
‣ Allow users to put its own definitions in json-files in
[UserDir]/Mod/PartDesign/Resources/Hole
‣ Contains several examples of cut-type definition json-files that are
propably not production-ready.
This uses a local copy of nlohmann::json¹ to read json-files.
__________
¹ This is a very nice,header-only C++ library under the MIT License
(https://github.com/nlohmann/json). I copied the single-file-version
and the forward-declaration-header into …/PartDesign/App/ so no new
dependencies arise.