diff --git a/docs/examples/viz_layout.py b/docs/examples/viz_layout.py index c7fd19e92..1859caf96 100644 --- a/docs/examples/viz_layout.py +++ b/docs/examples/viz_layout.py @@ -6,40 +6,41 @@ This example shows how to place different UI elements in different Layouts. The Layouts used here is GridLayout (with different cell shapes). -First, some imports. +First, let's import fury. """ -from fury import ui, window -from fury.layout import GridLayout +import fury ############################################################################### # We create some panels and then we arrange them in a grid fashion # # First, we create some panels with different sizes/positions -panel_1 = ui.Panel2D(size=(200, 200), color=(0.4, 0.6, 0.3), position=(100, 100)) +panel_1 = fury.ui.Panel2D(size=(200, 200), color=(0.4, 0.6, 0.3), position=(100, 100)) -panel_2 = ui.Panel2D(size=(250, 250), color=(0.8, 0.3, 0.5), position=(150, 150)) +panel_2 = fury.ui.Panel2D(size=(250, 250), color=(0.8, 0.3, 0.5), position=(150, 150)) ############################################################################### # Now we create two listboxes -listbox_1 = ui.ListBox2D(size=(150, 150), values=["First", "Second", "Third"]) +listbox_1 = fury.ui.ListBox2D(size=(150, 150), values=["First", "Second", "Third"]) -listbox_2 = ui.ListBox2D(size=(250, 250), values=["First", "Second", "Third"]) +listbox_2 = fury.ui.ListBox2D(size=(250, 250), values=["First", "Second", "Third"]) ############################################################################### # Now we create two different UI i.e. a slider and a listbox -slider = ui.LineSlider2D(length=150) -listbox = ui.ListBox2D(size=(150, 150), values=["First", "Second", "Third"]) +slider = fury.ui.LineSlider2D(length=150) +listbox = fury.ui.ListBox2D(size=(150, 150), values=["First", "Second", "Third"]) ############################################################################### # Now, we create grids with different shapes -rect_grid = GridLayout(position_offset=(0, 0, 0)) -square_grid = GridLayout(cell_shape="square", position_offset=(0, 300, 0)) -diagonal_grid = GridLayout(cell_shape="diagonal", position_offset=(0, 600, 0)) +rect_grid = fury.layout.GridLayout(position_offset=(0, 0, 0)) +square_grid = fury.layout.GridLayout(cell_shape="square", position_offset=(0, 300, 0)) +diagonal_grid = fury.layout.GridLayout( + cell_shape="diagonal", position_offset=(0, 600, 0) +) ############################################################################### @@ -50,7 +51,7 @@ diagonal_grid.apply([slider, listbox]) current_size = (1500, 1500) -show_manager = window.ShowManager(size=current_size, title="FURY UI Layout") +show_manager = fury.window.ShowManager(size=current_size, title="FURY UI Layout") show_manager.scene.add(panel_1, panel_2, listbox_1, listbox_2, slider, listbox) @@ -60,4 +61,4 @@ if interactive: show_manager.start() -window.record(show_manager.scene, out_path="ui_layout.png", size=(400, 400)) +fury.window.record(show_manager.scene, out_path="ui_layout.png", size=(400, 400)) diff --git a/docs/examples/viz_markers.py b/docs/examples/viz_markers.py index 600296c2d..5a532598d 100644 --- a/docs/examples/viz_markers.py +++ b/docs/examples/viz_markers.py @@ -8,7 +8,7 @@ import numpy as np -from fury import actor, window +import fury n = 10000 @@ -26,7 +26,7 @@ ############################################################################ # You can control the edge color and edge width for each marker -nodes_actor = actor.markers( +nodes_actor = fury.actor.markers( centers, marker=markers, edge_width=0.1, @@ -38,14 +38,14 @@ ############################################################################ # In addition, an 3D sphere it's also a valid type of marker -nodes_3d_actor = actor.markers( +nodes_3d_actor = fury.actor.markers( centers + np.ones_like(centers) * 25, marker="3d", colors=colors, scales=0.5, ) -scene = window.Scene() +scene = fury.window.Scene() scene.add(nodes_actor) scene.add(nodes_3d_actor) @@ -53,6 +53,6 @@ interactive = False if interactive: - window.show(scene, size=(600, 600)) + fury.window.show(scene, size=(600, 600)) -window.record(scene, out_path="viz_markers.png", size=(600, 600)) +fury.window.record(scene, out_path="viz_markers.png", size=(600, 600)) diff --git a/docs/examples/viz_morphing.py b/docs/examples/viz_morphing.py index 9bf996759..ecd229e6a 100644 --- a/docs/examples/viz_morphing.py +++ b/docs/examples/viz_morphing.py @@ -5,22 +5,20 @@ In this tutorial, we will show how to use morphing in a glTF model in FURY. """ -from fury import window -from fury.data import fetch_gltf, read_viz_gltf -from fury.gltf import glTF +import fury ############################################################################## # Retrieving the model with morphing in it (look at Khronoos samples). # We're choosing the `MorphStressTest` model here. -fetch_gltf("MorphStressTest", "glTF") -filename = read_viz_gltf("MorphStressTest") +fury.data.fetch_gltf("MorphStressTest", "glTF") +filename = fury.data.read_viz_gltf("MorphStressTest") ############################################################################## # Initializing the glTF object, You can additionally set `apply_normals=True`. # Note: Normals might not work as intended with morphing. -gltf_obj = glTF(filename, apply_normals=True) +gltf_obj = fury.gltf.glTF(filename, apply_normals=True) ############################################################################## # Get the morph timeline using `morph_timeline` method, Choose the animation @@ -40,8 +38,8 @@ # Initialize the show manager and add timeline to the scene (No need to add # actors to the scene separately). -scene = window.Scene() -showm = window.ShowManager( +scene = fury.window.Scene() +showm = fury.window.ShowManager( scene, size=(900, 768), reset_camera=True, order_transparent=True ) @@ -71,4 +69,4 @@ def timer_callback(_obj, _event): if interactive: showm.start() -window.record(scene, out_path="viz_morphing.png", size=(900, 768)) +fury.window.record(scene, out_path="viz_morphing.png", size=(900, 768)) diff --git a/docs/examples/viz_multithread.py b/docs/examples/viz_multithread.py index 33060f75f..2d491eefe 100644 --- a/docs/examples/viz_multithread.py +++ b/docs/examples/viz_multithread.py @@ -15,29 +15,29 @@ import numpy as np -from fury import actor, ui, window +import fury # Preparing to draw some spheres xyz = 10 * (np.random.random((100, 3)) - 0.5) colors = np.random.random((100, 4)) radii = np.random.random(100) + 0.5 -scene = window.Scene() -sphere_actor = actor.sphere( +scene = fury.window.Scene() +sphere_actor = fury.actor.sphere( centers=xyz, colors=colors, radii=radii, use_primitive=False ) scene.add(sphere_actor) # Preparing the show manager as usual -showm = window.ShowManager( +showm = fury.window.ShowManager( scene, size=(900, 768), reset_camera=False, order_transparent=True ) # showm.initialize() # Creating a text block to show a message and reset the camera -tb = ui.TextBlock2D(bold=True) +tb = fury.ui.TextBlock2D(bold=True) scene.add(tb) scene.ResetCamera() @@ -77,7 +77,7 @@ def add_remove_axes(): for i in range(100): if showm.lock_current(): if current_axes is None: - current_axes = actor.axes(scale=(0.20 * i, 0.20 * i, 0.20 * i)) + current_axes = fury.actor.axes(scale=(0.20 * i, 0.20 * i, 0.20 * i)) scene.add(current_axes) pass else: diff --git a/docs/examples/viz_network.py b/docs/examples/viz_network.py index 13140a96f..c6189fb67 100644 --- a/docs/examples/viz_network.py +++ b/docs/examples/viz_network.py @@ -15,14 +15,12 @@ import numpy as np -from fury import actor, colormap as cmap, window -from fury.data import fetch_viz_wiki_nw +import fury ############################################################################### # Then let's download some available datasets. - -files, folder = fetch_viz_wiki_nw() +files, folder = fury.data.fetch_viz_wiki_nw() categories_file, edges_file, positions_file = sorted(files.keys()) ############################################################################### @@ -40,7 +38,7 @@ index2category = np.unique(categories) -categoryColors = cmap.distinguishable_colormap(nb_colors=len(index2category)) +categoryColors = fury.colormap.distinguishable_colormap(nb_colors=len(index2category)) colors = np.array([categoryColors[category2index[category]] for category in categories]) @@ -68,7 +66,7 @@ # build 2 actors that we represent our data : sphere_actor for the nodes and # lines_actor for the edges. -sphere_actor = actor.sphere( +sphere_actor = fury.actor.sphere( centers=positions, colors=colors, radii=radii * 0.5, @@ -76,7 +74,7 @@ phi=8, ) -lines_actor = actor.line( +lines_actor = fury.actor.line( edgesPositions, colors=edgesColors, opacity=0.1, @@ -86,7 +84,7 @@ # All actors need to be added in a scene, so we build one and add our # lines_actor and sphere_actor. -scene = window.Scene() +scene = fury.window.Scene() scene.add(lines_actor) scene.add(sphere_actor) @@ -98,9 +96,9 @@ interactive = False if interactive: - window.show(scene, size=(600, 600)) + fury.window.show(scene, size=(600, 600)) -window.record(scene, out_path="journal_networks.png", size=(600, 600)) +fury.window.record(scene, out_path="journal_networks.png", size=(600, 600)) ############################################################################### # This example can be improved by adding some interactivy with slider, diff --git a/docs/examples/viz_network_animated.py b/docs/examples/viz_network_animated.py index d68a19e4c..2f144a411 100644 --- a/docs/examples/viz_network_animated.py +++ b/docs/examples/viz_network_animated.py @@ -18,8 +18,7 @@ import numpy as np -from fury import actor, colormap as cmap, window -from fury.utils import compute_bounds, update_actor, vertices_from_actor +import fury ############################################################################### # This demo has two modes. @@ -72,7 +71,7 @@ index2category = np.unique(categories) -category_colors = cmap.distinguishable_colormap(nb_colors=len(index2category)) +category_colors = fury.colormap.distinguishable_colormap(nb_colors=len(index2category)) colors = np.array( [category_colors[category2index[category]] for category in categories] @@ -98,12 +97,12 @@ # build 2 actors that we represent our data : sphere_actor for the nodes and # lines_actor for the edges. -sphere_actor = actor.sphere( +sphere_actor = fury.actor.sphere( centers=np.zeros(positions.shape), colors=colors, radii=radii * 0.5, theta=8, phi=8 ) -lines_actor = actor.line( +lines_actor = fury.actor.line( np.zeros((len(edges), 2, 3)), colors=edges_colors, lod=False, @@ -129,7 +128,7 @@ def new_layout_timer( b = 1.0 deltaT = 1.0 - sphere_geometry = np.array(vertices_from_actor(sphere_actor)) + sphere_geometry = np.array(fury.utils.vertices_from_actor(sphere_actor)) geometry_length = sphere_geometry.shape[0] / vertices_count if vertex_initial_positions is not None: @@ -199,18 +198,18 @@ def _timer(_obj, _event): iterate(1) else: pos[:] += (np.random.random(pos.shape) - 0.5) * 1.5 - spheres_positions = vertices_from_actor(sphere_actor) + spheres_positions = fury.utils.vertices_from_actor(sphere_actor) spheres_positions[:] = sphere_geometry + np.repeat(pos, geometry_length, axis=0) - edges_positions = vertices_from_actor(lines_actor) + edges_positions = fury.utils.vertices_from_actor(lines_actor) edges_positions[::2] = pos[edges_list[:, 0]] edges_positions[1::2] = pos[edges_list[:, 1]] - update_actor(lines_actor) - compute_bounds(lines_actor) + fury.utils.update_actor(lines_actor) + fury.utils.compute_bounds(lines_actor) - update_actor(sphere_actor) - compute_bounds(lines_actor) + fury.utils.update_actor(sphere_actor) + fury.utils.compute_bounds(lines_actor) showm.scene.reset_clipping_range() showm.render() @@ -225,7 +224,7 @@ def _timer(_obj, _event): # lines_actor and sphere_actor. -scene = window.Scene() +scene = fury.window.Scene() camera = scene.camera() @@ -238,7 +237,7 @@ def _timer(_obj, _event): # parameter max_iteractions of the timer callback to let the animation run for # more time. -showm = window.ShowManager( +showm = fury.window.ShowManager( scene, reset_camera=False, size=(900, 768), order_transparent=True, multi_samples=8 ) @@ -255,4 +254,4 @@ def _timer(_obj, _event): showm.start() -window.record(showm.scene, size=(900, 768), out_path="viz_animated_networks.png") +fury.window.record(showm.scene, size=(900, 768), out_path="viz_animated_networks.png") diff --git a/docs/examples/viz_no_interaction.py b/docs/examples/viz_no_interaction.py index d68b70076..1a968a5ef 100644 --- a/docs/examples/viz_no_interaction.py +++ b/docs/examples/viz_no_interaction.py @@ -12,10 +12,7 @@ # multiprocessing.set_start_method('spawn') import numpy as np -from fury import actor, colormap as cmap, window -from fury.data.fetcher import fetch_viz_wiki_nw -from fury.stream.client import FuryStreamClient -from fury.stream.server.main import web_server_raw_array +import fury if __name__ == "__main__": interactive = False @@ -24,7 +21,7 @@ window_size = (400, 400) - files, folder = fetch_viz_wiki_nw() + files, folder = fury.data.fetch_viz_wiki_nw() categories_file, edges_file, positions_file = sorted(files.keys()) positions = np.loadtxt(pjoin(folder, positions_file)) categories = np.loadtxt(pjoin(folder, categories_file), dtype=str) @@ -33,7 +30,9 @@ index2category = np.unique(categories) - categoryColors = cmap.distinguishable_colormap(nb_colors=len(index2category)) + categoryColors = fury.colormap.distinguishable_colormap( + nb_colors=len(index2category) + ) colors = np.array( [categoryColors[category2index[category]] for category in categories] @@ -49,19 +48,19 @@ edgesPositions = np.array(edgesPositions) edgesColors = np.average(np.array(edgesColors), axis=1) - sphere_actor = actor.sdf( + sphere_actor = fury.actor.sdf( centers=positions, colors=colors, primitives="sphere", scales=radii * 0.5, ) - lines_actor = actor.line( + lines_actor = fury.actor.line( edgesPositions, colors=edgesColors, opacity=0.1, ) - scene = window.Scene() + scene = fury.window.Scene() scene.add(lines_actor) scene.add(sphere_actor) @@ -70,7 +69,7 @@ position=(0, 0, 1000), focal_point=(0.0, 0.0, 0.0), view_up=(0.0, 0.0, 0.0) ) - showm = window.ShowManager( + showm = fury.window.ShowManager( scene, reset_camera=False, size=(window_size[0], window_size[1]), @@ -82,9 +81,9 @@ ms = 0 - stream = FuryStreamClient(showm, use_raw_array=True) + stream = fury.stream.FuryStreamClient(showm, use_raw_array=True) p = multiprocessing.Process( - target=web_server_raw_array, + target=fury.stream.server.web_server_raw_array, args=( stream.img_manager.image_buffers, stream.img_manager.info_buffer, @@ -100,4 +99,4 @@ stream.stop() stream.cleanup() - window.record(showm.scene, size=window_size, out_path="viz_no_interaction.png") + fury.window.record(showm.scene, size=window_size, out_path="viz_no_interaction.png") diff --git a/docs/examples/viz_pbr_interactive.py b/docs/examples/viz_pbr_interactive.py index 3238e8ac5..768363919 100644 --- a/docs/examples/viz_pbr_interactive.py +++ b/docs/examples/viz_pbr_interactive.py @@ -9,14 +9,7 @@ Let's start by importing the necessary modules: """ -from fury import actor, material, ui, window -from fury.data import fetch_viz_cubemaps, read_viz_cubemap -from fury.io import load_cubemap_texture -from fury.utils import ( - normals_from_actor, - tangents_from_direction_of_anisotropy, - tangents_to_actor, -) +import fury ############################################################################### # The following functions will help us to manage the sliders events. @@ -40,22 +33,22 @@ def change_slice_anisotropy(slider): def change_slice_anisotropy_direction_x(slider): global doa, normals, sphere doa[0] = slider.value - tangents = tangents_from_direction_of_anisotropy(normals, doa) - tangents_to_actor(sphere, tangents) + tangents = fury.utils.tangents_from_direction_of_anisotropy(normals, doa) + fury.utils.tangents_to_actor(sphere, tangents) def change_slice_anisotropy_direction_y(slider): global doa, normals, sphere doa[1] = slider.value - tangents = tangents_from_direction_of_anisotropy(normals, doa) - tangents_to_actor(sphere, tangents) + tangents = fury.utils.tangents_from_direction_of_anisotropy(normals, doa) + fury.utils.tangents_to_actor(sphere, tangents) def change_slice_anisotropy_direction_z(slider): global doa, normals, sphere doa[2] = slider.value - tangents = tangents_from_direction_of_anisotropy(normals, doa) - tangents_to_actor(sphere, tangents) + tangents = fury.utils.tangents_from_direction_of_anisotropy(normals, doa) + fury.utils.tangents_to_actor(sphere, tangents) def change_slice_anisotropy_rotation(slider): @@ -100,19 +93,19 @@ def win_callback(obj, event): ############################################################################### # Let's fetch a skybox texture from the FURY data repository. -fetch_viz_cubemaps() +fury.data.fetch_viz_cubemaps() ############################################################################### # The following function returns the full path of the 6 images composing the # skybox. -textures = read_viz_cubemap("skybox") +textures = fury.data.read_viz_cubemap("skybox") ############################################################################### # Now that we have the location of the textures, let's load them and create a # Cube Map Texture object. -cubemap = load_cubemap_texture(textures) +cubemap = fury.io.load_cubemap_texture(textures) ############################################################################### # The Scene object in FURY can handle cube map textures and extract light @@ -120,13 +113,13 @@ def win_callback(obj, event): # interactions. The ``skybox`` parameter takes as input a cube map texture and # performs the previously described process. -scene = window.Scene(skybox=cubemap) +scene = fury.window.Scene(skybox=cubemap) ############################################################################### # With the scene created, we can then populate it. In this demo we will only # add a sphere actor. -sphere = actor.sphere([[0, 0, 0]], (0.7, 0.7, 0.7), radii=2, theta=64, phi=64) +sphere = fury.actor.sphere([[0, 0, 0]], (0.7, 0.7, 0.7), radii=2, theta=64, phi=64) ############################################################################### # The direction of anisotropy (DoA) defines the direction at which all the @@ -137,17 +130,17 @@ def win_callback(obj, event): ############################################################################### # The following process gets the normals of the actor and computes the tangents # that are aligned to the provided DoA. Then it registers those tangents to the -# actor. +# fury.actor. -normals = normals_from_actor(sphere) -tangents = tangents_from_direction_of_anisotropy(normals, doa) -tangents_to_actor(sphere, tangents) +normals = fury.utils.normals_from_actor(sphere) +tangents = fury.utils.tangents_from_direction_of_anisotropy(normals, doa) +fury.utils.tangents_to_actor(sphere, tangents) ############################################################################### # With the tangents computed and in place, we have all the elements needed to # add some material properties to the actor. -pbr_params = material.manifest_pbr(sphere) +pbr_params = fury.material.manifest_pbr(sphere) ############################################################################### # Our actor is now ready to be added to the scene. @@ -157,7 +150,7 @@ def win_callback(obj, event): ############################################################################### # Let's setup now the window and the UI. -show_m = window.ShowManager( +show_m = fury.window.ShowManager( scene=scene, size=(1920, 1080), reset_camera=False, order_transparent=True ) @@ -165,7 +158,7 @@ def win_callback(obj, event): ############################################################################### # We will create one single panel with all of our labels and sliders. -control_panel = ui.Panel2D( +control_panel = fury.ui.Panel2D( (400, 500), position=(5, 5), color=(0.25, 0.25, 0.25), opacity=0.75, align="right" ) @@ -173,25 +166,25 @@ def win_callback(obj, event): # By using our previously defined function, we can easily create all the labels # we need for this demo. And then add them to the panel. -slider_label_metallic = ui.TextBlock2D(text="Metallic", font_size=16) -slider_label_roughness = ui.TextBlock2D(text="Roughness", font_size=16) -slider_label_anisotropy = ui.TextBlock2D(text="Anisotropy", font_size=16) -slider_label_anisotropy_rotation = ui.TextBlock2D( +slider_label_metallic = fury.ui.TextBlock2D(text="Metallic", font_size=16) +slider_label_roughness = fury.ui.TextBlock2D(text="Roughness", font_size=16) +slider_label_anisotropy = fury.ui.TextBlock2D(text="Anisotropy", font_size=16) +slider_label_anisotropy_rotation = fury.ui.TextBlock2D( text="Anisotropy Rotation", font_size=16 ) -slider_label_anisotropy_direction_x = ui.TextBlock2D( +slider_label_anisotropy_direction_x = fury.ui.TextBlock2D( text="Anisotropy Direction X", font_size=16 ) -slider_label_anisotropy_direction_y = ui.TextBlock2D( +slider_label_anisotropy_direction_y = fury.ui.TextBlock2D( text="Anisotropy Direction Y", font_size=16 ) -slider_label_anisotropy_direction_z = ui.TextBlock2D( +slider_label_anisotropy_direction_z = fury.ui.TextBlock2D( text="Anisotropy Direction Z", font_size=16 ) -slider_label_coat_strength = ui.TextBlock2D(text="Coat Strength", font_size=16) -slider_label_coat_roughness = ui.TextBlock2D(text="Coat Roughness", font_size=16) -slider_label_base_ior = ui.TextBlock2D(text="Base IoR", font_size=16) -slider_label_coat_ior = ui.TextBlock2D(text="Coat IoR", font_size=16) +slider_label_coat_strength = fury.ui.TextBlock2D(text="Coat Strength", font_size=16) +slider_label_coat_roughness = fury.ui.TextBlock2D(text="Coat Roughness", font_size=16) +slider_label_base_ior = fury.ui.TextBlock2D(text="Base IoR", font_size=16) +slider_label_coat_ior = fury.ui.TextBlock2D(text="Coat IoR", font_size=16) control_panel.add_element(slider_label_metallic, (0.01, 0.95)) control_panel.add_element(slider_label_roughness, (0.01, 0.86)) @@ -208,37 +201,37 @@ def win_callback(obj, event): ############################################################################### # Our sliders are created and added to the panel in the following way. -slider_slice_metallic = ui.LineSlider2D( +slider_slice_metallic = fury.ui.LineSlider2D( initial_value=pbr_params.metallic, max_value=1, length=195, text_template="{value:.1f}", ) -slider_slice_roughness = ui.LineSlider2D( +slider_slice_roughness = fury.ui.LineSlider2D( initial_value=pbr_params.roughness, max_value=1, length=195, text_template="{value:.1f}", ) -slider_slice_anisotropy = ui.LineSlider2D( +slider_slice_anisotropy = fury.ui.LineSlider2D( initial_value=pbr_params.anisotropy, max_value=1, length=195, text_template="{value:.1f}", ) -slider_slice_anisotropy_rotation = ui.LineSlider2D( +slider_slice_anisotropy_rotation = fury.ui.LineSlider2D( initial_value=pbr_params.anisotropy_rotation, max_value=1, length=195, text_template="{value:.1f}", ) -slider_slice_coat_strength = ui.LineSlider2D( +slider_slice_coat_strength = fury.ui.LineSlider2D( initial_value=pbr_params.coat_strength, max_value=1, length=195, text_template="{value:.1f}", ) -slider_slice_coat_roughness = ui.LineSlider2D( +slider_slice_coat_roughness = fury.ui.LineSlider2D( initial_value=pbr_params.coat_roughness, max_value=1, length=195, @@ -250,21 +243,21 @@ def win_callback(obj, event): # within that range we cover all the possible 3D directions needed to align the # tangents. -slider_slice_anisotropy_direction_x = ui.LineSlider2D( +slider_slice_anisotropy_direction_x = fury.ui.LineSlider2D( initial_value=doa[0], min_value=-1, max_value=1, length=195, text_template="{value:.1f}", ) -slider_slice_anisotropy_direction_y = ui.LineSlider2D( +slider_slice_anisotropy_direction_y = fury.ui.LineSlider2D( initial_value=doa[1], min_value=-1, max_value=1, length=195, text_template="{value:.1f}", ) -slider_slice_anisotropy_direction_z = ui.LineSlider2D( +slider_slice_anisotropy_direction_z = fury.ui.LineSlider2D( initial_value=doa[2], min_value=-1, max_value=1, @@ -277,14 +270,14 @@ def win_callback(obj, event): # cases, the values are defined in the range [1, 2.3] according to the # documentation of the material. -slider_slice_base_ior = ui.LineSlider2D( +slider_slice_base_ior = fury.ui.LineSlider2D( initial_value=pbr_params.base_ior, min_value=1, max_value=2.3, length=195, text_template="{value:.02f}", ) -slider_slice_coat_ior = ui.LineSlider2D( +slider_slice_coat_ior = fury.ui.LineSlider2D( initial_value=pbr_params.coat_ior, min_value=1, max_value=2.3, @@ -343,4 +336,4 @@ def win_callback(obj, event): if interactive: show_m.start() -window.record(scene, size=(1920, 1080), out_path="viz_pbr_interactive.png") +fury.window.record(scene, size=(1920, 1080), out_path="viz_pbr_interactive.png") diff --git a/docs/examples/viz_pbr_spheres.py b/docs/examples/viz_pbr_spheres.py index 318fcc51e..e0cfa6f59 100644 --- a/docs/examples/viz_pbr_spheres.py +++ b/docs/examples/viz_pbr_spheres.py @@ -17,17 +17,12 @@ import numpy as np -from fury import actor, material, window -from fury.utils import ( - normals_from_actor, - tangents_from_direction_of_anisotropy, - tangents_to_actor, -) +import fury ############################################################################### # Now set up a new scene. -scene = window.Scene() +scene = fury.window.Scene() scene.background((0.9, 0.9, 0.9)) ############################################################################### @@ -59,13 +54,15 @@ center = [[0, -5 * i, 0]] for j in range(num_values): center[0][0] = -25 + 5 * j - sphere = actor.sphere(center, color, radii=2, theta=32, phi=32) - normals = normals_from_actor(sphere) - tangents = tangents_from_direction_of_anisotropy(normals, (0, 1, 0.5)) - tangents_to_actor(sphere, tangents) + sphere = fury.actor.sphere(center, color, radii=2, theta=32, phi=32) + normals = fury.utils.normals_from_actor(sphere) + tangents = fury.utils.tangents_from_direction_of_anisotropy( + normals, (0, 1, 0.5) + ) + fury.utils.tangents_to_actor(sphere, tangents) keys = list(params) params[keys[0]] = np.round(0.1 * j, decimals=1) - material.manifest_pbr(sphere, **params) + fury.material.manifest_pbr(sphere, **params) scene.add(sphere) ############################################################################### @@ -83,12 +80,14 @@ for i, name in enumerate(labels): pos = [-40, -5 * i, 0] - label = actor.vector_text(name, pos=pos, scale=(0.8, 0.8, 0.8), color=(0, 0, 0)) + label = fury.actor.vector_text( + name, pos=pos, scale=(0.8, 0.8, 0.8), color=(0, 0, 0) + ) scene.add(label) for j in range(num_values): pos = [-26 + 5 * j, 3, 0] - label = actor.vector_text( + label = fury.actor.vector_text( str(np.round(j * 0.1, decimals=1)), pos=pos, scale=(0.8, 0.8, 0.8), @@ -123,10 +122,10 @@ center = [[0, -35 - (5 * i), 0]] for j in range(num_values): center[0][0] = -25 + 5 * j - sphere = actor.sphere(center, color, radii=2, theta=32, phi=32) + sphere = fury.actor.sphere(center, color, radii=2, theta=32, phi=32) keys = list(params) params[keys[0]] = iors[j] - material.manifest_pbr(sphere, **params) + fury.material.manifest_pbr(sphere, **params) scene.add(sphere) ############################################################################### @@ -136,12 +135,14 @@ for i, name in enumerate(labels): pos = [-40, -35 - (5 * i), 0] - label = actor.vector_text(name, pos=pos, scale=(0.8, 0.8, 0.8), color=(0, 0, 0)) + label = fury.actor.vector_text( + name, pos=pos, scale=(0.8, 0.8, 0.8), color=(0, 0, 0) + ) scene.add(label) for j in range(num_values): pos = [-26 + 5 * j, -32, 0] - label = actor.vector_text( + label = fury.actor.vector_text( "{:.02f}".format(iors[j]), pos=pos, scale=(0.8, 0.8, 0.8), color=(0, 0, 0) ) scene.add(label) @@ -151,6 +152,6 @@ interactive = False if interactive: - window.show(scene) + fury.window.show(scene) -window.record(scene, size=(600, 600), out_path="viz_pbr_spheres.png") +fury.window.record(scene, size=(600, 600), out_path="viz_pbr_spheres.png") diff --git a/docs/examples/viz_picking.py b/docs/examples/viz_picking.py index 772ca79d5..954cc9d5a 100644 --- a/docs/examples/viz_picking.py +++ b/docs/examples/viz_picking.py @@ -13,7 +13,7 @@ import numpy as np -from fury import actor, pick, ui, utils, window +import fury centers = 0.5 * np.array([[0, 0, 0], [100, 0, 0], [200, 0, 0.0]]) colors = np.array([[0.8, 0, 0], [0, 0.8, 0], [0, 0, 0.8]]) @@ -24,18 +24,18 @@ ############################################################################### # Let's create a panel to show what is picked -panel = ui.Panel2D(size=(400, 200), color=(1, 0.5, 0.0), align="right") +panel = fury.ui.Panel2D(size=(400, 200), color=(1, 0.5, 0.0), align="right") panel.center = (150, 200) -text_block = ui.TextBlock2D(text="Left click on object \n") +text_block = fury.ui.TextBlock2D(text="Left click on object \n") panel.add_element(text_block, (0.3, 0.3)) ############################################################################### # Build scene and add an actor with many objects. -scene = window.Scene() +scene = fury.window.Scene() -label_actor = actor.vector_text(text="Test") +label_actor = fury.actor.vector_text(text="Test") ############################################################################### # This actor is made with 3 cubes of different orientation @@ -47,23 +47,23 @@ [0, np.sqrt(2) / 2, np.sqrt(2) / 2], ] ) -fury_actor = actor.cube(centers, directions, colors, scales=radii) +fury_actor = fury.actor.cube(centers, directions, colors, scales=radii) ############################################################################### # Access the memory of the vertices of all the cubes -vertices = utils.vertices_from_actor(fury_actor) +vertices = fury.utils.vertices_from_actor(fury_actor) num_vertices = vertices.shape[0] num_objects = centers.shape[0] ############################################################################### # Access the memory of the colors of all the cubes -vcolors = utils.colors_from_actor(fury_actor, "colors") +vcolors = fury.utils.colors_from_actor(fury_actor, "colors") ############################################################################### # Adding an actor showing the axes of the world coordinates -ax = actor.axes(scale=(10, 10, 10)) +ax = fury.actor.axes(scale=(10, 10, 10)) scene.add(fury_actor) scene.add(label_actor) @@ -73,7 +73,7 @@ ############################################################################### # Create the Picking manager -pickm = pick.PickingManager() +pickm = fury.pick.PickingManager() ############################################################################### # Time to make the callback which will be called when we pick an object @@ -117,7 +117,7 @@ def left_click_callback(obj, event): vcolors[object_index * sec : object_index * sec + sec] += color_add # Tell actor that memory is modified - utils.update_actor(fury_actor) + fury.utils.update_actor(fury_actor) face_index = picked_info["face"] @@ -139,7 +139,7 @@ def left_click_callback(obj, event): ############################################################################### # Make the window appear -showm = window.ShowManager(scene, size=(1024, 768), order_transparent=True) +showm = fury.window.ShowManager(scene, size=(1024, 768), order_transparent=True) scene.add(panel) @@ -155,4 +155,4 @@ def left_click_callback(obj, event): ############################################################################### # Save the current framebuffer in a PNG file -window.record(showm.scene, size=(1024, 768), out_path="viz_picking.png") +fury.window.record(showm.scene, size=(1024, 768), out_path="viz_picking.png") diff --git a/docs/examples/viz_play_video.py b/docs/examples/viz_play_video.py index 920d2b1a7..dde63d78d 100644 --- a/docs/examples/viz_play_video.py +++ b/docs/examples/viz_play_video.py @@ -12,7 +12,7 @@ import cv2 import numpy as np -from fury import actor, window +import fury # The VideoCapturer Class @@ -48,16 +48,16 @@ def __init__(self, video, time=10): # Initialize Scene self.initialize_scene() # Create a Show Manager and Initialize it - self.show_manager = window.ShowManager( + self.show_manager = fury.window.ShowManager( self.scene, size=(900, 768), reset_camera=False, order_transparent=True ) # Initialize the Scene with actors def initialize_scene(self): - self.scene = window.Scene() + self.scene = fury.window.Scene() # Initialize a Plane actor with the 1st video frame along with # the actor grid which is to be updated in each iteration - self.plane_actor = actor.texture(self.current_video_frame) + self.plane_actor = fury.actor.texture(self.current_video_frame) self.scene.add(self.plane_actor) # The timer_callback function getting called by the show manager @@ -66,7 +66,7 @@ def timer_callback(self, _obj, _event): if isinstance(self.current_video_frame, np.ndarray): # update texture of the actor with the current frame image # by updating the actor grid - actor.texture_update(self.plane_actor, self.current_video_frame) + fury.actor.texture_update(self.plane_actor, self.current_video_frame) self.show_manager.scene.azimuth(1.5) # to rotate the camera else: self.show_manager.exit() @@ -90,4 +90,6 @@ def run(self): ) vp = VideoPlayer(video_url) vp.run() -window.record(vp.show_manager.scene, out_path="viz_play_video.png", size=(600, 600)) +fury.window.record( + vp.show_manager.scene, out_path="viz_play_video.png", size=(600, 600) +) diff --git a/docs/examples/viz_principled_spheres.py b/docs/examples/viz_principled_spheres.py index 018672433..82ded4337 100644 --- a/docs/examples/viz_principled_spheres.py +++ b/docs/examples/viz_principled_spheres.py @@ -21,12 +21,12 @@ import numpy as np -from fury import actor, material, window +import fury ############################################################################### # Now set up a new scene. -scene = window.Scene() +scene = fury.window.Scene() scene.background((0.9, 0.9, 0.9)) ############################################################################### @@ -56,12 +56,12 @@ center = np.array([[0, -5 * i, 0]]) for j in range(11): center[0][0] = -25 + 5 * j - sphere = actor.sphere( + sphere = fury.actor.sphere( center, colors=material_params[i][0], radii=2, theta=32, phi=32 ) keys = list(material_params[i][1]) material_params[i][1][keys[0]] = np.round(0.1 * j, decimals=1) - material.manifest_principled(sphere, **material_params[i][1]) + fury.material.manifest_principled(sphere, **material_params[i][1]) scene.add(sphere) ############################################################################### @@ -82,14 +82,14 @@ for i in range(10): pos = [-40, -5 * i, 0] - label = actor.vector_text( + label = fury.actor.vector_text( labels[i], pos=pos, scale=(0.8, 0.8, 0.8), color=(0, 0, 0) ) scene.add(label) for j in range(11): pos = [-26 + 5 * j, 5, 0] - label = actor.vector_text( + label = fury.actor.vector_text( str(np.round(j * 0.1, decimals=1)), pos=pos, scale=(0.8, 0.8, 0.8), @@ -102,6 +102,6 @@ interactive = False if interactive: - window.show(scene) + fury.window.show(scene) -window.record(scene, size=(600, 600), out_path="viz_principled_spheres.png") +fury.window.record(scene, size=(600, 600), out_path="viz_principled_spheres.png") diff --git a/docs/examples/viz_radio_buttons.py b/docs/examples/viz_radio_buttons.py index 71dd1c6fe..e10e5f376 100644 --- a/docs/examples/viz_radio_buttons.py +++ b/docs/examples/viz_radio_buttons.py @@ -11,13 +11,12 @@ import numpy as np -from fury import actor, ui, utils, window -from fury.data import fetch_viz_icons +import fury ############################################################################## # First we need to fetch some icons that are included in FURY. -fetch_viz_icons() +fury.data.fetch_viz_icons() ######################################################################## # Sphere and Radio Buttons @@ -25,7 +24,7 @@ # # Add a Sphere to the scene. -sphere = actor.sphere( +sphere = fury.actor.sphere( centers=np.array([[50, 0, 0]]), colors=np.array([[0, 0, 1]]), radii=11.0, @@ -36,7 +35,7 @@ # Creating a dict of possible options and mapping it with their values. options = {"Blue": (0, 0, 255), "Red": (255, 0, 0), "Green": (0, 255, 0)} -color_toggler = ui.RadioButton( +color_toggler = fury.ui.RadioButton( list(options), checked_labels=["Blue"], padding=1, @@ -48,10 +47,10 @@ # A callback which will set the values for the box def toggle_color(radio): - vcolors = utils.colors_from_actor(sphere) + vcolors = fury.utils.colors_from_actor(sphere) color = options[radio.checked_labels[0]] vcolors[:] = np.array(color) - utils.update_actor(sphere) + fury.utils.update_actor(sphere) color_toggler.on_change = toggle_color @@ -65,7 +64,7 @@ def toggle_color(radio): # manager. current_size = (800, 800) -show_manager = window.ShowManager(size=current_size, title="FURY Sphere Example") +show_manager = fury.window.ShowManager(size=current_size, title="FURY Sphere Example") show_manager.scene.add(sphere) show_manager.scene.add(color_toggler) @@ -82,4 +81,6 @@ def toggle_color(radio): if interactive: show_manager.start() -window.record(show_manager.scene, size=current_size, out_path="viz_radio_buttons.png") +fury.window.record( + show_manager.scene, size=current_size, out_path="viz_radio_buttons.png" +) diff --git a/docs/examples/viz_robot_arm_animation.py b/docs/examples/viz_robot_arm_animation.py index 1e9485d02..b35fd105c 100644 --- a/docs/examples/viz_robot_arm_animation.py +++ b/docs/examples/viz_robot_arm_animation.py @@ -8,13 +8,11 @@ import numpy as np -from fury import actor, window -from fury.animation import Animation, Timeline -from fury.utils import set_actor_origin +import fury -scene = window.Scene() +scene = fury.window.Scene() -showm = window.ShowManager( +showm = fury.window.ShowManager( scene, size=(900, 768), reset_camera=False, order_transparent=True ) showm.initialize() @@ -23,16 +21,20 @@ ############################################################################### # Creating robot arm components -base = actor.cylinder( +base = fury.actor.cylinder( np.array([[0, 0, 0]]), np.array([[0, 1, 0]]), colors=(0, 1, 0), radius=1 ) -main_arm = actor.box(np.array([[0, 0, 0]]), colors=(1, 0.5, 0), scales=(12, 1, 1)) +main_arm = fury.actor.box(np.array([[0, 0, 0]]), colors=(1, 0.5, 0), scales=(12, 1, 1)) -sub_arm = actor.box(np.array([[0, 0, 0]]), colors=(0, 0.5, 0.8), scales=(8, 0.7, 0.7)) -joint_1 = actor.sphere(np.array([[0, 0, 0]]), colors=np.array([1, 0, 1]), radii=1.2) -joint_2 = actor.sphere(np.array([[0, 0, 0]]), colors=np.array([1, 0, 1])) +sub_arm = fury.actor.box( + np.array([[0, 0, 0]]), colors=(0, 0.5, 0.8), scales=(8, 0.7, 0.7) +) +joint_1 = fury.actor.sphere( + np.array([[0, 0, 0]]), colors=np.array([1, 0, 1]), radii=1.2 +) +joint_2 = fury.actor.sphere(np.array([[0, 0, 0]]), colors=np.array([1, 0, 1])) -end = actor.cone( +end = fury.actor.cone( np.array([[0, 0, 0]]), np.array([[1, 0, 0]]), np.array([[1, 0, 0]]), @@ -42,18 +44,18 @@ ############################################################################### # Setting the center of both shafts to the beginning. -set_actor_origin(main_arm, np.array([-6, 0, 0])) -set_actor_origin(sub_arm, np.array([-4, 0, 0])) +fury.utils.set_actor_origin(main_arm, np.array([-6, 0, 0])) +fury.utils.set_actor_origin(sub_arm, np.array([-4, 0, 0])) ############################################################################### # Creating a timeline -timeline = Timeline(playback_panel=True) +timeline = fury.animation.Timeline(playback_panel=True) ############################################################################### # Creating animations -main_arm_animation = Animation([main_arm, joint_1], length=2 * np.pi) -child_arm_animation = Animation([sub_arm, joint_2]) -drill_animation = Animation(end) +main_arm_animation = fury.animation.Animation([main_arm, joint_1], length=2 * np.pi) +child_arm_animation = fury.animation.Animation([sub_arm, joint_2]) +drill_animation = fury.animation.Animation(end) ############################################################################### @@ -119,4 +121,4 @@ def rot_drill(t): if interactive: showm.start() -window.record(scene, out_path="viz_robot_arm.png", size=(900, 768)) +fury.window.record(scene, out_path="viz_robot_arm.png", size=(900, 768)) diff --git a/docs/examples/viz_roi_contour.py b/docs/examples/viz_roi_contour.py index 17590a3df..1a8b07806 100644 --- a/docs/examples/viz_roi_contour.py +++ b/docs/examples/viz_roi_contour.py @@ -24,8 +24,7 @@ from dipy.tracking import utils from dipy.tracking.streamline import Streamlines -from fury import actor, window -from fury.colormap import line_colors +import fury ############################################################################### # First, we need to generate some streamlines. For a more complete @@ -39,7 +38,7 @@ white_matter = (labels == 1) | (labels == 2) -csa_model = CsaOdfModel(gtab, sh_order=6) +csa_model = CsaOdfModel(gtab, sh_order_max=6) csa_peaks = peaks_from_model( csa_model, data, @@ -63,7 +62,7 @@ ############################################################################### # We will create a streamline actor from the streamlines. -streamlines_actor = actor.line(streamlines, line_colors(streamlines)) +streamlines_actor = fury.actor.line(streamlines, fury.colormap.line_colors(streamlines)) ############################################################################### # Next, we create a surface actor from the corpus callosum seed ROI. We @@ -74,7 +73,7 @@ surface_opacity = 0.5 surface_color = [0, 1, 1] -seedroi_actor = actor.contour_from_roi( +seedroi_actor = fury.actor.contour_from_roi( seed_mask, affine, surface_color, surface_opacity ) @@ -82,7 +81,7 @@ # Next, we initialize a ''Scene'' object and add both actors # to the rendering. -scene = window.Scene() +scene = fury.window.Scene() scene.add(streamlines_actor) scene.add(seedroi_actor) @@ -92,9 +91,9 @@ interactive = False if interactive: - window.show(scene) + fury.window.show(scene) # scene.zoom(1.5) # scene.reset_clipping_range() -window.record(scene, out_path="contour_from_roi_tutorial.png", size=(600, 600)) +fury.window.record(scene, out_path="contour_from_roi_tutorial.png", size=(600, 600)) diff --git a/docs/examples/viz_sdf_cylinder.py b/docs/examples/viz_sdf_cylinder.py index bebeb4f30..30cfa00db 100644 --- a/docs/examples/viz_sdf_cylinder.py +++ b/docs/examples/viz_sdf_cylinder.py @@ -19,13 +19,7 @@ import numpy as np -from fury import actor, window -from fury.shaders import ( - attribute_to_actor, - compose_shader, - import_fury_shader, - shader_to_actor, -) +import fury ############################################################################### # Cylinder using polygons @@ -87,7 +81,7 @@ # of sides used to define the bases of the cylinder) to see how it changes the # surface of the primitive. -cylinders_8 = actor.cylinder( +cylinders_8 = fury.actor.cylinder( centers[:3], dirs[:3], colors[:3], @@ -96,7 +90,7 @@ capped=True, resolution=8, ) -cylinders_16 = actor.cylinder( +cylinders_16 = fury.actor.cylinder( centers[3:6], dirs[3:6], colors[3:6], @@ -105,7 +99,7 @@ capped=True, resolution=16, ) -cylinders_32 = actor.cylinder( +cylinders_32 = fury.actor.cylinder( centers[6:9], dirs[6:9], colors[6:9], @@ -118,7 +112,7 @@ ############################################################################### # Next, we set up a new scene to add and visualize the actors created. -scene = window.Scene() +scene = fury.window.Scene() scene.add(cylinders_8) scene.add(cylinders_16) @@ -127,9 +121,9 @@ interactive = False if interactive: - window.show(scene) + fury.window.show(scene) -window.record(scene, size=(600, 600), out_path="viz_poly_cylinder.png") +fury.window.record(scene, size=(600, 600), out_path="viz_poly_cylinder.png") ############################################################################### # Visualize the surface geometry representation for the object. @@ -139,9 +133,9 @@ cylinders_32.GetProperty().SetRepresentationToWireframe() if interactive: - window.show(scene) + fury.window.show(scene) -window.record(scene, size=(600, 600), out_path="viz_poly_cylinder_geom.png") +fury.window.record(scene, size=(600, 600), out_path="viz_poly_cylinder_geom.png") ############################################################################### # Then we clean the scene to render the boxes we will use to render our @@ -167,7 +161,7 @@ # Now we create cylinders using box actor and SDF implementation on shaders. # For this, we first create a box actor. -box_actor = actor.box( +box_actor = fury.actor.box( centers=centers, directions=dirs, colors=colors, @@ -187,10 +181,10 @@ rep_radii = np.repeat(np.repeat(radius, 9), 8, axis=0) rep_heights = np.repeat(np.repeat(height, 9), 8, axis=0) -attribute_to_actor(box_actor, rep_centers, "center") -attribute_to_actor(box_actor, rep_directions, "direction") -attribute_to_actor(box_actor, rep_radii, "radius") -attribute_to_actor(box_actor, rep_heights, "height") +fury.shaders.attribute_to_actor(box_actor, rep_centers, "center") +fury.shaders.attribute_to_actor(box_actor, rep_directions, "direction") +fury.shaders.attribute_to_actor(box_actor, rep_radii, "radius") +fury.shaders.attribute_to_actor(box_actor, rep_heights, "height") ############################################################################### # Then we have the shader code implementation corresponding to vertex and @@ -225,7 +219,7 @@ # to apply our implementation to the shader creation process, this function # joins our code to the shader template that FURY has by default. -shader_to_actor(box_actor, "vertex", decl_code=vs_dec, impl_code=vs_impl) +fury.shaders.shader_to_actor(box_actor, "vertex", decl_code=vs_dec, impl_code=vs_impl) ############################################################################### # Fragment shaders are used to define the colors of each pixel being processed, @@ -252,14 +246,14 @@ # to transform our position vectors in order to align the direction of # cylinder with respect to the box. -vec_to_vec_rot_mat = import_fury_shader( +vec_to_vec_rot_mat = fury.shaders.import_fury_shader( os.path.join("utils", "vec_to_vec_rot_mat.glsl") ) ############################################################################### # We calculate the distance using the SDF function for the cylinder. -sd_cylinder = import_fury_shader(os.path.join("sdf", "sd_cylinder.frag")) +sd_cylinder = fury.shaders.import_fury_shader(os.path.join("sdf", "sd_cylinder.frag")) ############################################################################### # This is used on calculations for surface normals of the cylinder. @@ -283,24 +277,28 @@ ############################################################################### # We use central differences technique for computing surface normals. -central_diffs_normal = import_fury_shader(os.path.join("sdf", "central_diffs.frag")) +central_diffs_normal = fury.shaders.import_fury_shader( + os.path.join("sdf", "central_diffs.frag") +) ############################################################################### # We use cast_ray for the implementation of Ray Marching. -cast_ray = import_fury_shader(os.path.join("ray_marching", "cast_ray.frag")) +cast_ray = fury.shaders.import_fury_shader( + os.path.join("ray_marching", "cast_ray.frag") +) ############################################################################### # For the illumination of the scene we use the Blinn-Phong model. -blinn_phong_model = import_fury_shader( +blinn_phong_model = fury.shaders.import_fury_shader( os.path.join("lighting", "blinn_phong_model.frag") ) ############################################################################### # Now we use compose_shader to join our pieces of GLSL shader code. -fs_dec = compose_shader( +fs_dec = fury.shaders.compose_shader( [ fs_vars_dec, vec_to_vec_rot_mat, @@ -312,7 +310,7 @@ ] ) -shader_to_actor(box_actor, "fragment", decl_code=fs_dec) +fury.shaders.shader_to_actor(box_actor, "fragment", decl_code=fs_dec) ############################################################################### # Here we have the implementation of all the previous code with all the @@ -350,7 +348,9 @@ } """ -shader_to_actor(box_actor, "fragment", impl_code=sdf_cylinder_frag_impl, block="light") +fury.shaders.shader_to_actor( + box_actor, "fragment", impl_code=sdf_cylinder_frag_impl, block="light" +) ############################################################################### # Finally, we visualize the cylinders made using ray marching and SDFs. @@ -358,9 +358,9 @@ scene.add(box_actor) if interactive: - window.show(scene) + fury.window.show(scene) -window.record(scene, size=(600, 600), out_path="viz_sdf_cylinder.png") +fury.window.record(scene, size=(600, 600), out_path="viz_sdf_cylinder.png") ############################################################################### # References diff --git a/docs/examples/viz_sdfactor.py b/docs/examples/viz_sdfactor.py index 1223d38aa..7d99356dc 100644 --- a/docs/examples/viz_sdfactor.py +++ b/docs/examples/viz_sdfactor.py @@ -16,7 +16,7 @@ import numpy as np -from fury import actor, window +import fury ############################################################################### # Lets define variables for the SDF Actor @@ -30,7 +30,7 @@ ############################################################################### # Create SDF Actor -sdfactor = actor.sdf( +sdfactor = fury.actor.sdf( centers=centers, directions=dirs, colors=colors, @@ -41,7 +41,7 @@ ############################################################################## # Create a scene -scene = window.Scene() +scene = fury.window.Scene() scene.background((1.0, 0.8, 0.8)) scene.add(sdfactor) @@ -53,11 +53,11 @@ # manager. current_size = (1024, 720) -showm = window.ShowManager(scene, size=current_size, title="Visualize SDF Actor") +showm = fury.window.ShowManager(scene, size=current_size, title="Visualize SDF Actor") interactive = False if interactive: showm.start() -window.record(scene, out_path="viz_sdfactor.png", size=current_size) +fury.window.record(scene, out_path="viz_sdfactor.png", size=current_size) diff --git a/docs/examples/viz_selection.py b/docs/examples/viz_selection.py index 6c0a4c485..58b71ebca 100644 --- a/docs/examples/viz_selection.py +++ b/docs/examples/viz_selection.py @@ -22,7 +22,7 @@ import numpy as np -from fury import actor, pick, utils, window +import fury ############################################################################### # Adding many cubes of different sizes and colors @@ -44,31 +44,31 @@ ############################################################################### # Build scene and add an actor with many objects. -scene = window.Scene() +scene = fury.window.Scene() ############################################################################### # Build the actor containing all the cubes -cube_actor = actor.cube(centers, directions=(1, 0, 0), colors=colors, scales=radii) +cube_actor = fury.actor.cube(centers, directions=(1, 0, 0), colors=colors, scales=radii) ############################################################################### # Access the memory of the vertices of all the cubes -vertices = utils.vertices_from_actor(cube_actor) +vertices = fury.utils.vertices_from_actor(cube_actor) num_vertices = vertices.shape[0] num_objects = centers.shape[0] ############################################################################### # Access the memory of the colors of all the cubes -vcolors = utils.colors_from_actor(cube_actor, "colors") +vcolors = fury.utils.colors_from_actor(cube_actor, "colors") ############################################################################### # Create a rectangular 2d box as a texture rgba = 255 * np.ones((100, 200, 4)) rgba[1:-1, 1:-1] = np.zeros((98, 198, 4)) + 100 -texa = actor.texture_2d(rgba.astype(np.uint8)) +texa = fury.actor.texture_2d(rgba.astype(np.uint8)) scene.add(cube_actor) scene.add(texa) @@ -78,7 +78,7 @@ ############################################################################### # Create the Selection Manager -selm = pick.SelectionManager(select="faces") +selm = fury.pick.SelectionManager(select="faces") ############################################################################### # Tell Selection Manager to avoid selecting specific actors @@ -109,14 +109,14 @@ def hover_callback(_obj, _event): vcolors[object_index * sec : object_index * sec + sec] = ( color_change ) - utils.update_actor(cube_actor) + fury.utils.update_actor(cube_actor) showm.render() ############################################################################### # Make the window appear -showm = window.ShowManager( +showm = fury.window.ShowManager( scene, size=(1024, 768), order_transparent=True, reset_camera=False ) @@ -138,4 +138,4 @@ def hover_callback(_obj, _event): ############################################################################### # Save the current framebuffer in a PNG file -window.record(showm.scene, size=(1024, 768), out_path="viz_selection.png") +fury.window.record(showm.scene, size=(1024, 768), out_path="viz_selection.png") diff --git a/docs/examples/viz_shader.py b/docs/examples/viz_shader.py index 19b1a36ba..479b42289 100644 --- a/docs/examples/viz_shader.py +++ b/docs/examples/viz_shader.py @@ -7,19 +7,17 @@ This example shows how to use shaders to generate a shaded output. We will demonstrate how to load polydata then use a custom shader calls to render a custom shaded model. -First, a bunch of imports. +First, let's import FURY """ -from fury import io, ui, utils, window -from fury.data.fetcher import fetch_viz_models, read_viz_models -from fury.shaders import add_shader_callback, shader_to_actor +import fury ############################################################################### # Let's download and load the model -fetch_viz_models() -model = read_viz_models("utah.obj") +fury.data.fetch_viz_models() +model = fury.data.read_viz_models("utah.obj") ############################################################################### @@ -28,9 +26,9 @@ # For this example we use the standard utah teapot model. # currently supported formats include OBJ, VTK, FIB, PLY, STL and XML -utah = io.load_polydata(model) -utah = utils.get_polymapper_from_polydata(utah) -utah = utils.get_actor_from_polymapper(utah) +utah = fury.io.load_polydata(model) +utah = fury.utils.get_polymapper_from_polydata(utah) +utah = fury.utils.get_actor_from_polymapper(utah) mapper = utah.GetMapper() @@ -58,16 +56,18 @@ fragOutput0 = vec4(col, fragOutput0.a); """ -shader_to_actor( +fury.shaders.shader_to_actor( utah, "vertex", impl_code=vertex_shader_code_impl, decl_code=vertex_shader_code_decl ) -shader_to_actor(utah, "fragment", decl_code=fragment_shader_code_decl) -shader_to_actor(utah, "fragment", impl_code=fragment_shader_code_impl, block="light") +fury.shaders.shader_to_actor(utah, "fragment", decl_code=fragment_shader_code_decl) +fury.shaders.shader_to_actor( + utah, "fragment", impl_code=fragment_shader_code_impl, block="light" +) ############################################################################### # Let's create a scene. -scene = window.Scene() +scene = fury.window.Scene() global timer timer = 0 @@ -98,11 +98,11 @@ def shader_callback(_caller, _event, calldata=None): pass -add_shader_callback(utah, shader_callback) +fury.shaders.add_shader_callback(utah, shader_callback) ############################################################################### # Let's add a textblock to the scene with a custom message -tb = ui.TextBlock2D() +tb = fury.ui.TextBlock2D() tb.message = "Hello Shaders" ############################################################################### @@ -112,7 +112,7 @@ def shader_callback(_caller, _event, calldata=None): # manager. current_size = (1024, 720) -showm = window.ShowManager(scene, size=current_size, reset_camera=False) +showm = fury.window.ShowManager(scene, size=current_size, reset_camera=False) showm.add_timer_callback(True, 30, timer_callback) @@ -124,4 +124,4 @@ def shader_callback(_caller, _event, calldata=None): if interactive: showm.start() -window.record(showm.scene, size=current_size, out_path="viz_shader.png") +fury.window.record(showm.scene, size=current_size, out_path="viz_shader.png") diff --git a/docs/examples/viz_shapes.py b/docs/examples/viz_shapes.py index e7e64361c..33a88ec80 100644 --- a/docs/examples/viz_shapes.py +++ b/docs/examples/viz_shapes.py @@ -10,28 +10,29 @@ First, a bunch of imports. """ -from fury import ui, window -from fury.data import fetch_viz_icons +import fury ############################################################################## # First we need to fetch some icons that are included in FURY. -fetch_viz_icons() +fury.data.fetch_viz_icons() ############################################################################### # Let's draw some simple shapes. First, a rectangle. -rect = ui.Rectangle2D(size=(100, 100), position=(400, 400), color=(1, 0, 1)) +rect = fury.ui.Rectangle2D(size=(100, 100), position=(400, 400), color=(1, 0, 1)) ############################################################################### # Then we can draw a solid circle, or disk. -disk = ui.Disk2D(outer_radius=50, center=(400, 200), color=(1, 1, 0)) +disk = fury.ui.Disk2D(outer_radius=50, center=(400, 200), color=(1, 1, 0)) ############################################################################### # Add an inner radius to make a ring. -ring = ui.Disk2D(outer_radius=50, inner_radius=45, center=(500, 600), color=(0, 1, 1)) +ring = fury.ui.Disk2D( + outer_radius=50, inner_radius=45, center=(500, 600), color=(0, 1, 1) +) ############################################################################### @@ -39,7 +40,7 @@ # manager. current_size = (800, 800) -show_manager = window.ShowManager(size=current_size, title="FURY Shapes Example") +show_manager = fury.window.ShowManager(size=current_size, title="FURY Shapes Example") show_manager.scene.add(rect) show_manager.scene.add(disk) @@ -50,4 +51,4 @@ if interactive: show_manager.start() -window.record(show_manager.scene, size=current_size, out_path="viz_shapes.png") +fury.window.record(show_manager.scene, size=current_size, out_path="viz_shapes.png") diff --git a/docs/examples/viz_skinning.py b/docs/examples/viz_skinning.py index 0657e0b1d..010fbbf1b 100644 --- a/docs/examples/viz_skinning.py +++ b/docs/examples/viz_skinning.py @@ -6,22 +6,20 @@ glTF model in FURY. """ -from fury import window -from fury.data import fetch_gltf, read_viz_gltf -from fury.gltf import glTF +import fury ############################################################################## # Retrieving the model with skeletal animations. # We're choosing the `RiggedFigure` model here. -fetch_gltf("RiggedFigure", "glTF") -filename = read_viz_gltf("RiggedFigure") +fury.data.fetch_gltf("RiggedFigure", "glTF") +filename = fury.data.read_viz_gltf("RiggedFigure") ############################################################################## # Initializing the glTF object, You can additionally set `apply_normals=True`. # Note: Normals might not work well as intended with skinning animations. -gltf_obj = glTF(filename, apply_normals=False) +gltf_obj = fury.gltf.glTF(filename, apply_normals=False) ############################################################################## # Get the skinning timeline using `skin_timeline` method, Choose the animation @@ -43,8 +41,8 @@ # Initialize the show manager and add timeline to the scene (No need to add # actors to the scene separately). -scene = window.Scene() -showm = window.ShowManager( +scene = fury.window.Scene() +showm = fury.window.ShowManager( scene, size=(900, 768), reset_camera=True, order_transparent=True ) showm.initialize() @@ -73,4 +71,4 @@ def timer_callback(_obj, _event): if interactive: showm.start() -window.record(scene, out_path="viz_skinning.png", size=(900, 768)) +fury.window.record(scene, out_path="viz_skinning.png", size=(900, 768)) diff --git a/docs/examples/viz_slice.py b/docs/examples/viz_slice.py index 0a8c01303..e198b5aca 100644 --- a/docs/examples/viz_slice.py +++ b/docs/examples/viz_slice.py @@ -11,7 +11,7 @@ from dipy.data import fetch_bundles_2_subjects import nibabel as nib -from fury import actor, ui, window +import fury ############################################################################### # Let's download and load a T1. @@ -35,7 +35,7 @@ ############################################################################### # Create a Scene object which holds all the actors which we want to visualize. -scene = window.Scene() +scene = fury.window.Scene() scene.background((0.5, 0.5, 0.5)) ############################################################################### @@ -53,7 +53,7 @@ # transformation matrix. The default behavior of this function is to show the # middle slice of the last dimension of the resampled data. -slice_actor = actor.slicer(data, affine, value_range) +slice_actor = fury.actor.slicer(data, affine, value_range) ############################################################################### # The ``slice_actor`` contains an axial slice. @@ -81,12 +81,12 @@ ############################################################################### # In order to interact with the data you will need to uncomment the line below. -# window.show(scene, size=(600, 600), reset_camera=False) +# fury.window.show(scene, size=(600, 600), reset_camera=False) ############################################################################### # Otherwise, you can save a screenshot using the following command. -window.record(scene, out_path="slices.png", size=(600, 600), reset_camera=False) +fury.window.record(scene, out_path="slices.png", size=(600, 600), reset_camera=False) ############################################################################### # Render slices from FA with your colormap @@ -111,7 +111,7 @@ ############################################################################### # Notice here how the scale range is. We use FA min and max values to set it up -lut = actor.colormap_lookup_table( +lut = fury.actor.colormap_lookup_table( scale_range=(fa.min(), fa.max()), hue_range=(0.4, 1.0), saturation_range=(1, 1.0), @@ -122,7 +122,7 @@ # This is because the lookup table is applied in the slice after interpolating # to (0, 255). -fa_actor = actor.slicer(fa, affine, lookup_colormap=lut) +fa_actor = fury.actor.slicer(fa, affine, lookup_colormap=lut) scene.clear() scene.add(fa_actor) @@ -130,9 +130,11 @@ scene.reset_camera() scene.zoom(1.4) -# window.show(scene, size=(600, 600), reset_camera=False) +# fury.window.show(scene, size=(600, 600), reset_camera=False) -window.record(scene, out_path="slices_lut.png", size=(600, 600), reset_camera=False) +fury.window.record( + scene, out_path="slices_lut.png", size=(600, 600), reset_camera=False +) ############################################################################### # Now we would like to add the ability to click on a voxel and show its value @@ -142,19 +144,19 @@ # the ``ShowManager`` object, which allows accessing the pipeline in different # areas. -show_m = window.ShowManager(scene, size=(1200, 900)) +show_m = fury.window.ShowManager(scene, size=(1200, 900)) ############################################################################### # We'll start by creating the panel and adding it to the ``ShowManager`` -label_position = ui.TextBlock2D(text="Position:") -label_value = ui.TextBlock2D(text="Value:") +label_position = fury.ui.TextBlock2D(text="Position:") +label_value = fury.ui.TextBlock2D(text="Value:") -result_position = ui.TextBlock2D(text="") -result_value = ui.TextBlock2D(text="") +result_position = fury.ui.TextBlock2D(text="") +result_value = fury.ui.TextBlock2D(text="") -panel_picking = ui.Panel2D( +panel_picking = fury.ui.Panel2D( size=(250, 125), position=(20, 20), color=(0, 0, 0), opacity=0.75, align="left" ) @@ -203,7 +205,7 @@ def left_click_callback(obj, _ev): result_position.message = "" result_value.message = "" -show_m_mosaic = window.ShowManager(scene, size=(1200, 900)) +show_m_mosaic = fury.window.ShowManager(scene, size=(1200, 900)) def left_click_callback_mosaic(obj, _ev): @@ -260,4 +262,4 @@ def left_click_callback_mosaic(obj, _ev): # zoom in/out using the scroll wheel, and pick voxels with left click. -window.record(scene, out_path="mosaic.png", size=(900, 600), reset_camera=False) +fury.window.record(scene, out_path="mosaic.png", size=(900, 600), reset_camera=False) diff --git a/docs/examples/viz_solar_system.py b/docs/examples/viz_solar_system.py index 2e60bb351..ffd495d0d 100644 --- a/docs/examples/viz_solar_system.py +++ b/docs/examples/viz_solar_system.py @@ -13,21 +13,24 @@ import numpy as np -from fury import actor, io, ui, utils, window -from fury.data import fetch_viz_textures, read_viz_icons, read_viz_textures +import fury ############################################################################## # Create a scene to start. -scene = window.Scene() +scene = fury.window.Scene() # Create a panel and the start/pause buttons -panel = ui.Panel2D(size=(300, 100), color=(1, 1, 1), align="right") +panel = fury.ui.Panel2D(size=(300, 100), color=(1, 1, 1), align="right") panel.center = (400, 50) -pause_button = ui.Button2D(icon_fnames=[("square", read_viz_icons(fname="pause2.png"))]) -start_button = ui.Button2D(icon_fnames=[("square", read_viz_icons(fname="play3.png"))]) +pause_button = fury.ui.Button2D( + icon_fnames=[("square", fury.data.read_viz_icons(fname="pause2.png"))] +) +start_button = fury.ui.Button2D( + icon_fnames=[("square", fury.data.read_viz_icons(fname="play3.png"))] +) # Add the buttons on the panel @@ -91,7 +94,7 @@ }, {"filename": "8k_sun.jpg", "position": 0, "earth_days": 27, "scale": (5, 5, 5)}, ] -fetch_viz_textures() +fury.data.fetch_viz_textures() ############################################################################## # To take advantage of the previously defined data structure we are going to @@ -114,12 +117,12 @@ def init_planet(planet_data): planet_actor: actor The corresponding sphere actor with texture applied. """ - planet_file = read_viz_textures(planet_data["filename"]) - planet_image = io.load_image(planet_file) - planet_actor = actor.texture_on_sphere(planet_image) + planet_file = fury.data.read_viz_textures(planet_data["filename"]) + planet_image = fury.io.load_image(planet_file) + planet_actor = fury.actor.texture_on_sphere(planet_image) planet_actor.SetPosition(planet_data["position"], 0, 0) if planet_data["filename"] != "8k_saturn_ring_alpha.png": - utils.rotate(planet_actor, (90, 1, 0, 0)) + fury.utils.rotate(planet_actor, (90, 1, 0, 0)) planet_actor.SetScale(planet_data["scale"]) scene.add(planet_actor) return planet_actor @@ -185,7 +188,7 @@ def get_orbital_position(radius, time): def rotate_axial(actor, time, radius): axis = (0, radius, 0) angle = 50 / time - utils.rotate(actor, (angle, axis[0], axis[1], axis[2])) + fury.utils.rotate(actor, (angle, axis[0], axis[1], axis[2])) return angle @@ -198,7 +201,7 @@ def rotate_axial(actor, time, radius): # Next, create a ShowManager object. The ShowManager class is the interface # between the scene, the window and the interactor. -showm = window.ShowManager( +showm = fury.window.ShowManager( scene, size=(900, 768), reset_camera=False, order_transparent=True ) scene.add(panel) @@ -277,7 +280,7 @@ def calculate_path(r_planet, c): # This is for orbit visualization. We are using line actor for orbits. # After creating an actor we add it to the scene. -orbit_actor = actor.line(planet_tracks, colors=(1, 1, 1), linewidth=0.1) +orbit_actor = fury.actor.line(planet_tracks, colors=(1, 1, 1), linewidth=0.1) scene.add(orbit_actor) ############################################################################## @@ -331,4 +334,6 @@ def pause_animation(i_ren, _obj, _button): showm.add_timer_callback(True, 10, timer_callback) showm.start() -window.record(showm.scene, size=(900, 768), out_path="viz_solar_system_animation.png") +fury.window.record( + showm.scene, size=(900, 768), out_path="viz_solar_system_animation.png" +) diff --git a/docs/examples/viz_sphere.py b/docs/examples/viz_sphere.py index 92df3c73c..f81aae96f 100644 --- a/docs/examples/viz_sphere.py +++ b/docs/examples/viz_sphere.py @@ -7,7 +7,7 @@ import numpy as np -from fury import actor, window +import fury ############################################################################ # First thing, you have to specify centers and colors of the sphere @@ -18,7 +18,7 @@ ############################################################################ # The below sphere actor is generated by repeating the sphere primitive. -prim_sphere_actor = actor.sphere(centers, colors=colors, radii=5) +prim_sphere_actor = fury.actor.sphere(centers, colors=colors, radii=5) ############################################################################ # This time, we're using vtkSphereSource to generate the sphere actor @@ -26,9 +26,9 @@ cen2 = np.add(centers, np.array([12, 0, 0])) cols2 = np.array([1, 0, 0]) -vtk_sphere_actor = actor.sphere(cen2, colors=cols2, radii=5, use_primitive=False) +vtk_sphere_actor = fury.actor.sphere(cen2, colors=cols2, radii=5, use_primitive=False) -scene = window.Scene() +scene = fury.window.Scene() ############################################################################ # Adding our sphere actors to scene. @@ -39,6 +39,6 @@ interactive = False if interactive: - window.show(scene, size=(600, 600)) + fury.window.show(scene, size=(600, 600)) -window.record(scene, out_path="viz_sphere.png", size=(600, 600)) +fury.window.record(scene, out_path="viz_sphere.png", size=(600, 600)) diff --git a/docs/examples/viz_spiky.py b/docs/examples/viz_spiky.py index 3ab10c87c..a8de7e3ca 100644 --- a/docs/examples/viz_spiky.py +++ b/docs/examples/viz_spiky.py @@ -9,7 +9,7 @@ import numpy as np -from fury import actor, primitive, utils, window +import fury ############################################################################## # Create a sphere actor. Define the center, radius and color of a sphere. @@ -17,27 +17,27 @@ # sphere. # Let's create a scene. -scene = window.Scene() +scene = fury.window.Scene() ############################################################################## # The vertices are connected with triangles in order to specify the direction # of the surface normal. # ``prim_sphere`` provides a sphere with evenly distributed points -vertices, triangles = primitive.prim_sphere(name="symmetric362", gen_faces=False) +vertices, triangles = fury.primitive.prim_sphere(name="symmetric362", gen_faces=False) ############################################################################## # To be able to visualize the vertices, let's define a point actor with # green color. -point_actor = actor.point(vertices, point_radius=0.01, colors=(0, 1, 0)) +point_actor = fury.actor.point(vertices, point_radius=0.01, colors=(0, 1, 0)) ############################################################################## # Normals are the vectors that are perpendicular to the surface at each # vertex. We specify the normals at the vertices to tell the system # whether triangles represent curved surfaces. -normals = utils.normals_from_v_f(vertices, triangles) +normals = fury.utils.normals_from_v_f(vertices, triangles) ############################################################################## # The normals are usually used to calculate how the light will bounce on @@ -45,7 +45,7 @@ # spikes (represented with arrows). # So, let's create an arrow actor at the center of each vertex. -arrow_actor = actor.arrow( +arrow_actor = fury.actor.arrow( centers=vertices, directions=normals, colors=(1, 0, 0), @@ -61,7 +61,7 @@ primitive_colors = np.zeros(vertices.shape) primitive_colors[:, 2] = 180 -primitive_actor = utils.get_actor_from_primitive( +primitive_actor = fury.utils.get_actor_from_primitive( vertices=vertices, triangles=triangles, colors=primitive_colors, @@ -75,13 +75,13 @@ scene.add(point_actor) scene.add(arrow_actor) scene.add(primitive_actor) -scene.add(actor.axes()) +scene.add(fury.actor.axes()) ############################################################################## # The ShowManager class is the interface between the scene, the window and the # interactor. -showm = window.ShowManager( +showm = fury.window.ShowManager( scene, size=(900, 768), reset_camera=False, order_transparent=True ) @@ -108,7 +108,7 @@ def timer_callback(_obj, _event): showm.add_timer_callback(True, 200, timer_callback) showm.start() -window.record(showm.scene, size=(900, 768), out_path="viz_spiky.png") +fury.window.record(showm.scene, size=(900, 768), out_path="viz_spiky.png") ############################################################################## # Instead of arrows, you can choose other geometrical objects diff --git a/docs/examples/viz_spinbox.py b/docs/examples/viz_spinbox.py index 1fbe02f97..d7b9fdfae 100644 --- a/docs/examples/viz_spinbox.py +++ b/docs/examples/viz_spinbox.py @@ -12,18 +12,17 @@ import numpy as np -from fury import actor, ui, utils, window -from fury.data import fetch_viz_icons +import fury ############################################################################## # First we need to fetch some icons that are included in FURY. -fetch_viz_icons() +fury.data.fetch_viz_icons() ############################################################################### # Let's create a Cone. -cone = actor.cone( +cone = fury.actor.cone( centers=np.random.rand(1, 3), directions=np.random.rand(1, 3), colors=(1, 1, 1), @@ -33,7 +32,7 @@ ############################################################################### # Creating the SpinBox UI. -spinbox = ui.SpinBox( +spinbox = fury.ui.SpinBox( position=(200, 100), size=(300, 100), min_val=0, @@ -47,7 +46,7 @@ # manager. current_size = (800, 800) -show_manager = window.ShowManager(size=current_size, title="FURY SpinBox Example") +show_manager = fury.window.ShowManager(size=current_size, title="FURY SpinBox Example") show_manager.scene.add(cone) show_manager.scene.add(spinbox) @@ -62,7 +61,7 @@ def rotate_cone(spinbox): global previous_value change_in_value = spinbox.value - previous_value - utils.rotate(cone, (change_in_value, 1, 0, 0)) + fury.utils.rotate(cone, (change_in_value, 1, 0, 0)) previous_value = spinbox.value @@ -76,4 +75,4 @@ def rotate_cone(spinbox): if interactive: show_manager.start() -window.record(show_manager.scene, size=current_size, out_path="viz_spinbox.png") +fury.window.record(show_manager.scene, size=current_size, out_path="viz_spinbox.png") diff --git a/docs/examples/viz_spline_interpolator.py b/docs/examples/viz_spline_interpolator.py index c5ca86344..eff208200 100644 --- a/docs/examples/viz_spline_interpolator.py +++ b/docs/examples/viz_spline_interpolator.py @@ -8,13 +8,11 @@ import numpy as np -from fury import actor, window -from fury.animation import Animation, Timeline -from fury.animation.interpolator import spline_interpolator +import fury -scene = window.Scene() +scene = fury.window.Scene() -showm = window.ShowManager( +showm = fury.window.ShowManager( scene, size=(900, 768), reset_camera=False, order_transparent=True ) @@ -33,15 +31,15 @@ ############################################################################### # creating FURY dots to visualize the position values. -pos_dots = actor.dot(np.array(list(position_keyframes.values()))) +pos_dots = fury.actor.dot(np.array(list(position_keyframes.values()))) ############################################################################### # creating two timelines (one uses linear and the other uses' spline # interpolator), each timeline controls a sphere actor -sphere_linear = actor.sphere(np.array([[0, 0, 0]]), (1, 0.5, 0.2), 0.5) +sphere_linear = fury.actor.sphere(np.array([[0, 0, 0]]), (1, 0.5, 0.2), 0.5) -linear_anim = Animation() +linear_anim = fury.animation.Animation() linear_anim.add_actor(sphere_linear) linear_anim.set_position_keyframes(position_keyframes) @@ -53,13 +51,13 @@ ############################################################################### # creating a second timeline that translates another larger sphere actor using # spline interpolator. -sphere_spline = actor.sphere(np.array([[0, 0, 0]]), (0.3, 0.9, 0.6), 1) -spline_anim = Animation(sphere_spline) +sphere_spline = fury.actor.sphere(np.array([[0, 0, 0]]), (0.3, 0.9, 0.6), 1) +spline_anim = fury.animation.Animation(sphere_spline) spline_anim.set_position_keyframes(position_keyframes) ############################################################################### # Setting 5th degree spline interpolator for position keyframes. -spline_anim.set_position_interpolator(spline_interpolator, degree=5) +spline_anim.set_position_interpolator(fury.animation.spline_interpolator, degree=5) ############################################################################### # Wrapping animations up! @@ -69,7 +67,7 @@ ############################################################################### # First we create a timeline with a playback panel: -timeline = Timeline(playback_panel=True) +timeline = fury.animation.Timeline(playback_panel=True) ############################################################################### # Add visualization dots actor to the scene. @@ -94,4 +92,4 @@ if interactive: showm.start() -window.record(scene, out_path="viz_keyframe_animation_spline.png", size=(900, 768)) +fury.window.record(scene, out_path="viz_keyframe_animation_spline.png", size=(900, 768)) diff --git a/docs/examples/viz_surfaces.py b/docs/examples/viz_surfaces.py index 6cc62c551..fe19ecb91 100644 --- a/docs/examples/viz_surfaces.py +++ b/docs/examples/viz_surfaces.py @@ -14,9 +14,7 @@ import numpy as np -from fury import utils, window -from fury.io import load_polydata, save_polydata -from fury.lib import PolyData +import fury ############################################################################### # Import useful functions @@ -25,7 +23,7 @@ ############################################################################### # Create an empty ``PolyData`` -my_polydata = PolyData() +my_polydata = fury.lib.PolyData() ############################################################################### # Create a cube with vertices and triangles as numpy arrays @@ -65,43 +63,43 @@ ############################################################################### # Set vertices and triangles in the ``PolyData`` -utils.set_polydata_vertices(my_polydata, my_vertices) -utils.set_polydata_triangles(my_polydata, my_triangles) +fury.utils.set_polydata_vertices(my_polydata, my_vertices) +fury.utils.set_polydata_triangles(my_polydata, my_triangles) ############################################################################### # Save the ``PolyData`` file_name = "my_cube.vtk" -save_polydata(my_polydata, file_name) +fury.io.save_polydata(my_polydata, file_name) print("Surface saved in " + file_name) ############################################################################### # Load the ``PolyData`` -cube_polydata = load_polydata(file_name) +cube_polydata = fury.io.load_polydata(file_name) ############################################################################### # add color based on vertices position -cube_vertices = utils.get_polydata_vertices(cube_polydata) +cube_vertices = fury.utils.get_polydata_vertices(cube_polydata) colors = cube_vertices * 255 -utils.set_polydata_colors(cube_polydata, colors) +fury.utils.set_polydata_colors(cube_polydata, colors) print("new surface colors") -print(utils.get_polydata_colors(cube_polydata)) +print(fury.utils.get_polydata_colors(cube_polydata)) ############################################################################### # Visualize surfaces # get Actor -cube_actor = utils.get_actor_from_polydata(cube_polydata) +cube_actor = fury.utils.get_actor_from_polydata(cube_polydata) # Create a scene -scene = window.Scene() +scene = fury.window.Scene() scene.add(cube_actor) scene.set_camera(position=(10, 5, 7), focal_point=(0.5, 0.5, 0.5)) scene.zoom(3) # display -# window.show(scene, size=(600, 600), reset_camera=False) -window.record(scene, out_path="cube.png", size=(600, 600)) +# fury.window.show(scene, size=(600, 600), reset_camera=False) +fury.window.record(scene, out_path="cube.png", size=(600, 600)) diff --git a/docs/examples/viz_tab.py b/docs/examples/viz_tab.py index da6f542c1..a4814c71e 100644 --- a/docs/examples/viz_tab.py +++ b/docs/examples/viz_tab.py @@ -15,18 +15,17 @@ import numpy as np -from fury import actor, ui, window -from fury.data import fetch_viz_icons +import fury ############################################################################## # First we need to fetch some icons that are included in FURY. -fetch_viz_icons() +fury.data.fetch_viz_icons() ############################################################################### # First, we create the Tab UI. -tab_ui = ui.TabUI(position=(49, 94), size=(300, 300), nb_tabs=3, draggable=True) +tab_ui = fury.ui.TabUI(position=(49, 94), size=(300, 300), nb_tabs=3, draggable=True) ############################################################################### # We can also define the position of the Tab Bar. @@ -40,9 +39,9 @@ # # Now we prepare content for the first tab. -ring_slider = ui.RingSlider2D(initial_value=0, text_template="{angle:5.1f}°") +ring_slider = fury.ui.RingSlider2D(initial_value=0, text_template="{angle:5.1f}°") -line_slider_x = ui.LineSlider2D( +line_slider_x = fury.ui.LineSlider2D( initial_value=0, min_value=-10, max_value=10, @@ -50,7 +49,7 @@ text_alignment="Top", ) -line_slider_y = ui.LineSlider2D( +line_slider_y = fury.ui.LineSlider2D( initial_value=0, min_value=-10, max_value=10, @@ -58,7 +57,7 @@ text_alignment="Right", ) -cube = actor.box( +cube = fury.actor.box( centers=np.array([[10, 0, 0]]), directions=np.array([[0, 1, 0]]), colors=np.array([[0, 0, 1]]), @@ -105,17 +104,17 @@ def translate_cube_y(slider): # # Now we prepare content for second tab. -cylinder = actor.cylinder( +cylinder = fury.actor.cylinder( centers=np.array([[0, 0, 0]]), directions=np.array([[1, 1, 0]]), colors=np.array([[0, 1, 1]]), radius=1.0, ) -sphere = actor.sphere(centers=np.array([[5, 0, 0]]), colors=(1, 1, 0)) +sphere = fury.actor.sphere(centers=np.array([[5, 0, 0]]), colors=(1, 1, 0)) figure_dict = {"cylinder": cylinder, "sphere": sphere} -checkbox = ui.Checkbox(labels=["cylinder", "sphere"]) +checkbox = fury.ui.Checkbox(labels=["cylinder", "sphere"]) # Get difference between two lists. @@ -149,7 +148,7 @@ def set_figure_visiblity(checkboxes): # # Now we prepare content for third tab. -label = ui.TextBlock2D( +label = fury.ui.TextBlock2D( position=(600, 300), font_size=40, color=(1, 0.5, 0), @@ -168,7 +167,7 @@ def set_figure_visiblity(checkboxes): "Red": (1, 0, 0), } -color_combobox = ui.ComboBox2D( +color_combobox = fury.ui.ComboBox2D( items=list(colors.keys()), placeholder="Choose Text Color", size=(250, 150), @@ -228,7 +227,7 @@ def collapse(tab_ui): ############################################################################### # Next we prepare the scene and render it with the help of show manager. -sm = window.ShowManager(size=(800, 500), title="Viz Tab") +sm = fury.window.ShowManager(size=(800, 500), title="Viz Tab") sm.scene.add(tab_ui, cube, cylinder, sphere, label) # To interact with the ui set interactive = True @@ -237,4 +236,4 @@ def collapse(tab_ui): if interactive: sm.start() -window.record(sm.scene, size=(500, 500), out_path="viz_tab.png") +fury.window.record(sm.scene, size=(500, 500), out_path="viz_tab.png") diff --git a/docs/examples/viz_tesseract.py b/docs/examples/viz_tesseract.py index f037c9026..a66312ea4 100644 --- a/docs/examples/viz_tesseract.py +++ b/docs/examples/viz_tesseract.py @@ -14,8 +14,7 @@ import numpy as np -from fury import actor, utils, window -from fury.ui import TextBlock2D +import fury ############################################################################### # Let's define some variables and their descriptions: @@ -118,11 +117,11 @@ def connect_points(verts3D): ############################################################################### # Creating a scene object and configuring the camera's position -scene = window.Scene() +scene = fury.window.Scene() scene.set_camera( position=(0, 10, -1), focal_point=(0.0, 0.0, 0.0), view_up=(0.0, 0.0, 0.0) ) -showm = window.ShowManager(scene, size=(1920, 1080), order_transparent=True) +showm = fury.window.ShowManager(scene, size=(1920, 1080), order_transparent=True) ############################################################################### @@ -130,8 +129,8 @@ def connect_points(verts3D): verts3D = rotate4D(verts4D) if not wireframe: - points = actor.point(verts3D, colors=p_color) - point_verts = utils.vertices_from_actor(points) + points = fury.actor.point(verts3D, colors=p_color) + point_verts = fury.utils.vertices_from_actor(points) no_vertices = len(point_verts) / 16 initial_verts = point_verts.copy() - np.repeat(verts3D, no_vertices, axis=0) @@ -141,8 +140,10 @@ def connect_points(verts3D): # Connecting points with lines actor lines = connect_points(verts3D) -edges = actor.line(lines=lines, colors=e_color, lod=False, fake_tube=True, linewidth=4) -lines_verts = utils.vertices_from_actor(edges) +edges = fury.actor.line( + lines=lines, colors=e_color, lod=False, fake_tube=True, linewidth=4 +) +lines_verts = fury.utils.vertices_from_actor(edges) initial_lines = lines_verts.copy() - np.reshape(lines, (-1, 3)) scene.add(edges) @@ -150,7 +151,7 @@ def connect_points(verts3D): ############################################################################### # Initializing text box to display the name -tb = TextBlock2D(text="Tesseract", position=(900, 950), font_size=20) +tb = fury.ui.TextBlock2D(text="Tesseract", position=(900, 950), font_size=20) showm.scene.add(tb) ############################################################################### @@ -167,11 +168,11 @@ def timer_callback(_obj, _event): verts3D = rotate4D(verts4D) if not wireframe: point_verts[:] = initial_verts + np.repeat(verts3D, no_vertices, axis=0) - utils.update_actor(points) + fury.utils.update_actor(points) lines = connect_points(verts3D) lines_verts[:] = initial_lines + np.reshape(lines, (-1, 3)) - utils.update_actor(edges) + fury.utils.update_actor(edges) showm.render() angle += dtheta @@ -186,4 +187,4 @@ def timer_callback(_obj, _event): showm.add_timer_callback(True, 20, timer_callback) showm.start() -window.record(showm.scene, size=(600, 600), out_path="viz_tesseract.png") +fury.window.record(showm.scene, size=(600, 600), out_path="viz_tesseract.png") diff --git a/docs/examples/viz_texture.py b/docs/examples/viz_texture.py index 31043b706..fe46def4c 100644 --- a/docs/examples/viz_texture.py +++ b/docs/examples/viz_texture.py @@ -5,13 +5,12 @@ In this tutorial, we will show how to create a sphere with a texture. """ -from fury import actor, io, window -from fury.data import fetch_viz_textures, read_viz_textures +import fury ############################################################################## # Create a scene to start. -scene = window.Scene() +scene = fury.window.Scene() ############################################################################## # Load an image (png, bmp, jpeg or jpg) using ``io.load_image``. In this @@ -19,17 +18,17 @@ # Earth's surface from the fury Github after using ''fetch_viz_textures()'' # to download the available textures. -fetch_viz_textures() -filename = read_viz_textures("1_earth_8k.jpg") -image = io.load_image(filename) +fury.data.fetch_viz_textures() +filename = fury.data.read_viz_textures("1_earth_8k.jpg") +image = fury.io.load_image(filename) ############################################################################## -# Next, use ``actor.texture_on_sphere`` to add a sphere with the texture from +# Next, use ``fury.actor.texture_on_sphere`` to add a sphere with the texture from # your loaded image to the already existing scene. # To add a texture to your scene as visualized on a plane, use -# ``actor.texture`` instead. +# ``fury.actor.texture`` instead. -scene.add(actor.texture_on_sphere(image)) +scene.add(fury.actor.texture_on_sphere(image)) ############################################################################## # Lastly, record the scene, or set interactive to True if you would like to @@ -37,5 +36,5 @@ interactive = False if interactive: - window.show(scene, size=(600, 600), reset_camera=False) -window.record(scene, size=(900, 768), out_path="viz_texture.png") + fury.window.show(scene, size=(600, 600), reset_camera=False) +fury.window.record(scene, size=(900, 768), out_path="viz_texture.png") diff --git a/docs/examples/viz_timeline.py b/docs/examples/viz_timeline.py index 45218aacc..4e579e57f 100644 --- a/docs/examples/viz_timeline.py +++ b/docs/examples/viz_timeline.py @@ -18,14 +18,13 @@ import numpy as np -from fury import actor, window -from fury.animation import Animation, Timeline +import fury ############################################################################### # We create our ``Scene`` and ``ShowManager`` as usual. -scene = window.Scene() +scene = fury.window.Scene() -showm = window.ShowManager(scene, size=(900, 768)) +showm = fury.window.ShowManager(scene, size=(900, 768)) showm.initialize() ############################################################################### @@ -37,12 +36,12 @@ ############################################################################### # Creating a ``Timeline`` with a PlaybackPanel. -timeline = Timeline(playback_panel=True) +timeline = fury.animation.Timeline(playback_panel=True) ############################################################################### # Creating a Fury Animation as usual -anim = Animation() -sphere = actor.sphere(np.zeros([1, 3]), np.ones([1, 3])) +anim = fury.animation.Animation() +sphere = fury.actor.sphere(np.zeros([1, 3]), np.ones([1, 3])) anim.add_actor(sphere) # Now that the actor is add to the ``Animation``, setting keyframes to the # Animation will animate the actor accordingly. @@ -88,4 +87,6 @@ if interactive: showm.start() -window.record(scene, out_path="viz_keyframe_animation_timeline.png", size=(900, 768)) +fury.window.record( + scene, out_path="viz_keyframe_animation_timeline.png", size=(900, 768) +) diff --git a/docs/examples/viz_timers.py b/docs/examples/viz_timers.py index 4618cee44..e0217a7a5 100644 --- a/docs/examples/viz_timers.py +++ b/docs/examples/viz_timers.py @@ -17,24 +17,24 @@ import numpy as np -from fury import actor, ui, window +import fury xyz = 10 * np.random.rand(100, 3) colors = np.random.rand(100, 4) radii = np.random.rand(100) + 0.5 -scene = window.Scene() +scene = fury.window.Scene() -sphere_actor = actor.sphere(centers=xyz, colors=colors, radii=radii) +sphere_actor = fury.actor.sphere(centers=xyz, colors=colors, radii=radii) scene.add(sphere_actor) -showm = window.ShowManager( +showm = fury.window.ShowManager( scene, size=(900, 768), reset_camera=False, order_transparent=True ) -tb = ui.TextBlock2D(bold=True) +tb = fury.ui.TextBlock2D(bold=True) # use itertools to avoid global variables counter = itertools.count() @@ -66,4 +66,4 @@ def timer_callback(_obj, _event): showm.start() -window.record(showm.scene, size=(900, 768), out_path="viz_timer.png") +fury.window.record(showm.scene, size=(900, 768), out_path="viz_timer.png") diff --git a/docs/examples/viz_ui.py b/docs/examples/viz_ui.py index 31eecdc0b..8d50712e2 100644 --- a/docs/examples/viz_ui.py +++ b/docs/examples/viz_ui.py @@ -12,8 +12,7 @@ import numpy as np -from fury import actor, ui, window -from fury.data import fetch_viz_icons, read_viz_icons +import fury ############################################################################### # Shapes @@ -21,17 +20,19 @@ # # Let's start by drawing some simple shapes. First, a rectangle. -rect = ui.Rectangle2D(size=(200, 200), position=(400, 300), color=(1, 0, 1)) +rect = fury.ui.Rectangle2D(size=(200, 200), position=(400, 300), color=(1, 0, 1)) ############################################################################### # Then we can draw a solid circle, or disk. -disk = ui.Disk2D(outer_radius=50, center=(500, 500), color=(1, 1, 0)) +disk = fury.ui.Disk2D(outer_radius=50, center=(500, 500), color=(1, 1, 0)) ############################################################################### # Add an inner radius to make a ring. -ring = ui.Disk2D(outer_radius=50, inner_radius=45, center=(500, 300), color=(0, 1, 1)) +ring = fury.ui.Disk2D( + outer_radius=50, inner_radius=45, center=(500, 300), color=(0, 1, 1) +) ############################################################################### # Image @@ -40,13 +41,13 @@ # Now let's display an image. First we need to fetch some icons that are # included in FURY. -fetch_viz_icons() +fury.data.fetch_viz_icons() ############################################################################### # Now we can create an image container. -img = ui.ImageContainer2D( - img_path=read_viz_icons(fname="home3.png"), position=(450, 350) +img = fury.ui.ImageContainer2D( + img_path=fury.data.read_viz_icons(fname="home3.png"), position=(450, 350) ) ############################################################################### @@ -56,15 +57,15 @@ # Let's create some buttons and text and put them in a panel. First we'll # make the panel. -panel = ui.Panel2D(size=(300, 150), color=(1, 1, 1), align="right") +panel = fury.ui.Panel2D(size=(300, 150), color=(1, 1, 1), align="right") panel.center = (500, 400) ############################################################################### # Then we'll make two text labels and place them on the panel. # Note that we specify the position with integer numbers of pixels. -text = ui.TextBlock2D(text="Click me") -text2 = ui.TextBlock2D(text="Me too") +text = fury.ui.TextBlock2D(text="Click me") +text2 = fury.ui.TextBlock2D(text="Me too") panel.add_element(text, (50, 100)) panel.add_element(text2, (180, 100)) @@ -75,17 +76,17 @@ # percentages of the panel size. -button_example = ui.Button2D( - icon_fnames=[("square", read_viz_icons(fname="stop2.png"))] +button_example = fury.ui.Button2D( + icon_fnames=[("square", fury.data.read_viz_icons(fname="stop2.png"))] ) icon_files = [] -icon_files.append(("down", read_viz_icons(fname="circle-down.png"))) -icon_files.append(("left", read_viz_icons(fname="circle-left.png"))) -icon_files.append(("up", read_viz_icons(fname="circle-up.png"))) -icon_files.append(("right", read_viz_icons(fname="circle-right.png"))) +icon_files.append(("down", fury.data.read_viz_icons(fname="circle-down.png"))) +icon_files.append(("left", fury.data.read_viz_icons(fname="circle-left.png"))) +icon_files.append(("up", fury.data.read_viz_icons(fname="circle-up.png"))) +icon_files.append(("right", fury.data.read_viz_icons(fname="circle-right.png"))) -second_button_example = ui.Button2D(icon_fnames=icon_files) +second_button_example = fury.ui.Button2D(icon_fnames=icon_files) panel.add_element(button_example, (0.25, 0.33)) panel.add_element(second_button_example, (0.66, 0.33)) @@ -114,7 +115,7 @@ def change_icon_callback(i_ren, _obj, _button): # Let's add a cube to the scene and control it with sliders. -cube = actor.cube( +cube = fury.actor.cube( centers=np.array([[15, 0, 0]]), colors=np.array([[0, 0, 1]]), scales=np.array([[20, 20, 20]]), @@ -124,11 +125,11 @@ def change_icon_callback(i_ren, _obj, _button): ############################################################################### # Now we'll add three sliders: one circular and two linear. -ring_slider = ui.RingSlider2D( +ring_slider = fury.ui.RingSlider2D( center=(740, 400), initial_value=0, text_template="{angle:5.1f}°" ) -line_slider_x = ui.LineSlider2D( +line_slider_x = fury.ui.LineSlider2D( center=(500, 250), initial_value=0, min_value=-10, @@ -136,7 +137,7 @@ def change_icon_callback(i_ren, _obj, _button): orientation="horizontal", ) -line_slider_y = ui.LineSlider2D( +line_slider_y = fury.ui.LineSlider2D( center=(650, 350), initial_value=0, min_value=-10, @@ -187,7 +188,7 @@ def translate_cube_y(slider): # Finally, we can add a range slider. This element is composed of two sliders. # The first slider has two handles which let you set the range of the second. -range_slider_x = ui.RangeSlider( +range_slider_x = fury.ui.RangeSlider( line_width=8, handle_side=25, range_slider_center=(450, 450), @@ -201,7 +202,7 @@ def translate_cube_y(slider): shape="square", ) -range_slider_y = ui.RangeSlider( +range_slider_y = fury.ui.RangeSlider( line_width=8, handle_side=25, range_slider_center=(750, 400), @@ -263,7 +264,7 @@ def hide_all_examples(): ############################################################################### # Now we can create the menu. -listbox = ui.ListBox2D( +listbox = fury.ui.ListBox2D( values=values, position=(10, 300), size=(300, 200), multiselection=False ) @@ -291,7 +292,7 @@ def display_element(): # manager. current_size = (800, 800) -show_manager = window.ShowManager(size=current_size, title="FURY UI Example") +show_manager = fury.window.ShowManager(size=current_size, title="FURY UI Example") show_manager.scene.add(listbox) for example in examples: @@ -309,4 +310,4 @@ def display_element(): if interactive: show_manager.start() -window.record(show_manager.scene, size=current_size, out_path="viz_ui.png") +fury.window.record(show_manager.scene, size=current_size, out_path="viz_fury.ui.png") diff --git a/docs/examples/viz_ui_listbox.py b/docs/examples/viz_ui_listbox.py index c89335662..146d147b6 100644 --- a/docs/examples/viz_ui_listbox.py +++ b/docs/examples/viz_ui_listbox.py @@ -10,21 +10,20 @@ First, a bunch of imports. """ -from fury import ui, window -from fury.data import fetch_viz_icons +import fury ############################################################################## # First we need to fetch some icons that are included in FURY. -fetch_viz_icons() +fury.data.fetch_viz_icons() ############################################################################### # Create some text blocks that will be shown when # list elements will be selected -welcome_text = ui.TextBlock2D(text="Welcome", font_size=30, position=(500, 400)) -bye_text = ui.TextBlock2D(text="Bye", font_size=30, position=(500, 400)) -fury_text = ui.TextBlock2D(text="Fury", font_size=30, position=(500, 400)) +welcome_text = fury.ui.TextBlock2D(text="Welcome", font_size=30, position=(500, 400)) +bye_text = fury.ui.TextBlock2D(text="Bye", font_size=30, position=(500, 400)) +fury_text = fury.ui.TextBlock2D(text="Fury", font_size=30, position=(500, 400)) example = [welcome_text, bye_text, fury_text] @@ -43,7 +42,7 @@ def hide_all_examples(): # Create ListBox with the values as parameter. values = ["Welcome", "Bye", "Fury"] -listbox = ui.ListBox2D( +listbox = fury.ui.ListBox2D( values=values, position=(10, 300), size=(200, 200), multiselection=False ) @@ -64,7 +63,9 @@ def display_element(): # manager. current_size = (800, 800) -show_manager = window.ShowManager(size=current_size, title="FURY UI ListBox_Example") +show_manager = fury.window.ShowManager( + size=current_size, title="FURY UI ListBox_Example" +) show_manager.scene.add(listbox) show_manager.scene.add(welcome_text) @@ -75,4 +76,4 @@ def display_element(): if interactive: show_manager.start() -window.record(show_manager.scene, size=current_size, out_path="viz_listbox.png") +fury.window.record(show_manager.scene, size=current_size, out_path="viz_listbox.png") diff --git a/docs/examples/viz_ui_slider.py b/docs/examples/viz_ui_slider.py index 034761fc3..31e47f0c4 100644 --- a/docs/examples/viz_ui_slider.py +++ b/docs/examples/viz_ui_slider.py @@ -12,13 +12,12 @@ import numpy as np -from fury import actor, ui, window -from fury.data import fetch_viz_icons +import fury ############################################################################## # First we need to fetch some icons that are included in FURY. -fetch_viz_icons() +fury.data.fetch_viz_icons() ############################################################################### # Cube and sliders @@ -26,7 +25,7 @@ # # Add a cube to the scene . -cube = actor.cube( +cube = fury.actor.cube( centers=np.array([[15, 0, 0]]), colors=np.array([[0, 0, 1]]), scales=np.array([[20, 20, 20]]), @@ -37,11 +36,11 @@ # 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( +ring_slider = fury.ui.RingSlider2D( center=(630, 400), initial_value=0, text_template="{angle:5.1f}°" ) -hor_line_slider_text_top = ui.LineSlider2D( +hor_line_slider_text_top = fury.ui.LineSlider2D( center=(400, 230), initial_value=0, orientation="horizontal", @@ -50,7 +49,7 @@ text_alignment="top", ) -hor_line_slider_text_bottom = ui.LineSlider2D( +hor_line_slider_text_bottom = fury.ui.LineSlider2D( center=(400, 200), initial_value=0, orientation="horizontal", @@ -59,7 +58,7 @@ text_alignment="bottom", ) -ver_line_slider_text_left = ui.LineSlider2D( +ver_line_slider_text_left = fury.ui.LineSlider2D( center=(100, 400), initial_value=0, orientation="vertical", @@ -68,7 +67,7 @@ text_alignment="left", ) -ver_line_slider_text_right = ui.LineSlider2D( +ver_line_slider_text_right = fury.ui.LineSlider2D( center=(150, 400), initial_value=0, orientation="vertical", @@ -118,7 +117,7 @@ def translate_cube_hor(slider): # manager. current_size = (800, 800) -show_manager = window.ShowManager(size=current_size, title="FURY Cube Example") +show_manager = fury.window.ShowManager(size=current_size, title="FURY Cube Example") show_manager.scene.add(cube) show_manager.scene.add(ring_slider) @@ -150,4 +149,4 @@ def translate_cube_hor(slider): if interactive: show_manager.start() -window.record(show_manager.scene, size=current_size, out_path="viz_slider.png") +fury.window.record(show_manager.scene, size=current_size, out_path="viz_slider.png") diff --git a/docs/examples/viz_using_time_equations.py b/docs/examples/viz_using_time_equations.py index baf680b2c..a4ae678fd 100644 --- a/docs/examples/viz_using_time_equations.py +++ b/docs/examples/viz_using_time_equations.py @@ -8,21 +8,20 @@ import numpy as np -from fury import actor, window -from fury.animation import Animation +import fury -scene = window.Scene() +scene = fury.window.Scene() -showm = window.ShowManager( +showm = fury.window.ShowManager( scene, size=(900, 768), reset_camera=False, order_transparent=True ) -cube = actor.cube(np.array([[0, 0, 0]]), (0, 0, 0), (1, 0, 1), scales=6) +cube = fury.actor.cube(np.array([[0, 0, 0]]), (0, 0, 0), (1, 0, 1), scales=6) ############################################################################### # Creating an ``Animation`` to animate the actor and show its motion path. -anim = Animation(length=2 * np.pi, loop=True, motion_path_res=200) +anim = fury.animation.Animation(length=2 * np.pi, loop=True, motion_path_res=200) ############################################################################### # Adding the sphere actor to the timeline @@ -77,4 +76,6 @@ def scale_eval(t): if interactive: showm.start() -window.record(scene, out_path="viz_keyframe_animation_evaluators.png", size=(900, 768)) +fury.window.record( + scene, out_path="viz_keyframe_animation_evaluators.png", size=(900, 768) +) diff --git a/docs/examples/viz_widget.py b/docs/examples/viz_widget.py index 6768a843e..ee7b99da8 100644 --- a/docs/examples/viz_widget.py +++ b/docs/examples/viz_widget.py @@ -42,23 +42,22 @@ import numpy as np -from fury import actor, window -from fury.stream.widget import Widget +import fury interactive = False window_size = (720, 500) N = 4 centers = np.random.normal(size=(N, 3)) colors = np.random.uniform(0.1, 1.0, size=(N, 3)) -actors = actor.sphere(centers, opacity=0.5, radii=0.4, colors=colors) -scene = window.Scene() +actors = fury.actor.sphere(centers, opacity=0.5, radii=0.4, colors=colors) +scene = fury.window.Scene() scene.add(actors) -showm = window.ShowManager(scene, size=(window_size[0], window_size[1])) +showm = fury.window.ShowManager(scene, size=(window_size[0], window_size[1])) ########################################################################## # Create a stream widget -widget = Widget(showm, port=8000) +widget = fury.stream.Widget(showm, port=8000) # if you want to use webRTC, you can pass the argument to choose this encoding # which is a more robust option. @@ -86,4 +85,4 @@ async def main(): time.sleep(time_sleep) widget.stop() -window.record(showm.scene, size=window_size, out_path="viz_widget.png") +fury.window.record(showm.scene, size=window_size, out_path="viz_widget.png") diff --git a/docs/examples/viz_wrecking_ball.py b/docs/examples/viz_wrecking_ball.py index 1e574ccc3..31e9587a3 100644 --- a/docs/examples/viz_wrecking_ball.py +++ b/docs/examples/viz_wrecking_ball.py @@ -15,7 +15,7 @@ import numpy as np import pybullet as p -from fury import actor, ui, utils, window +import fury ############################################################################### # Initiate pybullet and enable gravity. @@ -52,7 +52,7 @@ # Creating the base plane actor. # Base -base_actor = actor.box( +base_actor = fury.actor.box( centers=np.array([[0, 0, 0]]), directions=[0, 0, 0], scales=(5, 5, 0.2), @@ -108,7 +108,7 @@ p.changeDynamics(bricks[idx], -1, lateralFriction=0.1, restitution=0.1) idx += 1 -brick_actor = actor.box( +brick_actor = fury.actor.box( centers=brick_centers, directions=brick_directions, scales=brick_sizes, @@ -160,7 +160,7 @@ link_heights = np.zeros(n_links) link_heights[:] = dx_link -rope_actor = actor.cylinder( +rope_actor = fury.actor.cylinder( centers=linkPositions, directions=linkDirections, colors=np.random.rand(n_links, 3), @@ -213,14 +213,14 @@ rope, -1, -1, -1, p.JOINT_FIXED, [0, 0, 0], [0, 0, 0], [0, 0, 2] ) -box_actor = actor.box( +box_actor = fury.actor.box( centers=np.array([[0, 0, 0]]), directions=np.array([[0, 0, 0]]), scales=(0.02, 0.02, 0.02), colors=np.array([[1, 0, 0]]), ) -ball_actor = actor.sphere( +ball_actor = fury.actor.sphere( centers=np.array([[0, 0, 0]]), radii=ball_radius, colors=np.array([1, 0, 1]) ) @@ -228,12 +228,12 @@ # Now we add the necessary actors to the scene and set the camera for better # visualization. -scene = window.Scene() +scene = fury.window.Scene() scene.set_camera((10.28, -7.10, 6.39), (0.0, 0.0, 0.4), (-0.35, 0.26, 1.0)) -scene.add(actor.axes(scale=(0.5, 0.5, 0.5)), base_actor, brick_actor) +scene.add(fury.actor.axes(scale=(0.5, 0.5, 0.5)), base_actor, brick_actor) scene.add(rope_actor, box_actor, ball_actor) -showm = window.ShowManager( +showm = fury.window.ShowManager( scene, size=(900, 768), reset_camera=False, order_transparent=True ) @@ -247,7 +247,7 @@ ############################################################################### # Calculate the vertices of the bricks. -brick_vertices = utils.vertices_from_actor(brick_actor) +brick_vertices = fury.utils.vertices_from_actor(brick_actor) num_vertices = brick_vertices.shape[0] num_objects = brick_centers.shape[0] brick_sec = int(num_vertices / num_objects) @@ -255,7 +255,7 @@ ############################################################################### # Calculate the vertices of the wrecking ball. -chain_vertices = utils.vertices_from_actor(rope_actor) +chain_vertices = fury.utils.vertices_from_actor(rope_actor) num_vertices = chain_vertices.shape[0] num_objects = brick_centers.shape[0] chain_sec = int(num_vertices / num_objects) @@ -316,7 +316,7 @@ def sync_chain(actor_list, multibody): counter = itertools.count() fpss = np.array([]) -tb = ui.TextBlock2D( +tb = fury.ui.TextBlock2D( position=(0, 680), font_size=30, color=(1, 0.5, 0), text="Avg. FPS: \nSim Steps: " ) scene.add(tb) @@ -355,8 +355,8 @@ def timer_callback(_obj, _event): pos = p.getLinkState(rope, p.getNumJoints(rope) - 1)[4] ball_actor.SetPosition(*pos) sync_chain(rope_actor, rope) - utils.update_actor(brick_actor) - utils.update_actor(rope_actor) + fury.utils.update_actor(brick_actor) + fury.utils.update_actor(rope_actor) # Simulate a step. p.stepSimulation() @@ -375,4 +375,4 @@ def timer_callback(_obj, _event): if interactive: showm.start() -window.record(scene, size=(900, 768), out_path="viz_wrecking_ball.png") +fury.window.record(scene, size=(900, 768), out_path="viz_wrecking_ball.png") diff --git a/docs/experimental/viz_molecular_demo.py b/docs/experimental/viz_molecular_demo.py index d72338a55..6f94154df 100644 --- a/docs/experimental/viz_molecular_demo.py +++ b/docs/experimental/viz_molecular_demo.py @@ -129,10 +129,10 @@ # 3. Creating and adding axes actor to the scene. # 4. Computing the bonding information for the molecule. # 5. Generating and adding various molecular representations to the scene. -scene = window.Scene() +scene = fury.window.Scene() scene.set_camera(position=(20, 10, 0), focal_point=(0, 0, 0), view_up=(0, 1, 0)) scene.zoom(0.8) -axes_actor = actor.axes() +axes_actor = fury.actor.axes() scene.add(axes_actor) molecule = mol.Molecule( @@ -172,9 +172,9 @@ ############################################################################### # creating a ShowManager object -showm = window.ShowManager(scene, size=dims, reset_camera=True, order_transparent=True) +showm = fury.window.ShowManager(scene, size=dims, reset_camera=True, order_transparent=True) -tb = ui.TextBlock2D( +tb = fury.ui.TextBlock2D( text=pdb_code.upper(), position=(screen_x_dim / 2 - 40, screen_y_dim / 12), font_size=30, @@ -189,5 +189,5 @@ interactive = False if interactive: - window.show(scene, size=dims, title=pdb_code.upper()) -window.record(scene, size=dims, out_path=pdb_code.upper() + '.png') + fury.window.show(scene, size=dims, title=pdb_code.upper()) +fury.window.record(scene, size=dims, out_path=pdb_code.upper() + '.png') diff --git a/docs/experimental/viz_multisdf.py b/docs/experimental/viz_multisdf.py index 37a78c5b4..fee954482 100644 --- a/docs/experimental/viz_multisdf.py +++ b/docs/experimental/viz_multisdf.py @@ -46,7 +46,7 @@ vtk.vtkShader.Fragment, '//VTK::Light::Impl', True, fs_impl_code, False ) -scene = window.Scene() +scene = fury.window.Scene() scene.background((1.0, 0.8, 0.8)) centers = np.array([[0, 0, 0]]) @@ -61,7 +61,7 @@ def timer_callback(obj, event): showm.render() -@window.vtk.calldata_type(window.vtk.VTK_OBJECT) +@fury.window.vtk.calldata_type(fury.window.vtk.VTK_OBJECT) def vtk_shader_callback(caller, event, calldata=None): program = calldata global timer @@ -72,15 +72,15 @@ def vtk_shader_callback(caller, event, calldata=None): pass -mapper.AddObserver(window.vtk.vtkCommand.UpdateShaderEvent, vtk_shader_callback) +mapper.AddObserver(fury.window.vtk.vtkCommand.UpdateShaderEvent, vtk_shader_callback) -showm = window.ShowManager(scene, reset_camera=False) +showm = fury.window.ShowManager(scene, reset_camera=False) showm.add_timer_callback(True, 10, timer_callback) scene.add(sdfactor) -scene.add(actor.axes()) +scene.add(fury.actor.axes()) showm.start() diff --git a/fury/__init__.pyi b/fury/__init__.pyi index ec5cb5563..9a961b136 100644 --- a/fury/__init__.pyi +++ b/fury/__init__.pyi @@ -59,6 +59,7 @@ from . import ( stream, testing, transform, + ui, utils, window, )