Skip to content

Enable pyqtgraph 0.14 compatibility in crosshair interaction paths#1176

Open
Copilot wants to merge 4 commits into
mainfrom
copilot/updatepyqtgraph
Open

Enable pyqtgraph 0.14 compatibility in crosshair interaction paths#1176
Copilot wants to merge 4 commits into
mainfrom
copilot/updatepyqtgraph

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 27, 2026

Disclaimer

This PR was created by GitHub copilot remotely from the mobile app to see if there could be any reasonable usage of this feature. There were some minor things off (like checking boundaries of plot with crosshair, adjusted by me in the last commit). I kept the original commits (just change their commit message to respect conventional commits).

I tested locally with all plotting widgets and it seems to work (but the adjustments were mostly to tests anyway).

Text from here is made by copilot, I just scratched or removed parts which I fixed already.

Description

BEC Widgets was pinned to pyqtgraph 0.13.7 and had crosshair event assumptions that break under pyqtgraph 0.14. This change updates the dependency and adapts crosshair move/click handling and tests to the 0.14 event model.

  • Dependency update

    • Relaxed pyqtgraph requirement from ==0.13.7 to ~=0.14.0.
  • Crosshair runtime compatibility

    • Replaced scene-rect containment checks with mapped-coordinate validation against viewRange().
    • Click handling now uses scenePos() (public API) and no longer depends on private event internals.
  • Crosshair test alignment with 0.14 behavior

    • Updated movement tests to use manual_pos for deterministic coverage.
    • Added synthetic click-event path using scenePos().
    • Clarified out-of-bounds 2D expectation to explicit clamp-to-image-bounds behavior.
scene_pos_getter = getattr(event, "scenePos", None)
if not callable(scene_pos_getter):
    return
scene_pos = scene_pos_getter()
mouse_point = self.plot_item.vb.mapSceneToView(scene_pos)
if self._is_within_view_range(mouse_point.x(), mouse_point.y()):
    ...

Related Issues

  • Issue: Make BW compatible with pyqtgraph 0.14

Type of Change

  • Dependency compatibility update (pyqtgraph 0.14 line)
  • Plot crosshair event handling and unit-test adaptation

How to test

  • QT_QPA_PLATFORM=offscreen QTWEBENGINE_DISABLE_SANDBOX=1 pytest -q tests/unit_tests/test_crosshair.py
  • QT_QPA_PLATFORM=offscreen QTWEBENGINE_DISABLE_SANDBOX=1 pytest -q tests/unit_tests/test_plot_base_next_gen.py tests/unit_tests/test_waveform.py tests/unit_tests/test_image_view_next_gen.py tests/unit_tests/test_heatmap_widget.py

Potential side effects

Crosshair move/click emission is now gated by mapped viewRange() bounds; this may slightly change behavior near plot edges/zoom boundaries.
For 2D items, out-of-range manual positions are treated via existing clamp-to-bounds behavior in snap logic.

Copilot AI linked an issue May 27, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Make BW compatible with pyqtgraph 0.14 Enable pyqtgraph 0.14 compatibility in crosshair interaction paths May 27, 2026
Copilot AI requested a review from wyzula-jan May 27, 2026 21:55
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

Benchmark comparison

Threshold: 20% (lower is better).
Result: 0 regression(s), 0 improvement(s) beyond threshold.

No benchmark regression exceeded the configured threshold.

No benchmark improvement exceeded the configured threshold.

All benchmark results
Benchmark Baseline Current Change Status
BEC IPython client with companion app 5.91908 s 5.83154 s -1.48% ok
BEC IPython client without companion app 2.21378 s 1.84926 s -16.47% ok
Import bec_widgets 0.0143291 s 0.013035 s -9.03% ok
tests/unit_tests/benchmarks/test_dock_area_benchmark.py::test_add_waveform_to_dock_area 0.151597 s 0.148688 s -1.92% ok

@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

❌ Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
bec_widgets/utils/crosshair.py 72.72% 1 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@wyzula-jan wyzula-jan marked this pull request as ready for review May 27, 2026 22:24
Copilot AI review requested due to automatic review settings May 27, 2026 22:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates BEC Widgets to support pyqtgraph 0.14 by adapting crosshair mouse move/click handling to the newer event model and aligning unit tests with the updated interaction paths.

Changes:

  • Relax pyqtgraph dependency from a strict 0.13.7 pin to the 0.14.x line.
  • Update crosshair move/click bounds checks to use ViewBox.viewRange() and click position retrieval via event.scenePos().
  • Refactor crosshair tests to use deterministic manual_pos movement and a synthetic click event using scenePos().

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
bec_widgets/utils/crosshair.py Switches bounds validation to viewRange() for move/click paths and uses scenePos() for click handling.
tests/unit_tests/test_crosshair.py Updates movement tests to manual_pos, adds a synthetic click-event path, and adjusts 2D out-of-bounds expectations.
pyproject.toml Relaxes pyqtgraph requirement to ~=0.14.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bec_widgets/utils/crosshair.py Outdated
Comment thread tests/unit_tests/test_crosshair.py Outdated
Comment thread tests/unit_tests/test_crosshair.py
Comment thread tests/unit_tests/test_crosshair.py Outdated
@wyzula-jan wyzula-jan force-pushed the copilot/updatepyqtgraph branch from 66cf0a7 to e747432 Compare May 28, 2026 09:39
@wyzula-jan wyzula-jan requested a review from a team May 28, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make BW compatible with pyqtgraph 0.14

3 participants