Skip to content

Fix Windows multitouch and MacOS trackpad gesture interactions

Sunderlandkyl requested to merge Sunderlandkyl/vtk:qt_gestures_vtk_8.90 into master

Previously the touch interactions in Qt worked for touchpad on MacOS, but not on Windows touchscreens. This commit adds support for multi-touch gestures on Windows touchscreens and fixes some errors in MacOS trackpad gestures.

List of gestures supported:

  • Tap
  • Tap And Hold
  • Pinch
  • Rotate
  • Pan
  • Swipe

Added new example QVTKTouchscreenRenderWindows to demonstrate the use of gesture events in a QVTKOpenGLNativeWidget. See demonstration video here: https://youtu.be/fpnqsDmJ0Y8

Implementation details:

Modified QVTKInteractorAdapter to invoke events using widget local coordinates

  • Qt coordinates are inconsistent between gestures, and even within the same gesture on different platforms (Windows touchscreen vs MacOS touchpad)
  • VTK expects the invoked events to be in the local coordinate frame

Updated vtkInteractorStyleMultiTouchCamera to utilize the updated events

  • Calls StartGesture() to switch interactor states when a Pinch/Rotate/Pan gesture is started. This prevents other states such as rotate from interfering with the gestures.
  • Adjusted behavior of the different gestures. Pinch and rotate are now performed relative to the position of the gesture on the screen, instead of dollying/rotating around the focal point.

Fixes made to support gestures:

  • Pass widget as parent to InteractorAdapter in QVTKRenderWindowAdapter. Without a widget, we cannot calculate local coordinates from QWidget::mapFromGlobal().
  • Pass -DQt5_DIR=${Qt5_DIR} to examples with the add_example CMake function. Qt examples would not build since they were missing Qt5_DIR.

Merge request reports