[fixed] [regression] number of decimals not taken into account
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
[fixed] [regression] number of decimals not taken into account
- set in the TD preferences to use alternate decimals and set it to "3":
result: the dimension has 2 digits, not 3
- now set in the TD preferences to use "global decimals"
- set in the general preferences to use 3 decimal places
- add new dimensions
result: the dimension has 2 digits, not 3
This is a regression to prior versions of FC 0.19 (must have been introduced recently).
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.20264 (Git)
Build type: Release
Branch: master
Hash: 107831e0a7769b4f09e2f8fdb0f8b59d100114dd
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)
- add new dimensionsresult: the dimension has 2 digits, not 3
- now set in the TD preferences to use "global decimals"
- set in the general preferences to use 3 decimal places
- add new dimensions
result: the dimension has 2 digits, not 3
This is a regression to prior versions of FC 0.19 (must have been introduced recently).
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.20264 (Git)
Build type: Release
Branch: master
Hash: 107831e0a7769b4f09e2f8fdb0f8b59d100114dd
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)
Last edited by uwestoehr on Sat Mar 28, 2020 1:20 pm, edited 1 time in total.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: [regression] number of decimals not taken into account
What is the preference for "FormatSpec"? If that is set to 2 digits, then "Use global decimals" and "Alternate decimals" are ignored.
Re: [regression] number of decimals not taken into account
But this contradicts the setting to use the global digits. I reset now me preferences and get this:wandererfan wrote: ↑Tue Mar 24, 2020 10:15 pm What is the preference for "FormatSpec"? If that is set to 2 digits, then "Use global decimals" and "Alternate decimals" are ignored.
So the default settings are to use the system-wide digits. I set them to 3 digits because I need this. Since this is a purpose decision, the TD prefs must take it into account and set the format accordingly.
I'll have a quick look if I could fix it.
Re: [regression] number of decimals not taken into account
Here's a PR: https://github.com/FreeCAD/FreeCAD/pull/3260
that does this:
So if there is a dot in the format, the first char after the dot is updated to either the global decimals or the specified alternate decimals.
Moreover when the update is also done when the dialog is loaded. This is important because of the use changed the system-wide decimals, TD might not have been loaded and can therefor not use the new value. So at least when the user opens the preferences, it will update to use the system-wide decimals.
What in my opinion is still missing is that in DrawViewDimension, the format is not used if its decimal number differs from that of the system-wide settings. This should be the case because the system-wide or alternate setting must actually be used, if the user set to use it. This can be for the cost that the current format is not used, but not the other way round as it is at the moment.
Could you please have a look? and also if my PR makes sense to you?
- babaroga
- Posts: 180
- Joined: Sun Aug 14, 2016 6:52 pm
- Location: Banja Luka, Republic of Srpska, Bosnia and Herzegovina
Re: [regression] number of decimals not taken into account
Hello,
In my usecase (furniture industry), I don't use fixed number of decimals.
So instead if %.2f i am using %.g. So if number is integer, it does not show any decimals.
So generally if I have some part wit eg. dimensions:
... and I pad it to 10 mm, I get:
So, maximum number of shown decimals is adjusted here:
If you have more decimals than in this settings, they will be rounded. So, if there is eg. set 1 decimal, you will get:
So, please, don't touch anything.
In my usecase (furniture industry), I don't use fixed number of decimals.
So instead if %.2f i am using %.g. So if number is integer, it does not show any decimals.
So generally if I have some part wit eg. dimensions:
... and I pad it to 10 mm, I get:
So, maximum number of shown decimals is adjusted here:
If you have more decimals than in this settings, they will be rounded. So, if there is eg. set 1 decimal, you will get:
So, please, don't touch anything.
Re: [regression] number of decimals not taken into account
I see now an issue with my patch: I don't check if the first character after the dot is a number. This is necessary because the format could e.g. be "%.g".uwestoehr wrote: ↑Wed Mar 25, 2020 2:43 am Here's a PR: https://github.com/FreeCAD/FreeCAD/pull/3260
-> I'll update the patch later today.
Re: [regression] number of decimals not taken into account
This could be a clean solution: TD uses "%.g" as default. If the user changes this format he knows what he is doing.
The issue is only that "%.g" takes always as many decimals as set system-wide. if the user set in the preferences to use e.g. 4 alternate decimals, "%.g" ignores this setting.
Wandererfan, do you see a method that "%.g" will take the alternate decimals as well? If yes, then "%.g" as default is in my opinion the clean solution.
- babaroga
- Posts: 180
- Joined: Sun Aug 14, 2016 6:52 pm
- Location: Banja Luka, Republic of Srpska, Bosnia and Herzegovina
Re: [regression] number of decimals not taken into account
It can be option for %.g , or fixed number of decimals with %.[something]f.
Eg, checkbox "fixed number of decimals" switch default format to%.[something]f . I think similar solution is offered in AutoCAD.
Eg, checkbox "fixed number of decimals" switch default format to%.[something]f . I think similar solution is offered in AutoCAD.
Re: [regression] number of decimals not taken into account
If this is not possible that "%.g" would also take the alternate decimals, my updated PR: https://github.com/FreeCAD/FreeCAD/pull/3260
is the best solution because it assures that always the set number of decimals will be used (for the cost that the format is lost of course). But at the moment the default format is "%.2f" and is blocking any change in the number of decimals.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: [regression] number of decimals not taken into account
This is the solution I intend to use:
- move default format spec to Advanced property tab and initialize it to blank.
- if formatSpec preference is blank, use global decimals or alternate decimals as specified on Dimension tab to build the initial formatSpec for each dimension.
- if formatSpec preference is not blank, use the formatSpec as specified in the preference.
- for average users, there is a simple choice of A or B
- if a user is advanced enough to go looking for formatSpec and compose a printf format string, then they are assumed to know what they are doing, and we just use the specified string.