multiwindows1.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. """
  2. Example of drawing objects on different windows
  3. and/or subwindows within the same window.
  4. We split the main window in many subwindows and draw
  5. something on specific windows.
  6. Then open an independent window and draw a shape on it.
  7. """
  8. from vedo import Mesh, dataurl, Plotter, printc
  9. ##########################################################################
  10. # this is one instance of the class Plotter with 5 raws and 5 columns
  11. plt1 = Plotter(shape=(5,5), axes=0)
  12. # set a different background color for a specific subwindow (the last one)
  13. plt1.background([0.8, 0.9, 0.9], at=24)
  14. # load the meshes and give them a name
  15. a = Mesh(dataurl+"shuttle.obj")
  16. b = Mesh(dataurl+"cessna.vtk").c("red")
  17. c = Mesh(dataurl+"porsche.ply")
  18. # show a Text2D in each renderer
  19. for i in range(25):
  20. plt1.at(i).show(f"renderer\nnr.{i}")
  21. plt1.at( 6).show(a)
  22. plt1.at(23).show(b)
  23. plt1.at(24).show(c)
  24. ##########################################################################
  25. # declare a second independent instance of the class Plotter
  26. # shape can also be given as a string, e.g.:
  27. # shape="2/6" means 2 renderers above and 6 below
  28. # shape="3|1" means 3 renderers on the left and one on the right
  29. s = Mesh(dataurl+'mug.ply')
  30. # Set the position of the horizontal of vertical splitting [0,1]:
  31. #settings.window_splitting_position = 0.5
  32. plt2 = Plotter(pos=(500, 250), shape='2/6')
  33. for i in range(len(plt2.renderers)):
  34. s2 = s.clone(deep=False).color(i)
  35. plt2.at(i).show(s2, f'renderer #{i}')
  36. printc(__doc__)
  37. plt2.interactive()
  38. plt2.close()
  39. plt1.close()