hover_legend.py 845 B

1234567891011121314151617181920212223242526272829
  1. """Hover mouse on mesh to
  2. visualize object details"""
  3. from vedo import Mesh, dataurl, Sphere, Cube, Points, Plotter
  4. mesh = Mesh(dataurl+"bunny.obj").color('k7')
  5. # Create multiple arrays associated to mesh vertices or cells
  6. mesh.pointdata['MYPOINTARRAY'] = mesh.coordinates[:,0]
  7. mesh.celldata['MYCELLARRAY'] = mesh.cell_centers().coordinates[:,1]
  8. # Create more objects
  9. sph = Sphere(pos=(-0.1,0.05,0.05), r=0.02)
  10. cub = Cube().alpha(0.5).linewidth(2)
  11. pts = Points(cub).c("violet").point_size(50)
  12. pts.name = 'The cube vertices' # can give a name to any objects
  13. # Create an instance of the plotter window
  14. plt = Plotter(N=2, sharecam=False)
  15. # Add a 2D hover legend to both renderers and show:
  16. cid0 = plt.at(0).add_hover_legend()
  17. plt.show(mesh, sph, __doc__)
  18. cid1 = plt.at(1).add_hover_legend()
  19. plt.show(cub, pts)
  20. plt.interactive().close()