-
Notifications
You must be signed in to change notification settings - Fork 64
cursor tool and better tooltips #947
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
Changes from 7 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
97442f5
new cursor tool, basics work
kushalkolar 034f719
lint and update api docs
clewis7 9a18381
add custom tooltip to figure
kushalkolar b08e744
Merge branch 'cursor-simpler' of https://github.com/fastplotlib/fastp…
kushalkolar cf0c6dd
example WIP
kushalkolar 86807c2
manual picking, world obj -> graphic mapping
kushalkolar 506fa2c
fix
kushalkolar f69ccc9
fix gc
kushalkolar c0c1203
stuff
kushalkolar cbc5127
Merge branch 'main' into cursor-simpler
kushalkolar 5630f23
Merge branch 'cursor-simpler' of https://github.com/fastplotlib/fastp…
kushalkolar c5f8eac
cursor and tooltips refactor, basically works
kushalkolar 9323e3a
much simpler tooltip and cursor
kushalkolar a59f686
move TextBox and Tooltip, update API docs
kushalkolar c60f1fe
cursor manages tooltips
kushalkolar 32493b1
update examples
kushalkolar ed297f5
black
kushalkolar 40f3357
cleanup
kushalkolar a3252eb
docstrings
kushalkolar c6133cd
update example
kushalkolar 75d13fe
update example
kushalkolar 6d535e7
add image space transforms examples
kushalkolar 00b51a9
finish space transforms examples
kushalkolar 1cafa74
typing
kushalkolar f585007
black
kushalkolar a64ce67
docstrings
kushalkolar a0f74c2
update examples
kushalkolar 6a648e7
textbox constructor takes args, docstrings
kushalkolar dd65092
True -> true
kushalkolar cd0f216
update names
kushalkolar 70c8088
update cursor examples
kushalkolar d4c3eb7
new ground truth screenshots for transforms
kushalkolar edca694
black
kushalkolar 3570fba
update
kushalkolar a7bf44c
revert persist kwarg in PlotArea animations stuff
kushalkolar fba5247
fix
kushalkolar 201b75c
message for image volumes
kushalkolar 32c7d5f
Update fastplotlib/graphics/_base.py
clewis7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| .. _api.Cursor: | ||
|
|
||
| Cursor | ||
| ****** | ||
|
|
||
| ====== | ||
| Cursor | ||
| ====== | ||
| .. currentmodule:: fastplotlib | ||
|
|
||
| Constructor | ||
| ~~~~~~~~~~~ | ||
| .. autosummary:: | ||
| :toctree: Cursor_api | ||
|
|
||
| Cursor | ||
|
|
||
| Properties | ||
| ~~~~~~~~~~ | ||
| .. autosummary:: | ||
| :toctree: Cursor_api | ||
|
|
||
| Cursor.alpha | ||
| Cursor.color | ||
| Cursor.edge_color | ||
| Cursor.edge_width | ||
| Cursor.marker | ||
| Cursor.mode | ||
| Cursor.pause | ||
| Cursor.position | ||
| Cursor.size | ||
| Cursor.size_space | ||
|
|
||
| Methods | ||
| ~~~~~~~ | ||
| .. autosummary:: | ||
| :toctree: Cursor_api | ||
|
|
||
| Cursor.add_subplot | ||
| Cursor.clear | ||
| Cursor.remove_subplot | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| .. _api.GraphicTooltip: | ||
|
|
||
| GraphicTooltip | ||
| ************** | ||
|
|
||
| ============== | ||
| GraphicTooltip | ||
| ============== | ||
| .. currentmodule:: fastplotlib | ||
|
|
||
| Constructor | ||
| ~~~~~~~~~~~ | ||
| .. autosummary:: | ||
| :toctree: GraphicTooltip_api | ||
|
|
||
| GraphicTooltip | ||
|
|
||
| Properties | ||
| ~~~~~~~~~~ | ||
| .. autosummary:: | ||
| :toctree: GraphicTooltip_api | ||
|
|
||
| GraphicTooltip.background_color | ||
| GraphicTooltip.font_size | ||
| GraphicTooltip.outline_color | ||
| GraphicTooltip.padding | ||
| GraphicTooltip.text_color | ||
| GraphicTooltip.world_object | ||
|
|
||
| Methods | ||
| ~~~~~~~ | ||
| .. autosummary:: | ||
| :toctree: GraphicTooltip_api | ||
|
|
||
| GraphicTooltip.clear | ||
| GraphicTooltip.display | ||
| GraphicTooltip.register | ||
| GraphicTooltip.unregister | ||
| GraphicTooltip.unregister_all | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,5 @@ Tools | |
|
|
||
| HistogramLUTTool | ||
| Tooltip | ||
| GraphicTooltip | ||
| Cursor | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| """ | ||
| Cursor tool with tooltips | ||
| ========================= | ||
|
|
||
| Cursor tool example that also displays tooltips | ||
| """ | ||
|
|
||
| import numpy as np | ||
| import fastplotlib as fpl | ||
| import imageio.v3 as iio | ||
| from pylinalg import vec_transform, mat_combine | ||
|
|
||
| img1 = iio.imread("imageio:camera.png") | ||
| img2 = iio.imread("imageio:astronaut.png") | ||
|
|
||
| scatter_data = np.random.normal(loc=256, scale=(50), size=(500)).reshape(250, 2) | ||
| line_data = np.random.rand(100, 2) * 512 | ||
|
|
||
| figure = fpl.Figure(shape=(2, 2), size=(500, 500)) | ||
|
|
||
| img = figure[0, 0].add_image(img1, cmap="viridis") | ||
| figure[0, 1].add_image(img2, metadata="image metadata") | ||
| figure[1, 0].add_scatter(scatter_data, sizes=5, metadata="scatter metadata") | ||
| figure[1, 1].add_line(line_data, metadata="line metadata") | ||
|
|
||
| cursor = fpl.Cursor(mode="crosshair", color="w") | ||
|
|
||
| for subplot in figure: | ||
| cursor.add_subplot(subplot) | ||
|
|
||
| figure.show_tooltips = True | ||
|
|
||
| tooltips2 = fpl.Tooltip() | ||
| tooltips2.world_object.visible = True | ||
| figure.add_tooltip(tooltips2) | ||
|
|
||
| @figure.renderer.add_event_handler("pointer_move") | ||
| def update(ev): | ||
| pos = figure[0, 0].map_screen_to_world(ev) | ||
| if pos is None: | ||
| return | ||
|
|
||
| x, y = figure[0, 1].map_world_to_screen(pos) | ||
| pick = subplot.get_pick_info((x, y)) | ||
|
|
||
| if pick is None: | ||
| tooltips2.visible = False | ||
| return | ||
|
|
||
| info = pick["graphic"].metadata | ||
| tooltips2.display((x, y), str(info)) | ||
|
|
||
| print((img.world_object.children[0].uniform_buffer.data["global_id"]).item()) | ||
| figure.show() | ||
|
|
||
|
|
||
| # NOTE: fpl.loop.run() should not be used for interactive sessions | ||
| # See the "JupyterLab and IPython" section in the user guide | ||
| if __name__ == "__main__": | ||
| print(__doc__) | ||
| fpl.loop.run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| """ | ||
| Cursor tool | ||
| =========== | ||
|
|
||
| Example with multiple subplots and an interactive cursor that marks the same position in each subplot. | ||
| """ | ||
|
|
||
| # test_example = False | ||
| # sphinx_gallery_pygfx_docs = 'screenshot' | ||
|
|
||
| import numpy as np | ||
| import fastplotlib as fpl | ||
| import imageio.v3 as iio | ||
| from pylinalg import vec_transform, mat_combine | ||
|
|
||
|
|
||
| # get some data | ||
| img1 = iio.imread("imageio:camera.png") | ||
| img2 = iio.imread("imageio:wikkie.png") | ||
| scatter_data = np.random.normal(loc=256, scale=(50), size=(500)).reshape(250, 2) | ||
| line_data = np.random.rand(100, 2) * 512 | ||
|
|
||
| # create a figure | ||
| figure = fpl.Figure(shape=(2, 2), size=(700, 750)) | ||
|
|
||
| # plot data | ||
| figure[0, 0].add_image(img1, cmap="viridis") | ||
| figure[0, 1].add_image(img2) | ||
| figure[1, 0].add_scatter(scatter_data, sizes=5, colors="r") | ||
| figure[1, 1].add_line(line_data, colors="r") | ||
|
|
||
| # creator a cursor in crosshair mode | ||
| cursor = fpl.Cursor(mode="crosshair", color="w") | ||
|
|
||
| # add all subplots to the cursor | ||
| for subplot in figure: | ||
| cursor.add_subplot(subplot) | ||
|
|
||
| # you can also set the cursor position programmatically | ||
| cursor.position = (256, 256) | ||
|
|
||
| figure.show() | ||
|
|
||
| # NOTE: fpl.loop.run() should not be used for interactive sessions | ||
| # See the "JupyterLab and IPython" section in the user guide | ||
| if __name__ == "__main__": | ||
| print(__doc__) | ||
| fpl.loop.run() |
|
kushalkolar marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| from ._histogram_lut import HistogramLUTTool | ||
| from ._tooltip import Tooltip | ||
| from ._tooltip import Tooltip, GraphicTooltip | ||
| from ._cursor import Cursor | ||
|
|
||
| __all__ = [ | ||
| "HistogramLUTTool", | ||
| "Tooltip", | ||
| "GraphicTooltip", | ||
| "Cursor", | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.