From 6b3169875f087c3eaf44d3972ab71d1b0819c22b Mon Sep 17 00:00:00 2001 From: Serge Koudoro Date: Fri, 3 Mar 2023 13:00:36 -0500 Subject: [PATCH 1/6] initialize iren in ui --- fury/ui/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fury/ui/core.py b/fury/ui/core.py index c0314fd94..7d65d7c04 100644 --- a/fury/ui/core.py +++ b/fury/ui/core.py @@ -176,7 +176,8 @@ def add_to_scene(self, scene): raise TypeError(msg) if callback[0] == self._scene: - + if not iren.GetInitialized(): + iren.Initialize() iren.add_callback(iren, callback[1], callback[2], args=[self]) else: iren.add_callback(*callback, args=[self]) From 454a85824b1694d1d68efe29ff71d603d5283905 Mon Sep 17 00:00:00 2001 From: Serge Koudoro Date: Fri, 3 Mar 2023 13:02:15 -0500 Subject: [PATCH 2/6] update tutorials --- .../01_introductory/viz_gltf_animated.py | 1 - .../tutorials/01_introductory/viz_morphing.py | 1 - .../01_introductory/viz_multithread.py | 32 +++++++++---------- .../tutorials/01_introductory/viz_skinning.py | 1 - .../viz_hierarchical_animation.py | 1 - .../05_animation/viz_interpolators.py | 1 - .../05_animation/viz_introduction.py | 1 - .../05_animation/viz_robot_arm_animation.py | 1 - docs/tutorials/05_animation/viz_timeline.py | 1 - 9 files changed, 16 insertions(+), 24 deletions(-) diff --git a/docs/tutorials/01_introductory/viz_gltf_animated.py b/docs/tutorials/01_introductory/viz_gltf_animated.py index 6060a4030..e2e97f3c6 100644 --- a/docs/tutorials/01_introductory/viz_gltf_animated.py +++ b/docs/tutorials/01_introductory/viz_gltf_animated.py @@ -18,7 +18,6 @@ showm = window.ShowManager( scene, size=(900, 768), reset_camera=False, order_transparent=True ) -showm.initialize() ############################################################################## diff --git a/docs/tutorials/01_introductory/viz_morphing.py b/docs/tutorials/01_introductory/viz_morphing.py index 6d8fa21f4..07f1e22a4 100644 --- a/docs/tutorials/01_introductory/viz_morphing.py +++ b/docs/tutorials/01_introductory/viz_morphing.py @@ -45,7 +45,6 @@ scene, size=(900, 768), reset_camera=True, order_transparent=True ) -showm.initialize() scene.add(animation) ############################################################################## diff --git a/docs/tutorials/01_introductory/viz_multithread.py b/docs/tutorials/01_introductory/viz_multithread.py index e1b711d89..a515272c9 100644 --- a/docs/tutorials/01_introductory/viz_multithread.py +++ b/docs/tutorials/01_introductory/viz_multithread.py @@ -10,31 +10,29 @@ adds and removes elements from the scene. """ -from fury import window, actor, ui +import time from threading import Thread + import numpy as np -import time +from fury import actor, ui, window # Preparing to draw some spheres -xyz = 10 * (np.random.random((100, 3))-0.5) +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(centers=xyz, - colors=colors, - radii=radii, - use_primitive=False) +sphere_actor = actor.sphere( + centers=xyz, colors=colors, radii=radii, use_primitive=False +) scene.add(sphere_actor) # Preparing the show manager as usual -showm = window.ShowManager(scene, - size=(900, 768), reset_camera=False, - order_transparent=True) - -# showm.initialize() +showm = window.ShowManager( + scene, size=(900, 768), reset_camera=False, order_transparent=True +) # Creating a text block to show a message and reset the camera tb = ui.TextBlock2D(bold=True) @@ -44,16 +42,17 @@ # Create a function to print a counter to the console def print_counter(): - print("") + print('') for i in range(100): - print("\rCounter: %d" % i, end="") - message = "Let's count up to 100 and exit :" + str(i+1) + print('\rCounter: %d' % i, end='') + message = "Let's count up to 100 and exit :" + str(i + 1) tb.message = message time.sleep(0.05) if showm.is_done(): break showm.exit() - print("") + print('') + # Create a function to rotate the camera @@ -67,6 +66,7 @@ def rotate_camera(): else: break + # Create a function to add or remove the axes and increase its scale diff --git a/docs/tutorials/01_introductory/viz_skinning.py b/docs/tutorials/01_introductory/viz_skinning.py index f537933a9..84efafcc3 100644 --- a/docs/tutorials/01_introductory/viz_skinning.py +++ b/docs/tutorials/01_introductory/viz_skinning.py @@ -47,7 +47,6 @@ showm = window.ShowManager( scene, size=(900, 768), reset_camera=True, order_transparent=True ) -showm.initialize() scene.add(animation) ############################################################################## diff --git a/docs/tutorials/05_animation/viz_hierarchical_animation.py b/docs/tutorials/05_animation/viz_hierarchical_animation.py index 35c9b454d..22df07226 100644 --- a/docs/tutorials/05_animation/viz_hierarchical_animation.py +++ b/docs/tutorials/05_animation/viz_hierarchical_animation.py @@ -15,7 +15,6 @@ showm = window.ShowManager( scene, size=(900, 768), reset_camera=False, order_transparent=True ) -showm.initialize() ############################################################################### # Creating the road diff --git a/docs/tutorials/05_animation/viz_interpolators.py b/docs/tutorials/05_animation/viz_interpolators.py index 6a63c112b..11ac677cf 100644 --- a/docs/tutorials/05_animation/viz_interpolators.py +++ b/docs/tutorials/05_animation/viz_interpolators.py @@ -66,7 +66,6 @@ showm = window.ShowManager( scene, size=(900, 768), reset_camera=False, order_transparent=True ) -showm.initialize() arrow = actor.arrow(np.array([[0, 0, 0]]), (0, 0, 0), (1, 0, 1), scales=6) diff --git a/docs/tutorials/05_animation/viz_introduction.py b/docs/tutorials/05_animation/viz_introduction.py index 86b5fa3d4..0fdf52d04 100644 --- a/docs/tutorials/05_animation/viz_introduction.py +++ b/docs/tutorials/05_animation/viz_introduction.py @@ -64,7 +64,6 @@ scene = window.Scene() showm = window.ShowManager(scene, size=(900, 768)) -showm.initialize() ############################################################################### diff --git a/docs/tutorials/05_animation/viz_robot_arm_animation.py b/docs/tutorials/05_animation/viz_robot_arm_animation.py index 24dc53700..dafe853c0 100644 --- a/docs/tutorials/05_animation/viz_robot_arm_animation.py +++ b/docs/tutorials/05_animation/viz_robot_arm_animation.py @@ -16,7 +16,6 @@ showm = window.ShowManager( scene, size=(900, 768), reset_camera=False, order_transparent=True ) -showm.initialize() ############################################################################### diff --git a/docs/tutorials/05_animation/viz_timeline.py b/docs/tutorials/05_animation/viz_timeline.py index 03eaac2e1..20f1e2cda 100644 --- a/docs/tutorials/05_animation/viz_timeline.py +++ b/docs/tutorials/05_animation/viz_timeline.py @@ -27,7 +27,6 @@ scene = window.Scene() showm = window.ShowManager(scene, size=(900, 768)) -showm.initialize() ############################################################################### # Creating a ``Timeline`` From 63ec1a1a017cc881016f9d8a66b0826a55928eed Mon Sep 17 00:00:00 2001 From: Serge Koudoro Date: Fri, 3 Mar 2023 13:02:58 -0500 Subject: [PATCH 3/6] update tests --- fury/tests/test_gltf.py | 3 --- fury/tests/test_thread.py | 28 ++++++++++++---------------- fury/tests/test_window.py | 1 - 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/fury/tests/test_gltf.py b/fury/tests/test_gltf.py index a5db1a2a6..e2c8c0b98 100644 --- a/fury/tests/test_gltf.py +++ b/fury/tests/test_gltf.py @@ -188,7 +188,6 @@ def test_simple_animation(): timeline.add_animation(animation) scene = window.Scene() showm = window.ShowManager(scene, size=(900, 768)) - showm.initialize() scene.add(timeline) @@ -255,7 +254,6 @@ def test_skinning(): scene = window.Scene() showm = window.ShowManager(scene, size=(900, 768)) - showm.initialize() scene.add(timeline) timeline.seek(1.0) @@ -329,7 +327,6 @@ def test_morphing(): scene = window.Scene() showm = window.ShowManager(scene, size=(900, 768)) - showm.initialize() timeline_1 = Timeline() timeline_1.add_animation(anim_1) diff --git a/fury/tests/test_thread.py b/fury/tests/test_thread.py index 86c850b54..b42e0025f 100644 --- a/fury/tests/test_thread.py +++ b/fury/tests/test_thread.py @@ -1,11 +1,12 @@ - import time from threading import Thread -from fury.utils import rotate, update_actor, vertices_from_actor + import numpy as np import numpy.testing as npt import pytest + from fury import actor, window +from fury.utils import rotate, update_actor, vertices_from_actor def test_multithreading(): @@ -14,19 +15,15 @@ def test_multithreading(): radii = np.random.random(100) + 0.5 scene = window.Scene() - sphere_actor = actor.sphere(centers = xyz, - colors = colors, - radii = radii, - use_primitive = False) + sphere_actor = actor.sphere( + centers=xyz, colors=colors, radii=radii, use_primitive=False + ) scene.add(sphere_actor) # Preparing the show manager as usual - showm = window.ShowManager(scene, - size = (900, 768), - reset_camera = False, - order_transparent = True) - - # showm.initialize() + showm = window.ShowManager( + scene, size=(900, 768), reset_camera=False, order_transparent=True + ) vsa = vertices_from_actor(sphere_actor) @@ -48,12 +45,11 @@ def callback1(): # showm.exit() # npt.assert_equal(np.sum(arr) > 1, True) - - thread_a = Thread(target = callback1) + thread_a = Thread(target=callback1) thread_a.start() - showm.start(multithreaded = True) + showm.start(multithreaded=True) thread_a.join() -test_multithreading() \ No newline at end of file +test_multithreading() diff --git a/fury/tests/test_window.py b/fury/tests/test_window.py index f45607fc9..cc328ffd0 100644 --- a/fury/tests/test_window.py +++ b/fury/tests/test_window.py @@ -606,7 +606,6 @@ def test_opengl_state_add_remove_and_check(): def test_add_animation_to_show_manager(): showm = window.ShowManager() - showm.initialize() cube = actor.cube(np.array([[2, 2, 3]])) From 8f7dced9135019bb2e9fe2213273fd06a5aa201f Mon Sep 17 00:00:00 2001 From: Serge Koudoro Date: Fri, 3 Mar 2023 13:03:14 -0500 Subject: [PATCH 4/6] update docs --- docs/source/fury-pybullet.rst | 1 - docs/source/getting_started.rst | 1 - 2 files changed, 2 deletions(-) diff --git a/docs/source/fury-pybullet.rst b/docs/source/fury-pybullet.rst index bd1c8077c..d278365b1 100644 --- a/docs/source/fury-pybullet.rst +++ b/docs/source/fury-pybullet.rst @@ -177,7 +177,6 @@ A ``window.ShowManager`` and ``itertools.count`` instance must be created before showm = window.ShowManager(scene, size=(900, 768), reset_camera=False, order_transparent=True) - showm.initialize() # Counter iterator for tracking simulation steps. counter = itertools.count() diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst index 800bdb034..a9493de23 100644 --- a/docs/source/getting_started.rst +++ b/docs/source/getting_started.rst @@ -42,7 +42,6 @@ Anything that has to be rendered needs to be added to the scene so let's create We set the window scene variables e.g. (width, height):: showm = window.ShowManager(scene, size=(1024,720), reset_camera=False) - showm.initialize() We add a text block to add some information:: From 5fcf4d65f5915364af410c4264bb26ebf2cd8b25 Mon Sep 17 00:00:00 2001 From: Serge Koudoro Date: Tue, 7 Mar 2023 13:58:35 -0500 Subject: [PATCH 5/6] check initialize in multithread --- fury/window.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fury/window.py b/fury/window.py index a31aba7aa..88b886e40 100644 --- a/fury/window.py +++ b/fury/window.py @@ -535,6 +535,8 @@ def start(self, multithreaded=False, desired_fps=60): else: self.window.SetWindowName(self.title) if multithreaded: + if not iren.GetInitialized(): + iren.Initialize() while self.iren.GetDone() is False: start_time = time.perf_counter() self.lock() From 29701ff23935014b4d41f3192500228f1aeeb41a Mon Sep 17 00:00:00 2001 From: Serge Koudoro Date: Tue, 7 Mar 2023 14:03:09 -0500 Subject: [PATCH 6/6] typo --- fury/window.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fury/window.py b/fury/window.py index 88b886e40..5cd3e2d57 100644 --- a/fury/window.py +++ b/fury/window.py @@ -535,8 +535,8 @@ def start(self, multithreaded=False, desired_fps=60): else: self.window.SetWindowName(self.title) if multithreaded: - if not iren.GetInitialized(): - iren.Initialize() + if not self.iren.GetInitialized(): + self.iren.Initialize() while self.iren.GetDone() is False: start_time = time.perf_counter() self.lock()