8000 Fix bounding box to not contain only shape interior but also edges by Czaki · Pull Request #7332 · napari/napari · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix bounding box to not contain only shape interior but also edges #7332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 21, 2024

Conversation

Czaki
Copy link
Collaborator
@Czaki Czaki commented Oct 15, 2024

References and relevant issues

https://napari.zulipchat.com/#narrow/stream/212875-general/topic/Issue.20grabbing.20lines.20in.20shape.20layer/near/477001240

Description

In #7144 we attempted to speed up mouse click testing in shapes by using shapes bounding boxes. However, there were two bugs in that implementation:

  • it did not account for edge width around shapes, so one could only click on the interior of a shape — which is hard for edge-only shapes like paths 😅
  • it did not account for certain classes of shapes data changes, so that the bounding box data was out of date when shapes were transformed, and clicking on the shape became impossible 🫣

This PR fixes both issues by:

  • supplementing the bounding box by 0.5 times the edge width.
  • Add missing cache clears.

It also adds tests for these missed elements.

@Czaki Czaki added this to the 0.5.5 milestone Oct 15, 2024
@Czaki Czaki added the bugfix PR with bugfix label Oct 15, 2024
@github-actions github-actions bot added the tests Something related to our tests label Oct 16, 2024
Copy link
codecov bot commented Oct 16, 2024

Codecov Report

All modifie 8000 d and coverable lines are covered by tests ✅

Project coverage is 92.74%. Comparing base (c1753bd) to head (b35147e).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7332      +/-   ##
==========================================
- Coverage   92.86%   92.74%   -0.12%     
==========================================
  Files         623      623              
  Lines       57479    57517      +38     
==========================================
- Hits        53376    53344      -32     
- Misses       4103     4173      +70     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Czaki Czaki marked this pull request as ready for review October 16, 2024 13:32
@imagesc-bot
Copy link

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/how-to-clear-shape-layer-in-napari/103785/2

Copy link
Collaborator
@willingc willingc left a comment

Choose a reason for hiding this comment

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

Python lgtm. A few suggestions on test function docstrings. Thanks @Czaki

Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
@jni jni added the ready to merge Last chance for comments! Will be merged in ~24h label Oct 17, 2024
@jni
Copy link
Member
jni commented Oct 17, 2024

I've updated the description to have more details without linking out. I think this should be safe to merge.

Copy link
Member
@psobolewskiPhD psobolewskiPhD left a comment

Choose a reason for hiding this comment

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

Makes sense to me, also tested this locally quite a bit.

@Czaki Czaki merged commit 594723b into napari:main Oct 21, 2024
44 checks passed
@Czaki Czaki deleted the fix_bounding_box branch October 21, 2024 12:27
@github-actions github-actions bot removed the ready to merge Last chance for comments! Will be merged in ~24h label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix PR with bugfix tests Something related to our tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0