Constraint icons size at Sketcher edit (PR ready)

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
chennes
Veteran
Posts: 3876
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Constraint icons size at Sketcher edit (PR ready)

Post by chennes »

abdullah wrote: Sun Jan 10, 2021 3:08 pm I think that what you mean is that this behaviour of separately treating geometry and constraints is inconsistent in your view and/or that evolved in time from a different behaviour that was proposed before.
Yes, I think I was just confused from the number of different proposals and parameters: I see that it is indeed working as designed, at that I needed to also change the fonts size.
However, it is observed that for a monitor 1.4 times the default dpi of 96 dpi, a line which defaults to 1px width will still be 1 pixel width due to rounding (truncation), while for a monitor 1.6 times the default dpi of 96 dpi, it would be 2px. The UI scaling factor is there to allow the user the possibility of configuring this scaling to his or her personal taste.
Is FreeCAD actually truncating it to an integer? OpenGL uses a float for linewidth, and it affects the display when antialiasing (as long as GL_LINE_SMOOTH is enabled).
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Constraint icons size at Sketcher edit (PR ready)

Post by abdullah »

chennes wrote: Sun Jan 10, 2021 4:59 pm Is FreeCAD actually truncating it to an integer? OpenGL uses a float for linewidth, and it affects the display when antialiasing (as long as GL_LINE_SMOOTH is enabled).
No, it is the developer who assumed pixels are ints and did not look into the documentation. The developer is me. Thanks for that :D.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Constraint icons size at Sketcher edit (PR ready)

Post by abdullah »

chennes wrote: Sun Jan 10, 2021 4:59 pm Is FreeCAD actually truncating it to an integer? OpenGL uses a float for linewidth, and it affects the display when antialiasing (as long as GL_LINE_SMOOTH is enabled).
git commit f87f1e57dc1926172270e0056174b27683a5b6f1

Now if you change the scaling factor by 5% (default of the spinbox) and update, you see how this is working way better. Thanks again!!
User avatar
vanuan
Posts: 539
Joined: Wed Oct 24, 2018 9:49 pm

Re: Constraint icons size at Sketcher edit (PR ready)

Post by vanuan »

abdullah wrote: Sun Jan 10, 2021 3:08 pm 2.2. The font size is provided for in pixels in preferences. One could observe changes in size of fonts using the same setting as before. The reason is that this pixel setting was being passed to coin, which uses points, directly without conversion. This PR converts pixels to points before passing them to coin.
Could you provide a link to documentation that says coin uses points. As I have read, SoText2 uses pixels, SoText3 uses world units.
The size of the fonts on screen is decided from the SoFont::size field of a preceding SoFont-node in the scene graph, which specifies the size in pixel dimensions. This value sets the approximate vertical dimension of the letters. The default value if no SoFont-nodes are used, is 10.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Constraint icons size at Sketcher edit (PR ready)

Post by abdullah »

