Example #1
0
    def _create_control(self, parent):
        """ Create the toolkit-specific control that represents the widget. """

        if self.off_screen_rendering:
            if hasattr(tvtk, 'EGLRenderWindow'):
                renwin = tvtk.EGLRenderWindow()
            elif hasattr(tvtk, 'OSOpenGLRenderWindow'):
                renwin = tvtk.OSOpenGLRenderWindow()
            else:
                renwin = tvtk.RenderWindow()
                # If we are doing offscreen rendering we set the window size to
                # (1,1) so the window does not appear at all
                renwin.size = (1, 1)

            self._renwin = renwin
            self._interactor = tvtk.GenericRenderWindowInteractor(
                render_window=renwin
            )
        else:
            renwin = self._renwin = tvtk.RenderWindow()
            self._interactor = tvtk.RenderWindowInteractor(
                render_window=renwin
            )

        renwin.trait_set(point_smoothing=self.point_smoothing,
                         line_smoothing=self.line_smoothing,
                         polygon_smoothing=self.polygon_smoothing)
        # Create a renderer and add it to the renderwindow
        self._renderer = tvtk.Renderer()
        renwin.add_renderer(self._renderer)
        # Save a reference to our camera so it is not GC'd -- needed for
        # the sync_traits to work.
        self._camera = self.camera

        # Sync various traits.
        self._renderer.background = self.background
        self.sync_trait('background', self._renderer)
        self._renderer.on_trait_change(self.render, 'background')
        self._camera.parallel_projection = self.parallel_projection
        self.sync_trait('parallel_projection', self._camera)
        renwin.off_screen_rendering = self.off_screen_rendering
        self.sync_trait('off_screen_rendering', self._renwin)
        self.render_window.on_trait_change(self.render, 'off_screen_rendering')
        self.render_window.on_trait_change(self.render, 'stereo_render')
        self.render_window.on_trait_change(self.render, 'stereo_type')
        self.camera.on_trait_change(self.render, 'parallel_projection')

        self._interactor.initialize()
        self._interactor.render()
        self.light_manager = light_manager.LightManager(self)
        if self.off_screen_rendering:
            # We want the default size to be the normal (300, 300).
            # Setting the size now should not resize the window if
            # offscreen is working properly in VTK.
            renwin.size = (300, 300)

        return self._interactor
Example #2
0
    def run(self):
        # Remove the renderer from the current render window.
        self.old_rw.remove_renderer(self.ren)

        # Creates renderwindow that should be used ONLY for
        # visualization in full screen
        full_rw = tvtk.RenderWindow(stereo_capable_window=True,
                                    full_screen=True)
        # add the current visualization
        full_rw.add_renderer(self.ren)

        # provides a simple interactor
        style = tvtk.InteractorStyleTrackballCamera()
        self.iren = tvtk.RenderWindowInteractor(render_window=full_rw,
                                                interactor_style=style)

        # Gets parameters for stereo visualization
        if self.old_rw.stereo_render:
            full_rw.set(stereo_type=self.old_rw.stereo_type,
                        stereo_render=True)

        # Starts the interactor
        self.iren.initialize()
        self.iren.render()
        self.iren.start()

        # Once the full screen window is quit this releases the
        # renderer before it is destroyed, and return it to the main
        # renderwindow.
        full_rw.remove_renderer(self.ren)
        self.old_rw.add_renderer(self.ren)
        self.old_rw.render()
        self.iren.disable()
Example #3
0
def compare_image(scene, img_path):
    """Given a MayaVi scene and a path to a valid image, this
    compares the image rendered on the scene to that saved as the
    image.

    This will pop up a new tvtk render window and use that to
    perform the image comparison.
    """
    abs_img_path = img_path
    if not os.path.isabs(img_path):
        abs_img_path = fixpath(img_path)

    s = scene.scene
    s.disable_render = True
    ren = s.renderer
    s.render_window.remove_renderer(ren)
    rw = tvtk.RenderWindow(size=(300, 300))
    rw.add_renderer(ren)
    ren.reset_camera()
    rw.render()
    try:
        compare_image_raw(rw, abs_img_path)
    finally:
        rw.remove_renderer(ren)
        s.render_window.add_renderer(ren)
        s.disable_render = False
        ren.reset_camera()
        s.render()
Example #4
0
 def setUp(self):
     self.cs = cs = tvtk.ConeSource()
     self.ef = ef = tvtk.ElevationFilter(input_connection=cs.output_port)
     self.m = m = tvtk.PolyDataMapper(input_connection=ef.output_port)
     self.a = tvtk.Actor(mapper=m)
     self.ren = tvtk.Renderer()
     self.ren.add_actor(self.a)
     self.renwin = tvtk.RenderWindow()
     self.renwin.add_renderer(self.ren)
Example #5
0
 def _create_tvtk_window(self, size=(500,500)):
     # create a renderer
     self.renderer = tvtk.Renderer()
     # create a render window and hand it the renderer
     self.render_window = tvtk.RenderWindow(size=size)
     self.render_window.add_renderer(self.renderer)
     # create interactor and hand it the render window
     # This handles mouse interaction with window.
     self.interactor = tvtk.RenderWindowInteractor(render_window=self.render_window)
     self.gui = None
Example #6
0
def get_render_window():
    ren = tvtk.Renderer(background=(0.0, 0.0, 0.0), automatic_light_creation=0)
    rw = tvtk.RenderWindow(size=(width, height))
    rw.off_screen_rendering = 0
    rw.add_renderer(ren)
    rw.multi_samples = 0
    ac = ren.active_camera
    ac.view_angle = 44.61
    #ren.reset_camera()
    return rw
 def test2(self):
     '''展开交互图像窗口的常用流程'''
     s = tvtk.CubeSource(x_length=1.0, y_length=2.0, z_length=3.0)
     m = tvtk.PolyDataMapper(input_connection=s.output_port)
     a = tvtk.Actor(mapper=m)
     r = tvtk.Renderer(background=(0.5, 0.5, 0.5))
     r.add_actor(a)
     w = tvtk.RenderWindow(size=(500, 500))
     w.add_renderer(r)
     i = tvtk.RenderWindowInteractor(render_window=w)
     i.initialize()
     i.start()
    def __init__(self, size=(300, 300), obj=None, update=True):
        tvtk.RenderWindowInteractor.__init__(self, obj, update)

        # create a renderer
        self.renderer = tvtk.Renderer()

        # create a render window and hand it the renderer
        self.render_window = tvtk.RenderWindow()
        self.render_window.add_renderer(self.renderer)
        self.render_window.size = size

        self.initialize()
Example #9
0
def test01():
    s = tvtk.ConeSource(height=6.0, radius=2.0)
    m = tvtk.PolyDataMapper(input_connection=s.output_port)

    a = tvtk.Actor(mapper=m)
    r = tvtk.Renderer(background=(1, 0, 0))
    r.add_actor(a)

    w = tvtk.RenderWindow(size=(300, 300))
    w.add_renderer(r)
    i = tvtk.RenderWindowInteractor(render_window=w)

    i.initialize()
    i.start()
Example #10
0
def show_window(size=(640, 480), snapshot_file='screenshot.png',
               timer_callback=None, renderer=renderer, axes=False):
    if IPC_VIS:
        # we will show window in another process. nothing to do here
        return

    # Renderer
    #renderer = tvtk.Renderer()
    #renderer.add_actor(actor)
    if axes:
        renderer.add_actor(axes_actor(1)) # add axes

    renderer.background = (1., 1., 1.)#(0.9, 0.9, 0.8)
    #renderer.background = (0.9, 0.9, 0.8)
    renderer.reset_camera()

    # Render Window
    renderWindow = tvtk.RenderWindow()
    renderWindow.add_renderer(renderer)

    # Interactor
    renderWindowInteractor = tvtk.RenderWindowInteractor()
    renderWindowInteractor.render_window = renderWindow

    def on_key_down(iren_style, key):
        rendrr = iren_style.GetCurrentRenderer()
        rendrr = tvtk.to_tvtk(rendrr)
        if key == '+':
            for act in rendrr.actors:
                act.property.point_size *= 1.1
        elif key == '-':
            for act in rendrr.actors:
                act.property.point_size /= 1.1
        elif key == 's':
            ren_win = rendrr.render_window
            w2if = tvtk.WindowToImageFilter(input=ren_win)
            w2if.update()
            writer = tvtk.PNGWriter(file_name=snapshot_file, input=w2if.output)
            writer.write()

    iren = InteractorStyleModified(key_callback=on_key_down,
                                  timer_callback=timer_callback)
    renderWindowInteractor.interactor_style = iren

    # Begin Interaction
    renderWindow.render()
    renderWindow.size = size
    #print 'Window size:', renderWindow.size
    renderWindowInteractor.create_repeating_timer(500)
    renderWindowInteractor.start()
