How to use the fury.ui.LineSlider2D 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 / tutorials / 02_ui / viz_ui_slider.py View on Github external
ring_slider = ui.RingSlider2D(center=(630, 400), initial_value=0,
                              text_template="{angle:5.1f}°")

hor_line_slider_text_top = ui.LineSlider2D(center=(400, 230), initial_value=0,
                                           orientation='horizontal',
                                           min_value=-10, max_value=10,
                                           text_alignment='top')

hor_line_slider_text_bottom = ui.LineSlider2D(center=(400, 200),
                                              initial_value=0,
                                              orientation='horizontal',
                                              min_value=-10, max_value=10,
                                              text_alignment='bottom')

ver_line_slider_text_left = ui.LineSlider2D(center=(100, 400), initial_value=0,
                                            orientation='vertical',
                                            min_value=-10, max_value=10,
                                            text_alignment='left')

ver_line_slider_text_right = ui.LineSlider2D(center=(150, 400),
                                             initial_value=0,
                                             orientation='vertical',
                                             min_value=-10, max_value=10,
                                             text_alignment='right')


###############################################################################
# We can use a callback to rotate the cube with the ring slider.

def rotate_cube(slider):
    angle = slider.value
github fury-gl / fury / fury / ui.py View on Github external
"""
        self.range_slider = \
            LineDoubleSlider2D(line_width=self.line_width,
                               inner_radius=self.inner_radius,
                               outer_radius=self.outer_radius,
                               handle_side=self.handle_side,
                               center=self.range_slider_center,
                               length=self.length, min_value=self.min_value,
                               max_value=self.max_value,
                               initial_values=(self.min_value,
                                               self.max_value),
                               font_size=self.font_size, shape=self.shape,
                               text_template=self.range_slider_text_template)

        self.value_slider = \
            LineSlider2D(line_width=self.line_width, length=self.length,
                         inner_radius=self.inner_radius,
                         outer_radius=self.outer_radius,
                         handle_side=self.handle_side,
                         center=self.value_slider_center,
                         min_value=self.min_value, max_value=self.max_value,
                         initial_value=(self.min_value + self.max_value) / 2,
                         font_size=self.font_size, shape=self.shape,
                         text_template=self.value_slider_text_template)

        # Add default events listener for this UI component.
        self.range_slider.handles[0].on_left_mouse_button_dragged = \
            self.range_slider_handle_move_callback
        self.range_slider.handles[1].on_left_mouse_button_dragged = \
            self.range_slider_handle_move_callback
github fury-gl / fury / docs / examples / viz_advanced.py View on Github external
# object which allows accessing the pipeline in different areas. Here is how:

show_m = window.ShowManager(scene, size=(1200, 900))
show_m.initialize()

###############################################################################
# After we have initialized the ``ShowManager`` we can go ahead and create
# sliders to move the slices and change their opacity.

line_slider_z = ui.LineSlider2D(min_value=0,
                                max_value=shape[2] - 1,
                                initial_value=shape[2] / 2,
                                text_template="{value:.0f}",
                                length=140)

line_slider_x = ui.LineSlider2D(min_value=0,
                                max_value=shape[0] - 1,
                                initial_value=shape[0] / 2,
                                text_template="{value:.0f}",
                                length=140)

line_slider_y = ui.LineSlider2D(min_value=0,
                                max_value=shape[1] - 1,
                                initial_value=shape[1] / 2,
                                text_template="{value:.0f}",
                                length=140)

opacity_slider = ui.LineSlider2D(min_value=0.0,
                                 max_value=1.0,
                                 initial_value=slicer_opacity,
                                 length=140)
github fury-gl / fury / docs / examples / viz_advanced.py View on Github external
text_template="{value:.0f}",
                                length=140)

line_slider_x = ui.LineSlider2D(min_value=0,
                                max_value=shape[0] - 1,
                                initial_value=shape[0] / 2,
                                text_template="{value:.0f}",
                                length=140)

line_slider_y = ui.LineSlider2D(min_value=0,
                                max_value=shape[1] - 1,
                                initial_value=shape[1] / 2,
                                text_template="{value:.0f}",
                                length=140)

opacity_slider = ui.LineSlider2D(min_value=0.0,
                                 max_value=1.0,
                                 initial_value=slicer_opacity,
                                 length=140)

###############################################################################
# Now we will write callbacks for the sliders and register them.


def change_slice_z(slider):
    z = int(np.round(slider.value))
    image_actor_z.display_extent(0, shape[0] - 1, 0, shape[1] - 1, z, z)


def change_slice_x(slider):
    x = int(np.round(slider.value))
    image_actor_x.display_extent(x, x, 0, shape[1] - 1, 0, shape[2] - 1)
github fury-gl / fury / docs / tutorials / 03_advanced_ui / viz_ui.py View on Github external
return cube_actor


cube = cube_maker(color=(0, 0, 1), size=(20, 20, 20), center=(15, 5, 0))

###############################################################################
# Now we'll add three sliders: one circular and two linear.

ring_slider = ui.RingSlider2D(center=(740, 400), initial_value=0,
                              text_template="{angle:5.1f}°")

line_slider_x = ui.LineSlider2D(center=(500, 250), initial_value=0,
                                min_value=-10, max_value=10,
                                orientation="horizontal")

line_slider_y = ui.LineSlider2D(center=(650, 350), initial_value=0,
                                min_value=-10, max_value=10,
                                orientation="vertical")

###############################################################################
# We can use a callback to rotate the cube with the ring slider.


def rotate_cube(slider):
    angle = slider.value
    previous_angle = slider.previous_value
    rotation_angle = angle - previous_angle
    cube.RotateX(rotation_angle)


ring_slider.on_change = rotate_cube
github fury-gl / fury / docs / examples / viz_advanced.py View on Github external
###############################################################################
# Now we would like to change the position of each ``image_actor`` using a
# slider. The sliders are widgets which require access to different areas of
# the visualization pipeline and therefore we don't recommend using them with
# ``show``. The more appropriate way is to use them with the ``ShowManager``
# object which allows accessing the pipeline in different areas. Here is how:

show_m = window.ShowManager(scene, size=(1200, 900))
show_m.initialize()

###############################################################################
# After we have initialized the ``ShowManager`` we can go ahead and create
# sliders to move the slices and change their opacity.

line_slider_z = ui.LineSlider2D(min_value=0,
                                max_value=shape[2] - 1,
                                initial_value=shape[2] / 2,
                                text_template="{value:.0f}",
                                length=140)

line_slider_x = ui.LineSlider2D(min_value=0,
                                max_value=shape[0] - 1,
                                initial_value=shape[0] / 2,
                                text_template="{value:.0f}",
                                length=140)

line_slider_y = ui.LineSlider2D(min_value=0,
                                max_value=shape[1] - 1,
                                initial_value=shape[1] / 2,
                                text_template="{value:.0f}",
                                length=140)
github fury-gl / fury / docs / tutorials / 02_ui / viz_ui_slider.py View on Github external
cube = cube_maker(color=(0, 0, 1), size=(20, 20, 20), center=(15, 0, 0))

###############################################################################
# Now we'll add five sliders: 1 circular and 4 linear sliders.
# By default the alignments are 'bottom' for horizontal and 'top' for vertical.

ring_slider = ui.RingSlider2D(center=(630, 400), initial_value=0,
                              text_template="{angle:5.1f}°")

hor_line_slider_text_top = ui.LineSlider2D(center=(400, 230), initial_value=0,
                                           orientation='horizontal',
                                           min_value=-10, max_value=10,
                                           text_alignment='top')

hor_line_slider_text_bottom = ui.LineSlider2D(center=(400, 200),
                                              initial_value=0,
                                              orientation='horizontal',
                                              min_value=-10, max_value=10,
                                              text_alignment='bottom')

ver_line_slider_text_left = ui.LineSlider2D(center=(100, 400), initial_value=0,
                                            orientation='vertical',
                                            min_value=-10, max_value=10,
                                            text_alignment='left')

ver_line_slider_text_right = ui.LineSlider2D(center=(150, 400),
                                             initial_value=0,
                                             orientation='vertical',
                                             min_value=-10, max_value=10,
                                             text_alignment='right')
github fury-gl / fury / docs / tutorials / 03_advanced_ui / viz_ui.py View on Github external
cube_actor = window.vtk.vtkActor()
    cube_actor.SetMapper(cube_mapper)
    if color is not None:
        cube_actor.GetProperty().SetColor(color)
    return cube_actor


cube = cube_maker(color=(0, 0, 1), size=(20, 20, 20), center=(15, 5, 0))

###############################################################################
# Now we'll add three sliders: one circular and two linear.

ring_slider = ui.RingSlider2D(center=(740, 400), initial_value=0,
                              text_template="{angle:5.1f}°")

line_slider_x = ui.LineSlider2D(center=(500, 250), initial_value=0,
                                min_value=-10, max_value=10,
                                orientation="horizontal")

line_slider_y = ui.LineSlider2D(center=(650, 350), initial_value=0,
                                min_value=-10, max_value=10,
                                orientation="vertical")

###############################################################################
# We can use a callback to rotate the cube with the ring slider.


def rotate_cube(slider):
    angle = slider.value
    previous_angle = slider.previous_value
    rotation_angle = angle - previous_angle
    cube.RotateX(rotation_angle)