vanuan wrote: Wed Jan 13, 2021 12:30 pm Could you provide a link to documentation that says coin uses points. As I have read, SoText2 uses pixels, SoText3 uses world units.
Actually I can't. The property says px as you quote... I would have sworn I read that the default font was 12 points (which @96dpi is 16px, not 10px, which appears to be default size)... Oh wait, it is also in the documentation:
The default 2D font is a built-in 8x12 points font.
On the good part, it is easy to fix. I will commit a fix later on. Thanks for the heads up... and sorry to those that will see the text size changed after the commit and will have readjust the setting :(
Elyas
Posts: 58
Joined: Fri Sep 04, 2020 12:25 pm

Re: Constraint icons size at Sketcher edit (PR ready)

Post by Elyas »

OS: openSUSE Leap 15.2 (KDE//usr/share/xsessions/default)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.23679 (Git)
Build type: Debug
Branch: master
Hash: 6b3936c8b8859f8d45a1f3e9859ef7e7bde5b271
Python version: 3.6.12
Qt version: 5.12.7
Coin version: 3.1.3
OCC version: 7.3.0
Locale: Russian/Russia (ru_RU)
Screenshot_20210115_081925.png
Screenshot_20210115_081925.png (168.87 KiB) Viewed 1840 times
After
:
Screenshot_20210115_084533.png
Screenshot_20210115_084533.png (188.21 KiB) Viewed 1840 times
OS: openSUSE Leap 15.2 (KDE//usr/share/xsessions/default)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.23707 (Git)
Build type: Debug
Branch: master
Hash: 919196fb9a200395b6dbd4777a3371e6c9383866
Python version: 3.6.12
Qt version: 5.12.7
Coin version: 3.1.3
OCC version: 7.3.0
Locale: Russian/Russia (ru_RU)
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Constraint icons size at Sketcher edit (PR ready)

Post by abdullah »

Elyas wrote: Fri Jan 15, 2021 5:51 am After
Yes. It turns out that Coin uses pixels for fonts, not points. So, the previous configuration did not correspond with the actual number of pixels indicated in the configuration. You need to change the configuration of the font size (px) in Sketcher preferences to a size that makes sense to you, which in your case is decreasing it quite a lot.

Sorry for the instability, but it was necessary to make this right.;)
Elyas
Posts: 58
Joined: Fri Sep 04, 2020 12:25 pm

Re: Constraint icons size at Sketcher edit (PR ready)

Post by Elyas »

abdullah wrote: Fri Jan 15, 2021 1:07 pm
Resizing doesn't matter. But the ratio of icon and text sizes is important.
Screenshot_20210115_163447.png
Screenshot_20210115_163447.png (197.03 KiB) Viewed 1793 times
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Constraint icons size at Sketcher edit (PR ready)

Post by abdullah »

Elyas wrote: Fri Jan 15, 2021 1:22 pm
abdullah wrote: Fri Jan 15, 2021 1:07 pm
Resizing doesn't matter. But the ratio of icon and text sizes is important.
Screenshot_20210115_163447.png
Elyas wrote: Fri Jan 15, 2021 1:22 pm Resizing doesn't matter. But the ratio of icon and text sizes is important.
This post is: a) to explain how it is working now and how it worked before , b) to determine if something is happening with HDPI monitors that I am not seeing myself and gather some information to investigate this issue.

a)
I am looking at your screenshot and I do not know why these icons are so small when compared with the text. I do not have a HDPI monitor and I do not see them so badly (bad proportion, big font, small icon) as it appears from your screenshots.

This after the merge of that commit, with font configured as you, 35px.
Screenshot_20210115_152348.png
Screenshot_20210115_152348.png (28.53 KiB) Viewed 1775 times
This is the same, but with that commit (67b45c7daefbdacbe5ef70cfce8d8c9cce5ebb97) reverted:
Screenshot_20210115_155601.png
Screenshot_20210115_155601.png (23.58 KiB) Viewed 1775 times
With the old situation, with 35px configured as font, I had:

coinfontsize = 26 px (this value depended on monitor dpi, mine is 96 dpi, because of wrong point conversion, 35*72/96), constrIconSize=28px (0.8*35, 0.8 is hardcoded), subindexofconstraints=22px (0.8*constrIconSize, 0.8 hardcoded). In my monitor, caliper in hand, a 0 of a constraint datum measures 0,77cm. The width of a perpendicular constraint measures 0.85 cm. The subindices of icons, including the comma which goes under the base line, 0.6cm.

With the new commit, with 35px configured as font, I have:

coinfontsize = 35 px (this value no longer depends on monitor dpi, it is just as configured), constrIconSize=28 px and subindexofconstraints=22px. The constraint datum measures 1,05cm. The latter two are the same as before.

Because I assume your QT reported dpi are higher that 96:

Code: Select all

int dpi = QApplication::desktop()->logicalDpiX();
proportionally you should see smaller constraint datum fonts with the old situation (35*72/dpi), because of wrong point compensation.

b)
For the current behaviour (with the new commit), there is no dpi compensation for fonts and constraint icons. If you configure 35px, you should see that the size of a constraint icon is 80% of the datum label text, and the subindices of constraints 80% of the icon size. At least that should be the situation if coin properly takes pixels.

With the current behaviour, could you please measure approximately (e.g. with a caliper or a ruler), the size of a 0 in a datum label constraint, the size of the width of the perpendicular constraint symbol and the size of the subindices (with the comma) and calculate the ratios? (mines, as you see above are between 70%-80%, my measuring skills are not that great).

If yours are different. Specifically, if with the new commit they are not around 70-80%, then coin may not be interpreting fontsize at pixels, or at least not for hdpi monitors. Then we will need some kind of dpi compensation/scaling (e.g. coinfontsize*=96/dpi).

Let me know your insight.
Post Reply