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

Add a Selection Gizmo #753

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Add a Selection Gizmo #753

wants to merge 2 commits into from

Conversation

schlegelp
Copy link
Contributor

@schlegelp schlegelp commented May 8, 2024

This is a draft PR for adding a selection gizmo (see #745).

python3 examples/feature_demo/selection_helper.py
Screen.Recording.2024-05-08.at.15.47.16.mov

Potential TODOs:

  • make sure this also works well in 3D
  • explore the possibility of a 3D selection gizmo (first click + drag creates 2d box, second click extends to 3d box)
  • allow multiple modifiers for starting the drag (e.g. shift-control click to start dragging)
  • handle WorldObjects in SelectionGizmo.is_inside
  • variations of the basic gizmo:
    • lasso selection (this should be fairly easy)
    • draggable selection rectangles

I'm aware that this might be out of the scope for pygfx itself as you may not want to weigh yourself down with having to maintain too many non-essential bits and pieces. If that's the case, no hard feeling! Also no worries if this implementation is going in the wrong direction.

Have a look & let me know what you think.

@schlegelp schlegelp requested a review from Korijn as a code owner May 8, 2024 13:49
@schlegelp schlegelp marked this pull request as draft May 8, 2024 13:49
self._ndc_to_screen = screen_space.inverse_matrix
self._screen_to_ndc = screen_space.matrix

def add_default_event_handlers(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a clear_handlers method would help with garbage collection

"pointer_move",
"pointer_up",
)
# Not sure we actually need to update the gizmo during rendering
Copy link
Contributor

Choose a reason for hiding this comment

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

true I'm a bit confused by this as well

@kushalkolar
Copy link
Contributor

kushalkolar commented May 8, 2024

What do you think about drawing a rectangle (or arbitrary shape with lasso) and allowing it to stay in the scene so it can be moved around? (That could be another selection tool class, I'm just thinking if it'd be easy to do here 🤔 )

@schlegelp
Copy link
Contributor Author

What do you think about drawing a rectangle (or arbitrary shape with lasso) and allowing it to stay in the scene so it can be moved around? (That could be another selection tool, I'm just to think if it'd be easy to do here 🤔 )

Certainly possible. I've added it to the potential TODOs.

@kushalkolar
Copy link
Contributor

A few other things I can think of are resize handlers and a circular/elliptical selection tool. Anyways we can chat more on Friday. This actually helps us a lot with the fastplotlib roadmap!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants