Commit Graph

64 Commits

Author SHA1 Message Date
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
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
5106c7e69a Base: UnitsApi: remove nowhere called init() 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
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
Benjamin Bræstrup Sayoc
6f619b5f1c Base: remove unneeded includes 2025-02-18 11:07:57 -06: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
9f7218ac75 Base: Units: remove unused defines 2024-12-23 17:48:42 +01:00
Ladislav Michl
379d7ea9d5 Base: Units: return std::string 2024-12-23 17:48:42 +01:00
Max Wilfinger
8ff5a1f688 Fix source string typos mentioned on Crowdin (#15261) 2024-07-08 17:18:31 -05:00
Ladislav Michl
3a25a66a05 Base: Do not use else before return 2024-01-21 16:14:12 +01:00
hasecilu
13209cc80c [Base/Units] Change strings' description
Affect strings presented to the user on the combobox to select unit system.

- The symbol to represent angles on "degree" unit is '°'
- Change imperial velocity to "ft/s" to enforce the use of 's' symnbol as second
2023-12-19 16:35:22 -06:00
wmayer
bd88162b9d fix readability-*:
* readability-const-return-type
* readability-container-data-pointer
* readability-container-size-empty
* readability-delete-null-pointer
* readability-else-after-return
* readability-inconsistent-declaration-parameter-name
* readability-redundant-member-init
* readability-redundant-smartptr-get
* readability-redundant-string-cstr
* readability-use-anyofallof
* readability-static-definition-in-anonymous-namespace
* readability-static-accessed-through-instance
* readability-simplify-boolean-expr
2023-11-16 01:22:08 +01:00
pre-commit-ci[bot]
57a333e2b2 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-11-16 00:24:09 +01:00
wandererfan
a2e26f5002 [Units]Add Meters-only schema (#7395)
- use correct unit for velocity

- typo in include guard
2023-11-16 00:24:09 +01:00
wmayer
985def3416 Base: apply clang format 2023-11-13 12:01:26 -05:00
wmayer
097d5d6fee Base: C++ core guidelines: init variables 2023-08-24 18:48:52 +02:00
Chris Hennes
8b73653633 Gui: Translate unit system UI 2023-05-15 20:16:46 -05:00
wmayer
7193ea0007 Base: [skip ci] fix readability-identifier-length 2022-11-19 16:54:08 +01:00
wandererfan
23b1ed84a4 [Units]Allow querying schema for unit of measure 2022-11-19 16:49:46 +01:00
wandererfan
c51f804b3b [Base]identify schemas which use multiple units
- allow querying a schema to determine if it uses multiple
  units for length (ex ft/in) or angles (ex DMS).
2022-08-31 16:31:27 -04:00
wmayer
6ff1ccb140 Base: use forward declaration instead of including Python.h 2022-03-03 19:18:07 +01:00
Uwe
4d0a5c045c [Base] Units and Uui: remove unused includes 2022-02-24 11:08:56 +01:00
wmayer
e38f378acc Base: harmonize UnitsApi::toString/UnitsApi::toNumber with UnitsSchema::toLocale 2022-02-06 12:47:13 +01:00
wmayer
e5a3854fe2 Base: [skip ci] fix inconsistency in overloaded UnitsApi::toNumber() 2022-02-06 08:49:50 +01:00
wmayer
5502d1f2a7 Base: clean-up code in UnitsApi 2022-01-25 00:26:47 +01:00
Syres916
ced5f31993 [Base] Remove one unnecessary precision level 2021-08-12 11:13:29 +01:00
Syres916
147e015fd2 [Base] Increase precision 2021-08-12 10:55:50 +01:00
luz paz
59b7e9fdd0 Base: remove Py2 code 2021-04-26 09:23:58 +02:00
wmayer
b0d29b745c Base: add convenience functions to create a QString from quantity 2021-04-20 14:56:29 +02:00
wmayer
e4f98b4512 Base: add convenience functions to create a QString from quantity or double 2021-04-20 14:07:20 +02:00
Benjamin Nauck
8a2cfc268e [Base] Remove includes to StdStlTools.h as that's not needed anymore
std::make_unique was introduced in c++14, so no need to use the back
ported version
2021-03-06 21:20:32 +01:00
luz paz
01b21e0d06 Base: Fix header uniformity, whitespace, and doxygen
[skip ci]
2020-11-22 18:12:16 +01:00
Bernd Hahnebach
0c9e6c6158 Base: add new unit schema for mm and N for use in FEM 2020-08-07 19:19:44 +02:00
luz.paz
011e5aedfa src/Base: [skip ci] fix header uniformity
This PR fixes header uniformity across all `src/Base` files
2019-12-25 11:38:58 +01:00
donovaly
bab14b5895 more fixes for the UnitsCalculator
- we must read out the unit system description UTF8 to get the characters ² and ³
- update unit system description according to today's unit "cft" addition
- don't hardcode the unit system descriptions in the .ui file
- add acceleration to imperial schema
2019-12-24 13:31:13 +01:00
wmayer
980c6ab227 Base: [skip ci] replace raw pointers of UnitsSchema with unique_ptr 2019-12-21 10:45:22 +01:00
wmayer
c16c7eda27 Base: [skip ci] make UnitSystem an enum class 2019-12-21 10:10:19 +01:00
wandererfan
fefe83ecbb Add ImperialCivil Units Schema
- units for civil engineering - ft, ft2, ft3, mph,
  and angles as degrees/minutes/seconds
2018-12-06 08:57:17 -03:00
luz.paz
9167064fc1 Misc. typos
Found via `codespell`
2018-04-25 09:41:33 -03:00
Unknown
e3eca59173 Misc. typo fixes
Various workbenches
2017-12-23 14:30:30 +01:00
wmayer
cf8c1f6956 fix warning 2017-08-13 16:58:06 +02:00
wmayer
35ddd3926b extend Python api of units:
+ get list of all available schemas
+ get currently set schema
+ translate a quantity to a given schema
2017-08-13 16:55:00 +02:00
Itai Nahshon
258ca0723d Add UnitsSchemaMmMin - izes are only in mm, speed in mm/munute. 2017-07-18 17:41:36 +02:00
Yorik van Havre
d4b7100bb2 py3: Base: files R-Z ported to python3
issue 0000995
2017-05-21 12:35:41 +02:00
wmayer
fb7094bf31 use specialized exception classes 2017-04-28 18:49:11 +02:00
wmayer
39e589a4d7 fix -Wextra in FreeCADBase 2016-09-21 15:02:02 +02:00
wmayer
61b62ee314 add class QuantityFormat to control user string of Quantity
do some code refactoration to reduce duplicate code
2016-08-06 19:06:29 +02:00