ui
#
|
A 2D overlay button and is of type vtkTexturedActor2D. |
|
A 2D set of :class:'Option' objects. |
|
UI element to create drop-down menus. |
|
A 2D disk UI component. |
|
The main Canvas(Panel2D) on which everything would be drawn. |
|
Create and Manage 2D Shapes. |
|
A menu to select files in the current folder. |
|
Add actors in a grid and interact with them individually. |
|
A 2D container to hold an image. |
|
A 2D Line Slider with two sliding rings. |
|
A 2D Line Slider. |
|
UI component that allows the user to select items from a list. |
|
The text displayed in a listbox. |
|
A set of a Button2D and a TextBlock2D to act as a single option for checkboxes and radio buttons. |
|
A 2D UI Panel. |
|
A playback controller that can do essential functionalities. |
|
A 2D set of :class:'Option' objects. |
|
A set of a LineSlider2D and a LineDoubleSlider2D. |
|
A 2D rectangle sub-classed from UI. |
|
A disk slider. |
|
Render content within a Tab. |
|
UI element to add multiple panels within a single window. |
|
Wrap over the default vtkTextActor and helps setting the text. |
|
An editable 2D text box that behaves as a UI component. |
Module: ui.containers
#
UI container module.
alias of |
|
alias of |
|
|
Add actors in a grid and interact with them individually. |
|
A 2D container to hold an image. |
|
A 2D UI Panel. |
alias of |
|
alias of |
|
alias of |
|
alias of |
|
|
A 2D rectangle sub-classed from UI. |
|
Render content within a Tab. |
|
UI element to add multiple panels within a single window. |
|
Wrap over the default vtkTextActor and helps setting the text. |
alias of |
|
alias of |
|
|
An umbrella class for all UI elements. |
|
Creates a grid of actors that lies in the xy-plane. |
|
Load an image. |
|
Rotate actor around axis by angle. |
|
Set Generic input function which takes into account VTK 5 or 6. |
Module: ui.core
#
UI core module that describe UI abstract class.
alias of |
|
|
A 2D overlay button and is of type vtkTexturedActor2D. |
alias of |
|
Manipulate the camera and interact with objects in the scene. |
|
|
A 2D disk UI component. |
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
|
A 2D rectangle sub-classed from UI. |
alias of |
|
|
Wrap over the default vtkTextActor and helps setting the text. |
alias of |
|
alias of |
|
|
An umbrella class for all UI elements. |
|
Load an image. |
|
Set Generic input function which takes into account VTK 5 or 6. |
|
Issue a warning, or maybe ignore it or raise an exception. |
Module: ui.elements
#
UI components module.
|
A 2D overlay button and is of type vtkTexturedActor2D. |
|
A 2D set of :class:'Option' objects. |
|
UI element to create drop-down menus. |
alias of |
|
|
A 2D disk UI component. |
|
The main Canvas(Panel2D) on which everything would be drawn. |
|
Create and Manage 2D Shapes. |
|
A menu to select files in the current folder. |
|
A 2D Line Slider with two sliding rings. |
|
A 2D Line Slider. |
|
UI component that allows the user to select items from a list. |
|
The text displayed in a listbox. |
|
All numbers inherit from this class. |
|
A set of a Button2D and a TextBlock2D to act as a single option for checkboxes and radio buttons. |
Dictionary that remembers insertion order |
|
|
A 2D UI Panel. |
|
A playback controller that can do essential functionalities. |
|
A 2D set of :class:'Option' objects. |
|
A set of a LineSlider2D and a LineDoubleSlider2D. |
|
A 2D rectangle sub-classed from UI. |
|
A disk slider. |
|
Wrap over the default vtkTextActor and helps setting the text. |
|
An editable 2D text box that behaves as a UI component. |
|
An umbrella class for all UI elements. |
|
Calculate the min, max position and the size of the bounding box. |
|
Clips overflowing text of TextBlock2D with respect to width. :param textblock: The textblock object whose text needs to be clipped. :type textblock: TextBlock2D :param width: Required width of the clipped text. :type width: int :param side: Clips the overflowing text according to side. It takes values "left" or "right". :type side: str, optional. |
|
Read specific icon from specific style. |
|
Rotate the given vertices by an angle. |
|
Set polydata vertices with a numpy array (ndarrays Nx3 int). |
|
Update actor. |
|
Access to vertices from actor. |
Module: ui.helpers
#
Helper variable or function for UI Elements.
|
Calculate the min, max position and the size of the bounding box. |
|
Checks if the text is overflowing. |
|
Clips overflowing text of TextBlock2D with respect to width. :param textblock: The textblock object whose text needs to be clipped. :type textblock: TextBlock2D :param width: Required width of the clipped text. :type width: int :param side: Clips the overflowing text according to side. It takes values "left" or "right". :type side: str, optional. |
|
Rotate the given vertices by an angle. |
|
Wraps overflowing text of TextBlock2D with respect to width. :param textblock: The textblock object whose text needs to be wrapped. :type textblock: TextBlock2D :param wrap_width: Required width of the wrapped text. :type wrap_width: int :param side: Clips the overflowing text according to side. It takes values "left" or "right". :type side: str, optional. |
Checkbox
#
- class fury.ui.Checkbox(labels, checked_labels=(), padding=1, font_size=18, font_family='Arial', position=(0, 0))[source]#
Bases:
UI
A 2D set of :class:’Option’ objects. Multiple options can be selected.
- __init__(labels, checked_labels=(), padding=1, font_size=18, font_family='Arial', position=(0, 0))[source]#
Init this class instance.
- Parameters:
checked_labels (list(str), optional) – List of labels that are checked on setting up.
padding (float, optional) – The distance between two adjacent options
font_size (int, optional) – Size of the text font.
font_family (str, optional) – Currently only supports Arial.
position ((float, float), optional) – Absolute coordinates (x, y) of the lower-left corner of the button of the first option.
- property font_size#
Gets the font size of text.
- property padding#
Get the padding between options.
ComboBox2D
#
- class fury.ui.ComboBox2D(items=[], position=(0, 0), size=(300, 200), placeholder='Choose selection...', draggable=True, selection_text_color=(0, 0, 0), selection_bg_color=(1, 1, 1), menu_text_color=(0.2, 0.2, 0.2), selected_color=(0.9, 0.6, 0.6), unselected_color=(0.6, 0.6, 0.6), scroll_bar_active_color=(0.6, 0.2, 0.2), scroll_bar_inactive_color=(0.9, 0.0, 0.0), menu_opacity=1.0, reverse_scrolling=False, font_size=20, line_spacing=1.4)[source]#
Bases:
UI
UI element to create drop-down menus.
- selection_box#
Display selection and placeholder text.
- Type:
- class:
‘TextBox2D’
- drop_down_button#
Button to show or hide menu.
- Type:
- class:
‘Button2D’
Container for item list.
- Type:
- class:
‘ListBox2D’
- __init__(items=[], position=(0, 0), size=(300, 200), placeholder='Choose selection...', draggable=True, selection_text_color=(0, 0, 0), selection_bg_color=(1, 1, 1), menu_text_color=(0.2, 0.2, 0.2), selected_color=(0.9, 0.6, 0.6), unselected_color=(0.6, 0.6, 0.6), scroll_bar_active_color=(0.6, 0.2, 0.2), scroll_bar_inactive_color=(0.9, 0.0, 0.0), menu_opacity=1.0, reverse_scrolling=False, font_size=20, line_spacing=1.4)[source]#
Init class Instance.
- Parameters:
items (list(string)) – List of items to be displayed as choices.
position ((float, float)) – Absolute coordinates (x, y) of the lower-left corner of this UI component.
size ((int, int)) – Width and height in pixels of this UI component.
placeholder (str) – Holds the default text to be displayed.
draggable ({True, False}) – Whether the UI element is draggable or not.
selection_text_color (tuple of 3 floats) – Color of the selected text to be displayed.
selection_bg_color (tuple of 3 floats) – Background color of the selection text.
menu_text_color (tuple of 3 floats.) – Color of the options displayed in drop down menu.
selected_color (tuple of 3 floats.) – Background color of the selected option in drop down menu.
unselected_color (tuple of 3 floats.) – Background color of the unselected option in drop down menu.
scroll_bar_active_color (tuple of 3 floats.) – Color of the scrollbar when in active use.
scroll_bar_inactive_color (tuple of 3 floats.) – Color of the scrollbar when inactive.
reverse_scrolling ({True, False}) – If True, scrolling up will move the list of files down.
font_size (int) – The font size of selected text in pixels.
line_spacing (float) – Distance between drop down menu’s items in pixels.
Toggle visibility of drop down menu list.
- Parameters:
i_ren (
CustomInteractorStyle
) –vtkactor (
vtkActor
) – The picked actorcombobox (
ComboBox2D
) –
- select_option_callback(i_ren, _obj, listboxitem)[source]#
Select the appropriate option
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actorlistboxitem (
ListBoxItem2D
) –
- property selected_text#
- property selected_text_index#
Disk2D
#
- class fury.ui.Disk2D(outer_radius, inner_radius=0, center=(0, 0), color=(1, 1, 1), opacity=1.0)[source]#
Bases:
UI
A 2D disk UI component.
- __init__(outer_radius, inner_radius=0, center=(0, 0), color=(1, 1, 1), opacity=1.0)[source]#
Initialize a 2D Disk.
- Parameters:
outer_radius (int) – Outer radius of the disk.
inner_radius (int, optional) – Inner radius of the disk. A value > 0, makes a ring.
center ((float, float), optional) – Coordinates (x, y) of the center of the disk.
color ((float, float, float), optional) – Must take values in [0, 1].
opacity (float, optional) – Must take values in [0, 1].
- property color#
Get the color of this UI component.
- property inner_radius#
- property opacity#
Get the opacity of this UI component.
- property outer_radius#
DrawPanel
#
- class fury.ui.DrawPanel(size=(400, 400), position=(0, 0), is_draggable=False)[source]#
Bases:
UI
The main Canvas(Panel2D) on which everything would be drawn.
- cal_min_boundary_distance(position)[source]#
Calculate the minimum distance between the current position and canvas boundary.
- property current_mode#
DrawShape
#
- class fury.ui.DrawShape(shape_type, drawpanel=None, position=(0, 0))[source]#
Bases:
UI
Create and Manage 2D Shapes.
- property center#
- property is_selected#
- rotate(angle)[source]#
Rotate the vertices of the UI component using specific angle.
- Parameters:
angle (float) – Value by which the vertices are rotated in radian.
GridUI
#
- class fury.ui.GridUI(actors, captions=None, caption_offset=(0, -100, 0), cell_padding=0, cell_shape='rect', aspect_ratio=1.7777777777777777, dim=None, rotation_speed=1, rotation_axis=(0, 1, 0))[source]#
Bases:
UI
Add actors in a grid and interact with them individually.
- __init__(actors, captions=None, caption_offset=(0, -100, 0), cell_padding=0, cell_shape='rect', aspect_ratio=1.7777777777777777, dim=None, rotation_speed=1, rotation_axis=(0, 1, 0))[source]#
Init scene.
- ANTICLOCKWISE_ROTATION_X = array([-10, 1, 0, 0])#
- ANTICLOCKWISE_ROTATION_Y = array([-10, 0, 1, 0])#
- CLOCKWISE_ROTATION_X = array([10, 1, 0, 0])#
- CLOCKWISE_ROTATION_Y = array([10, 0, 1, 0])#
ImageContainer2D
#
- class fury.ui.ImageContainer2D(img_path, position=(0, 0), size=(100, 100))[source]#
Bases:
UI
A 2D container to hold an image.
Currently Supports: - png and jpg/jpeg images
- img#
The image loaded from the specified path.
- Type:
ImageData
LineDoubleSlider2D
#
- class fury.ui.LineDoubleSlider2D(line_width=5, inner_radius=0, outer_radius=10, handle_side=20, center=(450, 300), length=200, initial_values=(0, 100), min_value=0, max_value=100, font_size=16, text_template='{value:.1f}', orientation='horizontal', shape='disk')[source]#
Bases:
UI
A 2D Line Slider with two sliding rings.
Useful for setting min and max values for something.
Currently supports: - Setting positions of both disks.
- track#
The line on which the handles move.
- Type:
vtkActor
- handles#
The moving slider disks.
- Type:
[
vtkActor
,vtkActor
]
- text#
The texts that show the values of the disks.
- Type:
- shape#
Describes the shape of the handle. Currently supports ‘disk’ and ‘square’.
- Type:
string
- __init__(line_width=5, inner_radius=0, outer_radius=10, handle_side=20, center=(450, 300), length=200, initial_values=(0, 100), min_value=0, max_value=100, font_size=16, text_template='{value:.1f}', orientation='horizontal', shape='disk')[source]#
Init this UI element.
- Parameters:
line_width (int) – Width of the line on which the disk will slide.
inner_radius (int) – Inner radius of the handles (if disk).
outer_radius (int) – Outer radius of the handles (if disk).
handle_side (int) – Side length of the handles (if sqaure).
length (int) – Length of the slider.
initial_values ((float, float)) – Initial values of the two handles.
min_value (float) – Minimum value of the slider.
max_value (float) – Maximum value of the slider.
font_size (int) – Size of the text to display alongside the slider (pt).
text_template (str, callable) – If str, text template can contain one or multiple of the replacement fields: {value:}, {ratio:}. If callable, this instance of :class:LineDoubleSlider2D will be passed as argument to the text template function.
orientation (str) – horizontal or vertical
shape (string) – Describes the shape of the handle. Currently supports ‘disk’ and ‘square’.
- property bottom_disk_ratio#
Return the ratio of the bottom disk.
- property bottom_disk_value#
Return the value of the bottom disk.
- property bottom_y_position#
- coord_to_ratio(coord)[source]#
Convert the x coordinate of a disk to the ratio.
- Parameters:
coord (float) –
- format_text(disk_number)[source]#
Return formatted text to display along the slider.
- Parameters:
disk_number (int) – Index of the disk.
- handle_move_callback(i_ren, vtkactor, _slider)[source]#
Handle movement.
- Parameters:
i_ren (
CustomInteractorStyle
) –vtkactor (
vtkActor
) – The picked actor_slider (
LineDoubleSlider2D
) –
- handle_release_callback(i_ren, vtkactor, _slider)[source]#
Change color when handle is released.
- Parameters:
i_ren (
CustomInteractorStyle
) –vtkactor (
vtkActor
) – The picked actor_slider (
LineDoubleSlider2D
) –
- property left_disk_ratio#
Return the ratio of the left disk.
- property left_disk_value#
Return the value of the left disk.
- property left_x_position#
- ratio_to_coord(ratio)[source]#
Convert the ratio to the absolute coordinate.
- Parameters:
ratio (float) –
- ratio_to_value(ratio)[source]#
Convert the ratio to the value of the disk.
- Parameters:
ratio (float) –
- property right_disk_ratio#
Return the ratio of the right disk.
- property right_disk_value#
Return the value of the right disk.
- property right_x_position#
- property top_disk_ratio#
Return the ratio of the top disk.
- property top_disk_value#
Return the value of the top disk.
- property top_y_position#
LineSlider2D
#
- class fury.ui.LineSlider2D(center=(0, 0), initial_value=50, min_value=0, max_value=100, length=200, line_width=5, inner_radius=0, outer_radius=10, handle_side=20, font_size=16, orientation='horizontal', text_alignment='', text_template='{value:.1f} ({ratio:.0%})', shape='disk')[source]#
Bases:
UI
A 2D Line Slider.
A sliding handle on a line with a percentage indicator.
- track#
The line on which the slider’s handle moves.
- Type:
- text#
The text that shows percentage.
- Type:
- shape#
Describes the shape of the handle. Currently supports ‘disk’ and ‘square’.
- Type:
string
- __init__(center=(0, 0), initial_value=50, min_value=0, max_value=100, length=200, line_width=5, inner_radius=0, outer_radius=10, handle_side=20, font_size=16, orientation='horizontal', text_alignment='', text_template='{value:.1f} ({ratio:.0%})', shape='disk')[source]#
Init this UI element.
- Parameters:
initial_value (float) – Initial value of the slider.
min_value (float) – Minimum value of the slider.
max_value (float) – Maximum value of the slider.
length (int) – Length of the slider.
line_width (int) – Width of the line on which the disk will slide.
inner_radius (int) – Inner radius of the handles (if disk).
outer_radius (int) – Outer radius of the handles (if disk).
handle_side (int) – Side length of the handles (if sqaure).
font_size (int) – Size of the text to display alongside the slider (pt).
orientation (str) – horizontal or vertical
text_alignment (str) – define text alignment on a slider. Left (default)/ right for the vertical slider or top/bottom (default) for an horizontal slider.
text_template (str, callable) – If str, text template can contain one or multiple of the replacement fields: {value:}, {ratio:}. If callable, this instance of :class:LineSlider2D will be passed as argument to the text template function.
shape (string) – Describes the shape of the handle. Currently supports ‘disk’ and ‘square’.
- property bottom_y_position#
- handle_move_callback(i_ren, _vtkactor, _slider)[source]#
Handle movement.
- Parameters:
i_ren (
CustomInteractorStyle
) –vtkactor (
vtkActor
) – The picked actorslider (
LineSlider2D
) –
- handle_release_callback(i_ren, _vtkactor, _slider)[source]#
Change color when handle is released.
- Parameters:
i_ren (
CustomInteractorStyle
) –vtkactor (
vtkActor
) – The picked actorslider (
LineSlider2D
) –
- property left_x_position#
- property ratio#
- property right_x_position#
- property top_y_position#
- track_click_callback(i_ren, _vtkactor, _slider)[source]#
Update disk position and grab the focus.
- Parameters:
i_ren (
CustomInteractorStyle
) –vtkactor (
vtkActor
) – The picked actor_slider (
LineSlider2D
) –
- property value#
ListBox2D
#
- class fury.ui.ListBox2D(values, position=(0, 0), size=(100, 300), multiselection=True, reverse_scrolling=False, font_size=20, line_spacing=1.4, text_color=(0.2, 0.2, 0.2), selected_color=(0.9, 0.6, 0.6), unselected_color=(0.6, 0.6, 0.6), scroll_bar_active_color=(0.6, 0.2, 0.2), scroll_bar_inactive_color=(0.9, 0.0, 0.0), background_opacity=1.0)[source]#
Bases:
UI
UI component that allows the user to select items from a list.
- on_change#
Callback function for when the selected items have changed.
- Type:
function
- __init__(values, position=(0, 0), size=(100, 300), multiselection=True, reverse_scrolling=False, font_size=20, line_spacing=1.4, text_color=(0.2, 0.2, 0.2), selected_color=(0.9, 0.6, 0.6), unselected_color=(0.6, 0.6, 0.6), scroll_bar_active_color=(0.6, 0.2, 0.2), scroll_bar_inactive_color=(0.9, 0.0, 0.0), background_opacity=1.0)[source]#
Init class instance.
- Parameters:
values (list of objects) – Values used to populate this listbox. Objects must be castable to string.
position ((float, float)) – Absolute coordinates (x, y) of the lower-left corner of this UI component.
size ((int, int)) – Width and height in pixels of this UI component.
multiselection ({True, False}) – Whether multiple values can be selected at once.
reverse_scrolling ({True, False}) – If True, scrolling up will move the list of files down.
font_size (int) – The font size in pixels.
line_spacing (float) – Distance between listbox’s items in pixels.
text_color (tuple of 3 floats) –
selected_color (tuple of 3 floats) –
unselected_color (tuple of 3 floats) –
scroll_bar_active_color (tuple of 3 floats) –
scroll_bar_inactive_color (tuple of 3 floats) –
background_opacity (float) –
- down_button_callback(i_ren, _obj, _list_box)[source]#
Pressing down button scrolls down in the combo box.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_list_box (
ListBox2D
) –
- scroll_click_callback(i_ren, _obj, _rect_obj)[source]#
Callback to change the color of the bar when it is clicked.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_rect_obj (
Rectangle2D
) –
- scroll_drag_callback(i_ren, _obj, _rect_obj)[source]#
Drag scroll bar in the combo box.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actorrect_obj (
Rectangle2D
) –
- scroll_release_callback(i_ren, _obj, _rect_obj)[source]#
Callback to change the color of the bar when it is released.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actorrect_obj (
Rectangle2D
) –
- select(item, multiselect=False, range_select=False)[source]#
Select the item.
- Parameters:
item (ListBoxItem2D's object) – Item to select.
multiselect ({True, False}) – If True and multiselection is allowed, the item is added to the selection. Otherwise, the selection will only contain the provided item unless range_select is True.
range_select ({True, False}) – If True and multiselection is allowed, all items between the last selected item and the current one will be added to the selection. Otherwise, the selection will only contain the provided item unless multi_select is True.
ListBoxItem2D
#
- class fury.ui.ListBoxItem2D(list_box, size, text_color=(1.0, 0.0, 0.0), selected_color=(0.4, 0.4, 0.4), unselected_color=(0.9, 0.9, 0.9), background_opacity=1.0)[source]#
Bases:
UI
The text displayed in a listbox.
- __init__(list_box, size, text_color=(1.0, 0.0, 0.0), selected_color=(0.4, 0.4, 0.4), unselected_color=(0.9, 0.9, 0.9), background_opacity=1.0)[source]#
Init ListBox Item instance.
- property element#
- left_button_clicked(i_ren, _obj, _list_box_item)[source]#
Handle left click for this UI element.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_list_box_item (
ListBoxItem2D
) –
Option
#
- class fury.ui.Option(label, position=(0, 0), font_size=18, checked=False)[source]#
Bases:
UI
A set of a Button2D and a TextBlock2D to act as a single option for checkboxes and radio buttons. Clicking the button toggles its checked/unchecked status.
Panel2D
#
- class fury.ui.Panel2D(size, position=(0, 0), color=(0.1, 0.1, 0.1), opacity=0.7, align='left', border_color=(1, 1, 1), border_width=0, has_border=False)[source]#
Bases:
UI
A 2D UI Panel.
Can contain one or more UI elements.
- alignment#
Alignment of the panel with respect to the overall screen.
- Type:
[left, right]
- __init__(size, position=(0, 0), color=(0.1, 0.1, 0.1), opacity=0.7, align='left', border_color=(1, 1, 1), border_width=0, has_border=False)[source]#
Init class instance.
- Parameters:
size ((int, int)) – Size (width, height) in pixels of the panel.
position ((float, float)) – Absolute coordinates (x, y) of the lower-left corner of the panel.
opacity (float) – Must take values in [0, 1].
align ([left, right]) – Alignment of the panel with respect to the overall screen.
border_color ((float, float, float), optional) – Must take values in [0, 1].
border_width (float, optional) – width of the border
has_border (bool, optional) – If the panel should have borders.
- add_element(element, coords, anchor='position')[source]#
Add a UI component to the panel.
The coordinates represent an offset from the lower left corner of the panel.
- property border_color#
- property border_width#
- property color#
- property opacity#
- remove_element(element)[source]#
Remove a UI component from the panel.
- Parameters:
element (UI) – The UI item to be removed.
PlaybackPanel
#
- class fury.ui.PlaybackPanel(loop=False, position=(0, 0), width=None)[source]#
Bases:
UI
A playback controller that can do essential functionalities. such as play, pause, stop, and seek.
- property current_time#
Get current time of the progress slider.
- Returns:
Progress slider current value.
- Return type:
- property current_time_str#
Returns current time as a string.
- Returns:
Current time formatted as a string in the form:HH:MM:SS.
- Return type:
- property final_time#
Set final progress slider time value.
- Returns:
Final time for the progress slider.
- Return type:
- property speed#
Returns current speed.
- Returns:
Current time formatted as a string in the form:HH:MM:SS.
- Return type:
RangeSlider
#
- class fury.ui.RangeSlider(line_width=5, inner_radius=0, outer_radius=10, handle_side=20, range_slider_center=(450, 400), value_slider_center=(450, 300), length=200, min_value=0, max_value=100, font_size=16, range_precision=1, orientation='horizontal', value_precision=2, shape='disk')[source]#
Bases:
UI
A set of a LineSlider2D and a LineDoubleSlider2D. The double slider is used to set the min and max value for the LineSlider2D
- range_slider#
The line slider which sets the min and max values
- Type:
- value_slider#
The line slider which sets the value
- Type:
- __init__(line_width=5, inner_radius=0, outer_radius=10, handle_side=20, range_slider_center=(450, 400), value_slider_center=(450, 300), length=200, min_value=0, max_value=100, font_size=16, range_precision=1, orientation='horizontal', value_precision=2, shape='disk')[source]#
Init this class instance.
- Parameters:
line_width (int) – Width of the slider tracks
inner_radius (int) – Inner radius of the handles.
outer_radius (int) – Outer radius of the handles.
handle_side (int) – Side length of the handles (if square).
range_slider_center ((float, float)) – Center of the LineDoubleSlider2D object.
value_slider_center ((float, float)) – Center of the LineSlider2D object.
length (int) – Length of the sliders.
min_value (float) – Minimum value of the double slider.
max_value (float) – Maximum value of the double slider.
font_size (int) – Size of the text to display alongside the sliders (pt).
range_precision (int) – Number of decimal places to show the min and max values set.
orientation (str) – horizontal or vertical
value_precision (int) – Number of decimal places to show the value set on slider.
shape (string) – Describes the shape of the handle. Currently supports ‘disk’ and ‘square’.
- range_slider_handle_move_callback(i_ren, obj, _slider)[source]#
Update range_slider’s handles.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_slider (
RangeSlider
) –
Rectangle2D
#
- class fury.ui.Rectangle2D(size=(0, 0), position=(0, 0), color=(1, 1, 1), opacity=1.0)[source]#
Bases:
UI
A 2D rectangle sub-classed from UI.
- __init__(size=(0, 0), position=(0, 0), color=(1, 1, 1), opacity=1.0)[source]#
Initialize a rectangle.
- property color#
Get the rectangle’s color.
- property height#
- property opacity#
Get the rectangle’s opacity.
- property width#
RingSlider2D
#
- class fury.ui.RingSlider2D(center=(0, 0), initial_value=180, min_value=0, max_value=360, slider_inner_radius=40, slider_outer_radius=44, handle_inner_radius=0, handle_outer_radius=10, font_size=16, text_template='{ratio:.0%}')[source]#
Bases:
UI
A disk slider.
A disk moves along the boundary of a ring. Goes from 0-360 degrees.
- text#
The text that shows percentage.
- Type:
- __init__(center=(0, 0), initial_value=180, min_value=0, max_value=360, slider_inner_radius=40, slider_outer_radius=44, handle_inner_radius=0, handle_outer_radius=10, font_size=16, text_template='{ratio:.0%}')[source]#
Init this UI element.
- Parameters:
center ((float, float)) – Position (x, y) of the slider’s center.
initial_value (float) – Initial value of the slider.
min_value (float) – Minimum value of the slider.
max_value (float) – Maximum value of the slider.
slider_inner_radius (int) – Inner radius of the base disk.
slider_outer_radius (int) – Outer radius of the base disk.
handle_outer_radius (int) – Outer radius of the slider’s handle.
handle_inner_radius (int) – Inner radius of the slider’s handle.
font_size (int) – Size of the text to display alongside the slider (pt).
text_template (str, callable) – If str, text template can contain one or multiple of the replacement fields: {value:}, {ratio:}, {angle:}. If callable, this instance of :class:RingSlider2D will be passed as argument to the text template function.
- property angle#
Return Angle (in rad) the handle makes with x-axis.
- handle_move_callback(i_ren, _obj, _slider)[source]#
Move the slider’s handle.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_slider (
RingSlider2D
) –
- handle_release_callback(i_ren, _obj, _slider)[source]#
Change color when handle is released.
- Parameters:
i_ren (
CustomInteractorStyle
) –vtkactor (
vtkActor
) – The picked actor_slider (
RingSlider2D
) –
- property mid_track_radius#
- property previous_value#
- property ratio#
- track_click_callback(i_ren, _obj, _slider)[source]#
Update disk position and grab the focus.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_slider (
RingSlider2D
) –
- property value#
TabPanel2D
#
- class fury.ui.TabPanel2D(position=(0, 0), size=(100, 100), title='New Tab', color=(0.5, 0.5, 0.5), content_panel=None)[source]#
Bases:
UI
Render content within a Tab.
- content_panel#
Hold all the content UI components.
- Type:
- class:
‘Panel2D’
- text_block#
Renders the title of the tab.
- Type:
- class:
‘TextBlock2D’
- __init__(position=(0, 0), size=(100, 100), title='New Tab', color=(0.5, 0.5, 0.5), content_panel=None)[source]#
Init class instance.
- Parameters:
position ((float, float)) – Absolute coordinates (x, y) of the lower-left corner of the UI component
size ((int, int)) – Width and height of the pixels of this UI component.
title (str) – Renders the title for Tab panel.
color (list of 3 floats) – Background color of tab panel.
content_panel (Panel2D) – Panel consisting of the content UI elements.
- add_element(element, coords, anchor='position')[source]#
Add a UI component to the content panel.
The coordinates represent an offset from the lower left corner of the panel.
- property color#
Return the background color of tab panel.
- remove_element(element)[source]#
Remove a UI component from the content panel.
- Parameters:
element (UI) – The UI item to be removed.
- property title#
Return the title of tab panel.
TabUI
#
- class fury.ui.TabUI(position=(0, 0), size=(100, 100), nb_tabs=1, active_color=(1, 1, 1), inactive_color=(0.5, 0.5, 0.5), draggable=False)[source]#
Bases:
UI
UI element to add multiple panels within a single window.
- tabs#
Stores all the instances of ‘TabPanel2D’ that renderes the contents.
- Type:
- class:
List of ‘TabPanel2D’
- __init__(position=(0, 0), size=(100, 100), nb_tabs=1, active_color=(1, 1, 1), inactive_color=(0.5, 0.5, 0.5), draggable=False)[source]#
Init class instance.
- Parameters:
position ((float, float)) – Absolute coordinates (x, y) of the lower-left corner of this UI component.
size ((int, int)) – Width and height in pixels of this UI component.
nb_tabs (int) – Number of tabs to be renders.
active_color (tuple of 3 floats.) – Background color of active tab panel.
inactive_color (tuple of 3 floats.) – Background color of inactive tab panels.
draggable (bool) – Whether the UI element is draggable or not.
- add_element(tab_idx, element, coords, anchor='position')[source]#
Add element to content panel after checking its existence.
- remove_element(tab_idx, element)[source]#
Remove element from content panel after checking its existence.
TextBlock2D
#
- class fury.ui.TextBlock2D(text='Text Block', font_size=18, font_family='Arial', justification='left', vertical_justification='bottom', bold=False, italic=False, shadow=False, size=None, color=(1, 1, 1), bg_color=None, position=(0, 0))[source]#
Bases:
UI
Wrap over the default vtkTextActor and helps setting the text.
Contains member functions for text formatting.
- actor#
The text actor.
- Type:
vtkTextActor
- __init__(text='Text Block', font_size=18, font_family='Arial', justification='left', vertical_justification='bottom', bold=False, italic=False, shadow=False, size=None, color=(1, 1, 1), bg_color=None, position=(0, 0))[source]#
Init class instance.
- Parameters:
text (str) – The initial text while building the actor.
color ((float, float, float)) – RGB: Values must be between 0-1.
bg_color ((float, float, float)) – RGB: Values must be between 0-1.
font_size (int) – Size of the text font.
font_family (str) – Currently only supports Arial.
justification (str) – left, right or center.
vertical_justification (str) – bottom, middle or top.
bold (bool) – Makes text bold.
italic (bool) – Makes text italicised.
shadow (bool) – Adds text shadow.
size ((int, int)) – Size (width, height) in pixels of the text bounding box.
- property background_color#
Get background color.
- property color#
Get text color.
- property italic#
Return whether the text is italicised.
- Returns:
Text is italicised if True.
- Return type:
- property shadow#
Return whether the text has shadow.
- Returns:
Text is shadowed if True.
- Return type:
TextBox2D
#
- class fury.ui.TextBox2D(width, height, text='Enter Text', position=(100, 10), color=(0, 0, 0), font_size=18, font_family='Arial', justification='left', bold=False, italic=False, shadow=False)[source]#
Bases:
UI
An editable 2D text box that behaves as a UI component.
Currently supports: - Basic text editing. - Cursor movements. - Single and multi-line text boxes. - Pre text formatting (text needs to be formatted beforehand).
- actor#
The text actor.
- Type:
vtkActor2d
- __init__(width, height, text='Enter Text', position=(100, 10), color=(0, 0, 0), font_size=18, font_family='Arial', justification='left', bold=False, italic=False, shadow=False)[source]#
Init this UI element.
- Parameters:
width (int) – The number of characters in a single line of text.
height (int) – The number of lines in the textbox.
text (str) – The initial text while building the actor.
color ((float, float, float)) – RGB: Values must be between 0-1.
font_size (int) – Size of the text font.
font_family (str) – Currently only supports Arial.
justification (str) – left, right or center.
bold (bool) – Makes text bold.
italic (bool) – Makes text italicised.
shadow (bool) – Adds text shadow.
- add_character(character)[source]#
Insert a character into the text and moves window and caret.
- Parameters:
character (str) –
- handle_character(key, key_char)[source]#
Handle button events.
# TODO: Need to handle all kinds of characters like !, +, etc.
- Parameters:
character (str) –
- key_press(i_ren, _obj, _textbox_object)[source]#
Handle Key press for textboxself.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_textbox_object (
TextBox2D
) –
- left_button_press(i_ren, _obj, _textbox_object)[source]#
Handle left button press for textbox.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_textbox_object (
TextBox2D
) –
- render_text(show_caret=True)[source]#
Render text after processing.
- Parameters:
show_caret (bool) – Whether or not to show the caret.
- set_message(message)[source]#
Set custom text to textbox.
- Parameters:
message (str) – The custom message to be set.
CellArray
#
- fury.ui.containers.CellArray#
alias of
vtkCellArray
FloatArray
#
- fury.ui.containers.FloatArray#
alias of
vtkFloatArray
GridUI
#
- class fury.ui.containers.GridUI(actors, captions=None, caption_offset=(0, -100, 0), cell_padding=0, cell_shape='rect', aspect_ratio=1.7777777777777777, dim=None, rotation_speed=1, rotation_axis=(0, 1, 0))[source]#
Bases:
UI
Add actors in a grid and interact with them individually.
- __init__(actors, captions=None, caption_offset=(0, -100, 0), cell_padding=0, cell_shape='rect', aspect_ratio=1.7777777777777777, dim=None, rotation_speed=1, rotation_axis=(0, 1, 0))[source]#
Init scene.
- ANTICLOCKWISE_ROTATION_X = array([-10, 1, 0, 0])#
- ANTICLOCKWISE_ROTATION_Y = array([-10, 0, 1, 0])#
- CLOCKWISE_ROTATION_X = array([10, 1, 0, 0])#
- CLOCKWISE_ROTATION_Y = array([10, 0, 1, 0])#
ImageContainer2D
#
- class fury.ui.containers.ImageContainer2D(img_path, position=(0, 0), size=(100, 100))[source]#
Bases:
UI
A 2D container to hold an image.
Currently Supports: - png and jpg/jpeg images
- img#
The image loaded from the specified path.
- Type:
ImageData
Panel2D
#
- class fury.ui.containers.Panel2D(size, position=(0, 0), color=(0.1, 0.1, 0.1), opacity=0.7, align='left', border_color=(1, 1, 1), border_width=0, has_border=False)[source]#
Bases:
UI
A 2D UI Panel.
Can contain one or more UI elements.
- alignment#
Alignment of the panel with respect to the overall screen.
- Type:
[left, right]
- __init__(size, position=(0, 0), color=(0.1, 0.1, 0.1), opacity=0.7, align='left', border_color=(1, 1, 1), border_width=0, has_border=False)[source]#
Init class instance.
- Parameters:
size ((int, int)) – Size (width, height) in pixels of the panel.
position ((float, float)) – Absolute coordinates (x, y) of the lower-left corner of the panel.
opacity (float) – Must take values in [0, 1].
align ([left, right]) – Alignment of the panel with respect to the overall screen.
border_color ((float, float, float), optional) – Must take values in [0, 1].
border_width (float, optional) – width of the border
has_border (bool, optional) – If the panel should have borders.
- add_element(element, coords, anchor='position')[source]#
Add a UI component to the panel.
The coordinates represent an offset from the lower left corner of the panel.
- property border_color#
- property border_width#
- property color#
- property opacity#
- remove_element(element)[source]#
Remove a UI component from the panel.
- Parameters:
element (UI) – The UI item to be removed.
Points
#
- fury.ui.containers.Points#
alias of
vtkPoints
PolyData
#
- fury.ui.containers.PolyData#
alias of
vtkPolyData
PolyDataMapper2D
#
- fury.ui.containers.PolyDataMapper2D#
alias of
vtkPolyDataMapper2D
Property2D
#
- fury.ui.containers.Property2D#
alias of
vtkProperty2D
Rectangle2D
#
- class fury.ui.containers.Rectangle2D(size=(0, 0), position=(0, 0), color=(1, 1, 1), opacity=1.0)[source]#
Bases:
UI
A 2D rectangle sub-classed from UI.
- __init__(size=(0, 0), position=(0, 0), color=(1, 1, 1), opacity=1.0)[source]#
Initialize a rectangle.
- property color#
Get the rectangle’s color.
- property height#
- property opacity#
Get the rectangle’s opacity.
- property width#
TabPanel2D
#
- class fury.ui.containers.TabPanel2D(position=(0, 0), size=(100, 100), title='New Tab', color=(0.5, 0.5, 0.5), content_panel=None)[source]#
Bases:
UI
Render content within a Tab.
- content_panel#
Hold all the content UI components.
- Type:
- class:
‘Panel2D’
- text_block#
Renders the title of the tab.
- Type:
- class:
‘TextBlock2D’
- __init__(position=(0, 0), size=(100, 100), title='New Tab', color=(0.5, 0.5, 0.5), content_panel=None)[source]#
Init class instance.
- Parameters:
position ((float, float)) – Absolute coordinates (x, y) of the lower-left corner of the UI component
size ((int, int)) – Width and height of the pixels of this UI component.
title (str) – Renders the title for Tab panel.
color (list of 3 floats) – Background color of tab panel.
content_panel (Panel2D) – Panel consisting of the content UI elements.
- add_element(element, coords, anchor='position')[source]#
Add a UI component to the content panel.
The coordinates represent an offset from the lower left corner of the panel.
- property color#
Return the background color of tab panel.
- remove_element(element)[source]#
Remove a UI component from the content panel.
- Parameters:
element (UI) – The UI item to be removed.
- property title#
Return the title of tab panel.
TabUI
#
- class fury.ui.containers.TabUI(position=(0, 0), size=(100, 100), nb_tabs=1, active_color=(1, 1, 1), inactive_color=(0.5, 0.5, 0.5), draggable=False)[source]#
Bases:
UI
UI element to add multiple panels within a single window.
- tabs#
Stores all the instances of ‘TabPanel2D’ that renderes the contents.
- Type:
- class:
List of ‘TabPanel2D’
- __init__(position=(0, 0), size=(100, 100), nb_tabs=1, active_color=(1, 1, 1), inactive_color=(0.5, 0.5, 0.5), draggable=False)[source]#
Init class instance.
- Parameters:
position ((float, float)) – Absolute coordinates (x, y) of the lower-left corner of this UI component.
size ((int, int)) – Width and height in pixels of this UI component.
nb_tabs (int) – Number of tabs to be renders.
active_color (tuple of 3 floats.) – Background color of active tab panel.
inactive_color (tuple of 3 floats.) – Background color of inactive tab panels.
draggable (bool) – Whether the UI element is draggable or not.
- add_element(tab_idx, element, coords, anchor='position')[source]#
Add element to content panel after checking its existence.
- remove_element(tab_idx, element)[source]#
Remove element from content panel after checking its existence.
TextBlock2D
#
- class fury.ui.containers.TextBlock2D(text='Text Block', font_size=18, font_family='Arial', justification='left', vertical_justification='bottom', bold=False, italic=False, shadow=False, size=None, color=(1, 1, 1), bg_color=None, position=(0, 0))[source]#
Bases:
UI
Wrap over the default vtkTextActor and helps setting the text.
Contains member functions for text formatting.
- actor#
The text actor.
- Type:
vtkTextActor
- __init__(text='Text Block', font_size=18, font_family='Arial', justification='left', vertical_justification='bottom', bold=False, italic=False, shadow=False, size=None, color=(1, 1, 1), bg_color=None, position=(0, 0))[source]#
Init class instance.
- Parameters:
text (str) – The initial text while building the actor.
color ((float, float, float)) – RGB: Values must be between 0-1.
bg_color ((float, float, float)) – RGB: Values must be between 0-1.
font_size (int) – Size of the text font.
font_family (str) – Currently only supports Arial.
justification (str) – left, right or center.
vertical_justification (str) – bottom, middle or top.
bold (bool) – Makes text bold.
italic (bool) – Makes text italicised.
shadow (bool) – Adds text shadow.
size ((int, int)) – Size (width, height) in pixels of the text bounding box.
- property background_color#
Get background color.
- property color#
Get text color.
- property italic#
Return whether the text is italicised.
- Returns:
Text is italicised if True.
- Return type:
- property shadow#
Return whether the text has shadow.
- Returns:
Text is shadowed if True.
- Return type:
Texture
#
- fury.ui.containers.Texture#
alias of
vtkTexture
TexturedActor2D
#
- fury.ui.containers.TexturedActor2D#
alias of
vtkTexturedActor2D
UI
#
- class fury.ui.containers.UI(position=(0, 0))[source]#
Bases:
object
An umbrella class for all UI elements.
While adding UI elements to the scene, we go over all the sub-elements that come with it and add those to the scene automatically.
- position#
Absolute coordinates (x, y) of the lower-left corner of this UI component.
- on_left_mouse_button_pressed#
Callback function for when the left mouse button is pressed.
- Type:
function
- on_left_mouse_button_released#
Callback function for when the left mouse button is released.
- Type:
function
- on_left_mouse_button_clicked#
Callback function for when clicked using the left mouse button (i.e. pressed -> released).
- Type:
function
- on_left_mouse_double_clicked#
Callback function for when left mouse button is double clicked (i.e pressed -> released -> pressed -> released).
- Type:
function
- on_left_mouse_button_dragged#
Callback function for when dragging using the left mouse button.
- Type:
function
- on_right_mouse_button_pressed#
Callback function for when the right mouse button is pressed.
- Type:
function
- on_right_mouse_button_released#
Callback function for when the right mouse button is released.
- Type:
function
- on_right_mouse_button_clicked#
Callback function for when clicking using the right mouse button (i.e. pressed -> released).
- Type:
function
- on_right_mouse_double_clicked#
Callback function for when right mouse button is double clicked (i.e pressed -> released -> pressed -> released).
- Type:
function
- on_right_mouse_button_dragged#
Callback function for when dragging using the right mouse button.
- Type:
function
- on_middle_mouse_button_pressed#
Callback function for when the middle mouse button is pressed.
- Type:
function
- on_middle_mouse_button_released#
Callback function for when the middle mouse button is released.
- Type:
function
- on_middle_mouse_button_clicked#
Callback function for when clicking using the middle mouse button (i.e. pressed -> released).
- Type:
function
- on_middle_mouse_double_clicked#
Callback function for when middle mouse button is double clicked (i.e pressed -> released -> pressed -> released).
- Type:
function
- on_middle_mouse_button_dragged#
Callback function for when dragging using the middle mouse button.
- Type:
function
- on_key_press#
Callback function for when a keyboard key is pressed.
- Type:
function
- property actors#
Actors composing this UI component.
- add_callback(prop, event_type, callback, priority=0)[source]#
Add a callback to a specific event for this UI component.
- Parameters:
prop (vtkProp) – The prop on which is callback is to be added.
event_type (string) – The event code.
callback (function) – The callback function.
priority (int) – Higher number is higher priority.
- add_to_scene(scene)[source]#
Allow UI objects to add their own props to the scene.
- Parameters:
scene (scene) –
- property center#
- property position#
- property size#
grid#
- fury.ui.containers.grid(actors, captions=None, caption_offset=(0, -100, 0), cell_padding=0, cell_shape='rect', aspect_ratio=1.7777777777777777, dim=None)[source]#
Creates a grid of actors that lies in the xy-plane.
- Parameters:
actors (list of vtkProp3D objects) – Actors to be layout in a grid manner.
captions (list of vtkProp3D objects or list of str) – Objects serving as captions (can be any vtkProp3D object, not necessarily text). There should be one caption per actor. By default, there are no captions.
caption_offset (tuple of float (optional)) – Tells where to position the caption w.r.t. the center of its associated actor. Default: (0, -100, 0).
cell_padding (tuple of 2 floats or float) – Each grid cell will be padded according to (pad_x, pad_y) i.e. horizontally and vertically. Padding is evenly distributed on each side of the cell. If a single float is provided then both pad_x and pad_y will have the same value.
cell_shape (str) – Specifies the desired shape of every grid cell. ‘rect’ ensures the cells are the tightest. ‘square’ ensures the cells are as wide as high. ‘diagonal’ ensures the content of the cells can be rotated without colliding with content of the neighboring cells.
aspect_ratio (float) – Aspect ratio of the grid (width/height). Default: 16:9.
dim (tuple of int) – Dimension (nb_rows, nb_cols) of the grid. If provided, aspect_ratio will be ignored.
- Returns:
Object that represents the grid containing all the actors and captions, if any.
- Return type:
fury.actor.Container
object
load_image#
rotate#
set_input#
- fury.ui.containers.set_input(vtk_object, inp)[source]#
Set Generic input function which takes into account VTK 5 or 6.
- Parameters:
vtk_object (vtk object) –
inp (vtkPolyData or vtkImageData or vtkAlgorithmOutput) –
- Return type:
vtk_object
Notes
- This can be used in the following way::
from fury.utils import set_input poly_mapper = set_input(PolyDataMapper(), poly_data)
Actor2D
#
- fury.ui.core.Actor2D#
alias of
vtkActor2D
Button2D
#
- class fury.ui.core.Button2D(icon_fnames, position=(0, 0), size=(30, 30))[source]#
Bases:
UI
A 2D overlay button and is of type vtkTexturedActor2D.
Currently supports:
- Multiple icons. - Switching between icons.
- property color#
Get the button’s color.
CellArray
#
- fury.ui.core.CellArray#
alias of
vtkCellArray
CustomInteractorStyle
#
- class fury.ui.core.CustomInteractorStyle[source]#
Bases:
vtkInteractorStyleUser
Manipulate the camera and interact with objects in the scene.
This interactor style allows the user to interactively manipulate (pan, rotate and zoom) the camera. It also allows the user to interact (click, scroll, etc.) with objects in the scene.
Several events handling methods from
vtkInteractorStyleUser
have been overloaded to allow the propagation of the events to the objects the user is interacting with.In summary, while interacting with the scene, the mouse events are as follows:
- Left mouse button: rotates the camera - Right mouse button: dollys the camera - Mouse wheel: dollys the camera - Middle mouse button: pans the camera
Disk2D
#
- class fury.ui.core.Disk2D(outer_radius, inner_radius=0, center=(0, 0), color=(1, 1, 1), opacity=1.0)[source]#
Bases:
UI
A 2D disk UI component.
- __init__(outer_radius, inner_radius=0, center=(0, 0), color=(1, 1, 1), opacity=1.0)[source]#
Initialize a 2D Disk.
- Parameters:
outer_radius (int) – Outer radius of the disk.
inner_radius (int, optional) – Inner radius of the disk. A value > 0, makes a ring.
center ((float, float), optional) – Coordinates (x, y) of the center of the disk.
color ((float, float, float), optional) – Must take values in [0, 1].
opacity (float, optional) – Must take values in [0, 1].
- property color#
Get the color of this UI component.
- property inner_radius#
- property opacity#
Get the opacity of this UI component.
- property outer_radius#
DiskSource
#
- fury.ui.core.DiskSource#
alias of
vtkDiskSource
FloatArray
#
- fury.ui.core.FloatArray#
alias of
vtkFloatArray
Points
#
- fury.ui.core.Points#
alias of
vtkPoints
PolyData
#
- fury.ui.core.PolyData#
alias of
vtkPolyData
PolyDataMapper2D
#
- fury.ui.core.PolyDataMapper2D#
alias of
vtkPolyDataMapper2D
Polygon
#
- fury.ui.core.Polygon#
alias of
vtkPolygon
Property2D
#
- fury.ui.core.Property2D#
alias of
vtkProperty2D
Rectangle2D
#
- class fury.ui.core.Rectangle2D(size=(0, 0), position=(0, 0), color=(1, 1, 1), opacity=1.0)[source]#
Bases:
UI
A 2D rectangle sub-classed from UI.
- __init__(size=(0, 0), position=(0, 0), color=(1, 1, 1), opacity=1.0)[source]#
Initialize a rectangle.
- property color#
Get the rectangle’s color.
- property height#
- property opacity#
Get the rectangle’s opacity.
- property width#
TextActor
#
- fury.ui.core.TextActor#
alias of
vtkTextActor
TextBlock2D
#
- class fury.ui.core.TextBlock2D(text='Text Block', font_size=18, font_family='Arial', justification='left', vertical_justification='bottom', bold=False, italic=False, shadow=False, size=None, color=(1, 1, 1), bg_color=None, position=(0, 0))[source]#
Bases:
UI
Wrap over the default vtkTextActor and helps setting the text.
Contains member functions for text formatting.
- actor#
The text actor.
- Type:
vtkTextActor
- __init__(text='Text Block', font_size=18, font_family='Arial', justification='left', vertical_justification='bottom', bold=False, italic=False, shadow=False, size=None, color=(1, 1, 1), bg_color=None, position=(0, 0))[source]#
Init class instance.
- Parameters:
text (str) – The initial text while building the actor.
color ((float, float, float)) – RGB: Values must be between 0-1.
bg_color ((float, float, float)) – RGB: Values must be between 0-1.
font_size (int) – Size of the text font.
font_family (str) – Currently only supports Arial.
justification (str) – left, right or center.
vertical_justification (str) – bottom, middle or top.
bold (bool) – Makes text bold.
italic (bool) – Makes text italicised.
shadow (bool) – Adds text shadow.
size ((int, int)) – Size (width, height) in pixels of the text bounding box.
- property background_color#
Get background color.
- property color#
Get text color.
- property italic#
Return whether the text is italicised.
- Returns:
Text is italicised if True.
- Return type:
- property shadow#
Return whether the text has shadow.
- Returns:
Text is shadowed if True.
- Return type:
Texture
#
- fury.ui.core.Texture#
alias of
vtkTexture
TexturedActor2D
#
- fury.ui.core.TexturedActor2D#
alias of
vtkTexturedActor2D
UI
#
- class fury.ui.core.UI(position=(0, 0))[source]#
Bases:
object
An umbrella class for all UI elements.
While adding UI elements to the scene, we go over all the sub-elements that come with it and add those to the scene automatically.
- position#
Absolute coordinates (x, y) of the lower-left corner of this UI component.
- on_left_mouse_button_pressed#
Callback function for when the left mouse button is pressed.
- Type:
function
- on_left_mouse_button_released#
Callback function for when the left mouse button is released.
- Type:
function
- on_left_mouse_button_clicked#
Callback function for when clicked using the left mouse button (i.e. pressed -> released).
- Type:
function
- on_left_mouse_double_clicked#
Callback function for when left mouse button is double clicked (i.e pressed -> released -> pressed -> released).
- Type:
function
- on_left_mouse_button_dragged#
Callback function for when dragging using the left mouse button.
- Type:
function
- on_right_mouse_button_pressed#
Callback function for when the right mouse button is pressed.
- Type:
function
- on_right_mouse_button_released#
Callback function for when the right mouse button is released.
- Type:
function
- on_right_mouse_button_clicked#
Callback function for when clicking using the right mouse button (i.e. pressed -> released).
- Type:
function
- on_right_mouse_double_clicked#
Callback function for when right mouse button is double clicked (i.e pressed -> released -> pressed -> released).
- Type:
function
- on_right_mouse_button_dragged#
Callback function for when dragging using the right mouse button.
- Type:
function
- on_middle_mouse_button_pressed#
Callback function for when the middle mouse button is pressed.
- Type:
function
- on_middle_mouse_button_released#
Callback function for when the middle mouse button is released.
- Type:
function
- on_middle_mouse_button_clicked#
Callback function for when clicking using the middle mouse button (i.e. pressed -> released).
- Type:
function
- on_middle_mouse_double_clicked#
Callback function for when middle mouse button is double clicked (i.e pressed -> released -> pressed -> released).
- Type:
function
- on_middle_mouse_button_dragged#
Callback function for when dragging using the middle mouse button.
- Type:
function
- on_key_press#
Callback function for when a keyboard key is pressed.
- Type:
function
- property actors#
Actors composing this UI component.
- add_callback(prop, event_type, callback, priority=0)[source]#
Add a callback to a specific event for this UI component.
- Parameters:
prop (vtkProp) – The prop on which is callback is to be added.
event_type (string) – The event code.
callback (function) – The callback function.
priority (int) – Higher number is higher priority.
- add_to_scene(scene)[source]#
Allow UI objects to add their own props to the scene.
- Parameters:
scene (scene) –
- property center#
- property position#
- property size#
load_image#
set_input#
- fury.ui.core.set_input(vtk_object, inp)[source]#
Set Generic input function which takes into account VTK 5 or 6.
- Parameters:
vtk_object (vtk object) –
inp (vtkPolyData or vtkImageData or vtkAlgorithmOutput) –
- Return type:
vtk_object
Notes
- This can be used in the following way::
from fury.utils import set_input poly_mapper = set_input(PolyDataMapper(), poly_data)
warn#
- fury.ui.core.warn(message, category=None, stacklevel=1, source=None)#
Issue a warning, or maybe ignore it or raise an exception.
Button2D
#
- class fury.ui.elements.Button2D(icon_fnames, position=(0, 0), size=(30, 30))[source]#
Bases:
UI
A 2D overlay button and is of type vtkTexturedActor2D.
Currently supports:
- Multiple icons. - Switching between icons.
- property color#
Get the button’s color.
Checkbox
#
- class fury.ui.elements.Checkbox(labels, checked_labels=(), padding=1, font_size=18, font_family='Arial', position=(0, 0))[source]#
Bases:
UI
A 2D set of :class:’Option’ objects. Multiple options can be selected.
- __init__(labels, checked_labels=(), padding=1, font_size=18, font_family='Arial', position=(0, 0))[source]#
Init this class instance.
- Parameters:
checked_labels (list(str), optional) – List of labels that are checked on setting up.
padding (float, optional) – The distance between two adjacent options
font_size (int, optional) – Size of the text font.
font_family (str, optional) – Currently only supports Arial.
position ((float, float), optional) – Absolute coordinates (x, y) of the lower-left corner of the button of the first option.
- property font_size#
Gets the font size of text.
- property padding#
Get the padding between options.
ComboBox2D
#
- class fury.ui.elements.ComboBox2D(items=[], position=(0, 0), size=(300, 200), placeholder='Choose selection...', draggable=True, selection_text_color=(0, 0, 0), selection_bg_color=(1, 1, 1), menu_text_color=(0.2, 0.2, 0.2), selected_color=(0.9, 0.6, 0.6), unselected_color=(0.6, 0.6, 0.6), scroll_bar_active_color=(0.6, 0.2, 0.2), scroll_bar_inactive_color=(0.9, 0.0, 0.0), menu_opacity=1.0, reverse_scrolling=False, font_size=20, line_spacing=1.4)[source]#
Bases:
UI
UI element to create drop-down menus.
- selection_box#
Display selection and placeholder text.
- Type:
- class:
‘TextBox2D’
- drop_down_button#
Button to show or hide menu.
- Type:
- class:
‘Button2D’
Container for item list.
- Type:
- class:
‘ListBox2D’
- __init__(items=[], position=(0, 0), size=(300, 200), placeholder='Choose selection...', draggable=True, selection_text_color=(0, 0, 0), selection_bg_color=(1, 1, 1), menu_text_color=(0.2, 0.2, 0.2), selected_color=(0.9, 0.6, 0.6), unselected_color=(0.6, 0.6, 0.6), scroll_bar_active_color=(0.6, 0.2, 0.2), scroll_bar_inactive_color=(0.9, 0.0, 0.0), menu_opacity=1.0, reverse_scrolling=False, font_size=20, line_spacing=1.4)[source]#
Init class Instance.
- Parameters:
items (list(string)) – List of items to be displayed as choices.
position ((float, float)) – Absolute coordinates (x, y) of the lower-left corner of this UI component.
size ((int, int)) – Width and height in pixels of this UI component.
placeholder (str) – Holds the default text to be displayed.
draggable ({True, False}) – Whether the UI element is draggable or not.
selection_text_color (tuple of 3 floats) – Color of the selected text to be displayed.
selection_bg_color (tuple of 3 floats) – Background color of the selection text.
menu_text_color (tuple of 3 floats.) – Color of the options displayed in drop down menu.
selected_color (tuple of 3 floats.) – Background color of the selected option in drop down menu.
unselected_color (tuple of 3 floats.) – Background color of the unselected option in drop down menu.
scroll_bar_active_color (tuple of 3 floats.) – Color of the scrollbar when in active use.
scroll_bar_inactive_color (tuple of 3 floats.) – Color of the scrollbar when inactive.
reverse_scrolling ({True, False}) – If True, scrolling up will move the list of files down.
font_size (int) – The font size of selected text in pixels.
line_spacing (float) – Distance between drop down menu’s items in pixels.
Toggle visibility of drop down menu list.
- Parameters:
i_ren (
CustomInteractorStyle
) –vtkactor (
vtkActor
) – The picked actorcombobox (
ComboBox2D
) –
- select_option_callback(i_ren, _obj, listboxitem)[source]#
Select the appropriate option
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actorlistboxitem (
ListBoxItem2D
) –
- property selected_text#
- property selected_text_index#
Command
#
- fury.ui.elements.Command#
alias of
vtkCommand
Disk2D
#
- class fury.ui.elements.Disk2D(outer_radius, inner_radius=0, center=(0, 0), color=(1, 1, 1), opacity=1.0)[source]#
Bases:
UI
A 2D disk UI component.
- __init__(outer_radius, inner_radius=0, center=(0, 0), color=(1, 1, 1), opacity=1.0)[source]#
Initialize a 2D Disk.
- Parameters:
outer_radius (int) – Outer radius of the disk.
inner_radius (int, optional) – Inner radius of the disk. A value > 0, makes a ring.
center ((float, float), optional) – Coordinates (x, y) of the center of the disk.
color ((float, float, float), optional) – Must take values in [0, 1].
opacity (float, optional) – Must take values in [0, 1].
- property color#
Get the color of this UI component.
- property inner_radius#
- property opacity#
Get the opacity of this UI component.
- property outer_radius#
DrawPanel
#
- class fury.ui.elements.DrawPanel(size=(400, 400), position=(0, 0), is_draggable=False)[source]#
Bases:
UI
The main Canvas(Panel2D) on which everything would be drawn.
- cal_min_boundary_distance(position)[source]#
Calculate the minimum distance between the current position and canvas boundary.
- property current_mode#
DrawShape
#
- class fury.ui.elements.DrawShape(shape_type, drawpanel=None, position=(0, 0))[source]#
Bases:
UI
Create and Manage 2D Shapes.
- property center#
- property is_selected#
- rotate(angle)[source]#
Rotate the vertices of the UI component using specific angle.
- Parameters:
angle (float) – Value by which the vertices are rotated in radian.
FileMenu2D
#
- class fury.ui.elements.FileMenu2D(directory_path, extensions=None, position=(0, 0), size=(100, 300), multiselection=True, reverse_scrolling=False, font_size=20, line_spacing=1.4)[source]#
Bases:
UI
A menu to select files in the current folder.
Can go to new folder, previous folder and select multiple files.
- extensions#
To show all files, extensions=[“*”] or [“”] List of extensions to be shown as files.
- Type:
[‘extension1’, ‘extension2’, ….]
- listbox#
Container for the menu.
- Type:
- class:
‘ListBox2D’
- __init__(directory_path, extensions=None, position=(0, 0), size=(100, 300), multiselection=True, reverse_scrolling=False, font_size=20, line_spacing=1.4)[source]#
Init class instance.
- Parameters:
extensions (list(string)) – List of extensions to be shown as files.
directory_path (string) – Path of the directory where this dialog should open.
position ((float, float)) – Absolute coordinates (x, y) of the lower-left corner of this UI component.
size ((int, int)) – Width and height in pixels of this UI component.
multiselection ({True, False}) – Whether multiple values can be selected at once.
reverse_scrolling ({True, False}) – If True, scrolling up will move the list of files down.
font_size (int) – The font size in pixels.
line_spacing (float) – Distance between listbox’s items in pixels.
- directory_click_callback(i_ren, _obj, listboxitem)[source]#
Handle the move into a directory if it has been clicked.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actorlistboxitem (
ListBoxItem2D
) –
- get_all_file_names()[source]#
Get file and directory names.
- Returns:
all_file_names – List of all file and directory names as string.
- Return type:
list((string, {“directory”, “file”}))
- get_directory_names()[source]#
Find names of all directories in the current_directory
- Returns:
directory_names – List of all directory names as string.
- Return type:
list(string)
- get_file_names()[source]#
Find names of all files in the current_directory
- Returns:
file_names – List of all file names as string.
- Return type:
list(string)
- scroll_callback(i_ren, _obj, _filemenu_item)[source]#
Handle scroll and change the slot text colors.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_filemenu_item (
FileMenu2D
) –
LineDoubleSlider2D
#
- class fury.ui.elements.LineDoubleSlider2D(line_width=5, inner_radius=0, outer_radius=10, handle_side=20, center=(450, 300), length=200, initial_values=(0, 100), min_value=0, max_value=100, font_size=16, text_template='{value:.1f}', orientation='horizontal', shape='disk')[source]#
Bases:
UI
A 2D Line Slider with two sliding rings.
Useful for setting min and max values for something.
Currently supports: - Setting positions of both disks.
- track#
The line on which the handles move.
- Type:
vtkActor
- handles#
The moving slider disks.
- Type:
[
vtkActor
,vtkActor
]
- text#
The texts that show the values of the disks.
- Type:
- shape#
Describes the shape of the handle. Currently supports ‘disk’ and ‘square’.
- Type:
string
- __init__(line_width=5, inner_radius=0, outer_radius=10, handle_side=20, center=(450, 300), length=200, initial_values=(0, 100), min_value=0, max_value=100, font_size=16, text_template='{value:.1f}', orientation='horizontal', shape='disk')[source]#
Init this UI element.
- Parameters:
line_width (int) – Width of the line on which the disk will slide.
inner_radius (int) – Inner radius of the handles (if disk).
outer_radius (int) – Outer radius of the handles (if disk).
handle_side (int) – Side length of the handles (if sqaure).
length (int) – Length of the slider.
initial_values ((float, float)) – Initial values of the two handles.
min_value (float) – Minimum value of the slider.
max_value (float) – Maximum value of the slider.
font_size (int) – Size of the text to display alongside the slider (pt).
text_template (str, callable) – If str, text template can contain one or multiple of the replacement fields: {value:}, {ratio:}. If callable, this instance of :class:LineDoubleSlider2D will be passed as argument to the text template function.
orientation (str) – horizontal or vertical
shape (string) – Describes the shape of the handle. Currently supports ‘disk’ and ‘square’.
- property bottom_disk_ratio#
Return the ratio of the bottom disk.
- property bottom_disk_value#
Return the value of the bottom disk.
- property bottom_y_position#
- coord_to_ratio(coord)[source]#
Convert the x coordinate of a disk to the ratio.
- Parameters:
coord (float) –
- format_text(disk_number)[source]#
Return formatted text to display along the slider.
- Parameters:
disk_number (int) – Index of the disk.
- handle_move_callback(i_ren, vtkactor, _slider)[source]#
Handle movement.
- Parameters:
i_ren (
CustomInteractorStyle
) –vtkactor (
vtkActor
) – The picked actor_slider (
LineDoubleSlider2D
) –
- handle_release_callback(i_ren, vtkactor, _slider)[source]#
Change color when handle is released.
- Parameters:
i_ren (
CustomInteractorStyle
) –vtkactor (
vtkActor
) – The picked actor_slider (
LineDoubleSlider2D
) –
- property left_disk_ratio#
Return the ratio of the left disk.
- property left_disk_value#
Return the value of the left disk.
- property left_x_position#
- ratio_to_coord(ratio)[source]#
Convert the ratio to the absolute coordinate.
- Parameters:
ratio (float) –
- ratio_to_value(ratio)[source]#
Convert the ratio to the value of the disk.
- Parameters:
ratio (float) –
- property right_disk_ratio#
Return the ratio of the right disk.
- property right_disk_value#
Return the value of the right disk.
- property right_x_position#
- property top_disk_ratio#
Return the ratio of the top disk.
- property top_disk_value#
Return the value of the top disk.
- property top_y_position#
LineSlider2D
#
- class fury.ui.elements.LineSlider2D(center=(0, 0), initial_value=50, min_value=0, max_value=100, length=200, line_width=5, inner_radius=0, outer_radius=10, handle_side=20, font_size=16, orientation='horizontal', text_alignment='', text_template='{value:.1f} ({ratio:.0%})', shape='disk')[source]#
Bases:
UI
A 2D Line Slider.
A sliding handle on a line with a percentage indicator.
- track#
The line on which the slider’s handle moves.
- Type:
- text#
The text that shows percentage.
- Type:
- shape#
Describes the shape of the handle. Currently supports ‘disk’ and ‘square’.
- Type:
string
- __init__(center=(0, 0), initial_value=50, min_value=0, max_value=100, length=200, line_width=5, inner_radius=0, outer_radius=10, handle_side=20, font_size=16, orientation='horizontal', text_alignment='', text_template='{value:.1f} ({ratio:.0%})', shape='disk')[source]#
Init this UI element.
- Parameters:
initial_value (float) – Initial value of the slider.
min_value (float) – Minimum value of the slider.
max_value (float) – Maximum value of the slider.
length (int) – Length of the slider.
line_width (int) – Width of the line on which the disk will slide.
inner_radius (int) – Inner radius of the handles (if disk).
outer_radius (int) – Outer radius of the handles (if disk).
handle_side (int) – Side length of the handles (if sqaure).
font_size (int) – Size of the text to display alongside the slider (pt).
orientation (str) – horizontal or vertical
text_alignment (str) – define text alignment on a slider. Left (default)/ right for the vertical slider or top/bottom (default) for an horizontal slider.
text_template (str, callable) – If str, text template can contain one or multiple of the replacement fields: {value:}, {ratio:}. If callable, this instance of :class:LineSlider2D will be passed as argument to the text template function.
shape (string) – Describes the shape of the handle. Currently supports ‘disk’ and ‘square’.
- property bottom_y_position#
- handle_move_callback(i_ren, _vtkactor, _slider)[source]#
Handle movement.
- Parameters:
i_ren (
CustomInteractorStyle
) –vtkactor (
vtkActor
) – The picked actorslider (
LineSlider2D
) –
- handle_release_callback(i_ren, _vtkactor, _slider)[source]#
Change color when handle is released.
- Parameters:
i_ren (
CustomInteractorStyle
) –vtkactor (
vtkActor
) – The picked actorslider (
LineSlider2D
) –
- property left_x_position#
- property ratio#
- property right_x_position#
- property top_y_position#
- track_click_callback(i_ren, _vtkactor, _slider)[source]#
Update disk position and grab the focus.
- Parameters:
i_ren (
CustomInteractorStyle
) –vtkactor (
vtkActor
) – The picked actor_slider (
LineSlider2D
) –
- property value#
ListBox2D
#
- class fury.ui.elements.ListBox2D(values, position=(0, 0), size=(100, 300), multiselection=True, reverse_scrolling=False, font_size=20, line_spacing=1.4, text_color=(0.2, 0.2, 0.2), selected_color=(0.9, 0.6, 0.6), unselected_color=(0.6, 0.6, 0.6), scroll_bar_active_color=(0.6, 0.2, 0.2), scroll_bar_inactive_color=(0.9, 0.0, 0.0), background_opacity=1.0)[source]#
Bases:
UI
UI component that allows the user to select items from a list.
- on_change#
Callback function for when the selected items have changed.
- Type:
function
- __init__(values, position=(0, 0), size=(100, 300), multiselection=True, reverse_scrolling=False, font_size=20, line_spacing=1.4, text_color=(0.2, 0.2, 0.2), selected_color=(0.9, 0.6, 0.6), unselected_color=(0.6, 0.6, 0.6), scroll_bar_active_color=(0.6, 0.2, 0.2), scroll_bar_inactive_color=(0.9, 0.0, 0.0), background_opacity=1.0)[source]#
Init class instance.
- Parameters:
values (list of objects) – Values used to populate this listbox. Objects must be castable to string.
position ((float, float)) – Absolute coordinates (x, y) of the lower-left corner of this UI component.
size ((int, int)) – Width and height in pixels of this UI component.
multiselection ({True, False}) – Whether multiple values can be selected at once.
reverse_scrolling ({True, False}) – If True, scrolling up will move the list of files down.
font_size (int) – The font size in pixels.
line_spacing (float) – Distance between listbox’s items in pixels.
text_color (tuple of 3 floats) –
selected_color (tuple of 3 floats) –
unselected_color (tuple of 3 floats) –
scroll_bar_active_color (tuple of 3 floats) –
scroll_bar_inactive_color (tuple of 3 floats) –
background_opacity (float) –
- down_button_callback(i_ren, _obj, _list_box)[source]#
Pressing down button scrolls down in the combo box.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_list_box (
ListBox2D
) –
- scroll_click_callback(i_ren, _obj, _rect_obj)[source]#
Callback to change the color of the bar when it is clicked.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_rect_obj (
Rectangle2D
) –
- scroll_drag_callback(i_ren, _obj, _rect_obj)[source]#
Drag scroll bar in the combo box.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actorrect_obj (
Rectangle2D
) –
- scroll_release_callback(i_ren, _obj, _rect_obj)[source]#
Callback to change the color of the bar when it is released.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actorrect_obj (
Rectangle2D
) –
- select(item, multiselect=False, range_select=False)[source]#
Select the item.
- Parameters:
item (ListBoxItem2D's object) – Item to select.
multiselect ({True, False}) – If True and multiselection is allowed, the item is added to the selection. Otherwise, the selection will only contain the provided item unless range_select is True.
range_select ({True, False}) – If True and multiselection is allowed, all items between the last selected item and the current one will be added to the selection. Otherwise, the selection will only contain the provided item unless multi_select is True.
ListBoxItem2D
#
- class fury.ui.elements.ListBoxItem2D(list_box, size, text_color=(1.0, 0.0, 0.0), selected_color=(0.4, 0.4, 0.4), unselected_color=(0.9, 0.9, 0.9), background_opacity=1.0)[source]#
Bases:
UI
The text displayed in a listbox.
- __init__(list_box, size, text_color=(1.0, 0.0, 0.0), selected_color=(0.4, 0.4, 0.4), unselected_color=(0.9, 0.9, 0.9), background_opacity=1.0)[source]#
Init ListBox Item instance.
- property element#
- left_button_clicked(i_ren, _obj, _list_box_item)[source]#
Handle left click for this UI element.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_list_box_item (
ListBoxItem2D
) –
Number
#
Option
#
- class fury.ui.elements.Option(label, position=(0, 0), font_size=18, checked=False)[source]#
Bases:
UI
A set of a Button2D and a TextBlock2D to act as a single option for checkboxes and radio buttons. Clicking the button toggles its checked/unchecked status.
OrderedDict
#
- class fury.ui.elements.OrderedDict[source]#
Bases:
dict
Dictionary that remembers insertion order
- __init__(*args, **kwargs)#
- clear() None. Remove all items from od. #
- copy() a shallow copy of od #
- fromkeys(value=None)#
Create a new ordered dictionary with keys from iterable and values set to value.
- items() a set-like object providing a view on D's items #
- keys() a set-like object providing a view on D's keys #
- move_to_end(key, last=True)#
Move an existing element to the end (or beginning if last is false).
Raise KeyError if the element does not exist.
- pop(k[, d]) v, remove specified key and return the corresponding #
value. If key is not found, d is returned if given, otherwise KeyError is raised.
- popitem(last=True)#
Remove and return a (key, value) pair from the dictionary.
Pairs are returned in LIFO order if last is true or FIFO order if false.
- setdefault(key, default=None)#
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from dict/iterable E and F. #
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values #
Panel2D
#
- class fury.ui.elements.Panel2D(size, position=(0, 0), color=(0.1, 0.1, 0.1), opacity=0.7, align='left', border_color=(1, 1, 1), border_width=0, has_border=False)[source]#
Bases:
UI
A 2D UI Panel.
Can contain one or more UI elements.
- alignment#
Alignment of the panel with respect to the overall screen.
- Type:
[left, right]
- __init__(size, position=(0, 0), color=(0.1, 0.1, 0.1), opacity=0.7, align='left', border_color=(1, 1, 1), border_width=0, has_border=False)[source]#
Init class instance.
- Parameters:
size ((int, int)) – Size (width, height) in pixels of the panel.
position ((float, float)) – Absolute coordinates (x, y) of the lower-left corner of the panel.
opacity (float) – Must take values in [0, 1].
align ([left, right]) – Alignment of the panel with respect to the overall screen.
border_color ((float, float, float), optional) – Must take values in [0, 1].
border_width (float, optional) – width of the border
has_border (bool, optional) – If the panel should have borders.
- add_element(element, coords, anchor='position')[source]#
Add a UI component to the panel.
The coordinates represent an offset from the lower left corner of the panel.
- property border_color#
- property border_width#
- property color#
- property opacity#
- remove_element(element)[source]#
Remove a UI component from the panel.
- Parameters:
element (UI) – The UI item to be removed.
PlaybackPanel
#
- class fury.ui.elements.PlaybackPanel(loop=False, position=(0, 0), width=None)[source]#
Bases:
UI
A playback controller that can do essential functionalities. such as play, pause, stop, and seek.
- property current_time#
Get current time of the progress slider.
- Returns:
Progress slider current value.
- Return type:
- property current_time_str#
Returns current time as a string.
- Returns:
Current time formatted as a string in the form:HH:MM:SS.
- Return type:
- property final_time#
Set final progress slider time value.
- Returns:
Final time for the progress slider.
- Return type:
- property speed#
Returns current speed.
- Returns:
Current time formatted as a string in the form:HH:MM:SS.
- Return type:
RadioButton
#
- class fury.ui.elements.RadioButton(labels, checked_labels, padding=1, font_size=18, font_family='Arial', position=(0, 0))[source]#
Bases:
Checkbox
A 2D set of :class:’Option’ objects. Only one option can be selected.
- __init__(labels, checked_labels, padding=1, font_size=18, font_family='Arial', position=(0, 0))[source]#
Init class instance.
- Parameters:
checked_labels (list(str), optional) – List of labels that are checked on setting up.
padding (float, optional) – The distance between two adjacent options
font_size (int, optional) – Size of the text font.
font_family (str, optional) – Currently only supports Arial.
position ((float, float), optional) – Absolute coordinates (x, y) of the lower-left corner of the button of the first option.
RangeSlider
#
- class fury.ui.elements.RangeSlider(line_width=5, inner_radius=0, outer_radius=10, handle_side=20, range_slider_center=(450, 400), value_slider_center=(450, 300), length=200, min_value=0, max_value=100, font_size=16, range_precision=1, orientation='horizontal', value_precision=2, shape='disk')[source]#
Bases:
UI
A set of a LineSlider2D and a LineDoubleSlider2D. The double slider is used to set the min and max value for the LineSlider2D
- range_slider#
The line slider which sets the min and max values
- Type:
- value_slider#
The line slider which sets the value
- Type:
- __init__(line_width=5, inner_radius=0, outer_radius=10, handle_side=20, range_slider_center=(450, 400), value_slider_center=(450, 300), length=200, min_value=0, max_value=100, font_size=16, range_precision=1, orientation='horizontal', value_precision=2, shape='disk')[source]#
Init this class instance.
- Parameters:
line_width (int) – Width of the slider tracks
inner_radius (int) – Inner radius of the handles.
outer_radius (int) – Outer radius of the handles.
handle_side (int) – Side length of the handles (if square).
range_slider_center ((float, float)) – Center of the LineDoubleSlider2D object.
value_slider_center ((float, float)) – Center of the LineSlider2D object.
length (int) – Length of the sliders.
min_value (float) – Minimum value of the double slider.
max_value (float) – Maximum value of the double slider.
font_size (int) – Size of the text to display alongside the sliders (pt).
range_precision (int) – Number of decimal places to show the min and max values set.
orientation (str) – horizontal or vertical
value_precision (int) – Number of decimal places to show the value set on slider.
shape (string) – Describes the shape of the handle. Currently supports ‘disk’ and ‘square’.
- range_slider_handle_move_callback(i_ren, obj, _slider)[source]#
Update range_slider’s handles.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_slider (
RangeSlider
) –
Rectangle2D
#
- class fury.ui.elements.Rectangle2D(size=(0, 0), position=(0, 0), color=(1, 1, 1), opacity=1.0)[source]#
Bases:
UI
A 2D rectangle sub-classed from UI.
- __init__(size=(0, 0), position=(0, 0), color=(1, 1, 1), opacity=1.0)[source]#
Initialize a rectangle.
- property color#
Get the rectangle’s color.
- property height#
- property opacity#
Get the rectangle’s opacity.
- property width#
RingSlider2D
#
- class fury.ui.elements.RingSlider2D(center=(0, 0), initial_value=180, min_value=0, max_value=360, slider_inner_radius=40, slider_outer_radius=44, handle_inner_radius=0, handle_outer_radius=10, font_size=16, text_template='{ratio:.0%}')[source]#
Bases:
UI
A disk slider.
A disk moves along the boundary of a ring. Goes from 0-360 degrees.
- text#
The text that shows percentage.
- Type:
- __init__(center=(0, 0), initial_value=180, min_value=0, max_value=360, slider_inner_radius=40, slider_outer_radius=44, handle_inner_radius=0, handle_outer_radius=10, font_size=16, text_template='{ratio:.0%}')[source]#
Init this UI element.
- Parameters:
center ((float, float)) – Position (x, y) of the slider’s center.
initial_value (float) – Initial value of the slider.
min_value (float) – Minimum value of the slider.
max_value (float) – Maximum value of the slider.
slider_inner_radius (int) – Inner radius of the base disk.
slider_outer_radius (int) – Outer radius of the base disk.
handle_outer_radius (int) – Outer radius of the slider’s handle.
handle_inner_radius (int) – Inner radius of the slider’s handle.
font_size (int) – Size of the text to display alongside the slider (pt).
text_template (str, callable) – If str, text template can contain one or multiple of the replacement fields: {value:}, {ratio:}, {angle:}. If callable, this instance of :class:RingSlider2D will be passed as argument to the text template function.
- property angle#
Return Angle (in rad) the handle makes with x-axis.
- handle_move_callback(i_ren, _obj, _slider)[source]#
Move the slider’s handle.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_slider (
RingSlider2D
) –
- handle_release_callback(i_ren, _obj, _slider)[source]#
Change color when handle is released.
- Parameters:
i_ren (
CustomInteractorStyle
) –vtkactor (
vtkActor
) – The picked actor_slider (
RingSlider2D
) –
- property mid_track_radius#
- property previous_value#
- property ratio#
- track_click_callback(i_ren, _obj, _slider)[source]#
Update disk position and grab the focus.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_slider (
RingSlider2D
) –
- property value#
TextBlock2D
#
- class fury.ui.elements.TextBlock2D(text='Text Block', font_size=18, font_family='Arial', justification='left', vertical_justification='bottom', bold=False, italic=False, shadow=False, size=None, color=(1, 1, 1), bg_color=None, position=(0, 0))[source]#
Bases:
UI
Wrap over the default vtkTextActor and helps setting the text.
Contains member functions for text formatting.
- actor#
The text actor.
- Type:
vtkTextActor
- __init__(text='Text Block', font_size=18, font_family='Arial', justification='left', vertical_justification='bottom', bold=False, italic=False, shadow=False, size=None, color=(1, 1, 1), bg_color=None, position=(0, 0))[source]#
Init class instance.
- Parameters:
text (str) – The initial text while building the actor.
color ((float, float, float)) – RGB: Values must be between 0-1.
bg_color ((float, float, float)) – RGB: Values must be between 0-1.
font_size (int) – Size of the text font.
font_family (str) – Currently only supports Arial.
justification (str) – left, right or center.
vertical_justification (str) – bottom, middle or top.
bold (bool) – Makes text bold.
italic (bool) – Makes text italicised.
shadow (bool) – Adds text shadow.
size ((int, int)) – Size (width, height) in pixels of the text bounding box.
- property background_color#
Get background color.
- property color#
Get text color.
- property italic#
Return whether the text is italicised.
- Returns:
Text is italicised if True.
- Return type:
- property shadow#
Return whether the text has shadow.
- Returns:
Text is shadowed if True.
- Return type:
TextBox2D
#
- class fury.ui.elements.TextBox2D(width, height, text='Enter Text', position=(100, 10), color=(0, 0, 0), font_size=18, font_family='Arial', justification='left', bold=False, italic=False, shadow=False)[source]#
Bases:
UI
An editable 2D text box that behaves as a UI component.
Currently supports: - Basic text editing. - Cursor movements. - Single and multi-line text boxes. - Pre text formatting (text needs to be formatted beforehand).
- actor#
The text actor.
- Type:
vtkActor2d
- __init__(width, height, text='Enter Text', position=(100, 10), color=(0, 0, 0), font_size=18, font_family='Arial', justification='left', bold=False, italic=False, shadow=False)[source]#
Init this UI element.
- Parameters:
width (int) – The number of characters in a single line of text.
height (int) – The number of lines in the textbox.
text (str) – The initial text while building the actor.
color ((float, float, float)) – RGB: Values must be between 0-1.
font_size (int) – Size of the text font.
font_family (str) – Currently only supports Arial.
justification (str) – left, right or center.
bold (bool) – Makes text bold.
italic (bool) – Makes text italicised.
shadow (bool) – Adds text shadow.
- add_character(character)[source]#
Insert a character into the text and moves window and caret.
- Parameters:
character (str) –
- handle_character(key, key_char)[source]#
Handle button events.
# TODO: Need to handle all kinds of characters like !, +, etc.
- Parameters:
character (str) –
- key_press(i_ren, _obj, _textbox_object)[source]#
Handle Key press for textboxself.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_textbox_object (
TextBox2D
) –
- left_button_press(i_ren, _obj, _textbox_object)[source]#
Handle left button press for textbox.
- Parameters:
i_ren (
CustomInteractorStyle
) –obj (
vtkActor
) – The picked actor_textbox_object (
TextBox2D
) –
- render_text(show_caret=True)[source]#
Render text after processing.
- Parameters:
show_caret (bool) – Whether or not to show the caret.
- set_message(