File: multiwindows2.py

package info (click to toggle)
vedo 2025.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,404 kB
  • sloc: python: 64,792; javascript: 1,932; xml: 437; sh: 139; makefile: 6
file content (26 lines) | stat: -rw-r--r-- 839 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""Multiple plotter sync-ed windows"""
from vedo import *

acts = [Ellipsoid().color('Bisque'),
        Cone().color('RosyBrown'),
        Cylinder().color('Chocolate'),
]

opts = dict(axes=1, interactive=False, new=True, size=(390,390))
ts = [f"Window nr.{i}" for i in range(4)]

plt0 = show(acts[0], **opts, pos=( 200,0), title=ts[0], viewup='z')
plt1 = show(acts[1], **opts, pos=( 600,0), title=ts[1], camera=plt0.camera)
plt2 = show(acts[2], __doc__, **opts, pos=(1000,0), title=ts[2], camera=plt0.camera)
plts = [plt0, plt1, plt2]

def func(evt):
    for i in range(3):
        if ts[i] != evt.title: # only update the other windows
            plts[i].render()

for plt in plts:
    plt.add_callback('Interaction', func)
    plt.add_callback('EndInteraction', func) # because zooming is not an "Interaction" event

plt.interactive()