Move constraint following mouse move question.

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
User avatar
paddle
Veteran
Posts: 1413
Joined: Mon Feb 03, 2020 4:47 pm

Move constraint following mouse move question.

Post by paddle »

hey guys,
In Constrain Contextually, when you're creating a constrain, the constrain follows your mouse pointer until you 'drop' it and it gets validated.

To do so the moveConstraint function is used.

Code: Select all

sketchgui->moveConstraint(ConStr.size() - 1, onSketchPos);
It works well, but my issue is that it moves right on top of the mouse pointer. Which is not ideal for visibility.
move constr.png
move constr.png (4.88 KiB) Viewed 1588 times
So I'd like to be able to shift it slightly on one side or the other to get the text out of the way.
My problem is that moveConstraint use Base::Vector2d which are coordinate in X,Y mm. So if I do something like :

Code: Select all

sketchgui->moveConstraint(ConStr.size() - 1, onSketchPos + Base::Vector2d(5,5) );
Then the constraint moves 5mm to the right and 5mm to the top. But that means that it is not consistent. If I zoom or dezoom then the shift becomes too much or too less. What I need is to find a way to shift it by a number pixels.

Anyone knows how?
Post Reply