Commit Graph

1500 Commits

Author SHA1 Message Date
wmayer
11a05b71b7 Base: Use nested std::array for Matrix4D class 2025-06-16 10:05:43 +02:00
wmayer
13232cbc7b Base: Simplify Base::Matrix4D
As discussed in https://forum.freecad.org/viewtopic.php?t=65959 reduce code duplications
2025-06-16 10:05:43 +02:00
wmayer
7998f57048 Base: Use i,j consistently for iterations Matrix4D
As discussed in https://forum.freecad.org/viewtopic.php?t=65959
use consistently i,j to iterate over rows and columns
2025-06-16 10:05:43 +02:00
wmayer
e9ef35c53d Base: Do not use short int in Matrix4D
As discussed in https://forum.freecad.org/viewtopic.php?t=65959
replace short with int.
2025-06-16 10:05:43 +02:00
Chris Hennes
c134c05e8b Base: Disable XML external entity expansion
Addresses https://github.com/FreeCAD/FreeCAD/security/code-scanning/29
2025-06-13 10:44:01 +02:00
Benjamin Nauck
92bf6e5f2a Merge pull request #21147 from 3x380V/units
Units rework II
2025-06-04 15:58:00 +02:00
wmayer
d1e9c7b013 Base: Fix size in array 2025-06-04 14:14:20 +02:00
wmayer
a4d971020d Base: Fix typo 2025-06-04 14:14:20 +02:00
wmayer
2fe7b30ee9 Base: Remove weird error parameter from encode 2025-06-04 14:14:20 +02:00
wmayer
231680c9ce Base: Allow to also throw exception by given Python type 2025-06-04 14:14:20 +02:00
wmayer
2c60e83f25 Base: Improve Python exception handling
If the Python profiler is activated then transporting the dict as
exception object is broken where InteractiveInterpreter::runCode()
fails to restore it.
To fix the problem use Exception::setPyException() instead inside
the macto PY_CATCH and the generated wrapper code.

This also improves exception handling in command line mode.
2025-06-04 14:14:20 +02:00
bofdahof
2e0df80e84 Base: Units: refactor
Refactor Units making it constexpr, immutable, with repetition reduced.
Separate data from code.

Constexpr constructed units allow constructing predefined Quantities
from predefined unit types.
2025-06-03 09:31:38 +02:00
Ladislav Michl
a0917bcc7c Base: Units: introduce unit one
Dimensionless quantities have all exponents equal to zero.
Such quantities are simply numbers. The associated unit is
the unit one, symbol 1, although this is rarely explicitly
written.

See chapter 2.3.3 Dimensions of quantities, The International
System of Units, 9th edition.
2025-06-03 09:31:38 +02:00
Ladislav Michl
0c9584ab2d Base: Quantity: use isDimensionless whenever feasible
Quantity is often queried for Unit just to see if it has a dimension.
Ask Quantity directly using isDimensionless() method and modify that
method not to care about Quantity value validity; no user was ever
asking for value validity.
2025-06-03 09:31:38 +02:00
Ladislav Michl
4a9eccf530 Base: minor refactoring of UnitsSchema::toLocale 2025-06-03 09:31:38 +02:00
Ladislav Michl
16d736fb96 Base: fix UnitsSchema::translate
Schema translation previously returned factor 0 and unit string
of input quantity if there was no translation match. Restore
that behaviour as well as returned factor and unit string of
imperial schemas.

Fixes: 1155f0d752 ("Base: simplify UnitsSchemas management")
2025-06-03 09:31:38 +02:00
samrg472
03006b706a Fix compiling ProgressIndicator with precompiled headers 2025-06-02 16:35:10 -05:00
Kacper Donat
df6949dcde Merge pull request #21427 from tritao/async-occt-progress
Part: Introduce `OCCTProgressIndicator` and port operations to support it.
2025-06-02 18:04:38 +02:00
David Carter
0603113ba2 Core: Fix Thermal Conductivity units conversion
It appears that unit conversions for thermal conductivity were reversed
when migrating to the new system versus conversions in 1.0 and earlier.
2025-06-02 11:03:46 -05:00
Yorik van Havre
640642eed2 Translations: Merged crowdin translations 2025-06-02 11:48:26 +02:00
Yorik van Havre
26e16765b0 Translations: updated ts files 2025-06-02 11:07:28 +02:00
James Stanley
a2de481445 Base: Add Base::ProgressIndicator for OCCT progress reporting
Introduce a new `ProgressIndicator` base class
(`ProgressIndicator.h`/`.cpp`) with a singleton-managed, no-op default
implementation matching OCCT’s `Message_ProgressIndicator` interface.
Update `CMakeLists.txt` to include the new sources.
2025-05-30 14:10:28 +01:00
David Carter
7927977bf8 Core: Correct unit merge errors
Several units were merged our of order. This corrects the ordering.
2025-05-20 19:45:09 +02:00
Benjamin Nauck
1b6ac3408e Base: Fix use after free in unit error message 2025-05-20 12:34:00 +02:00
Andrea
0f9a16260d Removed empty functions
Removed empty functions
2025-05-19 18:25:17 +02:00
Ladislav Michl
baad73f0e3 Base: fix conversion to kilometers in Standart unit schema
Fixes: 1155f0d752 ("Base: simplify UnitsSchemas management")
2025-05-19 12:15:51 +02:00
Ladislav Michl
d69a143a17 Base: align unit format to Quantity parser expectations
Quantity parser is unable to deal with exponents written in
supersript, so change it back to ^n.