Example #11
0
def get_render_window(options):
    ren = tvtk.Renderer(background=(0.0, 0.0, 0.0))
    rw = tvtk.RenderWindow(size=(width, height))
    rw.off_screen_rendering = 0
    rw.add_renderer(ren)
    rw.multi_samples = 0
    ac = ren.active_camera
    ac.view_angle = 44.61

    ac.position = [options.shift, -options.distance, options.height]
    ac.view_up = [0, 0, 1]
    ac.focal_point = [options.shift, 0, options.height]
    ac.pitch(options.tilt)

    return rw
Example #12
0
def test01():
    # 1. 创建数据源,设置参数,并且将参数映射给数据m
    s = tvtk.CubeSource(x_length=1.0, y_length=2.0, z_length=3.0)
    m = tvtk.PolyDataMapper(input_connection=s.output_port)
    # 2. 创建背景和行为(可以转动),并且将行为送给 背景
    a = tvtk.Actor(mapper=m)
    r = tvtk.Renderer(background=(0, 0, 0))
    r.add_actor(a)
    # 3. 创建左面窗口的大小,并且将渲染器放入窗口
    w = tvtk.RenderWindow(size=(300, 300))
    w.add_renderer(r)

    # 4. 创建交互界面,将窗口放入
    i = tvtk.RenderWindowInteractor(render_window=w)

    i.initialize()
    i.start()
Example #13
0
    def render_bitmap(self,
                      width,
                      height,
                      filename=None,
                      azimuth=15.0,
                      elevation=30.0,
                      roll=0.0,
                      zoom=1.0,
                      pan_h=0.0,
                      pan_v=0.0):
        renderer = tvtk.Renderer()
        for actor in self.scene.actor_list:
            renderer.add_actor(actor)
        renderer.background = (1, 1, 0.8)

        renderer.reset_camera()
        camera = renderer.active_camera
        camera.roll(roll)
        camera.elevation(elevation)
        camera.azimuth(azimuth)
        camera.dolly(zoom)
        camera.yaw(pan_h)
        camera.pitch(pan_v)

        renderWindow = tvtk.RenderWindow()
        renderWindow.off_screen_rendering = True
        renderWindow.add_renderer(renderer)
        renderWindow.size = (width, height)
        renderWindow.render()

        windowToImageFilter = tvtk.WindowToImageFilter()
        windowToImageFilter.input = renderWindow
        windowToImageFilter.update()

        writer = tvtk.PNGWriter()
        if filename is not None:
            writer.file_name = filename
            writer.write_to_memory = False
        else:
            writer.write_to_memory = True
        writer.input_connection = windowToImageFilter.output_port
        writer.write()
        #data = numpy.asarray(writer.result).tostring()
        return writer.result
Example #14
0
def test_source():

    # 创建一个长方体数据源,并且同时设置其长宽高
    s = tvtk.CubeSource(x_length=1.0, y_length=2.0, z_length=3.0)
    # 使用PolyDataMapper将数据转换为图形数据
    m = tvtk.PolyDataMapper(input_connection=s.output_port)
    # 创建一个Actor
    a = tvtk.Actor(mapper=m)
    # 创建一个Renderer,将Actor添加进去
    r = tvtk.Renderer(background=(0, 0, 0))
    r.add_actor(a)
    # 创建一个RenderWindow(窗口),将Renderer添加进去
    w = tvtk.RenderWindow(size=(300, 300))
    w.add_renderer(r)
    # 创建一个RenderWindowInteractor(窗口的交互工具)
    i = tvtk.RenderWindowInteractor(render_window=w)
    # 开启交互
    i.initialize()
    i.start()
