Sketcher icon SoPath coordinates

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Posts: 2788
Joined: Sun May 04, 2014 3:16 pm

Sketcher icon SoPath coordinates

Postby abdullah » Sat Nov 10, 2018 5:58 pm

I am trying to fix issue #3619.

I am getting quite a strange behaviour when preselecting combined constraints:
ConstraintPreselection.gif (148.1 KiB) Viewed 81 times
Some groups of constraints get an "offset preselection" while others do not get a preselection at all.

I wanted to ask if this statement in the source is true or not:

Code: Select all

SbVec2f iconCoords = viewer->screenCoordsOfPath(path);
// Coordinates of the mouse cursor on the icon, origin at top-left for Qt
// but bottom-left for OIV.
// The coordinates are needed in Qt format, i.e. from top to bottom.
int iconX = cursorPos[0] - iconCoords[0] + iconSize[0]/2,
iconY = cursorPos[1] - iconCoords[1] - iconSize[1]/2;
iconY = iconSize[1] - iconY;
basically, is "iconCoords", which is obtained from the path really the center of the icon coordinates?

If this statement were true, I think that the iconY calculation is wrong and should be:
iconY = cursorPos[1] - iconCoords[1] + iconSize[1]/2;
the reason is that if (cursorPos[1] - iconCoords[1]) is the vector defining the deviation of the position of the cursor from the center of the icon, the coordinates from the bottom-left (inventor) should be iconsize.y/2 larger, which in the next line gets transformed to qt format (left-top), by substracting the calculated value from the iconsize.y.

This is the relevant line in the code: ... .cpp#L1670

In any case, this does not solve the problem. I am beginning to think that "path" is not providing the center of the combined icon. But I have a very poor knowledge of Coin3d. That's the reason for my question...