8000 Emit highlight event only if selection changed by Czaki · Pull Request #7162 · napari/napari · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Emit highlight event only if selection changed #7162

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 1 commit into from
Aug 8, 2024

Conversation

Czaki
Copy link
Collaborator
@Czaki Czaki commented Aug 5, 2024

References and relevant issues

closes #7071

Description

Currently, on main, we omit a highlight event every time when _set_highlight method is called. However, it is called every time the zoom or canvas size is changed to fix some problems with highlights (see #6425)

I think that it should be emitted only if selection is changed.

@Czaki Czaki added the bugfix PR with bugfix label Aug 5, 2024
@Czaki Czaki added this to the 0.5.2 milestone Aug 5, 2024
Copy link
codecov bot commented Aug 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.90%. Comparing base (698fd85) to head (a2463b4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7162      +/-   ##
==========================================
- Coverage   92.99%   92.90%   -0.10%     
==========================================
  Files         619      619              
  Lines       56729    56733       +4     
==========================================
- Hits        52757    52706      -51     
- Misses       3972     4027      +55     

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

Copy link
Contributor
@melonora melonora left a comment

Choose a reason for hiding this comment

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

LGTM! thanks

@melonora melonora added the ready to merge Last chance for comments! Will be merged in ~24h label Aug 5, 2024
@Czaki Czaki merged commit b7a8d00 into napari:main Aug 8, 2024
47 checks passed
@Czaki Czaki deleted the fix_higligth_problem branch August 8, 2024 09:26
@github-actions github-actions bot removed the ready to merge Last chance for comments! Will be merged in ~24h label Aug 8, 2024
psobolewskiPhD added a commit to psobolewskiPhD/napari that referenced this pull request Aug 17, 2024
jni pushed a commit that referenced this pull request Aug 18, 2024
…" (#7201)

# References and relevant issues
This reverts commit b7a8d00.
Closes: #7187
Re-opens: #7071
Alternative to #7188

# Description
#7162 resulted in major un-intended
(lack of tests 😬) consequences to:
1. selecting points and shapes with the selection tool
2. drawing shapes
3. editing shapes using the vertex selection tool
4. moving shapes using the selection tool

I had made #7188 as a naive fix to
the first symptoms: points selection, but the issue is more far reaching
and requires more thought. See also some discussion here:
https://napari.zulipchat.com/#narrow/stream/212875-general/topic/highlight

My suggestion here is to just revert #7162 because the unintended
consequences are far more severe than the original issue. Then we can
return to the drawing board to disentangle highlights from selection and
try to address the original event related issue more precisely.
jni pushed a commit that referenced this pull request Aug 29, 2024
# References and relevant issues

This PR fixes highlight performance problems in the Shapes layer. #7162
tried to fix them by reducing the frequency of highlight events, but
that had to be reverted (#7187, #7201). Instead, this dramatically
speeds up highlighting when the event is fired.

# Description

For performance reasons, the Shapes layer creates a *single* mesh
containing all shapes and shape edges, and this is what is sent to VisPy
to draw.

When highlighting, prior to this PR, we needed to find the Shape edges
that are being highlighted within that giant mesh (linear in the number
of vertices, and iterated in a Python for-loop).

With this PR, instead, we look at the precomputed mesh stored in each
highlighted shape and stack them together. Therefore, the complexity is
linear in the number of vertices in the highlighted shapes, and the
constant factors should also be reduced.

Before this PR:
<img width="343" alt="Screenshot 2024-08-29 at 11 50 34"
src="https://github.com/user-attachments/assets/bf2fb01d-494a-42c4-8f06-53dc14dbac0b">

After This PR

<img width="273" alt="Screenshot 2024-08-29 at 11 50 43"
src="https://github.com/user-attachments/assets/52720dad-19bc-42c4-949d-e62bd5544e34">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix PR with bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Highlight event emitted when zooming
2 participants
0