def test_marker_actor(interactive=False): scene = window.Scene() scene.background((1, 1, 1)) centers_3do = np.array([[4, 0, 0], [4, 4, 0], [4, 8, 0]]) markers_2d = ['o', 's', 'd', '^', 'p', 'h', 's6', 'x', '+'] center_markers_2d = np.array( [[0, i*2, 0] for i in range(len(markers_2d))]) fake_spheres = actor.markers( centers_3do, colors=(0, 1, 0), scales=1, marker='3d' ) markers_2d = actor.markers( center_markers_2d, colors=(0, 1, 0), scales=1, marker=markers_2d ) scene.add(fake_spheres) scene.add(markers_2d) if interactive: window.show(scene) arr = window.snapshot(scene) colors = np.array([[0, 1, 0] for i in range(12)]) report = window.analyze_snapshot(arr, colors=colors) npt.assert_equal(report.objects, 12)
def test_opengl_state_simple(): for gl_state in [ window.gl_reset_blend, window.gl_enable_depth, window.gl_disable_depth, window.gl_enable_blend, window.gl_disable_blend, window.gl_set_additive_blending, window.gl_set_normal_blending, window.gl_set_multiplicative_blending, window.gl_set_subtractive_blending, window.gl_set_additive_blending_white_background ]: scene = window.Scene() centers = np.array([[0, 0, 0], [-.1, 0, 0], [.1, 0, 0]]) colors = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) actors = actor.markers( centers, marker='s', colors=colors, marker_opacity=.5, scales=.2, ) showm = window.ShowManager(scene, size=(900, 768), reset_camera=False, order_transparent=False) scene.add(actors) # single effect shaders.shader_apply_effects(showm.window, actors, effects=gl_state) showm.render()
def test_opengl_state_add_remove_and_check(): scene = window.Scene() centers = np.array([ [0, 0, 0], [-.1, 0, 0], [.1, 0, 0] ]) colors = np.array([ [1, 0, 0], [0, 1, 0], [0, 0, 1] ]) actor_no_depth_test = actor.markers( centers, marker='s', colors=colors, marker_opacity=.5, scales=.2, ) showm = window.ShowManager( scene, size=(900, 768), reset_camera=False, order_transparent=False) scene.add(actor_no_depth_test) showm.render() state = window.gl_get_current_state(showm.window.GetState()) before_depth_test = state['GL_DEPTH_TEST'] npt.assert_equal(before_depth_test, True) # TODO: we are getting bad request for enum status # it seems we are not provide the correct values # vtkOpenGLState.cxx:1299 WARN| Bad request for enum status id_observer = shaders.shader_apply_effects( showm.window, actor_no_depth_test, effects=[ window.gl_reset_blend, window.gl_disable_blend, window.gl_disable_depth]) showm.render() state = window.gl_get_current_state(showm.window.GetState()) # print('type', type(showm.window.GetState())) after_depth_test = state['GL_DEPTH_TEST'] npt.assert_equal(after_depth_test, False) # removes the no_depth_test effect remove_observer_from_actor(actor_no_depth_test, id_observer) showm.render() state = window.gl_get_current_state(showm.window.GetState()) after_remove_depth_test_observer = state['GL_DEPTH_TEST'] npt.assert_equal(after_remove_depth_test_observer, True)
from fury.shaders import shader_apply_effects from fury.utils import remove_observer_from_actor from fury import window, actor import itertools ############################################################################### # We just proceed as usual: creating the actors and initializing a scene in # FURY centers = np.array([[0, 0, 0], [-.1, 0, 0], [.1, 0, 0]]) colors = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) actor_no_depth_test = actor.markers( centers, marker='s', colors=colors, marker_opacity=.5, scales=.2, ) actor_normal_blending = actor.markers( centers - np.array([[0, -.5, 0]]), marker='s', colors=colors, marker_opacity=.5, scales=.2, ) actor_add_blending = actor.markers( centers - np.array([[0, -1, 0]]), marker='s', colors=colors, marker_opacity=.5,
marker_symbols = ['o', 's', 'd', '^', 'p', 'h', 's6', 'x', '+'] markers = [ np.random.choice(marker_symbols) for i in range(n)] centers = np.random.normal(size=(n, 3), scale=10) colors = np.random.uniform(size=(n, 3)) ############################################################################ # You can control the edge color and edge width for each marker nodes_actor = actor.markers( centers, marker=markers, edge_width=.1, edge_color=[255, 255, 0], colors=colors, scales=.5, ) ############################################################################ # In addition, an 3D sphere it's also a valid type of marker nodes_3d_actor = actor.markers( centers+np.ones_like(centers)*25, marker='3d', colors=colors, scales=.5, ) scene = window.Scene()