Skip to content
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

Tooltip when hovering over atlas images #85

Merged
merged 10 commits into from
Sep 4, 2023
Merged

Tooltip when hovering over atlas images #85

merged 10 commits into from
Sep 4, 2023

Conversation

alessandrofelder
Copy link
Member

@alessandrofelder alessandrofelder commented Aug 29, 2023

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?
Being able to display the region info when hovering over any atlas image in 2d is a sought-after feature.

What does this PR do?
(This PR is a workaround until napari allows developers to provide custom tooltips for the selected layer. We can track this sort of thing in meta-issue #87)

An initial implementation of a layer tooltip.

  • implemented as a QLabel that appears when moving the mouse over any atlas images (annotation, default reference, additional reference).
  • displayed text matches what brainreg-segment displays as help
  • napari_atlas_representation constructor switches on all layer tooltips in napari

References

Closes #26

How has this PR been tested?

Two additional tests added that cover added functionality
Existing tests pass
Manual testing looks reasonable

Is this a breaking change?

No

Does this PR require an update to the documentation?

Opened an issue in the docs brainglobe/brainglobe.github.io#59

Checklist:

@codecov
Copy link

codecov bot commented Aug 29, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.25% 🎉

Comparison is base (0e30dd4) 97.05% compared to head (55d9d4e) 97.30%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #85      +/-   ##
==========================================
+ Coverage   97.05%   97.30%   +0.25%     
==========================================
  Files           7        7              
  Lines         339      371      +32     
==========================================
+ Hits          329      361      +32     
  Misses         10       10              
Files Changed Coverage Δ
brainrender_napari/napari_atlas_representation.py 100.00% <100.00%> (ø)

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

@alessandrofelder alessandrofelder changed the title wip:quick and dirty viewer tooltip Tooltip when hovering over atlas images Aug 31, 2023
@alessandrofelder alessandrofelder marked this pull request as ready for review August 31, 2023 10:33
@alessandrofelder alessandrofelder marked this pull request as draft August 31, 2023 10:35
tooltip does not need to depend on annotation
improve docstrings
@adamltyson
Copy link
Member

@alessandrofelder this works for me, but for some reason the brain region tooltip is displayed with an offset. The other tooltips in the widget work fine.
Screenshot from 2023-08-31 12-19-09

@@ -15,23 +18,40 @@ class NapariAtlasRepresentation:
mesh_opacity: float = 0.4
mesh_blending: str = "translucent_no_depth"

def __post_init__(self) -> None:
"""Setup a custom QLabel tooltip and enable napari layer tooltips"""
self._tooltip = QLabel(self.viewer.window.qt_viewer.parent())
Copy link
Member

Choose a reason for hiding this comment

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

This line produces a deprecation warning:

FutureWarning: Public access to Window.qt_viewer is deprecated and will be removed in
v0.5.0. It is considered an "implementation detail" of the napari
application, not part of the napari viewer model. If your use case
requires access to qt_viewer, please open an issue to discuss.!

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes - I don't think we have a nice way around this if we want a tooltip until napari allows custom layer tooltips. It's something that should be easy to contribute to napari before 0.5.0 and then fix here, but better to get the tool to users earlier, I think?

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, but is there an ETA for v0.5.0? If it's soon, then we'll have an issue.

Copy link
Member Author

@alessandrofelder alessandrofelder Aug 31, 2023

Choose a reason for hiding this comment

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

from a zulip convo in June, it's not soon, but I could be wrong.

@alessandrofelder
Copy link
Member Author

alessandrofelder commented Aug 31, 2023

the brain region tooltip is displayed with an offset. The other tooltips in the widget work fine.

Thanks, that offset shouldn't be as big! I'll try to fix!

@adamltyson adamltyson merged commit f65836c into main Sep 4, 2023
11 checks passed
@adamltyson adamltyson deleted the viewer-tooltips branch September 4, 2023 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Allow user to hover over a brain region and see the metadata.
2 participants