You might know that I uses arrows to drag objects.
I have a problem where the first click user do on the drawing is far from being the position of the arrow. This causes a jump in the mouse movement.
The solution is to move the mouse cursor after first click to the position of the arrow. But the arrow is drawn at 3D world and the mouse QTCursor-set position is 2D.
I know I can make a variable and always count the diff .. But that is not so good.
Is there a way to convert the COIN3D drawing position to QT 2D position so I an set the mouse cursor at the origin position of the COIN3D drawing?
Or what do you suggest.
Thank you for your help.
[Solved using variable] QTCursor postion set based on COIN3D Drawing location after a click?
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
[Solved using variable] QTCursor postion set based on COIN3D Drawing location after a click?
Last edited by mariwan on Tue Dec 07, 2021 8:58 pm, edited 1 time in total.
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
Re: QTCursor postion set based on COIN3D Drawing location after a click?
Would you have a minimal Python snippet just to fully understand the issue?
Re: QTCursor postion set based on COIN3D Drawing location after a click?
Pleaes you need to have my Workbench installed and loaded in your freecad.
Now run the code and try to click/drag the arrow. You will see the the location is different compared to the mouse click. I must have them the same otherwise the arrow will jump first time you use which can cause a big (extrude, chamfer ..etc ) tool.
Now run the code and try to click/drag the arrow. You will see the the location is different compared to the mouse click. I must have them the same otherwise the arrow will jump first time you use which can cause a big (extrude, chamfer ..etc ) tool.
Code: Select all
import ThreeDWidgets.fr_arrow_widget as wd
import ThreeDWidgets.fr_coinwindow as wnn
from ThreeDWidgets.constant import FR_COLOR
def callback_move(userData : wd.userDataObject =None):
ArrowObject = userData.ArrowObj # Arrow object
click=App.Vector(ArrowObject.w_parent.link_to_root_handle.w_lastEventXYZ.Coin_x,
ArrowObject.w_parent.link_to_root_handle.w_lastEventXYZ.Coin_y,
ArrowObject.w_parent.link_to_root_handle.w_lastEventXYZ.Coin_z)
print("clicked at", str(click))
print("Widget located at", ArrowObject.w_vector)
ArrowObject.w_vector=click
ArrowObject.redraw()
mywin = wnn.Fr_CoinWindow()
vectors=App.Vector(0,0,0)
rot=[0,0,0,0]
root=(wd.Fr_Arrow_Widget(vectors, "X-Axis", 1, FR_COLOR.FR_OLIVEDRAB, rot))
root.w_move_callback_=callback_move
mywin.addWidget(root)
mywin.show()
- Attachments
-
- 1.JPG (35.7 KiB) Viewed 781 times
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
Re: QTCursor postion set based on COIN3D Drawing location after a click?
I belive I will use this solution.
Still I don't know how to set the cursor at that position .. might not be good either. So, this solution works.
Code: Select all
import ThreeDWidgets.fr_one_arrow_widget as wd
import ThreeDWidgets.fr_coinwindow as wnn
from ThreeDWidgets.constant import FR_COLOR
class test:
global runOunce
def __init__(self):
self.runOunce = None
def callback_move(self,userData : wd.userDataObject = None):
PadObj = userData.PadObj # Arrow object
click=App.Vector(PadObj.w_parent.link_to_root_handle.w_lastEventXYZ.Coin_x,
PadObj.w_parent.link_to_root_handle.w_lastEventXYZ.Coin_y,
PadObj.w_parent.link_to_root_handle.w_lastEventXYZ.Coin_z)
if self.runOunce == None:
self.runOunce = click.sub(PadObj.w_vector[0])
PadObj.w_vector[0]=click.sub(self.runOunce)
PadObj.redraw()
print(self.runOunce,"self.runOunce")
def runme(self):
mywin = wnn.Fr_CoinWindow()
vectors=[App.Vector(0,0,0), App.Vector(0,0,0)]
rot=[0,0,0,0]
rot1=[1,0,0,0.31]
root=wd.Fr_OneArrow_Widget(vectors, "X-Axis")
root.w_move_callback_=self.callback_move
mywin.addWidget(root)
mywin.show()
a=test()
a.runme()
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_