Commit Graph

105 Commits

Author SHA1 Message Date
wmayer
1dfe98a10d Core: Improve PropertyMaterialList::readString 2024-06-17 16:30:25 +02:00
wmayer
59377a48a9 Core: Make sure that PropertyMaterialList cannot become empty
The PropertyMaterialList is supposed to guarantee that it always has at least one element
2024-06-15 18:31:24 -05:00
wmayer
87a7bc1d81 Fix compiler warnings 2024-06-02 14:59:45 +02:00
David Carter
5feb963f9d Material: Appearance Updates 2
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
2024-06-01 19:57:16 -05:00
wmayer
58988a7482 Core: Fix memory leaks with PySequence_GetItem 2024-05-08 23:40:27 +02:00
wmayer
65dbd776fb Core: Fix crash when loading a file with v0.21 that was created with v0.22
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
2024-05-06 17:56:25 +02:00
wmayer
ecc0da8036 App: Create PropertyMaterialList with a single material element 2024-04-25 17:04:36 +02:00
wmayer
92ac3cc0d3 Core: avoid conversion from float to double or vice-versa
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.
2024-04-09 22:15:51 +02:00
wmayer
acb7be7a95 App: Add PropertyMaterialList::resizeByOneIfNeeded to avoid code duplication 2024-04-09 22:15:51 +02:00
wmayer
2d7d394960 App: fix PropertyMaterial::Save to create valid XML output 2024-04-09 22:15:51 +02:00
wmayer
bb10ff72b5 App: refactor MaterialPy to avoid code duplication 2024-04-09 22:15:51 +02:00
David Carter
ba20441935 Material: Material appearance
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.
2024-04-04 07:39:58 -05:00
André Caldas
89dbab9b0e Avoids using getNameInDocument() to test if DocumentObject is attached to a Document.
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.
2023-12-11 17:37:58 +01:00
Abdullah Tahiri
b52d05b11a App: PropertyStandard - make developer warning only for the developer
=====================================================================

Issue #11183

- The message is not useful for the user in terms of content.
- The user can do nothing about it, but move on.
2023-12-09 11:06:04 +01:00
wmayer
d305f306df Core: Revert superfluous changes made with PR #9521 2023-10-09 15:06:45 +02:00
AgCaliva
3da00e36a3 Merge Master 2023-08-30 16:24:16 -03:00
wmayer
1cf1a90a17 App: modernize C++: use default member init 2023-08-23 19:51:44 +02:00
wmayer
4991475341 App: modernize C++: use range-based for loop 2023-08-14 16:40:25 +02:00
AgCaliva
9cf1cdadbc Implemented DocumentReader for GuiDocument.xml reading. Final 2023-06-30 20:50:36 -03:00
AgCaliva
1db4bcf374 Revert "DocumentReader implemented for GuiDocument.xml reading."
This reverts commit 2eb5fd7f132035e24880bd88076d49ed368e23e0.
2023-06-30 20:27:12 -03:00
AgCaliva
69b324e422 DocumentReader implemented for GuiDocument.xml reading. 2023-06-30 18:41:00 -03:00
0penBrain
ebc5cb16a9 [Core] Add possibility to set color with tuple of integers, fixes #8344 2023-02-12 18:16:59 +01:00
berniev
22dcf5866f App: use empty 2022-08-06 19:29:59 +02:00
berniev
b6cae3bfdf App: Modernise ctors dtors defs etc 2022-08-01 00:34:46 +02:00
berniev
85170b2879 remove redundant void 2022-07-31 10:27:44 +02:00
andrea
61a5551940 Remove unused code into App 2022-07-23 14:27:50 +02:00
wmayer
ab6c75fad9 Core: replace PyObject_IsTrue with Base::asBoolean 2022-07-16 14:04:05 +02:00
wmayer
2628fb0350 App: fix memory leaks in Enumeration class and simplify code 2022-06-25 18:18:57 +02:00
marioalexis
1bc43b8606 App: Use PyObject_IsTrue in combination with conditional ternary operator 2022-06-22 19:50:03 -04:00
Chris Hennes
f7edc74eee App: PR6497 move return statement to new line 2022-03-29 12:33:37 -05:00
wmayer
91e4e468dd Base: move ILogger sub-classes to their own source files in order to reduce including stream classes in client code 2022-03-06 10:13:47 +01:00
Uwe
a8c912d6f8 [App] Expression and Extension: remove unused includes 2022-02-25 18:06:57 +01:00
Uwe
d88397f3d6 [App] Placement and Property: remove unused includes 2022-02-24 01:09:00 +01:00
Zheng, Lei
54c484df9b App: add Property::isSame() API
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.
2021-12-21 21:41:02 -07:00
Chris Hennes
7687582d53 App: fix compilation of PropertyStandard.cpp during cherry-pick 2021-11-14 20:45:09 -06:00
Zheng, Lei
26ba872aa6 App/Gui: improve expression binding of PropertyEnumeration
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.
2021-11-14 20:45:09 -06:00
wmayer
e92325c9c9 App: remove some more deprecated Py2 code
and remove deprecated void from function signature and replace 0 or NULL with nullptr
2021-04-26 10:55:56 +02:00
wmayer
30e9ba9609 App: add convenience methods to get minimum, maximum and step size of property constraints 2021-03-03 08:12:03 +01:00
vosk
9ad15a0a3d [App] [skip ci] - Fix python new references leaking 2021-02-19 17:25:25 +01:00
luz paz
84553bf191 App: Fix header uniformity, trailing whitespace, and doxygen headers 2020-11-19 13:38:37 +01:00
M G Berberich
7f328ac376 [PartDesign] Dynamic hole cut-types
‣ 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.
2020-10-31 12:49:00 +01:00
wmayer
d60f75b3b0 App: [skip ci] fix PropertyEnumeration::setEnums to avoid to produce index values out of range 2020-10-19 16:09:57 +02:00
Priit Laes
d6b8725b34 build: boost: Drop branches requiring boost-1.46 2020-10-13 12:56:28 +02:00
wmayer
6c020f554d + fix Enumeration::contains: the current index is irrelevant when searching for an entry in the enumeration
+ only print a warning if the enumeration is not empty but the restored index is < 0
2020-05-19 08:45:02 +02:00
wmayer
939419fb29 App: [skip ci] remove duplicate check 2020-05-09 16:44:08 +02:00
Zheng, Lei
8030d56397 App: fix some property's setPathValue() 2020-05-09 16:36:33 +02:00
wmayer
70a51373a3 App: [skip ci] handle types long and unsigned long in PropertyFloat::setPathValue() 2020-04-27 12:44:54 +02:00
Zheng, Lei
b2eef61a0b App: fix PropertyBool::setPathValue() 2020-04-01 13:28:05 +02:00
luz.paz
019f73852c src/App: [skip ci] fix header uniformity
This PR fixes header uniformity across all `src/App` files
2019-12-25 11:38:43 +01:00
wmayer
9fa56345cf core system
force strict ISO C++ (-Wpedantic)
TODO: still a lot of variadic macros are not valid ISO C++
2019-09-18 01:01:14 +02:00