pyvista icon indicating copy to clipboard operation
pyvista copied to clipboard

pythreejs Plotter support for point labels

Open darikg opened this issue 1 year ago • 4 comments

Describe the feature you would like to be added.

The pythreejs plotter currently does not support point labels. It'd be nice to have this since the pythreejs/jupyterlab integration is really nice.

I've poked around a bit and found:

  1. Pyvista's pythreejs adapter works by converting the actors in the VTK plotter to their pythreejs equivalents
  2. Plotter.add_point_labels(..., show_points=True) adds two actors:
  • an actor whose GetMapper().GetInputAsDataSet() returns a PolyData with the corresponding points, and label values stored in point_data['labels']
  • an actor whose GetMapper() returns a vtkLabelPlacementMapper that does not have a GetInputAsDataSet method
  1. with Plotter.add_point_labels(..., show_points=False), only the latter of the two actors above is added

It seems like it'd be pretty easy to pull points and labels out of that first actor, and represent them as pythreejs TextGeometry objects, but if show_points=False is used, I don't know how to get the points/labels out of that vtkLabelPlacementMapper.

cc @akaszynski, I think you did all the original pythreejs work?

Links to VTK Documentation, Examples, or Class Definitions.

No response

Pseudocode or Screenshots

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

darikg avatar Jul 09 '22 19:07 darikg

It'd be nice to have this since the pythreejs/jupyterlab integration is really nice.

Fully agree. It's a missing feature I've been meaning to add.

cc @akaszynski, I think you did all the original pythreejs work?

Yes, and it's a bit of work, not sure how much I'll be able to maintain it without help.

akaszynski avatar Jul 10 '22 14:07 akaszynski

Yes, and it's a bit of work

I'm sure! I'm happy to submit a PR here, just not sure how to use the vtkLabelPlacementMapper. Or do you think it'd be ok to just require the original add_point_labels have use show_points=True?

darikg avatar Jul 10 '22 20:07 darikg

Yes, and it's a bit of work

I'm sure! I'm happy to submit a PR here, just not sure how to use the vtkLabelPlacementMapper. Or do you think it'd be ok to just require the original add_point_labels have use show_points=True?

I think that's acceptable. Just as long as you raise a helpful ValueError to let the user know what the issue is.

akaszynski avatar Jul 10 '22 23:07 akaszynski

Ah, looks like pythreejs hasn't implemented TextGeometry yet https://github.com/jupyter-widgets/pythreejs/issues/199

darikg avatar Jul 12 '22 12:07 darikg

Closing as we don't plan on further developing the pythreejs jupyter backend. This may be possible with the new trame-based backend in the future, but is also currently limited by VTK.js not support text actors

banesullivan avatar Jan 27 '23 18:01 banesullivan