GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — add rectangular region selector by clewis7 · Pull Request #576 · fastplotlib/fastplotlib

Conversation

@clewis7

@clewis7 clewis7 commented Aug 2, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

#142 Rectangle selector

  • rectangle selector implementation
  • add selector methods for graphics (e.g. LineGraphic, ImageGraphic, etc.)
  • get_selected_indices() and get_selected_data() methods
    • add a mode argument, one of "partial", "full", "ignore" that handles when selector is not covering part of graphic
  • add vertices on the corners

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
clewis7 added 5 commits August 2, 2024 15:07
@clewis7
start working on adding rectangle region selector
d262570
@clewis7
rename selector tool
d7f3148
@clewis7
update line setting, remove origin
d0a04e6
@clewis7
fix selection feature
8ddfc8a
@clewis7
fix pick write issue
c3e2cef
@clewis7

clewis7 commented Aug 2, 2024

Copy link
Copy Markdown
Member Author
rectangle-.2.mp4
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar
kushalkolar reviewed Aug 2, 2024
View reviewed changes
Comment thread fastplotlib/graphics/selectors/_rectangle_region.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

clewis7 added 3 commits August 3, 2024 11:48
@clewis7
rename file, fix line initialization
db37714
@clewis7
add fixed axis if given, make sure bounds enforced
f8b7f02
@clewis7
add methods for graphics
72defab
@clewis7

clewis7 commented Aug 5, 2024

Copy link
Copy Markdown
Member Author
rectangle_selection.mp4
kushalkolar reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

clewis7 added 3 commits August 5, 2024 10:14
@clewis7
get selected ixs and data for images
3f068cf
@clewis7
add rectangle methods
dcc3774
@clewis7
better lower bound limit for collections
4b7e00d
kushalkolar
kushalkolar reviewed Aug 5, 2024
View reviewed changes
Comment thread fastplotlib/graphics/image.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar

kushalkolar commented Aug 5, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I wonder if a method that returns a mask and then using the mask for get_selected_data() could be useful, since it is about 20% faster:

In [20]: %%timeit
    ...: a[(a > 50_000) & (a < 100_000)]
    ...: 
    ...: 
620 μs ± 7.79 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)

In [21]: %%timeit
    ...: a[np.where((a > 50_000) & (a < 100_000))]
    ...: 
    ...: 
747 μs ± 31.6 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

clewis7 added 2 commits August 6, 2024 14:23
@clewis7
add vertices
4dda743
@clewis7
screen space instead of world space for vertices
4ab552f
kushalkolar
kushalkolar reviewed Aug 6, 2024
View reviewed changes
Comment thread fastplotlib/graphics/selectors/_rectangle.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/selectors/_rectangle.py
)

for vertex in self.vertices:
vertex.world.z = -0.25

@kushalkolar kushalkolar Aug 6, 2024

Copy link
Copy Markdown
Member

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.

why -0.25 🤔

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@clewis7 clewis7 Aug 7, 2024

Copy link
Copy Markdown
Member Author

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.

the edges get set to -0.5, so if the vertices are -0.25 then they will be on top of the edges

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kushalkolar kushalkolar Aug 8, 2024

Copy link
Copy Markdown
Member

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.

how does this scale with rectangle size and camera zoom?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@clewis7 clewis7 Aug 9, 2024

Copy link
Copy Markdown
Member Author

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.

what do you mean?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kushalkolar kushalkolar Aug 10, 2024

Copy link
Copy Markdown
Member

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.

Sometimes world objects will have weird overlapping when the z-planes are close with very high or very low zoom, I just tried it and it seems fine within reasonable levels.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
clewis7 added 4 commits August 7, 2024 09:39
@clewis7
change vertices to square, change vertex color
0a63cac
@clewis7
fix selection for line collections
3e33aa5
@clewis7
add example
74f0925
@clewis7
update api docs, add example
c466dab
@clewis7
clewis7 marked this pull request as ready for review August 8, 2024 14:55
clewis7 added 3 commits August 8, 2024 10:57
@clewis7
lint
ad203b2
@clewis7
update conf and api files
86b0d5d
@clewis7
this file should be deleted
4ffffa1
kushalkolar
kushalkolar reviewed Aug 9, 2024
View reviewed changes

