Different viewing modes in different renderers? #1123
-
Hello,
But here I can only pan and zoom the image and the cube stays put. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Unfortunately you cannot. from vedo import *
cube = Cube().rotate_x(10)
img = Image(dataurl+"images/dog.jpg") # this is 3D
plt = Plotter(shape=(1,2), sharecam=False)
plt.at(0).add(cube).reset_camera()
plt.at(1).add(img)
plt.renderers[0].InteractiveOff()
plt.show()
plt.interactive().close() |
Beta Was this translation helpful? Give feedback.
-
What about this: from vedo import *
from vedo.interactor_modes import MousePan
settings.enable_default_keyboard_callbacks = False
def activate(event):
if event.keypress == "z": # activate left renderer
plt.renderers[1].InteractiveOff()
plt.renderers[0].InteractiveOn()
plt.at(0).user_mode(0)
if event.keypress == "x": # activate right renderer
plt.renderers[0].InteractiveOff()
plt.renderers[1].InteractiveOn()
plt.at(1).user_mode(mouse_pan)
elif event.keypress == "q":
plt.break_interaction()
mouse_pan = MousePan()
plt = Plotter(shape=(1,2), sharecam=False)
plt.at(0).add(Cube().color('blue8'), "Press z").reset_camera()
plt.at(1).add(Cube().color('red5'), "Press x")
plt.add_callback('key press', activate)
plt.renderers[1].InteractiveOff()
plt.show(interactive=True).close() |
Beta Was this translation helpful? Give feedback.
-
Thank you, Marco! Who said it was not possible?! 😉🤝
|
Beta Was this translation helpful? Give feedback.
-
This is a possibly improved version with highlighting of the active renderer:
then from vedo import *
from vedo.interactor_modes import MousePan
settings.enable_default_keyboard_callbacks = False
active = 0
inactive = 1
cube = Cube().rotate_x(10)
img = Image(dataurl+"images/dog.jpg")
def toggle_active(event):
global active, inactive
if event.keypress == "Tab": # toggle active renderer
active, inactive = inactive, active
plt.at(active).user_mode(modes[active])
plt.at(inactive).remove(frames[inactive]).freeze(True)
plt.at(active).add(frames[active]).freeze(False)
plt.render()
frame0 = RendererFrame(lw=10, c="red5", alpha=1)
frame1 = RendererFrame(lw=10, c="red5", alpha=1)
plt = Plotter(shape=(1,2), sharecam=False)
modes = [0, MousePan()]
frames = [frame0, frame1]
plt.at(0).add(cube, frame0, "Press TAB to toggle active panel").reset_camera()
plt.at(1).add(img)
plt.add_callback('key press', toggle_active)
plt.at(inactive).freeze()
plt.show(interactive=True).close() |
Beta Was this translation helpful? Give feedback.
Thank you, Marco! Who said it was not possible?! 😉🤝