-
Notifications
You must be signed in to change notification settings - Fork 53
add rectangular region selector #576
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
rectangle-.2.mp4 |
rectangle_selection.mp4 |
I wonder if a method that returns a mask and then using the mask for 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) |
) | ||
|
||
for vertex in self.vertices: | ||
vertex.world.z = -0.25 |
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 🤔
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
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?
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?
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.
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()
.
) | ||
|
||
for vertex in self.vertices: | ||
vertex.world.z = -0.25 |
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?
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 |
) | ||
|
||
for vertex in self.vertices: | ||
vertex.world.z = -0.25 |
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.
Chiming in here because Kushal showed this to me IRL yesterday. Pretty cool!!!! I had two comments:
Keep it going. I love to see these demos! |
#142 Rectangle selector
LineGraphic
,ImageGraphic
, etc.)get_selected_indices()
andget_selected_data()
methodsmode
argument, one of"partial", "full", "ignore"
that handles when selector is not covering part of graphic