Commit Graph

111 Commits

Author SHA1 Message Date
pre-commit-ci[bot]
9fe130cd73 All: Reformat according to new standard 2025-11-11 13:49:01 +01:00
PhoneDroid
c913317c28 [ Base ]: Updated SPDX 2025-10-14 10:00:04 -05:00
Markus Reitböck
5a423dab39 Base: use CMake to generate precompiled headers on all platforms
"Professional CMake" book suggest the following:

"Targets should build successfully with or without compiler support for precompiled headers. It
should be considered an optimization, not a requirement. In particular, do not explicitly include a
precompile header (e.g. stdafx.h) in the source code, let CMake force-include an automatically
generated precompile header on the compiler command line instead. This is more portable across
the major compilers and is likely to be easier to maintain. It will also avoid warnings being
generated from certain code checking tools like iwyu (include what you use)."

Therefore, removed the "#include <PreCompiled.h>" from sources, also
there is no need for the "#ifdef _PreComp_" anymore
2025-09-14 09:47:01 +02:00
Ladislav Michl
9f87add8cc Base: UnitsSchema: use basic imperial conversion constants
Use well defined basic constants for conversion of imperial units.
This makes code hopefully easily readable and verificable.
2025-09-05 17:31:55 +02:00
Ladislav Michl
a5f039dd6a Base: QuantityFormat: avoid storing formatting defaults
User defined precision and fractional inch are stored on QuantityFormat
construction making changes persistent to object life time.
Change that so until not explicitely overriden, user defined values
are always returned.

Co-authored-by: Matthias Danner <28687794+matthiasdanner@users.noreply.github.com>
2025-09-05 17:31:54 +02:00
Ladislav Michl
0278a1298d Base: refactor unit formatting defaults
Defaults for both precision (number of digits after decimal point)
and denominator (number of fractions) are defined on various places
making difficult to find which default is used for various tasks.
Store these values at one central place: UnitsApi. Unless overriden
by user, default values are defined by unitSchemasDataPack.
2025-09-05 17:31:54 +02:00
Ladislav Michl
1c99a9377c Base: Quantity: attribute pressure quantities to pressure unit
Although CompressiveStrength is of the same dimension as Pressure,
make it more straightforward and use base unit.
2025-09-05 17:31:54 +02:00
Ladislav Michl
1691fce36b Base: Quantity: remove redundant 'this' 2025-09-05 17:31:54 +02:00
Ladislav Michl
51aaaaff45 Base: make UnitsApi::toNumber method of Quantity
This static method takes Quantity as a parameter, so make it
method of Quantity directly.
2025-09-05 17:31:54 +02:00
Ladislav Michl
81e1321b32 Base: make UnitsApi::toString method of Quantity
This static method takes Quantity as a parameter, so make it
method of Quantity directly.
2025-09-05 17:31:54 +02:00
Ladislav Michl
533dd1b7ce Base: Quantity: Assign work unit to all energy quantities
Fixes: 847e2f5c85 ("Base: Units: refactor")
2025-08-25 00:05:06 +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
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
4480b8d8cb Base: cleanup Quantity class 2025-04-27 00:42:47 +02:00
Ladislav Michl
ce82b109d5 Base: Quantity: rename lexer and parser files
Rename files according 7d233dc ("Gui: Rename generated lexer files
to match core naming pattern"). Note that C space errors (space
before tabs, spaces on blank lines, etc.) still need to be fixed
manually after regenerating lexer file.
2025-04-08 11:09:36 +02:00
Benjamin Nauck
cb51f3fd2c Base: Add #include <limits> where used 2025-03-31 23:50:30 +02:00
Benjamin Nauck
3253f2c2de Base: Use std::numeric_limits and std::numbers instead of defines 2025-03-29 13:32:37 +01:00
Ladislav Michl
49ce1e0449 Base: Quantity: use std::nan 2024-12-23 17:48:42 +01:00
Ladislav Michl
3bddb723d5 Base: UnitsSchema: return std::string 2024-12-23 17:48:42 +01:00
Ladislav Michl
0b3adee2ab Base: Quantity: return std::string 2024-12-23 17:48:42 +01:00
Ladislav Michl
379d7ea9d5 Base: Units: return std::string 2024-12-23 17:48:42 +01:00
wmayer
defc6cd906 Base: Fix memory leak in Quantity::parse
If an exception is thrown then the allocated buffer won't be cleaned up. To make this exception-safe the class
StringBufferCleaner is added using the RAII idiom
2024-04-25 14:34:02 +02:00
Adrián Insaurralde Avalos
592b31eb7b Base: escape quotes in Quantity::getSafeUserString
fix #12204 and fix #12206
2024-02-12 12:09:30 -06:00
Chris Hennes
cfd41683a5 Core: Enable compiling with MSVC /permissive- (#11014)
* Base: Fixes for MSVC permissive-

* App: Fixes for MSVC permissive-

* Gui: Fixes for MSVC permissive-

* Main: Fixes for MSVC permissive-

* Fem: Fixes for MSVC permissive-

* Material: Fixes for MSVC permissive-

* Part: Fixes for MSVC permissive-

* Mesh: Fixes for MSVC permissive-

* Points: Fixes for MSVC permissive-

* Robot: Fixes for MSVC permissive-

* TechDraw: Fixes for MSVC permissive-

* Path: Fixes for MSVC permissive-

* Core; Changes per review comments

* TD: Revision from wandererfan

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-11-27 17:37:29 +01:00
wmayer
985def3416 Base: apply clang format 2023-11-13 12:01:26 -05:00
mosfet80
cb607ffe1e [BASE] Removed dead code (#10330) 2023-08-28 10:41:20 -05:00
Daniel-Khodabakhsh
071200ac8a Add various matrix related expression functions (#8603)
Adds a few new Expression functions with the goal to:

- Simplify Placement, Rotation, Vector and Matrix object creation.
- Add new matrix functions for rotation and translation.
2023-03-11 20:13:23 -06:00
wmayer
a23d862b2b Base: fix/ignore some clang-tidy warnings 2023-02-28 15:17:06 +01:00
wmayer
545aa0eed9 Base: make static const predefined quantities 2023-02-28 15:17:06 +01:00
wmayer
752e33d340 Base: fix Lint warnings in Quantity 2023-02-28 15:17:06 +01:00
wmayer
c8a35d85fe Base: fix pow() of Quantity 2023-02-27 22:13:08 +01:00
wmayer
75fedd8146 Base: handle several Lint warnings 2023-02-27 20:07:01 +01:00
wmayer
57eb7a5b07 Base: add missing != operator to Quantity 2023-02-27 20:07:01 +01:00
0penBrain
0d577a8789 Base: introduce 'getSafeUserUnit' that fallbacks to full precision and internal unit ...
... in case unit schema would zero a non-zero quantity

 For example, using '1 mil' with UnitsSchemaImperialDecimal schema
2023-02-23 15:22:07 +01:00
Uwe
a58c74c556 [Core] disable the the unit Oersted
- is not feasible for practical usage and (was up to now not used, thus no consequence)
  moreover, Oersted is a cgs unit while we use SI units, thus also not suitable for FEM, only makes problems for magnetization
2023-02-08 19:59:36 +01:00
luzpaz
79e150a81b Fix trailing whitespace, typos, headers
Fix trailing whitespace, typos, and header uniformity.
2023-01-23 00:34:37 +01:00
wmayer
6653991a97 Gui/Mod: handle several compiler warnings:
* ignore -Wfree-nonheap-object for generated code
* replace 0 with Qt::NoModifier when creating a QKeyEvent
* in Qt 5.14 QCombobox::activated(QString) is deprecated, use textActivated
* don't mix QCheckBox::setChecked() with tristate API
2022-11-29 10:36:02 +01:00
0penBrain
caa4784550 Base: fix quantity construction when unit as string is empty 2022-04-02 18:09:35 +02:00
Chris Hennes
b5c72abee4 Base: PR6497 move return statement to new line 2022-03-29 12:34:34 -05:00
wmayer
4a343ab31e Base/App: fix warnings from code analysers:
* convert old-style-casts to explicit C++ casts where possible
* make some implicit conversions explicit
2022-03-06 23:49:30 +01:00
Uwe
686a025416 [Base] Quantity, Rotation, Stream: remove unused includes 2022-03-01 11:27:54 +01:00
wmayer
cad0d01883 Base: modernize C++11
* remove redundant void-arg
* use nullptr
* replace deprecated headers
2022-01-25 20:21:30 +01:00
wmayer
3945dc0f74 Base: only handle Base::ParserError exceptions for quantity expressions 2022-01-22 01:15:12 +01:00
0penBrain
66c513c698 [Core] Fix Quantity construction with value as double + unit as string 2022-01-21 14:56:11 +01:00
Preslav
5030d8bb6d Added stiffness units to FreeCAD [mN/m, N/m, kN/m, MN/m] 2021-08-16 12:27:41 +01:00
wmayer
e4f98b4512 Base: add convenience functions to create a QString from quantity or double 2021-04-20 14:07:20 +02:00
donovaly
6c67300d62 [Base] add electrical conductivity
- this is necessary to perform electrodynamics simulations. Since the typical values are in the range of 1e6 S/m, we need the new units kS and MS

- since this is for simulations, also add electrical conductivity to the FEM material cards
2021-03-25 17:13:52 +01:00
David Carter
6c57cebc9b Base: fixes #0004586: Conversion error for PoundForce (lbf) 2021-03-03 12:39:49 +01:00