-
-
Notifications
You must be signed in to change notification settings - Fork 443
Add optional fixed length
parameter to scale bar
#7167
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
Conversation
…erlay` classes * **ScaleBarOverlay class** - Add `fixed_width` parameter with default value `None` * **VispyScaleBarOverlay class** - Add handling for `fixed_width` parameter - Update `_on_zoom_change` method to use `fixed_width` if not `None` - Add `_on_fixed_width_change` method * **Examples** - Add example usage of `viewer.scale_bar.fixed_width` in `examples/scale_bar.py` * **Tests** - Add test for `fixed_width` parameter in `VispyScaleBarOverlay` class - Add test for `fixed_width` parameter in `ScaleBarOverlay` class
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7167 +/- ##
==========================================
- Coverage 93.01% 92.92% -0.10%
==========================================
Files 619 620 +1
Lines 56757 56777 +20
==========================================
- Hits 52792 52758 -34
- Misses 3965 4019 +54 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this! It's great to see how relatively small the change needed was, and how little help you needed to do this! Great work 💪
I left a few comments, none of them big issues.
The main thing I'm unsure about is the name width
, which to me is a bit strange. Maybe this is typical nomenclature and I'm unaware, but to me width means the other direction ("thickness" of the line). So I'd rather call this length
. Otherwise, size
for something more generic. I feel like @psobolewskiPhD will have opinions on this :)
for more information, see https://pre-commit.ci
Thanks @brisvag for the quick review :)
I must admit that the github workspace helps big time in getting started to find the right places for modifications :) As for the naming conventions, I went with On the GUI for scale bar control - is there already an issue for this? |
I find this more intuitive, yeah. No risk of confusing them, unlike "width".
I don't think so! Feel free to create and link to the other one! |
Co-authored-by: Lorenzo Gaifas <brisvag@gmail.com>
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good to me :) Let's see what CI thinks about it now.
Co-authored-by: Lorenzo Gaifas <brisvag@gmail.com>
length
parameter to scale bar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @jo-mueller ! Thanks for picking this up
Co-authored-by: Lorenzo Gaifas <brisvag@gmail.com>
Co-Authored-By: Lorenzo Gaifas <brisvag@gmail.com>
Wrong line :P it's the |
Co-Authored-By: Lorenzo Gaifas <brisvag@gmail.com>
I'm dumb 🙈 thanks for the fix(es) :) |
It did look very similar :P It's annoying cause when a code line is far enough from the changes in the PR, github doesn't allow to make suggestions on it, so you have to resort to linking like above ^^' I think we might be done 💪 |
@jo-mueller since the description will become the commit message, could you update it so it reflects the current status? |
@brisvag you mean the title of the PR? |
I mean the description of the pr, which still refers to |
@brisvag should be correct now - I updated the gif and all the descriptions :) |
Idea (but also ok to leave for followup): update the example |
Co-Authored-By: Lorenzo Gaifas <brisvag@gmail.com>
Good to flag it, thanks! I think @melonora's on it already :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Late to the party, but love it.
length
makes sense to me as the name.
Because it came to my mind playing with this, for a followup PR: it should be possible to disable the text, so show just the scale bar -- then in the legend you say all the scale bars are 50 um or whatever and don't deal with text clipping the scale bar (make the font large and zoom out a bit).
I'm not sure adding this to the export_figure
example makes much sense for this, because it uses reset_view, so you can't get a zoomed view. This is more for a figure with two different zoom levels? Like an inset for example.
What we need to do--in a followup PR--is update the scale_bar example to include all the cool new shit you can do. It's been on my todo #7007 👀
Co-Authored-By: Lorenzo Gaifas <brisvag@gmail.com>
@psobolewskiPhD I have added it here because I think there's no harm in showing some functionality in multiple different places of the docs. But I also agree, a more comprehensive example on how to use the scale bar would be a great addon to the docs. The |
Hm. Maybe it will be a nice improvement to change the length parameter from float to pint.Qunatity). To use one parameter to define the length of scale bar? |
I think it could go either way... but maybe two parameters of simple types is more ergonomic to work with, since most people are not familiar with pint? |
Description
Fixes #7164
This PR adds a mew parameter
length
to the scale bar that allows to set the the scale to a fixed width in physical units which will grow or shrink together with the zoom of the canvas.Changes
ScaleBarOverlay class
length
parameter with default valueNone
VispyScaleBarOverlay class
length
parameter_on_zoom_change
method to usefixed_width
if notNone
_on_length_change
methodChecklist
(open a PR on the docs repository (https://github.com/napari/docs) if relevant!)
length
parameter inVispyScaleBarOverlay
class