multi_viewer2.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from vedo import settings, Plotter, ParametricShape, VedoLogo, Text2D
  2. settings.renderer_frame_width = 1
  3. ##############################################################################
  4. def on_left_click(evt):
  5. if not evt.object: return
  6. shapename.text(f'This is called: {evt.object.name}, on renderer nr.{evt.at}')
  7. plt.at(1).remove(objs).add(evt.object).reset_camera()
  8. objs.clear()
  9. objs.append(evt.object)
  10. ##############################################################################
  11. sy, sx, dx = 0.12, 0.12, 0.01
  12. # Define the renderers rectangle areas
  13. # to help finding bottomleft&topright corners check out utils.grid_corners()
  14. shape = [
  15. dict(bottomleft=(0,0), topright=(1,1), bg='k7'), # the full empty window
  16. dict(bottomleft=(dx*2+sx,0.01), topright=(1-dx,1-dx), bg='w'), # the display window
  17. dict(bottomleft=(dx,sy*1), topright=(dx+sx,sy*2), bg='k8', bg2='lb'), # CrossCap
  18. dict(bottomleft=(dx,sy*2), topright=(dx+sx,sy*3), bg='k8', bg2='lb'),
  19. dict(bottomleft=(dx,sy*3), topright=(dx+sx,sy*4), bg='k8', bg2='lb'),
  20. dict(bottomleft=(dx,sy*4), topright=(dx+sx,sy*5), bg='k8', bg2='lb'),
  21. dict(bottomleft=(dx,sy*5), topright=(dx+sx,sy*6), bg='k8', bg2='lb'),
  22. dict(bottomleft=(dx,sy*6), topright=(dx+sx,sy*7), bg='k8', bg2='lb'),
  23. dict(bottomleft=(dx,sy*7), topright=(dx+sx,sy*8), bg='k8', bg2='lb'), # RandomHills
  24. ]
  25. plt = Plotter(shape=shape, sharecam=False, size=(1050, 980))
  26. plt.add_callback("when i click my mouse button please call", on_left_click)
  27. for i in range(2,9):
  28. ps = ParametricShape(i).color(i)
  29. pname = Text2D(ps.name, c='k', bg='blue', s=0.7, font='Calco')
  30. plt.at(i).show(ps, pname)
  31. shapename = Text2D(pos='top-center', c='r', bg='y', font='Calco') # empty text
  32. vlogo = VedoLogo(distance=5)
  33. objs = [vlogo]
  34. title = "My Multi Viewer 1.0"
  35. instr = "Click on the left panel to select a shape\n"
  36. instr+= "Press h to print the full list of options"
  37. plt.at(1).show(
  38. vlogo, shapename,
  39. Text2D(title, pos=(0.5,0.85), s=2.5, c='dg', font='Kanopus', justify='center'),
  40. Text2D(instr, bg='g', pos=(0.5,0.05), s=1.2, font='Quikhand', justify='center'),
  41. )
  42. plt.interactive().close()