Commit Graph

99 Commits

Author SHA1 Message Date
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
wmayer
994578d8af encode keys of PropertyMap when saving as XML 2019-09-05 18:51:35 +02:00
Zheng, Lei
3c242e05f6 App: ignore unit in PropertyBool/Float/Integer
In other word, those property now accept expression result with a unit,
by ignoring it.
2019-08-30 15:50:26 +02:00
Zheng, Lei
00166c2346 DocumentObject: add allowDuplicateLabel/onBeforeChangeLabel()
These two APIs allow an object to control its own labeling rules.
The previous auto re-labeling for uniqueness logic is moved from
ObjectLabelObserver (resides in Application.cpp) to PropertyString.

DocumentObject::allowDuplicateLabel() is used to inform PropertyString
that the object allows duplicate label regardless of application
setting. onBeforeChangeLabel() is called before actual label change to
give object a chance to override the new label.
2019-08-17 14:52:09 +02:00
Zheng, Lei
be6ec3fdfc App: Property related API changes
Property:

* Extended property status bitset. Mirror most of PropertyType and
  allow dynamic change property type.

* Cache property name and type to improve performance

* Centralize property status change signalling

* Change aboutToSetValue()/hasSetValue() to virtual

* Add new API getFullName() to obtain full quanlified name of the property

AtomicPropertyChangeInterface:

* Allow calling aboutToSetValue()/hasSetValue() when actually changed

PropertyLists:

* Refactor implementation by an abstract class PropertyListBase and a
  template class PropertyListsT, to allow better code reuse.
  PropertyListT is derived from AtomicPropertyChangeInterface to allow
  more efficient change on individual elements.

* All list type property now accept setting python value as a dictionary
  with index as key to set individual element of a list.

* Add touch list for more efficient handling of value changes. The list
  contains the index of changed value. And empty touch list should be
  treated as the entire list is changed. PropertyContainerPy expose this
  functionality with getPropertyTouchList().

PropertyPersistentObject:

* New property to allow dynamic creation of any FreeCAD object derived
  from Base::Persistence, and use it as a property.

DynamicProperty:

* Use boost multi_index_container for efficient property lookup while
  keeping order.

* Modify to be allowed to use in PropertyContainer directly

PropertyContainer:

* Use boost multi_index_container for efficient property lookup while
  keeping order.

* Allow adding/removing dynamic property on all property container

* Modify Save/Restore() to persist property status, and better handle
  transient property which can now be dynamically enabled/disabled per
  object.

* Add new API getFullName() to obtain full quanlified name of the property.
  Implemented by Document, DocumentObject, and also
  ViewProviderDocumentObject if future patch

DocumentObject and FeaturePython are modified to accommondate the
dynamic property changes.

Removed get/setCustomAttribute() implementation from DocumentObjectPy,
and rely on PropertyContainerPy for the implementation, because of the
additional dynamic property support in property container.

Gui::ViewProviderDocumentObject, which is derived from
PropertyContainer, is also modified accordingly
2019-08-17 14:52:09 +02:00
wmayer
4c04933fd7 fix bug when checking for str type in PropertyEnumeration::setPyObject 2019-04-07 12:16:18 +02:00
wmayer
9bdd92989e PVS: V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. 2019-03-08 18:56:16 +01:00