Commit Graph

1426 Commits

Author SHA1 Message Date
Benjamin Nauck
ae686942a7 Base: Use std::numeric_limits and std::numbers instead of defines 2025-03-29 13:32:37 +01:00
marioalexis
8c6e77ee97 Base: Improve schema translation for electrical units 2025-03-28 07:43:15 +01:00
marioalexis
406a834a6d Base: Add volume charge density unit 2025-03-27 21:13:21 +01:00
Chris Hennes
67982f3963 Base: Add Console::DestructorError as noexcept
Create a new console output that eats exceptions so it is safe to use in a destructor.
2025-03-25 09:45:25 +01:00
Chris Hennes
af8a86f6bf Base: Eliminate use of deprecated PyWeakref_GetObject
Co-authored-by: João Matos <joao@tritao.eu>
2025-03-23 22:43:03 +01:00
Chris Hennes
ebc0dc165d Base: Initialize tp_versions_used in PyTypeObject (3.13)
This field is undocumented, but exists in the source code for 3.13
(see https://github.com/python/cpython/blob/3.13/Include/cpython/object.h#L232)
and gives a compiler warning if left uninitialized.
2025-03-23 22:42:08 +01:00
bofdahof
4ceecd0857 Replace std::endl with '\n' 2025-03-21 23:30:41 -05:00
bofdahof
e4ebaba805 Exception.cpp 2025-03-21 22:39:41 -05:00
Florian Foinant-Willig
7bf1b5d787 Fix FreeCAD#19588 2025-03-20 20:14:50 +01:00
tritao
8d36987f16 Base: Remove XML binding files. 2025-03-19 20:04:19 -05:00
Chris Hennes
64d658e38a FreeCAD: Compiler warning fixes 2025-03-19 10:13:34 +01:00
Chris Hennes
e574fa1efc Merge pull request #19899 from tritao/cmake-cleanup-targets
CMake: Cleanup targets with transitive dependencies
2025-03-17 13:15:37 -05:00
bofdahof
f8be6f5233 Base: Switch small enum base type to std::uint8_t
int and size_t are much larger than necessary for storage of these
enum types.
2025-03-17 12:34:14 -05:00
tritao
6c2c6847eb CMake: Cleanup targets with transitive dependencies 2025-03-17 12:12:06 +00:00
Chris Hennes
5f623390fb Merge pull request #20142 from bofdahof/ranges
Apply C++20 std::ranges (mainly to std::find)
2025-03-17 03:08:27 -05:00
Chris Hennes
4fcdac28fb Merge pull request #19583 from hyarion/refactor/base-type
Refactor Base::Type
2025-03-17 00:03:22 -05:00
bofdahof
77689e3bb1 Base: apply std::ranges 2025-03-16 17:14:51 -05:00
Chris Hennes
dced463dc6 Merge pull request #19428 from tritao/base-tracy-profiler
Base: Add Tracy frame profiling support.
2025-03-14 04:12:05 +00:00
Joao Matos
7ae14d6bd5 Base: Add build support and instrumentation for the Tracy profiler. 2025-03-14 03:41:30 +00:00
Chris Hennes
be8b92182c Merge pull request #19921 from mosfet80/QT_CLEAN
REMOVE old QT<= 5.14 code
2025-03-11 20:54:59 +00:00
mos
c70a7933e6 Removed old Python code <3.10 2025-03-07 16:34:08 -06:00
Benjamin Nauck
a0a64c1fb8 Base: Make Type::importModule private 2025-03-06 20:50:04 +01:00
Benjamin Nauck
e7119ee243 Base: Add documentation of Type 2025-03-06 20:50:04 +01:00
Benjamin Nauck
ece25df768 Base: Add asserts to check that Type has been initialized 2025-03-06 20:50:04 +01:00
Benjamin Nauck
280c1c610d Base: Minor cleanup
* Add const
* Add final
* [[nodiscard]]
* Fix parameter names
* Add TypeId instead of unsigned int
* Add "BadType" string constant

Some some other tweaks
2025-03-06 20:49:58 +01:00
Andrea
da66720d3a REMOVE old QT<= 5.14 code
Ubuntu 22.04  use qt 1.15.3.
In the code is still used qt code <5.10.
A cleanup was done by removing qT code version used in ubuntu 18.04.
2025-03-05 09:32:06 +01:00
PaddleStroke
50394a6ef3 Update PreCompiled.h 2025-03-03 10:21:37 -06:00
Chris Hennes
7f1c43a335 Merge pull request #19636 from kadet1090/color-in-base
Base: Move App::Color to Base
2025-03-02 16:36:40 -06:00
Chris Hennes
0c4ed644c4 Merge pull request #19450 from tritao/base-python-api-model
Base: Modernize Python bindings APIs
2025-03-02 16:34:25 -06:00
Chris Hennes
6512dc69e9 Merge pull request #19761 from chennes/coverityFixesFeb2025
Base: Coverity fixes from February 2025 run (round 1)
2025-03-02 16:15:17 -06:00
Joao Matos
c71e11101a Base: Modernize Python bindings APIs 2025-03-01 16:32:22 +00:00
Chris Hennes
cf477695f9 Merge pull request #19671 from kadet1090/placement-indicator
Gui: Add Show Placement helper
2025-02-25 17:40:58 +00:00
Benjamin Bræstrup Sayoc
755229df23 Build: suppress warnings from 3rd party libraries
Warnings from 3rd parties are not relevant and are only polluting the warning output. Marking these libraries as SYSTEM suppresses warning.

https://gcc.gnu.org/onlinedocs/cpp/Invocation.html#index-I
https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html
2025-02-25 14:39:05 +00:00
ᴩʜᴏɴᴇᴅʀᴏɪᴅ
cf21e9a542 [ Doxygen ] Improved Parameter Group - Copy & Insert (#19563) 2025-02-24 10:52:34 -06:00
Chris Hennes
5f35875c46 Merge pull request #19516 from tritao/tools-python-bindings-gen
Tools: Introduce a new Python-based C++ bindings generator
2025-02-24 16:39:24 +00:00
Joao Matos
cc6ffb44de Core: Move PyCXX library to src/3rdParty. 2025-02-24 16:36:06 +00:00
Kacper Donat
7078982660 Base: Add Vector3*::Unit* axis constants
This is simple helper that can be used to replace hardcoded values of
base axis with properly labeled ones.
2025-02-24 17:30:27 +01:00
Kacper Donat
62432046bf Gui: Fix empty sketch plane rendering 2025-02-24 17:30:27 +01:00
Kevin Martin
41f09db9e1 Address performance of existing unique-name generation (Part 2) (#18676)
As described in Issue 16849, the existing Tools::getUniqueName method
requires calling code to form a vector of existing names to be avoided.

This leads to poor performance both in the O(n) cost of building such a
vector and also getUniqueName's O(n) algorithm for actually generating
the unique name (where 'n' is the number of pre-existing names).

This has  particularly noticeable cost in documents with large numbers
of DocumentObjects because generating both Names and Labels for each new
object incurs this cost. During an operation such as importing this
results in an O(n^2) time spent generating names.

The other major cost is in the saving of the temporary backup file,
which uses name generation for the "files" embedded in the Zip file.
Documents can easily need several such "files" for each object in the
document.

This update includes the following changes to use the newly-added
UniqueNameManager as a replacement for the old Tools::getUniqueName
method and deletes the latter to remove any temptation to use it as
its usage model breeds inefficiency:

Eliminate Tools::getUniqueName, its local functions, and its unit tests.

Make DocumentObject naming use the new UniqueNameManager class.

Make DocumentObject Label naming use the new UniqueNameManager class.
This needs to monitor DocumentObject Labels for changes since this
property is not read-only. The special handling for the Label
property, which includes optionally forcing uniqueness and updating
links in referencing objects, has been mostly moved from
PropertyString to DocumentObject.

Add Document::containsObject(DocumentObject*) for a definitive
test of an object being in a Document. This is needed because
DocumentObjects can be in a sort of limbo (e.g. when they are in the
Undo/Redo lists) where they have a parent linkage to the Document but
should not participate in Label collision checks.

Rename Document.getStandardObjectName to getStandardObjectLabel
to better represent what it does.

Use new UniqueNameManager for Writer internal filenames within the zip
file.

Eliminate unneeded Reader::FileNames collection. The file names
already exist in the FileList collection elements. The only existing
use for the FileNames collection was to determine if there were any
files at all, and with FileList and FileNames being parallel
vectors, they both had the same length so FileList could be used
for this test..

Use UniqueNameManager for document names and labels. This uses ad hoc
UniqueNameManager objects created on the spot on the assumption that
document creation is relatively rare and there are few documents, so
although the cost is O(n), n itself is small.

Use an ad hoc UniqueNameManager to name new DymanicProperty entries.
This is only done if a property of the proposed name already exists,
since such a check is more-or-less O(log(n)), almost never finds a
collision, and avoids the O(n) building of the UniqueNameManager.
If there is a collision an ad-hoc UniqueNameManager is built
and discarded after use.
The property management classes have a bit of a mess of methods
including several to populate various collection types with all
existing properties. Rather than introducing yet another such
collection-specific method to fill a UniqueNameManager, a
visitProperties method was added which calls a passed function for
each property. The existing code (e.g. getPropertyMap) would be
simpler if they all used this but the cost of calling a lambda
for each property must be considered. It would clarify the semantics
of these methods, which have a bit of variance in which properties
populate the passed collection, e.g. when there are duplicate names..
Ideally the PropertyContainer class would keep a central directory of
all properties ("static", Dynamic, and exposed by ExtensionContainer and
other derivations) and a permanent UniqueNameManager. However the
Property management is a bit of a mess making such a change a project
unto itself.
2025-02-24 10:23:53 -06:00
Benjamin Nauck
140527d64a Base: Use pass by value instead of reference as size is small 2025-02-24 08:30:18 +01:00
Benjamin Nauck
e956bc2101 Base: Constrain size of Base::Type 2025-02-24 08:30:18 +01:00
Benjamin Nauck
27222321c6 Base: Use constant for Type::BadType instead Type::badType() 2025-02-24 08:30:18 +01:00
Benjamin Nauck
a9828d6fea Base: Use isBad() instead of comparing types with == 2025-02-24 08:30:18 +01:00
Kacper Donat
2f35f1c561 Base: Add fromPercent and toPercent helpers 2025-02-23 22:51:13 +01:00
Kacper Donat
7f984811e8 Gui: Add 3 point lighting 2025-02-23 22:51:13 +01:00
Chris Hennes
318d6e1555 Base: Stop exception from leaking from Console().*
These are sometimes used in destructors, where a raised exception calls terminate()
2025-02-21 10:56:41 -06:00
tritao
8ba573712c Tools: Introduce a Python-based API bindings template generator.
This extends the existing XML-based template generator to allow an
additional kind of Python-based input.

The Python code is read as source code to an AST to a typed model
equivalent to the existing XML model, and processed by the existing
code templates into compatible code.

This provides a few benefits, namely readability is much increased,
but more importantly, it allows associating the APIs with Python's new
typing information, which will allow to provide accurate type hinting
without additional downstream processing in the future.

Right now this is just a proof-of-concept but if the approach is
well received, then a more complete implementation can be done with
further conversion of existing binding files.

Here is an example of how it looks, though I still think the metadata
is too verbose and can be made to look nicer with some further work.

```python
from ..Base.Metadata import metadata
from ..Base.Persistence import PersistencePy
from typing import Any, Optional, List

@metadata(
    Father="PersistencePy",
    Name="DocumentPy",
    Twin="Document",
    TwinPointer="Document",
    Include="Gui/Document.h",
    Namespace="Gui",
    FatherInclude="Base/PersistencePy.h",
    FatherNamespace="Base"
)
class DocumentPy(PersistencePy):
    """
    This is a Document class.

    Author: Werner Mayer (wmayer@users.sourceforge.net)
    Licence: LGPL
    """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        """
        Constructor for DocumentPy.
        """
        super(DocumentPy, self).__init__(*args, **kwargs)
        pass

    def show(self, objName: str) -> None:
        """
        show(objName) -> None

        Show an object.

        Parameters:
            objName (str): Name of the `Gui.ViewProvider` to show.
        """
        pass
```
2025-02-21 16:32:13 +00:00
Kacper Donat
12a69fe296 Base: Add isNullOrEmpty string helper
This adds isNullOrEmpty string helper that cheks if string is... well
null or empty. It is done to improve readability of the code and better
express intent.
2025-02-21 15:04:43 +01:00
Benjamin Bræstrup Sayoc
dda05369c4 Base: remove unneeded includes 2025-02-18 11:07:57 -06:00
Kacper Donat
1ce7c678bb Base: Add Color parameter Type
This adds Color parameter type to the ParameterGroup. Internally colors
are stored as unsigned longs so it only is convienance layer.
2025-02-17 21:10:26 +01:00