Example #15
0
def ShowACube(x, y, z, backgroundcolor=(0, 0, 0)):
    #立方体源
    s = tvtk.CubeSource(x_length=x, y_length=y, z_length=z)
    #转换源为图形数据
    m = tvtk.PolyDataMapper(input_connection=s.output_port)
    #创建Actor,并将图形数据接入
    a = tvtk.Actor(mapper=m)
    #创建渲染,并将Actor接入
    r = tvtk.Renderer(background=backgroundcolor)
    r.add_actor(a)
    #创建窗口,并将渲染接入
    w = tvtk.RenderWindow(size=(900, 900))
    w.add_renderer(r)
    #创建交互,并将窗口接入
    i = tvtk.RenderWindowInteractor(render_window=w)

    #开始运行
    i.initialize()
    i.start()
Example #16
0
    def run(self):
        # Remove the renderer from the current render window.
        self.old_rw.remove_renderer(self.ren)

        # Creates renderwindow tha should be used ONLY for
        # visualization in full screen
        full_rw = tvtk.RenderWindow(stereo_capable_window=True,
                                    full_screen=True)
        # add the current visualization
        full_rw.add_renderer(self.ren)

        # Under OS X there is no support for creating a full screen
        # window so we set the size of the window here.
        if sys.platform == 'darwin':
            full_rw.size = tuple(wx.GetDisplaySize())

        # provides a simple interactor
        style = tvtk.InteractorStyleTrackballCamera()
        self.iren = tvtk.RenderWindowInteractor(render_window=full_rw,
                                                interactor_style=style)

        # Gets parameters for stereo visualization
        if self.old_rw.stereo_render:
            full_rw.trait_set(stereo_type=self.old_rw.stereo_type,
                              stereo_render=True)

        # Starts the interactor
        self.iren.initialize()
        self.iren.render()
        self.iren.start()

        # Once the full screen window is quit this releases the
        # renderer before it is destroyed, and return it to the main
        # renderwindow.
        full_rw.remove_renderer(self.ren)
        self.old_rw.add_renderer(self.ren)
        self.old_rw.render()
        self.iren.disable()
Example #17
0
s2 = tvtk.ConeSource(center=(1, 5, 6))
# pprint(dir(s2))
print(s2)
a = 1
# a.__getattribute__()
# # a.__se
# a.__get
# 显示一个三维度对象
for item in dir(tvtk):
    if not item.endswith("Source"): continue
    try:
        s2 = tvtk.__getattribute__(item)()
        if not hasattr(s2, "output_port"):
            print(item)
            continue
        print("on:", item)
        # pprint(dir(s2.output_port))
        m = tvtk.PolyDataMapper(input_connection=s2.output_port)
        a = tvtk.Actor(mapper=m)
        # b = tvtk.Actor(mapper =  tvtk.PolyDataMapper(input_connection=s1.output_port))
        r = tvtk.Renderer(background=(0, 0, 0))
        r.add_actor(a)
        # r.add_actor(b)
        w = tvtk.RenderWindow(size=(500, 500))
        w.add_renderer(r)
        i = tvtk.RenderWindowInteractor(render_window=w)
        # i.initialize()
        i.start()
    except:
        pass
