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

Editable annotations and persistent selection overlays #12468

Merged
merged 53 commits into from
Feb 4, 2023

Conversation

mattpap
Copy link
Contributor

@mattpap mattpap commented Oct 7, 2022

Extracted relevant changes from PR #12074.

TODO:

  • investigate not working modes with select_every_mousemove
  • limit editability when dimension != "both"
  • persist the overlay when switching tools (allow pan, zoom, etc.)
  • better editability for origin == "center"
  • redesign RangeTool using editable annotations
  • add support for move/resize limits
  • allow event propagation (e.g. hover passthrough)
  • allow alt key to override select_every_mousemove
  • resolve corner cases of overlay persistence across tool switching
  • add interactive visual integration tests

These are partially done in separate work:

  • formalize multiple selection overlay support
  • add support for resize/move handles

Example (from #12074, but it works the same here):

Screencast.2022-04-01.23.53.28.mp4

@mattpap mattpap added this to the 3.1 milestone Oct 7, 2022
@mattpap mattpap force-pushed the mattpap/3412_persistent_overlays branch from d4a92c9 to d57a4b8 Compare October 7, 2022 09:38
@codecov
Copy link

codecov bot commented Oct 7, 2022

Codecov Report

Merging #12468 (10ca016) into branch-3.1 (d354c6a) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@              Coverage Diff               @@
##           branch-3.1   #12468      +/-   ##
==============================================
+ Coverage       92.29%   92.30%   +0.01%     
==============================================
  Files             314      314              
  Lines           19727    19755      +28     
==============================================
+ Hits            18207    18235      +28     
  Misses           1520     1520              

@mattpap mattpap force-pushed the mattpap/3412_persistent_overlays branch from d57a4b8 to 0885ffc Compare October 9, 2022 09:35
@mattpap mattpap force-pushed the mattpap/3412_persistent_overlays branch from 5a6fa70 to 0c4f636 Compare October 12, 2022 22:25
@ianthomas23
Copy link
Member

Thanks, this is really useful functionality.

For the TODO of limit editability when dimensions != "both" do we need an equivalent dimensions property on BoxAnnotation and limit BoxAnnotationView._hit_test() to exclude checking hits_top and hits_bottom if dimensions == "width" (and similar for dimensions == "height")? Oh, we would also need to limit dragging to the appropriate dimension.

Another possible item for the TODO list is support for origin == "center" in BoxAnnotation as well as BoxSelectTool so that editing of the box remains symmetric about the center.

For persisting of the overlay when switching tools I've had some success in other work by switching the BoxAnnotation coordinates to data units when the BoxSelectTool is inactive, and back to canvas units when active.

@mattpap mattpap changed the base branch from branch-3.0 to branch-3.1 November 2, 2022 18:40
@mattpap mattpap force-pushed the mattpap/3412_persistent_overlays branch 4 times, most recently from efbc27b to 89762b1 Compare November 14, 2022 13:43
@mattpap mattpap force-pushed the mattpap/3412_persistent_overlays branch 3 times, most recently from b977069 to 7275b4b Compare November 20, 2022 20:09
@mattpap mattpap changed the title Persistent box selection overlay Editable annotations and persistent selection overlays Nov 20, 2022
@mattpap mattpap force-pushed the mattpap/3412_persistent_overlays branch 2 times, most recently from b57e960 to 331d1ae Compare November 30, 2022 10:12
@mattpap mattpap force-pushed the mattpap/3412_persistent_overlays branch from 49c3bc5 to 94d4754 Compare December 6, 2022 17:17
@mattpap mattpap force-pushed the mattpap/3412_persistent_overlays branch from 94d4754 to 9cca74b Compare December 11, 2022 00:18
@mattpap mattpap force-pushed the mattpap/3412_persistent_overlays branch 2 times, most recently from 95f59ae to d2dc2f4 Compare January 6, 2023 02:02
@mattpap mattpap force-pushed the mattpap/3412_persistent_overlays branch 3 times, most recently from 593066e to 5152871 Compare January 11, 2023 16:02
@mattpap mattpap force-pushed the mattpap/3412_persistent_overlays branch from 42e8810 to 010d1a5 Compare January 31, 2023 11:52
Copy link
Member

@ianthomas23 ianthomas23 left a comment

Choose a reason for hiding this comment

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

All my comments have been dealt with, so I am approving this.

There are some test failures.

@mattpap mattpap force-pushed the mattpap/3412_persistent_overlays branch from 010d1a5 to b984856 Compare February 1, 2023 15:39
@mattpap mattpap force-pushed the mattpap/3412_persistent_overlays branch from b984856 to 4e14d6e Compare February 1, 2023 21:48
@mattpap mattpap force-pushed the mattpap/3412_persistent_overlays branch from 4e14d6e to 10ca016 Compare February 2, 2023 17:47
@mattpap
Copy link
Contributor Author

mattpap commented Feb 2, 2023

This is fully ready now. More testing and documentation will follow next week. Unless there are any objections, I would like to merged this soon.

@mattpap mattpap merged commit 1c51e4b into branch-3.1 Feb 4, 2023
@mattpap mattpap deleted the mattpap/3412_persistent_overlays branch February 4, 2023 10:28
Chiemezuo pushed a commit to Chiemezuo/bokeh that referenced this pull request Aug 27, 2024
* Add support for persistent box selection

* Add support for hover to BoxAnnotation

* Improved handling of Escape key

* Add BoxSelectTool.persistent property

* Respect *_units in BoxSelectToolView

* Add persistent_selections example

* Update RangeTool's unit tests

* Make box overlays always editable

* Improve edge detection for small distances

* Use data units by default in box select overlay

* More intuitive tool button press handling

* Show tool button menu with space bar when active

* Respect key modifiers when editing selections

* Allow to persist selection overlays across tool changes

* Allow more specific self in computed defaults

* Allow to limit resizing and movement of boxes

* First clear selection overlay then the selection

* Expose alt_key modifier in UI events

* Add support for symmetric box resizing

* Redesign RangeTool using editable BoxAnnotation

* Validate box when flipping sides during resizing

* Very rudimentary support for rounded corners

* Preliminary support for auto-ranging of annotations

* Include BoxAnnotation in *.blf files

* Add support for editable PolyAnnotation

* Add support for persistent poly and lasso select

* Use BBox in serializable state

* Add edge detection to PolyAnnotation

* Add support for editable Span annotation

* Allow Arrayable PolyAnnotation.{xs,ys}

* Use alt key for continuous selection

* Very rudimentary support for event propagation

* Finalize persistent poly/lasso selections

* Increase bundle size allowance

* Robustify handling of mappers in poly annotation

* Propagate hover in range tool's overlay

* Simplify mapper resolution in BoxAnnotation

* Implement pinch/rotate in UIEvents

Also prevents default if pan/pinch/rotate is performed.

* Add support for pinch resize to BoxAnnotation

* Generalize border_radius in BoxAnnotation

* Update implementation after the rebase

* Don't use unnecessary 'let' in select_tool.ts

* Remove dead code from select_tool.ts

* Extract common logic into RegionSelectTool

* Allow only one persistent selection overlay

* Refactor persistent_selections example

* RangeTool is not a gesture tool anymore

* Don't select via edit before finished

* Add visual regression tests

For bokeh#5829, bokeh#8081, bokeh#9047 and bokeh#9381.

* Fix argument names in GlyphAPI.block()

* Don't fail catastrophically in BBox.from_lrtb()

* Add editable BoxAnnotation visual tests

* Allow to capture state at image capture time
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.