@kushalkolar kushalkolar left a comment

Copy link
Copy Markdown
Member

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.

Wondering if you tried the selector with different offsets for the parent graphic, does it return the correct selection, and correct arrays for get_selected_indices() and get_selected_data().

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread fastplotlib/graphics/selectors/_rectangle.py
)

for vertex in self.vertices:
vertex.world.z = -0.25

@kushalkolar kushalkolar Aug 8, 2024

Copy link
Copy Markdown
Member

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.

how does this scale with rectangle size and camera zoom?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread fastplotlib/graphics/_features/_selection_features.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/_features/_selection_features.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/image.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/image.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/selectors/_rectangle.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/selectors/_rectangle.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/selectors/_rectangle.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/selectors/_rectangle.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/selectors/_rectangle.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar

kushalkolar commented Aug 9, 2024

Copy link
Copy Markdown
Member

For collection a helper method that gets indices or returns graphics under the selection could be useful. Not hard to implement currently, we can think about and add more helper functions later 😄

line_collection = figure[0, 0].add_line_collection(circles, cmap="jet", thickness=5)

rs = line_collection.add_rectangle_selector()

@rs.add_event_handler("selection")
def bah(ev):
    line_collection.cmap = "jet"
    ixs = ev.get_selected_indices()

    # iterate through each of the selected indices, if the array size > 0 that mean it's under the selection
    selected_line_ixs = [i for i in range(len(ixs)) if ixs[i].size > 0]
    line_collection[selected_line_ixs].colors = "w"
rectangle_selector-2024-08-08_23.43.52.mp4
clewis7 reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@clewis7
requested changes, update with better example, more comments
4962838
clewis7 added 2 commits August 9, 2024 10:29
@clewis7
fix offset when adding rectangle selector so fill events happen
28f247b
@clewis7
update api docs
8e109b7
kushalkolar
kushalkolar requested changes Aug 10, 2024
View reviewed changes
Comment thread examples/desktop/selectors/rectangle_selector.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/selectors/_rectangle.py
)

for vertex in self.vertices:
vertex.world.z = -0.25

@kushalkolar kushalkolar Aug 10, 2024

Copy link
Copy Markdown
Member

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.

Sometimes world objects will have weird overlapping when the z-planes are close with very high or very low zoom, I just tried it and it seems fine within reasonable levels.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread fastplotlib/graphics/selectors/_rectangle.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar
kushalkolar requested changes Aug 10, 2024
View reviewed changes
Comment thread fastplotlib/graphics/image.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/image.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hmaarrfk

hmaarrfk commented Aug 14, 2024

Copy link
Copy Markdown
Contributor

Chiming in here because Kushal showed this to me IRL yesterday. Pretty cool!!!!

I had two comments:

  1. We once had pretty bad performance from pygfx_object.world.matrix so we ended up caching it ourselves.... maybe i should open an issue to pygfx on that. It made iterating through the list of "selectable objects" we had kinda slow.
  2. Bonus points for thinking about how to do this in 3D. We didn't get to that part either....
  3. Bonus points for doing this all on the GPU in WGSL and just make "highlighting" a property of your shaders ;)

Keep it going. I love to see these demos!

kushalkolar reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@clewis7
requested changes
da90444
kushalkolar
kushalkolar approved these changes Aug 24, 2024
View reviewed changes
@kushalkolar
kushalkolar merged commit c12b2c8 into main Aug 24, 2024
@kushalkolar
kushalkolar deleted the rectangle_selector branch August 28, 2024 19:05
@kushalkolar kushalkolar mentioned this pull request Nov 18, 2024
feat: Histogram Widget pyapp-kit/ndv#52
Merged
2 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kushalkolar kushalkolar kushalkolar approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@clewis7 @kushalkolar @hmaarrfk
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.