gazebosim / gz-gui

Builds on top of Qt to provide widgets which are useful when developing robotics applications, such as a 3D view, plots, dashboard, etc, and can be used together in a convenient unified interface.
https://gazebosim.org
Apache License 2.0
67 stars 39 forks source link

Fix large / unexpected camera movements #502

Closed iche033 closed 1 year ago

iche033 commented 1 year ago

Signed-off-by: Ian Chen ichen@osrfoundation.org

🦟 Bug fix

Related issue: https://github.com/gazebosim/gz-sim/issues/1085

Summary

Fixes large / unexpected camera movement when orbiting / panning due to missing mouse events.

More info:

The Minimal Scene is responsible for propagating all mouse events to other GUI plugins. However, mouse events were continuously overriden by the latest ones before they can be propagated / processed. This causes important events like a mouse press to be lost. The Interactive View Control relies on mouse press pos to determine the anchor point for camera orbiting and panning, so if it misses a mouse press pos, it justs uses the last anchor point for camera movements. When the anchor point is far away, it causes large camera jumps.

This gif shows the problem. The first pan motion successfully sets the anchor point (yellow ellipsoid). Subsequent camera orbit and pan motions miss the mouse press events and thus they still use the old anchor point that's on top of the red box.

missing_mouse_events

This PRs fixes the issue by storing mouse events in a list in Minimal Scene instead of just the latest event, and makes sure that the Interactive View Control always handles mouse press events.

Checklist

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

iche033 commented 1 year ago

linters

fixed. 23d8993

codecov[bot] commented 1 year ago

Codecov Report

Merging #502 (f68805b) into ign-gui6 (cdbd53c) will decrease coverage by 0.50%. The diff coverage is 8.33%.

@@             Coverage Diff              @@
##           ign-gui6     #502      +/-   ##
============================================
- Coverage     67.46%   66.95%   -0.51%     
============================================
  Files            39       39              
  Lines          5286     5290       +4     
============================================
- Hits           3566     3542      -24     
- Misses         1720     1748      +28     
Impacted Files Coverage Δ
...interactive_view_control/InteractiveViewControl.cc 15.51% <0.00%> (-0.37%) :arrow_down:
src/plugins/minimal_scene/MinimalScene.cc 60.00% <15.38%> (-4.65%) :arrow_down:
src/plugins/scene3d/Scene3D.cc 49.87% <0.00%> (+0.25%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.