Sketcher icon SoPath coordinates

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!
Post Reply
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Sketcher icon SoPath coordinates

Post by abdullah »

I am trying to fix issue #3619.

I am getting quite a strange behaviour when preselecting combined constraints:
ConstraintPreselection.gif
ConstraintPreselection.gif (148.1 KiB) Viewed 416 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:
https://github.com/FreeCAD/FreeCAD/blob ... .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...
Post Reply