[Possible bug] Vertical Dimensions do not appear centered by default

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
ToniTen
Posts: 240
Joined: Fri Sep 04, 2020 10:11 am

[Possible bug] Vertical Dimensions do not appear centered by default

Post by ToniTen »

I recently realized that vertical dimensions, when at their default location, under all the options for "Standards and Style", all appear offset down and not centered, but what appears to my eyes the height of a line of text, at the font size set for the dimension label:
Screenshot_2022-01-17_15-14-39.png
Screenshot_2022-01-17_15-14-39.png (45.94 KiB) Viewed 2196 times
All dimensions are left "as is" after adding them, default "Standards and Style" is changed between views to ensure that the dimensions are not manually modified in any way. Center lines are added to the faces to better visualize the offset
Is this intentional? As shown, horizontal dimensions are centered, but vertical dimensions are offset. At any scale, the offset is the same: just one line of text.

I've also attached the FreeCAD file that I used to generate this.

FreeCAD version information:

Code: Select all

OS: Ubuntu 18.04.6 LTS (XFCE/xubuntu)
Word size of FreeCAD: 64-bit
Version: 0.20.27078 (Git) AppImage
Build type: Release
Branch: (HEAD detached at bcdd926)
Hash: bcdd926686f2245fe60baface1cce1ab3dff7a5b
Python version: 3.9.9
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.3
Locale: Spanish/Spain (es_ES)
Attachments
vertical dimension location.FCStd
(17.24 KiB) Downloaded 24 times
User avatar
bensay
Posts: 202
Joined: Wed Dec 22, 2021 8:14 pm
Location: Danmark
Contact:

Re: [Possible bug] Vertical Dimensions do not appear centered by default

Post by bensay »

Addition: as far as I know, the numbers are only centered at creation, meaning if touched/moved, it is no longer located according to norms. Maybe there should be a feature that allows the user to recenter all numbers and relocating them according to ISO/ASME standards?
ToniTen
Posts: 240
Joined: Fri Sep 04, 2020 10:11 am

Re: [Possible bug] Vertical Dimensions do not appear centered by default

Post by ToniTen »

bensay wrote: Tue Jan 18, 2022 8:42 am Addition: as far as I know, the numbers are only centered at creation, meaning if touched/moved, it is no longer located according to norms. Maybe there should be a feature that allows the user to recenter all numbers and relocating them according to ISO/ASME standards?
Now that TechDrawTools has landed in master, there is, though it's in a slightly unintuitive way:
ToniTen wrote: Mon Jan 17, 2022 12:04 pmUsing the "Extensions: Attributes/Modifications"/ "Position Horizontal|vertica Chain Dimensions"|"Cascade Horizontal Dimensions" will center the dimension over the dimension line, even if only one dimension is selected.
The vertical equivalents will move the dimension back to it's default, offset down position
These tools are intended for creating multiple dimensions on the same line/ nested dimensions, but they work with just one dimension just fine.
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: [Possible bug] Vertical Dimensions do not appear centered by default

Post by Syres »

ToniTen wrote: Mon Jan 17, 2022 2:27 pm all appear offset down and not centered, but what appears to my eyes the height of a line of text, at the font size set for the dimension label:
I tried to make an expression for the Base>Y parameter but it would appear Font Size is not exposed to be used as an expression. I could definitely create a macro to look up the font size and make a calculation but it would be better done in the core code. I'll have a look and see what I can find but I also need to be certain that this isn't platform/font specific.

The line in the core code is https://github.com/FreeCAD/FreeCAD/blob ... s.cpp#L772

I've just added 2.5 and it worked so just need to work out how to look up the font size and divide by two IMHO.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [Possible bug] Vertical Dimensions do not appear centered by default

Post by wandererfan »

Syres wrote: Tue Jan 18, 2022 6:50 pm The line in the core code is https://github.com/FreeCAD/FreeCAD/blob ... s.cpp#L772
IIRC, the anchor point for a text item is the top left corner. If the X & Y parameters are being used as entered, that would give the 1/2 line offset error.

There is/was a function to center the dimension text on an (x, y) position. Maybe it isn't being used now??

The font size isn't stored in the Dimension. The preference value (Mod/TechDraw/Dimensions/FontSize) is used.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [Possible bug] Vertical Dimensions do not appear centered by default

Post by wandererfan »

Syres wrote: Wed Jan 19, 2022 3:39 pm Something like https://github.com/Syres916/FreeCAD/com ... 908fe951df
That will work. Mine is this:

Code: Select all

# include <Mod/TechDraw/App/Preferences.h>

    double fontSize = Preferences::dimFontSizeMM();
    dim->Y.setValue(-mid.y + 0.5 * fontSize);
All 3 types of length dimension seem to benefit from this adjustment.

I have a change for isometric extension lines in the q. I can include this change with that.
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: [Possible bug] Vertical Dimensions do not appear centered by default

Post by Syres »

wandererfan wrote: Wed Jan 19, 2022 7:31 pm I have a change for isometric extension lines in the q. I can include this change with that.
Cheers
ToniTen
Posts: 240
Joined: Fri Sep 04, 2020 10:11 am

Re: [Possible bug] Vertical Dimensions do not appear centered by default

Post by ToniTen »

Oh so it is a bug. Thanks everybody for working on it. I was unsure if it intended behaviour, since I am not formally trained in the production of industrial drawings, and FreeCAD usually errs on the side of following the norms, hence the "[Possible bug]" tag
edi
Posts: 481
Joined: Fri Jan 17, 2020 1:32 pm

Re: [Possible bug] Vertical Dimensions do not appear centered by default

Post by edi »

Syres wrote: Wed Jan 19, 2022 3:39 pm Something like https://github.com/Syres916/FreeCAD/com ... 908fe951df
Could we install a general function "getFontSize" somewhere ? In DrawUtil ? The situation of calculating the vertical midposition occures often.
Post Reply