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

Left click to pick points #2266

Merged
merged 8 commits into from
Mar 28, 2022
Merged

Conversation

p-j-smith
Copy link
Contributor

Overview

Resolves #2193
Indirectly addresses: #1285 pyvista/pyvista-support#249

Hi, I've added the ability to pick points on a mesh by clicking the left mouse button.

Details

I've added an optional left_clicking keyword to enable_point_picking. If set to True, an observer is added to the interactor that will launch a pick event when the left button is clicked.

Because the pick event is not created using by pressing 'P', there is no red box around the picked point (I think the red box is generated by a KeyReleaseEvent associated with vtkRenderWindowInteractor on the C++ side, and cannot be disabled from Python).

I'm not sure this is the best way to go about adding this functionality, so I've not yet added tests. I've added a simple example to the end ofexamples/02_plot/point_picking.py.

@github-actions github-actions bot added the documentation Anything related to the documentation/website label Feb 24, 2022
@codecov
Copy link

codecov bot commented Feb 24, 2022

Codecov Report

Merging #2266 (530f8a2) into main (c5b5330) will increase coverage by 0.07%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2266      +/-   ##
==========================================
+ Coverage   93.40%   93.48%   +0.07%     
==========================================
  Files          75       74       -1     
  Lines       15615    15728     +113     
==========================================
+ Hits        14585    14703     +118     
+ Misses       1030     1025       -5     

@banesullivan
Copy link
Member

Because the pick event is not created using by pressing 'P', there is no red box around the picked point (I think the red box is generated by a KeyReleaseEvent associated with vtkRenderWindowInteractor on the C++ side, and cannot be disabled from Python).

This is a fantastic side effect!

I'm liking the changes you have so far!

@banesullivan banesullivan self-requested a review March 9, 2022 05:01
@banesullivan banesullivan mentioned this pull request Mar 10, 2022
8 tasks
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.

LGTM.

Note: for whatever reason LeftButtonPressEvent isn’t being triggered despite simulating it. I skipped coverage of the function that would be triggered by this event. Since we have coverage of the rest of this feature, I’m fine with approving this. We can consider looking into this later.

@akaszynski akaszynski enabled auto-merge (squash) March 19, 2022 10:28
@akaszynski
Copy link
Member

Merging as there has been no additional feedback and it's time for a release.

@akaszynski akaszynski merged commit c707245 into pyvista:main Mar 28, 2022
@p-j-smith
Copy link
Contributor Author

Hi, thanks for the reviews and for merging! Sorry for not getting back to you - I was away for a couple of weeks

@akaszynski
Copy link
Member

Hi, thanks for the reviews and for merging! Sorry for not getting back to you - I was away for a couple of weeks

No problem at all! Thanks for adding this feature.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to use mouse click with enable_point_picking
3 participants