The micro prefix is expected to be U+00B5, not U+03BC, so change
it back as well. Note, that \x escape sequence reads till the
whitespace or the end of string, thus microFarad becomes
  "\xC2\xB5""F

Fixes: 1155f0d752 ("Base: simplify UnitsSchemas management")
2025-05-19 12:15:51 +02:00
Ladislav Michl
3e09bf975c Base: fix QuantityPy::getValueAs
Fixes: 77f4515963 ("Base: refactor QuantityPy class")
2025-05-19 12:15:51 +02:00
bofdahof
d4a031583f Base: restore output format of imperial fraction units
Fixes: 1155f0d752 ("Base: simplify UnitsSchemas management")
2025-05-19 12:15:51 +02:00
Kohei Takahashi
0a78771733 Base: Fixed segfault on destructing cached string (#20563)
* Base: Fixed segfault on destructing cached string

Xerces default memory manager is deleted before destructing static local
variable and segfault.

---------

Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2025-05-15 17:23:03 +00:00
Luz Paz
ee4fa234c9 Fix various typos
Missed by the codespell CI not being functional for a period of time.
2025-05-15 10:59:48 -05:00
Ladislav Michl
602880ed80 Base: revert to using ASCII chararacters for imperial lengths
The new unit schema management is using U+2032 and U+2033 characters
for feet and inches while parser is expecting only ' and ", while
U+2032 and U+2033 are used for arcminute and arcsecond.

While this is not an ideal solution and parser should deal with both,
revert back to ASCII for now.

Fixes: 1155f0d752 ("Base: simplify UnitsSchemas management")
2025-05-14 11:39:09 +02:00
Syres916
67d0345870 Base: fix default unit schema
Fix the transcription error which occured while moving into
single structure. Default schema now uses milimeters again.

Fixes: 1155f0d752 ("Base: simplify UnitsSchemas management")
2025-05-14 10:25:47 +02:00
Ladislav Michl
e577bebe56 Base: fix Python interface for Unit schema selection
Fixes: 1155f0d752 ("Base: simplify UnitsSchemas management")
2025-05-14 10:20:49 +02:00
Ladislav Michl
2e35afd6e0 Base: sort returned Unit schema description
Return schemas name and description vectors sorted by number, so
index can be used later to select particular schema.

Fixes: 1155f0d752 ("Base: simplify UnitsSchemas management")
2025-05-14 10:20:49 +02:00
Chris Hennes
952485dcbb Merge pull request #19907 from benj5378/getAttribute
Base: make getAttribute template
2025-05-12 10:39:55 -05:00
Benjamin Bræstrup Sayoc
2b1aec0041 Base: make getAttribute template 2025-05-09 15:54:57 +02:00
bofdahof
ba2c2ca5ad Console: rename PascalCase named methods to camelCase 2025-05-06 17:50:21 +02:00
bofdahof
1dbc0638c3 Console: misc refactors
- use C++20 contains where appropriate
- add nolint redundant qualifier
- remove old todo
- remove redundant enum name
- add const
- remove redundant classname
- remove redundant inline
- remove redundant namespace
2025-05-06 17:50:21 +02:00
Ladislav Michl
9683cf1e4f Base: rename Exception's PascalCase methods to camelCase 2025-05-05 23:50:01 +02:00
bofdahof
bf4ace0957 Base: simplify Exception
Remove repetition. Add functions to replace macros, but keep macros
in use for now as some compilers have broken std::source_location
support.
2025-05-05 23:50:01 +02:00
Jacob Oursland
4b03b614eb Base: use nullptr instead of 0 in Base. 2025-05-05 12:12:15 -05:00
bofdahof
353acbb27b Base: simplify UnitsSchemas management
Fixes: Maintaining schemas is difficult and error-prone

- Facilitate easy schemas add, remove, change, etc.
- Remove 14 files containing approx 2,190 lines of if/else code and data
- Place data in one file (UnitsSchemasData.h) using a normalized structure (including special functions)
- Isolate and simplify data operations (code)
- Remove schemas enum to keep data independent of code
- Separate responsibilities: Specifications, data, schemas, schema
- Add schema data 'isDefault'
- Add schema data name
- Prefer algorithms to raw loops
- Add schemas unit tests
- Tweak quantity unit tests
2025-04-27 00:45:54 +02:00
bofdahof
d23c204537 Base: refactor QuantityPy class 2025-04-27 00:45:47 +02:00
bofdahof
4480b8d8cb Base: cleanup Quantity class 2025-04-27 00:42:47 +02:00
Ladislav Michl
8ba8c04b20 Base: remove explicit namespace-name qualifier from *PyImp.cpp
Explicit Base namespace-name is used randomly across PyImp sources.
Remove it.
2025-04-27 00:05:32 +02:00
Ladislav Michl
3769dfd338 Base: cleanup includes in *PyImp.cpp
Sort includes and implicitely add missing ones. While there
consistently explain where generated files some from.
2025-04-27 00:05:32 +02:00
Ladislav Michl
99f86bd40a Base, Gui: remove lefovers from xml -> pyi conversion 2025-04-25 11:57:24 +02:00
Kacper Donat
81b675733d CMake: Rebuild .cpp/.h files from .pyi on build 2025-04-24 16:40:24 -05:00
Pieter Hijma
519b78d775 [Doc] Improve documentation PropertyContainer 2025-04-22 13:42:50 +02:00