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

Picking overhaul #4254

Merged
merged 60 commits into from
Jun 25, 2023
Merged

Picking overhaul #4254

merged 60 commits into from
Jun 25, 2023

Conversation

banesullivan
Copy link
Member

@banesullivan banesullivan commented Apr 10, 2023

An internal overhaul to the picking interface to improve stability and useability with the following upgrades:

  • Picking now works across subplots (see new "poked renderer" APIs)
  • Right-click point picking is enabled by default
  • A new "element" picking interface to select individual meshes, cells, faces, and edges (not recommended for points)
  • Improved setter/getter for picker types

The redesign splits picking into two modes:

  1. Point-based picking - use the cursor to pick a single point within the scene and use that point to perform an operation (e.g., select the mesh, cell, face, edge at that point)
  2. Rectangle-based picking - use a selection rectangle on the viewport of the scene to make an area-based selection. This will build a frustum from the viewport area to use to select within the scene

All additional picking methods build on those two interfaces.

Backward compatibility is maintained for the most part (some callbacks did change). Specifically, I need to document what changed:

  • use_mesh argument for point picking has been removed
  • the passed values for some callbacks have changed

Resolves

Resolves #1012
Resolves #3564
Resolves #2578
Resolves #3027 - makes it easier to choose which picker to use
Resolves #3703
Resolves #3915
Resolves #4381
Resolves #2520

To do

  • Minor implementation cleanups
  • Verify all examples work as expected
  • Complete and check documentation
  • Improve picker setter/getter interface for tab-completion (not just hardcoded strings)
  • Additional tests for coverage
  • Provide examples for new capabilities

@github-actions github-actions bot added documentation Anything related to the documentation/website enhancement Changes that enhance the library labels Apr 10, 2023
@codecov
Copy link

codecov bot commented Apr 10, 2023

Codecov Report

Merging #4254 (9f9d7a5) into main (a2fb25e) will decrease coverage by 0.06%.
The diff coverage is 93.19%.

@@            Coverage Diff             @@
##             main    #4254      +/-   ##
==========================================
- Coverage   95.82%   95.77%   -0.06%     
==========================================
  Files         127      127              
  Lines       21105    21357     +252     
==========================================
+ Hits        20224    20454     +230     
- Misses        881      903      +22     

@banesullivan banesullivan added the breaking-change Changes that break backwards compatibility, especially changed default parameters. label Jun 12, 2023
@akaszynski
Copy link
Member

@banesullivan, don't take this as a complete review, but local testing (both unit and functional) of this branch on a closed source library that makes heavy use of the existing picking API works with no issues.

Full review will likely happen over the weekend, but don't wait for me if you'd like to merge sooner.

@banesullivan banesullivan removed the breaking-change Changes that break backwards compatibility, especially changed default parameters. label Jun 23, 2023
@banesullivan
Copy link
Member Author

@pyvista/developers, ready for review if anyone has the bandwidth

Copy link
Contributor

@annehaley annehaley left a comment

Choose a reason for hiding this comment

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

There are several new methods in plotting/picking.py and plotting/render_window_interactor that codecov is warning about.

Comment on lines +13 to +15
* Face: pick a single face of a cell on the mesh
* Edge: pick a single edge of a cell on the mesh
* Point: pick a single point on the mesh
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Face: pick a single face of a cell on the mesh
* Edge: pick a single edge of a cell on the mesh
* Point: pick a single point on the mesh
* Point: pick a single point on the mesh (equivalent to :func:`enable_point_picking() <pyvista.Plotter.enable_point_picking>`.)

What about helper methods for enable_face_picking and enable_edge_picking?

Copy link
Contributor

Choose a reason for hiding this comment

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

I also see a method enable_rectangle_picking, is there a reason it's left out of this group of examples?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is actually a bit different than enable_point_picking. enable_point_picking picks points under the cursor: sometimes in free space, sometimes on a mesh, and if the right picker is chosen, sometimes it will snap to points. enable_element_picking specifically snaps to points on a mesh. This is why I left it out.

enable_rectangle_picking isn't meant to be used directly, so I don't want to advertise it. enable_rectangle_through_picking and enable_rectangle_visible_picking are the interfaces meant to be used for this type of picking. Further, rectangle selection picks under some sort of area or volume whereas these methods are point-based picking

examples/02-plot/element-picking.py Outdated Show resolved Hide resolved
examples/02-plot/element-picking.py Outdated Show resolved Hide resolved
pyvista/plotting/picking.py Outdated Show resolved Hide resolved
pyvista/plotting/picking.py Outdated Show resolved Hide resolved
tests/plotting/test_picking.py Outdated Show resolved Hide resolved
examples/02-plot/point-picking.py Outdated Show resolved Hide resolved
examples/02-plot/surface-picking.py Outdated Show resolved Hide resolved
pyvista/plotting/picking.py Outdated Show resolved Hide resolved
banesullivan and others added 6 commits June 24, 2023 15:43
Co-authored-by: Anne Haley <anne.haley@kitware.com>
Co-authored-by: Anne Haley <anne.haley@kitware.com>
Co-authored-by: Anne Haley <anne.haley@kitware.com>
Co-authored-by: Anne Haley <anne.haley@kitware.com>
@banesullivan
Copy link
Member Author

Thanks for the review, @annehaley!

There are several new methods in plotting/picking.py and plotting/render_window_interactor that codecov is warning about.

This is a big PR, so things are falling through the cracks. Coverage stands at 93.19% for the diff alone (above my bar) but this is a big PR, so the missing ~7% is still significant. I'm unsure if I have the bandwidth to get us to 100% right now. I'll take another look at the missing coverage and see if anything seems problematic

Copy link
Member

@akaszynski akaszynski left a comment

Choose a reason for hiding this comment

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

Functional testing passes on my end, and integration testing with a closed source application that uses picking (on windows and linux) works. Made one minor commit as it would fail when running it interactively. Otherwise, LGTM.

@banesullivan banesullivan enabled auto-merge (squash) June 24, 2023 23:02
@banesullivan banesullivan mentioned this pull request Jun 24, 2023
@banesullivan banesullivan merged commit 8eb1b2d into main Jun 25, 2023
24 checks passed
@banesullivan banesullivan deleted the feat/picking-overhaul branch June 25, 2023 00:18
@akaszynski akaszynski mentioned this pull request Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Anything related to the documentation/website enhancement Changes that enhance the library
Projects
None yet
3 participants