# class
Example #18
0
    def initialize(self, X, Y, initial_data=None, vmin=None, vmax=None):
        """
		Create objects to plot on
		"""
        if initial_data == None:
            initial_data = zeros(shape(X))
            if vmin == None:
                self.vmin = -1.0
            if vmax == None:
                self.vmax = 1.0
        else:
            if vmin == None:
                self.vmin = np.min(np.min(initial_data))
            if vmax == None:
                self.vmax = np.max(np.max(initial_data))
        x_min = np.min(np.min(X))
        y_min = np.min(np.min(Y))
        x_max = np.max(np.max(X))
        y_max = np.max(np.max(Y))
        x_middle = (x_min + x_max) / 2
        y_middle = (y_min + y_max) / 2
        z_middle = np.mean(np.mean(initial_data))
        L = x_max - x_min
        diffs = np.shape(X)
        x_diff = diffs[0]
        y_diff = diffs[1]
        z_diff = 1.0  #self.vmax-self.vmin

        self.tvtk = tvtk
        self.sp = tvtk.StructuredPoints(origin=(x_middle, y_middle, z_middle),
                                        dimensions=(x_diff, y_diff, 1),
                                        spacing=(2 * L / (x_diff - 1),
                                                 2 * L / (y_diff - 1), 100.0))

        self.z = np.transpose(initial_data).flatten()

        self.sp.point_data.scalars = self.z
        self.geom_filter = tvtk.ImageDataGeometryFilter(input=self.sp)
        self.warp = tvtk.WarpScalar(input=self.geom_filter.output)
        self.normals = tvtk.PolyDataNormals(input=self.warp.output)

        # The rest of the VTK pipeline.
        self.m = tvtk.PolyDataMapper(input=self.normals.output,
                                     scalar_range=(self.vmin, self.vmax))
        p = tvtk.Property(opacity=0.5, color=(1, 1, 1), representation="s")
        self.a = tvtk.Actor(mapper=self.m, property=p)

        self.ren = tvtk.Renderer(background=(0.0, 0.0, 0.0))

        self.ren.add_actor(self.a)

        # Get a nice view.
        self.cam = self.ren.active_camera
        self.cam.azimuth(-50)
        self.cam.roll(90)

        # Create a RenderWindow, add the renderer and set its size.
        self.rw = tvtk.RenderWindow(size=(800, 800))
        self.rw.add_renderer(self.ren)

        # Create the RenderWindowInteractor
        self.rwi = tvtk.RenderWindowInteractor(render_window=self.rw)

        self.rwi.initialize()
        self.ren.reset_camera()
        self.rwi.render()
# method.  Using the output property will work fine if all you want is
# the default output.  OTOH if you want the N'th output use
# get_output(N).
m.input = cs.output  # or m.input = cs.get_output()

# Create the actor and set its mapper.
a = tvtk.Actor()
a.mapper = m

# Create a Renderer, add the actor and set its background color.
ren = tvtk.Renderer()
ren.add_actor(a)
ren.background = (0.1, 0.2, 0.4)

# Create a RenderWindow, add the renderer and set its size.
rw = tvtk.RenderWindow()
rw.add_renderer(ren)
rw.size = (300, 300)

# Create the RenderWindowInteractor
rwi = tvtk.RenderWindowInteractor()
rwi.render_window = rw

# Setup a box widget.
bw = tvtk.BoxWidget()
bw.interactor = rwi
bw.place_factor = 1.25
bw.prop3d = a
bw.place_widget()

Example #20
0
        p1 = seg.origin
        p2 = p1 + seg.MAX_RAY_LENGTH * seg.direction
        i = self.intersect_with_line(p1, p2)
        if i is None:
            return None
        i = numpy.array(i)
        dist = numpy.sqrt(((i - p1)**2).sum())
        return dist, i, 0, self


if __name__ == "__main__":
    oap = OffAxisParabloid()

    mapper = tvtk.PolyDataMapper(input=oap.pipeline.output)
    actor = tvtk.Actor(mapper=mapper)
    ren = tvtk.Renderer()
    ren.add_actor(actor)

    ax = tvtk.Axes(origin=(0, 0, 0))
    axes_map = tvtk.PolyDataMapper(input=ax.output)
    axes_act = tvtk.Actor(mapper=axes_map)
    ren.add_actor(axes_act)

    ren.background = (0.7, 0.6, 0.5)

    renwin = tvtk.RenderWindow()
    renwin.add_renderer(ren)

    iren = tvtk.RenderWindowInteractor(render_window=renwin)
    iren.start()
Example #21
0
s = tvtk.CubeSource(x_length=1.0, y_length=2.0, z_length=3.0)
 
print("s= \n",s)
 
# 将三维数据源映射为二维图形显示
m = tvtk.PolyDataMapper(input_connection = s.output_port)
print("m=\n",m)
 
# 创建一个显示实体
a = tvtk.Actor(mapper=m)
print("a= \n",a)
# 创建一个渲染器
r = tvtk.Renderer(background=(0,0,0))
print("r= \n",r)
# 添加显示实体
r.add_actor(a)
 
# 创建一个显示窗口
w = tvtk.RenderWindow(size=(300,300),position=(300,300))
print("w= \n",w)
# 添加渲染器
w.add_renderer(r)
 
# 创建一个交互器
i = tvtk.RenderWindowInteractor(render_window=w)
print("i= \n",i)
 
# 初始化交互器
i.initialize()
# 启动
i.start()
Example #22
0
    else:
        raise ValueError("ary must be 3 dimensional.")

    return img


sz = (256, 256, 3)
array_3d = zeros(sz, uint8)
img = image_from_array(array_3d)

t = tvtk.Texture(interpolate=1)
configure_input_data(t, img)
a.texture = t

# Renderwindow stuff and add actor.
rw = tvtk.RenderWindow(size=(600, 600))
ren = tvtk.Renderer(background=(0.1, 0.2, 0.4))
rw.add_renderer(ren)
rwi = tvtk.RenderWindowInteractor(render_window=rw)
ren.add_actor(a)
rwi.initialize()

# create a little wave to slide across the image.
wave = 1 / sqrt(2 * pi) * exp(-arange(-2, 2, .05)**2 / 2) * 255
# have to use += here because = doesn't respect broadcasting correctly.
array_3d[:len(wave)] += wave.astype(uint8)[:, None, None]

import time
t1 = time.time()
N = 256
for i in range(N):
Example #23
0
from tvtk.api import tvtk
#创建一个长方体数据源,并且同时设置其长宽高
s = tvtk.CubeSource(x_length=1.0,y_length=2.0,z_length=3.0)
#使用PolyDataMapepr将数据转化为图形数据
m = tvtk.PolyDataMapper(input_connection=s.output_port)
#以上为可视化管线
#================
#以下为图行管线
#创建一个Actor
a = tvtk.Actor(mapper=m)
#创建一个Renderer,并对图像背景设置一种颜色,将Actor添加进去。
r = tvtk.Renderer(background=(0,0,0))
r.add_actor(a)
#创建一个RenderWindow(窗口),将Renderer添加进去
w = tvtk.RenderWindow(size=(350,350))
w.add_renderer(r)
#创建一个RenderWindowInteractor(窗口交互工具)
i = tvtk.RenderWindowInteractor(render_window=w)
#================
#开启交互
i.initialize()
i.start()
Example #24
0
from numpy import array

### DATA
data = array([[0, 0, 0, 10], [1, 0, 0, 20], [0, 1, 0, 20], [0, 0, 1, 30]], 'f')

triangles = array([[0, 1, 3], [0, 3, 2], [1, 2, 3], [0, 2, 1]])

points = data[:, :3]
temperature = data[:, -1]

### TVTK PIPELINE
# create a renderer
renderer = tvtk.Renderer()

# create a render window and hand it the renderer
render_window = tvtk.RenderWindow(size=(400, 400))
render_window.add_renderer(renderer)

# create interactor and hand it the render window
# This handles mouse interaction with window.
interactor = tvtk.RenderWindowInteractor(render_window=render_window)

# Create a mesh from the data created above.
mesh = tvtk.PolyData(points=points, polys=triangles)
mesh.point_data.scalars = temperature

# Set the mapper to scale temperature range
# across the entire range of colors
mapper = tvtk.PolyDataMapper()
configure_input_data(mapper, mesh)
mapper.scalar_range = min(temperature), max(temperature)
# -*- coding: utf-8 -*-
from tvtk.api import tvtk

# 创建一个圆锥数据源,并且同时设置其高度,底面半径和底面圆的分辨率(用36边形近似)
cs = tvtk.ConeSource(height=3.0, radius=1.0, resolution=36)
# 使用PolyDataMapper将数据转换为图形数据
m = tvtk.PolyDataMapper(input_connection=cs.output_port)
# 创建一个Actor
a = tvtk.Actor(mapper=m)
# 创建一个Renderer,将Actor添加进去
ren = tvtk.Renderer(background=(1, 1, 1))
ren.add_actor(a)
# 创建一个RenderWindow(窗口),将Renderer添加进去
rw = tvtk.RenderWindow(size=(300, 300))
rw.add_renderer(ren)
# 创建一个RenderWindowInteractor(窗口的交互工具)
rwi = tvtk.RenderWindowInteractor(render_window=rw)
# 开启交互
rwi.initialize()
rwi.start()
Example #26
0
    def ipython_view(self, width, height, view={}):
        import ipywidgets as widgets
        from IPython.display import Image, display, clear_output

        renderer = tvtk.Renderer()
        for actor in self.scene.actor_list:
            renderer.add_actor(actor)
        renderer.background = (1, 1, 0.8)
        #
        renderer.reset_camera()
        camera = renderer.active_camera
        if "position" in view:
            camera.position = view['position']
        if "focal_point" in view:
            camera.focal_point = view['focal_point']
        if "view_up" in view:
            camera.view_up = view['view_up']
#
        renderWindow = tvtk.RenderWindow()
        renderWindow.off_screen_rendering = True
        renderWindow.add_renderer(renderer)
        renderWindow.size = (width, height)
        renderWindow.render()

        windowToImageFilter = tvtk.WindowToImageFilter()
        windowToImageFilter.input = renderWindow
        windowToImageFilter.update()
        #
        filename = "/dev/shm/temp_vtk_put.png"
        writer = tvtk.PNGWriter()
        writer.file_name = filename
        writer.write_to_memory = False
        writer.input_connection = windowToImageFilter.output_port
        writer.write()

        view_out = {}

        def show():
            clear_output(wait=True)
            renderer.reset_camera_clipping_range()
            renderer.modified()
            renderWindow.render()
            windowToImageFilter.input = renderWindow
            windowToImageFilter.modified()
            windowToImageFilter.update()
            writer.write()
            view_out.update({
                "position": tuple(camera.position),
                "view_up": tuple(camera.view_up),
                "focal_point": tuple(camera.focal_point)
            })
            return display(Image(filename), grp)

        def r_up(arg):
            camera.orthogonalize_view_up()
            camera.elevation(10)
            return show()

        def r_down(arg):
            camera.orthogonalize_view_up()
            camera.elevation(-10)
            return show()

        def r_left(arg):
            camera.orthogonalize_view_up()
            camera.azimuth(10)
            return show()

        def r_right(arg):
            camera.orthogonalize_view_up()
            camera.azimuth(-10)
            return show()

        def pan_left(arg):
            camera.orthogonalize_view_up()
            camera.yaw(-2)
            return show()

        def pan_right(arg):
            camera.orthogonalize_view_up()
            camera.yaw(2)
            return show()

        def pan_up(arg):
            camera.orthogonalize_view_up()
            camera.pitch(-2)
            return show()

        def pan_down(arg):
            camera.orthogonalize_view_up()
            camera.pitch(2)
            return show()

        def roll_left(arg):
            camera.roll(10)
            return show()

        def roll_right(arg):
            camera.roll(-10)
            return show()

        def zoom_in(arg):
            camera.dolly(1.2)
            return show()

        def zoom_out(arg):
            camera.dolly(0.8)
            return show()

        b1 = widgets.Button(description='\u2191')
        b1.on_click(r_up)
        b2 = widgets.Button(description='\u2193')
        b2.on_click(r_down)
        b3 = widgets.Button(description='\u2190')
        b3.on_click(r_left)
        b4 = widgets.Button(description='\u2192')
        b4.on_click(r_right)
        b5 = widgets.Button(description='\u21ba')
        b5.on_click(roll_left)
        b6 = widgets.Button(description='\u21bb')
        b6.on_click(roll_right)

        b7 = widgets.Button(description='+')
        b7.on_click(zoom_in)
        b8 = widgets.Button(description='-')
        b8.on_click(zoom_out)
        b9 = widgets.Button(description='\u2190')
        b9.on_click(pan_left)
        b10 = widgets.Button(description='\u2192')
        b10.on_click(pan_right)
        b11 = widgets.Button(description='\u2191')
        b11.on_click(pan_up)
        b12 = widgets.Button(description='\u2193')
        b12.on_click(pan_down)

        grp1 = widgets.HBox(border_style="solid",
                            border_width=1,
                            border_radius=5,
                            padding=2,
                            margin=1)
        grp1.children = [b1, b2, b3, b4, b5, b6]

        grp2 = widgets.HBox(border_style="solid",
                            border_width=1,
                            border_radius=5,
                            padding=2,
                            margin=1)
        grp2.children = [b7, b8, b9, b10, b11, b12]

        grp = widgets.HBox(children=[grp1, grp2])

        show()
        return view_out