Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove initialize #749

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/source/fury-pybullet.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
1 change: 0 additions & 1 deletion docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::

Expand Down
1 change: 0 additions & 1 deletion docs/tutorials/01_introductory/viz_gltf_animated.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
showm = window.ShowManager(
scene, size=(900, 768), reset_camera=False, order_transparent=True
)
showm.initialize()


##############################################################################
Expand Down
1 change: 0 additions & 1 deletion docs/tutorials/01_introductory/viz_morphing.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
scene, size=(900, 768), reset_camera=True, order_transparent=True
)

showm.initialize()
scene.add(animation)

##############################################################################
Expand Down
32 changes: 16 additions & 16 deletions docs/tutorials/01_introductory/viz_multithread.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand All @@ -67,6 +66,7 @@ def rotate_camera():
else:
break


# Create a function to add or remove the axes and increase its scale


Expand Down
1 change: 0 additions & 1 deletion docs/tutorials/01_introductory/viz_skinning.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
showm = window.ShowManager(
scene, size=(900, 768), reset_camera=True, order_transparent=True
)
showm.initialize()
scene.add(animation)

##############################################################################
Expand Down
1 change: 0 additions & 1 deletion docs/tutorials/05_animation/viz_hierarchical_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
showm = window.ShowManager(
scene, size=(900, 768), reset_camera=False, order_transparent=True
)
showm.initialize()

###############################################################################
# Creating the road
Expand Down
1 change: 0 additions & 1 deletion docs/tutorials/05_animation/viz_interpolators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion docs/tutorials/05_animation/viz_introduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
scene = window.Scene()

showm = window.ShowManager(scene, size=(900, 768))
showm.initialize()


###############################################################################
Expand Down
1 change: 0 additions & 1 deletion docs/tutorials/05_animation/viz_robot_arm_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
showm = window.ShowManager(
scene, size=(900, 768), reset_camera=False, order_transparent=True
)
showm.initialize()


###############################################################################
Expand Down
1 change: 0 additions & 1 deletion docs/tutorials/05_animation/viz_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
scene = window.Scene()

showm = window.ShowManager(scene, size=(900, 768))
showm.initialize()

###############################################################################
# Creating a ``Timeline``
Expand Down
3 changes: 0 additions & 3 deletions fury/tests/test_gltf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
28 changes: 12 additions & 16 deletions fury/tests/test_thread.py
Original file line number Diff line number Diff line change
@@ -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():
Expand All @@ -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)

Expand All @@ -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()
test_multithreading()
1 change: 0 additions & 1 deletion fury/tests/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]))

Expand Down
3 changes: 2 additions & 1 deletion fury/ui/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 2 additions & 0 deletions fury/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@ def start(self, multithreaded=False, desired_fps=60):
else:
self.window.SetWindowName(self.title)
if multithreaded:
if not self.iren.GetInitialized():
self.iren.Initialize()
while self.iren.GetDone() is False:
start_time = time.perf_counter()
self.lock()
Expand Down