-
Notifications
You must be signed in to change notification settings - Fork 4
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 in background plotter #133
Comments
One more question. Is there a method to click on an object and "select" it , or get the name of the actor? |
For this first, problem, perhaps try passing
Hm. I'm not sure I follow what the issue is here. Large values for the coordinates (i.e. scale) should not matter or affect the picker. I have a feeling this has to do with the coarse resolution of the meshes you currently have.
Sort of. You can use the point picking to do this and have the callback work some magic on the selected mesh with the import pyvista as pv
p = pv.Plotter(notebook=0)
# add all your meshes to the scene
N = 5
for i in range(N):
for j in range(N):
center = (i, j, 0)
mesh = pv.Sphere(center=center)
p.add_mesh(mesh, color=True)
# Make a custom callback to handle picked meshes
def callback(mesh, idx):
print(mesh.memory_address, idx)
return
# Enable the use_mesh argument!
p.enable_point_picking(callback=callback, use_mesh=True)
p.show() |
Dear Bane, I’ve seen that the original VTK picker returns, in addition to the closer node that is what you are using now, also PCOORDS: parametric coordinates within the face (e.g. triangle) of a PolyData. Using these and the coordinates of the three nodes it is easy to obtain a better point picker. If you can give us some suggestions, we can try to expose also this method. Thanks!! |
Hello, I attach a notebook and some very simple meshes to reproduce the problems I have with picking. You have to unzip both and run the notebook. You will see that, in addition to the standard Background Plotter menus, you have a new "Interpretation" menu, with line and plane picking. If you try them, you will see that:
I am really struggling with this! Thanks very much! |
Update: it is possible that the VTK picker that returns PCOORDS and all nodes of a triangle corresponds to enable_cell_picking in PyVista. Would it be possible to extract PCOORDS and absolute node coords from that? Thanks! |
Dear Bane, we have another problem with the background plotter. We are using
enable_path_picking
to pick lines in a plotter where we have some mesh. The meshes are in UTM coordinates, with very large numbers like [540169.0, 5094171.2, 2316.6] and I suspect that this is part of the problem since when we were testing on small objects the problem was less pronounced.The problem is two-sided:
The
enable_path_picking
tool returns nodes of the underlying mesh, and if the mesh has a coarse resolution, these points are very far apart. I tried to see if it is possible to use theuse_mesh=False
option as in the underlying methodenable_point_picking
, but it does not work.This is the part of the problem that I think is related to large coordinates: when using meshes in UTM the picking is even more erratic, and this results in completely messed up paths.
Thanks!
The text was updated successfully, but these errors were encountered: