How to use the fury.window.vtk function in fury

To help you get started, we’ve selected a few fury examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fury-gl / fury / docs / experimental / viz_shader_canvas_sk.py View on Github external
showm.render()
    # scene.azimuth(10)


@window.vtk.calldata_type(window.vtk.VTK_OBJECT)
def vtk_shader_callback(caller, event, calldata=None):
    program = calldata
    global timer
    if program is not None:
        try:
            program.SetUniformf("time", timer)
        except ValueError:
            pass


mapper.AddObserver(window.vtk.vtkCommand.UpdateShaderEvent,
                   vtk_shader_callback)

mapper.AddShaderReplacement(
    vtk.vtkShader.Vertex,
    "//VTK::Normal::Dec",
    True,
    """
    //VTK::Normal::Dec
    out vec4 myVertexMC;
    in vec3 my_centers[3]; // now declare our attribute
    out vec3 my_centers_out[3];
    """,
    False
)

mapper.AddShaderReplacement(
github fury-gl / fury / docs / experimental / viz_shader_sines_1.py View on Github external
showm.render()
    # scene.azimuth(10)


@window.vtk.calldata_type(window.vtk.VTK_OBJECT)
def vtk_shader_callback(caller, event, calldata=None):
    program = calldata
    global timer
    if program is not None:
        try:
            program.SetUniformf("time", timer)
        except ValueError:
            pass


mapper.AddObserver(window.vtk.vtkCommand.UpdateShaderEvent,
                   vtk_shader_callback)

mapper.AddShaderReplacement(
    vtk.vtkShader.Fragment,  # // in the fragment shader
    "//VTK::Light::Impl",  # // replace the light block
    False,  # // after the standard replacements
    """
    //VTK::Light::Impl  // we still want the default calc
    vec3 rColor = vec3(.9, .0, .3);
    vec3 gColor = vec3(.0, .9, .3);
    vec3 bColor = vec3(.0, .3, .9);
    vec3 yColor = vec3(.9, .9, .3);

    float yScale = .5;  // 1 / 2. Original
    float xScale = 2.5;  // 5. Original
    float shiftScale = .2;  // .2 Original
github fury-gl / fury / docs / experimental / viz_multisdf.py View on Github external
global timer
    timer += 1.0
    showm.render()


@window.vtk.calldata_type(window.vtk.VTK_OBJECT)
def vtk_shader_callback(caller, event, calldata=None):
    program = calldata
    global timer
    if program is not None:
        try:
            program.SetUniformf("time", timer)
        except ValueError:
            pass

mapper.AddObserver(window.vtk.vtkCommand.UpdateShaderEvent,
                   vtk_shader_callback)

showm = window.ShowManager(scene, reset_camera=False)

showm.initialize()
showm.add_timer_callback(True, 10, timer_callback)


scene.add(sdfactor)
scene.add(actor.axes())

showm.start()
github fury-gl / fury / docs / tutorials / 04_shaders / viz_shader.py View on Github external
###############################################################################
# Let's add a textblock to the scene with a custom message

tb = ui.TextBlock2D()
tb.message = "Hello Shaders"

###############################################################################
# Change the property of the actor

utah.GetProperty().SetOpacity(0.5)

###############################################################################
# Invoke callbacks to any VTK object

mapper.AddObserver(window.vtk.vtkCommand.UpdateShaderEvent,
                   vtk_shader_callback)


###############################################################################
# Show Manager
#
# Now that all the elements have been initialised, we add them to the show
# manager.

current_size = (1024, 720)
showm = window.ShowManager(scene, size=current_size, reset_camera=False)

showm.initialize()
showm.add_timer_callback(True, 30, timer_callback)

scene.add(utah)
github fury-gl / fury / docs / tutorials / 03_advanced_ui / viz_ui.py View on Github external
def cube_maker(color=(1, 1, 1), size=(0.2, 0.2, 0.2), center=(0, 0, 0)):
    cube = window.vtk.vtkCubeSource()
    cube.SetXLength(size[0])
    cube.SetYLength(size[1])
    cube.SetZLength(size[2])
    if center is not None:
        cube.SetCenter(*center)
    cube_mapper = window.vtk.vtkPolyDataMapper()
    cube_mapper.SetInputConnection(cube.GetOutputPort())
    cube_actor = window.vtk.vtkActor()
    cube_actor.SetMapper(cube_mapper)
    if color is not None:
        cube_actor.GetProperty().SetColor(color)
    return cube_actor
github fury-gl / fury / docs / tutorials / 03_advanced_ui / viz_ui.py View on Github external
def cube_maker(color=(1, 1, 1), size=(0.2, 0.2, 0.2), center=(0, 0, 0)):
    cube = window.vtk.vtkCubeSource()
    cube.SetXLength(size[0])
    cube.SetYLength(size[1])
    cube.SetZLength(size[2])
    if center is not None:
        cube.SetCenter(*center)
    cube_mapper = window.vtk.vtkPolyDataMapper()
    cube_mapper.SetInputConnection(cube.GetOutputPort())
    cube_actor = window.vtk.vtkActor()
    cube_actor.SetMapper(cube_mapper)
    if color is not None:
        cube_actor.GetProperty().SetColor(color)
    return cube_actor