Implementing Mouse Jogging using QtPyVCP

More
31 Jul 2023 17:04 - 31 Jul 2023 18:42 #276649 by DauntlessA
I've found an implementation of mouse jogging in GladeVCP, and I was wondering how might be best to implement this in QtPyVCP to integrate into Probe_Basic:


The GladeVCP implementation uses ‘gtk motion-notify-event fed to axis.x/y.jog-counts hal pins, jog-scale set to camera resolution (0.017mm/pixel)’
The aim of this is to implement Datron-Style jogging using a touchscreen and a camera:


(20 seconds into the video)

In Qt, QMouseEvent can be used to extract data on mouse interactions with the widget: doc.qt.io/qt-6/qmouseevent.html
doc.qt.io/qt-6/qwidget.html#mouseMoveEvent
The coordinates from QMouseEvent::pos() reports the position of the mouse cursor, relative to this widget.

doc.qt.io/qt-6/qwidget.html#mousePressEvent
The coordinates will only be reported if a hal pin ‘MousePressEvent=true’


The initial coordinates when the mousePressEvent begins can be set to 0,0 (by subtracting the initial coordinates). Subsequent coordinates reported by QMouseEvent::pos() are therefore used incremental coordinates. In this manner, the widget can be ‘swiped’ to jog the machine, rather than clicking on a specified position.

doc.qt.io/qt-6/qwidget.html#mouseReleaseEvent
This may not need to be monitored, as we can instead use a hal pin ‘MousePressEvent=false’.
Either way, the effect of ending the mouse press should reset the coordinate position such that a new press equals 0,0 again.

So ultimately I need to enable mouseMoveEvent and mousePressEvent for a camera widget, and pass mouseMoveEvent and QMouseEvent::pos() to hal.
How would these values be made into QtPyVCP pins that can be passed to hal? Is this possible in QtPyVCP?

Once I have the hal pins, I'm fairly confident in doing the hal logic. The main issue right now is how I'll get the data I need into hal.
That said, in terms of my hal implemention, I just need to apply the correct scaling and invert the direction (as is common with any implementation of swipe gestures).

If anyone has any ideas on how best this can be implemented I'd really appreciate any help! Thanks!
Last edit: 31 Jul 2023 18:42 by DauntlessA. Reason: Added time of interest in video, since video timestamp isn't functioning. Formatting.

Please Log in or Create an account to join the conversation.

More
01 Aug 2023 15:35 #276708 by Lcvette
hmmm.. that's interesting indeed!  I am not sure how that would occur however, because QtPyVCP does not use GTK that is out, but with do use vtk for all plotting, I would guess that is something that would need to be sorted there.  the vtk files are here in the dev folder:

/home/(your_pc)/dev/qtpyvcp/src/qtpyvcp/widgets/display_widgets/

I would imagine this is where the magic would need to happen.  you can check the vtk documents here:

docs.vtk.org/en/latest/

I Think somewhere in there you will find what you need.  cool idea!

Chris
The following user(s) said Thank You: DauntlessA

Please Log in or Create an account to join the conversation.

More
01 Aug 2023 16:04 #276710 by KCJ
You should be able to do this as you describe using standard QT widgets (has nothing to do with VTK).

The part that’s going to be difficult is getting the response time fast enough using the HAL interface. It might be best to implement in such a way you can tap the target position on the camera display, and hit a “move to here” button.
The following user(s) said Thank You: Lcvette, DauntlessA

Please Log in or Create an account to join the conversation.

More
02 Aug 2023 04:51 #276756 by DauntlessA
Yeah, that's definitely an option as well depending on how the latency turns out. Logic-wise it could also be simpler as well.

The first problem to tackle is how to get the signals from a qWidget into HAL.
From what I can see, I'd essentially I'd be implementing a custom HAL widget with out pins to pass the values I need to HAL, or modifying an existing widget to add this functionality (which is basically the same thing)?

I can see the source code for a hal widget containing an out pin, for example Hal Slider, which is a qSlider qWidget.(www.qtpyvcp.com/_modules/qtpyvcp/widgets...gets/hal_slider.html)
(doc.qt.io/qt-6/qslider.html)
From what I can see a member function (if I'm using the correct terminology) can be referenced as follows, for example:
def mouseDoubleClickEvent(self, event):
self.setValue(100)

But I'm still a little unsure right now how I'd directly connect a member function and a hal pin. In that qSlider example it references 'val':

def onValueChanged(self, val):
if self._s32_value_pin is not None:
self._s32_value_pin.value = val
self._float_value_pin.value = val / 100.0

But I can't see how this is linked to an attribute of the slider. Is an alias defined in another location? Can I use this to directly reference the member function I want to use e.g.
def onValueChanged(self, QMouseEvent::pos()):
self._s32_value_pin.value = QMouseEvent::pos()
(I know the number format might be different from this example, that said I can't easily see what the format would be doc.qt.io/qt-6/qwidget.html#mouseMoveEvent)

If you are able to give an example it would be very useful.
Thanks so much for the help!

Please Log in or Create an account to join the conversation.

Moderators: KCJLcvette
Time to create page: 0.070 seconds
Powered by Kunena Forum