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
vanuan
Posts: 539
Joined: Wed Oct 24, 2018 9:49 pm

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

Post by vanuan »

Let's look at the implementation of Quarter. It doesn't appear to use the setPixelsPerInch method:
https://coin3d.github.io/Coin/html/clas ... d342b11d44

So it means that by default SoFont uses pixels, not points to determine the font size (72 pixels per inch instead of 96).

To determine the font size in pixels when text scaling is set to 200%, Qt uses the following formula:

Code: Select all

device_pixel_ratio = 2 // 200%
pixels = points / 72 * 96 * device_pixel_ratio
Currently, Quarter doesn't appear to use device_pixel_ratio at all. Neither does it use a 96 logical dpi value to account for differences between screens and printers. It just assumes a logical dpi of 72 and draws everything in low resolution.

Maybe, you're right and just setting dpi to 96 multiplied by device pixel ratio (using setPixelsPerInch method) would help.
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 »

There's even a comment about that in a portion of code that is used to grab the picture from Quarter:

https://github.com/FreeCAD/FreeCAD/blob ... 1627-L1630
//NOTE: To support pixels per inch we must use SbViewportRegion::setPixelsPerInch( ppi );
//The default value is 72.0.
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 »

Looking further at Coin3D code, it doesn't appear Viewport's PPI is used anywhere. Which suggests that SoFont is implemented to specify the size in pixels, while it was supposed to take into an account the pixels per point value of the viewport.
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 »

Quick look:

Code: Select all

viewer = FreeCADGui.ActiveDocument.ActiveView.getViewer()
rm = viewer.getSoRenderManager()
vp = rm.getViewportRegion()
vp.getPixelsPerInch()
# 72.0
vp.getPixelsPerPoint() 
# 1.0
confirms that pixel = point as far as Coin3D is concerned.
User avatar
chennes
Veteran
Posts: 3881
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 »

Is anyone else suddenly getting black boxes around their constraints?
ConstraingBlackBoxes.png
ConstraingBlackBoxes.png (2.92 KiB) Viewed 1516 times
This just started happening to me in the last couple of weeks. I haven't done a bisect yet to track down the exact commit, but I'll get on that soon.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Elyas
Posts: 58
Joined: Fri Sep 04, 2020 12:25 pm

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

Post by Elyas »

chennes wrote: Thu Jan 28, 2021 1:30 am Is anyone else suddenly getting black boxes around their constraints?
As far as I remember,
I got rid of it with some kind of setting in Display - 3D View - Rendering. Anti-aliasing may be.
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

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

Post by chrisb »

Do you get this always? Sometimes all red vanishes from a sketch - this happens mostly while selecting - and returns as suddenly as it comes, e.g. by applying a constraint. Werner said it comes from something running out of resources.

If it is always, I would guess it comes from Abdullah's recent highDPI changes.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
chennes
Veteran
Posts: 3881
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 »

Elyas wrote: Thu Jan 28, 2021 6:43 am As far as I remember,
I got rid of it with some kind of setting in Display - 3D View - Rendering. Anti-aliasing may be.
Oh, awesome, thanks for the tip. I had been testing a bug report from the other day and left line smoothing on. Switching back to MSAA8x resolved the issue. Line smoothing is an old (and not very good) AA strategy anyway, so I'm not sure it's worth spending time actually fixing this particular glitch.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Hologram
Posts: 201
Joined: Thu Nov 03, 2022 3:05 pm

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

Post by Hologram »

chrisb wrote: Tue Jan 05, 2021 11:04 pm Right now I have the feeling I would like to have two independent scale factors, or fontsize plus icon scale. But then I have to admit, that I lived for years with a fixed icon size and I never had changed to fontsize until I got a highdpi display.
It appears a single scale factor ended up being implemented. I am wondering though, is it possible to scale the icons independently from the dimension text? I prefer the icons to be relatively large, because that helps me to identify them better.
Dimension text.png
Dimension text.png (128.68 KiB) Viewed 627 times
I would need the text to be about half its current size. My font size is 13 in the stylesheet and I am using a 1.5 view scale with a 40px font size here, which obviously is way too large for text, but pretty comfortable for the icons (27 inch 4k Screen set to 175% scaling). It looks like the icons are half the text size, which would explain the discrepancy between the two.
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

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

Post by chrisb »

Hologram wrote: Wed Jan 25, 2023 10:56 pm I am wondering though, is it possible to scale the icons independently from the dimension text?
How about to increase the ViewScaleRatio and decrease the font size.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply