-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore the window when picking points (#1908)
- Loading branch information
Paul Smith
committed
Dec 23, 2021
1 parent
a331ab3
commit dc60a8d
Showing
5 changed files
with
202 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
""" | ||
.. _point_picking_example: | ||
Picking points on a mesh | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
This example demonstrates how to pick points on meshes using | ||
:func:`enable_point_picking() <pyvista.Plotter.enable_point_picking>`. | ||
""" | ||
|
||
# sphinx_gallery_thumbnail_number = 2 | ||
import pyvista as pv | ||
|
||
############################################################################### | ||
# Pick points on a sphere | ||
# +++++++++++++++++++++++ | ||
# | ||
sphere = pv.Sphere() | ||
|
||
p = pv.Plotter() | ||
p.add_mesh(sphere, pickable=True) | ||
p.enable_point_picking() | ||
p.show() | ||
|
||
############################################################################### | ||
# Ignore the 3D window | ||
# ++++++++++++++++++++ | ||
# | ||
# In the above example, both points on the mesh and points in the 3d window can be | ||
# selected. It is possible instead pick only points on the mesh. | ||
sphere = pv.Sphere() | ||
|
||
p = pv.Plotter() | ||
p.add_mesh(sphere, pickable=True) | ||
p.enable_point_picking(pickable_window=False) # Make the 3D window unpickable | ||
p.show() | ||
|
||
############################################################################### | ||
# Modify which actors are pickable | ||
# ++++++++++++++++++++++++++++++++ | ||
# | ||
# After enabling point picking, we can modify which actors are pickable. | ||
sphere = pv.Sphere() | ||
cube = pv.Cube() | ||
cube.translate([10, 10, 0]) | ||
|
||
p = pv.Plotter() | ||
sphere_actor = p.add_mesh(sphere, pickable=True) # initially pickable | ||
cube_actor = p.add_mesh(cube, pickable=False) # initially unpickable | ||
p.enable_point_picking(pickable_window=False) | ||
|
||
p.pickable_actors = [sphere_actor, cube_actor] # now both are pickable | ||
p.view_xy() | ||
p.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters