[Merged] PR #3923 Sketcher: Fix merged constraint preselection bug

Post here if you have re-based and finalised code to integrate into master, which was discussed, agreed to and tested in other forums. You can also submit your PR directly on github.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
Bei3lay
Posts: 34
Joined: Wed Aug 28, 2019 6:48 am

[Merged] PR #3923 Sketcher: Fix merged constraint preselection bug

Post by Bei3lay »

Hello. There is bug in sketcher that does not allow you to preselect constraints if you increase zoom. See https://imgur.com/a/1WXSmNQ. It only happens if constraint icons are close enough to each other so that they get merged into a single icon. I've looked through the tracker and didn't find anything similar to this. Solution is pretty simple but it took a few weeks to find it.
Last edited by Bei3lay on Mon Oct 12, 2020 4:07 pm, edited 1 time in total.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [PR #3923] Sketcher: Fix merged constraint preselection bug

Post by Kunda1 »

Please add the about info of the FC version you can recreate this bug on
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Bei3lay
Posts: 34
Joined: Wed Aug 28, 2019 6:48 am

Re: [PR #3923] Sketcher: Fix merged constraint preselection bug

Post by Bei3lay »

I think you can recreate it on any version. I've checked 0.18 and the latest build of 0.19
OS: Linux Mint 19.3 (X-Cinnamon/cinnamon)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22614 (Git)
Build type: Debug
Branch: master
Hash: 9c20ce05edd82d6a76f48c1948beab7098927ed5
Python version: 3.6.9
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
chrisb
Veteran
Posts: 54197
Joined: Tue Mar 17, 2015 9:14 am

Re: [PR #3923] Sketcher: Fix merged constraint preselection bug

Post by chrisb »

I can only confirm half of this issue: if an element has multiple constraints, it is not possible to select one of them. There should be a trycker entry for this.
This behaviour doesn't change here even I zoom in or out.

OS: macOS 10.15
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22611 (Git)
Build type: Release
Branch: master
Hash: 7eeec7a5990cc786723225ca8de16ca3186545b3
Python version: 3.8.5
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: C/Default (C)
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Bei3lay
Posts: 34
Joined: Wed Aug 28, 2019 6:48 am

Re: [PR #3923] Sketcher: Fix merged constraint preselection bug

Post by Bei3lay »

In the file https://github.com/FreeCAD/FreeCAD/blob ... Sketch.cpp function ViewProviderSketch::detectPreselectionConstr there is a commented line that would print a lot of relevant variables. You can see that if you increase zoom, the icon position coordinates become huge. For example, my output for low zoom

Code: Select all

Abs(-9.989820,-0.095376),Trans(1.250000,0.000000),Coords(245,144),iCoords(249.608734,159.353897),icon(6,34),isize(23,35),boundingbox([0,19],[15,34])
high zoom

Code: Select all

Abs(-9.989820,-0.095376),Trans(1.250000,0.000000),Coords(340,165),iCoords(244433.703125,174.197723),icon(-244082,28),isize(23,35),boundingbox([0,19],[15,34])
Here
  • Abs - Absolute position of the icon on sketch plane
  • Trans - relative position of the icon on sketch plane
  • Coords - cursor coordinates on the screen
  • iCoords - icon coordinates on the screen
  • icon - position of the cursor relative to the position of the icon
Notice large x coordinates of icon position (iCoords(244433.703125,174.197723)) and cursor position relative to the icon (icon(-244082,28)). The change is continuous, so it is noticable that after slightly changing zoom, the bounding box of the constraint would slightly shift relative to the icon. But as you increase zoom enough, it would shift beyond the icon. In this case Coin would still detect that cursor points to the icon, but particular constraint would not be detected, because of the wrong coordinates.

The output will only be printed when cursor is moving over one of the merged icons.
Post Reply