def setUp(self): """Initial setting up of test fixture, automatically called by TestCase before any other test method is invoked""" e = NullEngine() # Uncomment to see visualization for debugging etc. #e = Engine() e.start() s = e.new_scene() self.e = e self.s = s ############################################################ # Create a new scene and set up the visualization. d = ArraySource() sc, vec = self.make_data() d.origin = (-5, -5, -5) d.scalar_data = sc d.vector_data = vec e.add_source(d) # Create an outline for the data. o = Outline() e.add_module(o) # View the data. st = Streamline() e.add_module(st) widget = st.seed.widget widget.trait_set(radius=1.0, center=(-4.0, -4.0, -4.0), theta_resolution=4, phi_resolution=4) st = Streamline(streamline_type='ribbon') seed = st.seed seed.widget = seed.widget_list[1] e.add_module(st) seed.widget.trait_set(point1=(-5.0, -4.5, -4.0), point2=(-5.0, -4.5, 4.0)) st.ribbon_filter.width = 0.25 st = Streamline(streamline_type='tube') seed = st.seed seed.widget = seed.widget_list[2] e.add_module(st) seed.widget.trait_set(center=(-5.0, 1.5, -2.5)) st.tube_filter.radius = 0.15 st = Streamline(streamline_type='tube') seed = st.seed seed.widget = seed.widget_list[3] e.add_module(st) seed.widget.position = (-5.0, 3.75, 3.75) st.tube_filter.radius = 0.2 self.st = st self.scene = e.current_scene return
def setUp(self): """Initial setting up of test fixture, automatically called by TestCase before any other test method is invoked""" e = NullEngine() # Uncomment to see visualization for debugging etc. #e = Engine() e.start() s=e.new_scene() self.e=e self.s=s ############################################################ # Create a new scene and set up the visualization. d = ArraySource() sc, vec = self.make_data() d.origin = (-5, -5, -5) d.scalar_data = sc d.vector_data = vec e.add_source(d) # Create an outline for the data. o = Outline() e.add_module(o) # View the data. st = Streamline() e.add_module(st) widget = st.seed.widget widget.set(radius=1.0, center=(-4.0, -4.0, -4.0), theta_resolution=4, phi_resolution=4) st = Streamline(streamline_type='ribbon') seed = st.seed seed.widget = seed.widget_list[1] e.add_module(st) seed.widget.set(point1=(-5.0, -4.5, -4.0), point2=(-5.0, -4.5, 4.0)) st.ribbon_filter.width = 0.25 st = Streamline(streamline_type='tube') seed = st.seed seed.widget = seed.widget_list[2] e.add_module(st) seed.widget.set(center=(-5.0, 1.5, -2.5)) st.tube_filter.radius = 0.15 st = Streamline(streamline_type='tube') seed = st.seed seed.widget = seed.widget_list[3] e.add_module(st) seed.widget.position=(-5.0, 3.75, 3.75) st.tube_filter.radius = 0.2 self.st = st self.scene = e.current_scene return
def setUp(self): """Initial setting up of test fixture, automatically called by TestCase before any other test method is invoked""" e = NullEngine() # Uncomment to see visualization for debugging etc. #e = Engine() e.start() s=e.new_scene() self.e=e self.s=s ############################################################ # Create a new scene and set up the visualization. d = ArraySource() sc, vec = self.make_data() d.origin = (-5, -5, -5) d.scalar_data = sc d.vector_data = vec e.add_source(d) # Create an outline for the data. o = Outline() e.add_module(o) # Glyphs for the scalars g = Glyph() e.add_module(g) g.glyph.glyph_source.glyph_position = 'center' g.glyph.glyph.vector_mode = 'use_normal' g.glyph.glyph.scale_factor = 0.5 g.glyph.mask_points.on_ratio = 20 g.actor.property.line_width = 1.0 v = VectorCutPlane() glyph = v.glyph gs = glyph.glyph_source gs.glyph_position = 'tail' gs.glyph_source = gs.glyph_list[1] e.add_module(v) v.implicit_plane.set(normal=(0, 1, 0), origin=(0, 3, 0)) v = VectorCutPlane() glyph = v.glyph gs = glyph.glyph_source gs.glyph_source = gs.glyph_list[2] gs.glyph_position = 'head' e.add_module(v) v.implicit_plane.set(normal=(0, 1, 0), origin=(0, -2, 0)) self.g=g self.v=v self.scene = e.current_scene return
def setUp(self): """Initial setting up of test fixture, automatically called by TestCase before any other test method is invoked""" e = NullEngine() # Uncomment to see visualization for debugging etc. #e = Engine() e.start() s = e.new_scene() self.e = e self.s = s ############################################################ # Create a new scene and set up the visualization. d = ArraySource() sc, vec = self.make_data() d.origin = (-5, -5, -5) d.scalar_data = sc d.vector_data = vec e.add_source(d) # Create an outline for the data. o = Outline() e.add_module(o) # Glyphs for the scalars g = Glyph() e.add_module(g) g.glyph.glyph_source.glyph_position = 'center' g.glyph.glyph.vector_mode = 'use_normal' g.glyph.glyph.scale_factor = 0.5 g.glyph.mask_points.on_ratio = 20 g.actor.property.line_width = 1.0 v = VectorCutPlane() glyph = v.glyph gs = glyph.glyph_source gs.glyph_position = 'tail' gs.glyph_source = gs.glyph_list[1] e.add_module(v) v.implicit_plane.set(normal=(0, 1, 0), origin=(0, 3, 0)) v = VectorCutPlane() glyph = v.glyph gs = glyph.glyph_source gs.glyph_source = gs.glyph_list[2] gs.glyph_position = 'head' e.add_module(v) v.implicit_plane.set(normal=(0, 1, 0), origin=(0, -2, 0)) self.g = g self.v = v self.scene = e.current_scene return
def do(self): ############################################################ # Imports. script = self.script from mayavi.sources.array_source import ArraySource from mayavi.modules.outline import Outline from mayavi.modules.streamline import Streamline ############################################################ # Create a new scene and set up the visualization. s = self.new_scene() d = ArraySource() sc, vec = self.make_data() d.origin = (-5, -5, -5) d.scalar_data = sc d.vector_data = vec script.add_source(d) # Create an outline for the data. o = Outline() script.add_module(o) # View the data. st = Streamline() script.add_module(st) widget = st.seed.widget widget.set(radius=1.0, center=(-4.0, -4.0, -4.0), theta_resolution=4, phi_resolution=4) st = Streamline(streamline_type='ribbon') seed = st.seed seed.widget = seed.widget_list[1] script.add_module(st) seed.widget.set(point1=(-5.0, -4.5, -4.0), point2=(-5.0, -4.5, 4.0)) st.ribbon_filter.width = 0.25 st = Streamline(streamline_type='tube') seed = st.seed seed.widget = seed.widget_list[2] script.add_module(st) seed.widget.set(center=(-5.0, 1.5, -2.5)) st.tube_filter.radius = 0.15 st = Streamline(streamline_type='tube') seed = st.seed seed.widget = seed.widget_list[3] script.add_module(st) seed.widget.position = (-5.0, 3.75, 3.75) st.tube_filter.radius = 0.2 # Set the scene to a suitable view. s.scene.z_plus_view() c = s.scene.camera c.azimuth(-30) c.elevation(30) s.render() # Update the streamlines. mm = o.module_manager for child in mm.children[1:]: child.update_streamlines = True # Now compare the image. self.compare_image(s, 'images/test_streamline.png') ############################################################ # Test if the modules respond correctly when the components # are changed. tf = st.tube_filter st.tube_filter = tf.__class__() st.tube_filter = tf st.ribbon_filter = st.ribbon_filter.__class__() seed = st.seed st.seed = seed.__class__() st.seed = seed st.actor = st.actor.__class__() tracer = st.stream_tracer st.stream_tracer = tracer.__class__() st.stream_tracer = tracer s.render() # Now compare the image. self.compare_image(s, 'images/test_streamline.png') s.render() ############################################################ # Test if saving a visualization and restoring it works. bg = s.scene.background # Save visualization. f = BytesIO() f.name = abspath('test.mv2') # We simulate a file. script.save_visualization(f) f.seek(0) # So we can read this saved data. # Remove existing scene. engine = script.engine engine.close_scene(s) # Load visualization script.load_visualization(f) s = engine.current_scene # Set the scene to a suitable view. s.scene.z_plus_view() c = s.scene.camera c.azimuth(-30) c.elevation(30) s.render() s.scene.background = bg # Now compare the image. self.compare_image(s, 'images/test_streamline.png') ############################################################ # Test if the MayaVi2 visualization can be deepcopied. # Pop the source object. sources = s.children s.children = [] # Add it back to see if that works without error. s.children.extend(sources) s.scene.reset_zoom() # Now compare the image. self.compare_image(s, 'images/test_streamline.png') # Now deepcopy the source and replace the existing one with # the copy. This basically simulates cutting/copying the # object from the UI via the right-click menu on the tree # view, and pasting the copy back. sources1 = copy.deepcopy(sources) s.children[:] = sources s.scene.reset_zoom() self.compare_image(s, 'images/test_streamline.png')
def do(self): ############################################################ # Imports. script = self.script from mayavi.sources.array_source import ArraySource from mayavi.modules.outline import Outline from mayavi.modules.streamline import Streamline ############################################################ # Create a new scene and set up the visualization. s = self.new_scene() d = ArraySource() sc, vec = self.make_data() d.origin = (-5, -5, -5) d.scalar_data = sc d.vector_data = vec script.add_source(d) # Create an outline for the data. o = Outline() script.add_module(o) # View the data. st = Streamline() script.add_module(st) widget = st.seed.widget widget.set(radius=1.0, center=(-4.0, -4.0, -4.0), theta_resolution=4, phi_resolution=4) st = Streamline(streamline_type='ribbon') seed = st.seed seed.widget = seed.widget_list[1] script.add_module(st) seed.widget.set(point1=(-5.0, -4.5, -4.0), point2=(-5.0, -4.5, 4.0)) st.ribbon_filter.width = 0.25 st = Streamline(streamline_type='tube') seed = st.seed seed.widget = seed.widget_list[2] script.add_module(st) seed.widget.set(center=(-5.0, 1.5, -2.5)) st.tube_filter.radius = 0.15 st = Streamline(streamline_type='tube') seed = st.seed seed.widget = seed.widget_list[3] script.add_module(st) seed.widget.position=(-5.0, 3.75, 3.75) st.tube_filter.radius = 0.2 # Set the scene to a suitable view. s.scene.z_plus_view() c = s.scene.camera c.azimuth(-30) c.elevation(30) s.render() # Update the streamlines. mm = o.module_manager for child in mm.children[1:]: child.update_streamlines = True # Now compare the image. self.compare_image(s, 'images/test_streamline.png') ############################################################ # Test if the modules respond correctly when the components # are changed. tf = st.tube_filter st.tube_filter = tf.__class__() st.tube_filter = tf st.ribbon_filter = st.ribbon_filter.__class__() seed = st.seed st.seed = seed.__class__() st.seed = seed st.actor = st.actor.__class__() tracer = st.stream_tracer st.stream_tracer = tracer.__class__() st.stream_tracer = tracer s.render() # Now compare the image. self.compare_image(s, 'images/test_streamline.png') s.render() ############################################################ # Test if saving a visualization and restoring it works. bg = s.scene.background # Save visualization. f = BytesIO() f.name = abspath('test.mv2') # We simulate a file. script.save_visualization(f) f.seek(0) # So we can read this saved data. # Remove existing scene. engine = script.engine engine.close_scene(s) # Load visualization script.load_visualization(f) s = engine.current_scene # Set the scene to a suitable view. s.scene.z_plus_view() c = s.scene.camera c.azimuth(-30) c.elevation(30) s.render() s.scene.background = bg # Now compare the image. self.compare_image(s, 'images/test_streamline.png') ############################################################ # Test if the MayaVi2 visualization can be deepcopied. # Pop the source object. sources = s.children s.children = [] # Add it back to see if that works without error. s.children.extend(sources) s.scene.reset_zoom() # Now compare the image. self.compare_image(s, 'images/test_streamline.png') # Now deepcopy the source and replace the existing one with # the copy. This basically simulates cutting/copying the # object from the UI via the right-click menu on the tree # view, and pasting the copy back. sources1 = copy.deepcopy(sources) s.children[:] = sources s.scene.reset_zoom() self.compare_image(s, 'images/test_streamline.png')
def do(self): ############################################################ # Imports. script = self.script from mayavi.sources.array_source import ArraySource from mayavi.modules.outline import Outline from mayavi.modules.surface import Surface from mayavi.modules.vectors import Vectors ############################################################ # Create a new scene and set up the visualization. s = self.new_scene() d = ArraySource() self.check_input_validation(d) sc, vec = self.make_2d_data() d.origin = (-1, -1, 0) d.scalar_data = sc d.vector_data = vec script.add_source(d) # Create an outline for the data. o = Outline() script.add_module(o) # View the data. s = Surface() script.add_module(s) v = Vectors() script.add_module(v) # Add a 3D data source d = ArraySource() sc, vec = self.make_3d_data() d.scalar_data = sc d.vector_data = vec script.add_source(d) # Create an outline for the data. o = Outline() script.add_module(o) # View a slice. s = Surface() script.add_module(s) v = Vectors() script.add_module(v) # Set the scene to a suitable view. s.scene.z_plus_view() c = s.scene.camera c.azimuth(-30) c.elevation(30) self.check() ############################################################ # Test if saving a visualization and restoring it works. bg = s.scene.background # Save visualization. f = StringIO() f.name = abspath('test.mv2') # We simulate a file. script.save_visualization(f) f.seek(0) # So we can read this saved data. # Remove existing scene. engine = script.engine engine.close_scene(s) # Load visualization script.load_visualization(f) s = engine.current_scene # Set the scene to a suitable view. s.scene.z_plus_view() c = s.scene.camera c.azimuth(-30) c.elevation(30) s.scene.background = bg self.check() ############################################################ # Test if the MayaVi2 visualization can be deepcopied. # Pop the source object. sources = s.children s.children = [] # Add it back to see if that works without error. s.children.extend(sources) s.scene.reset_zoom() self.check() # Now deepcopy the source and replace the existing one with # the copy. This basically simulates cutting/copying the # object from the UI via the right-click menu on the tree # view, and pasting the copy back. sources1 = copy.deepcopy(sources) s.children[:] = sources s.scene.reset_zoom() self.check()
def do(self): ############################################################ # Imports. script = self.script from mayavi.sources.array_source import ArraySource from mayavi.modules.outline import Outline from mayavi.modules.glyph import Glyph from mayavi.modules.vector_cut_plane import VectorCutPlane ############################################################ # Create a new scene and set up the visualization. s = self.new_scene() d = ArraySource() sc, vec = self.make_data() d.origin = (-5, -5, -5) d.scalar_data = sc d.vector_data = vec script.add_source(d) # Create an outline for the data. o = Outline() script.add_module(o) # Glyphs for the scalars g = Glyph() script.add_module(g) g.glyph.glyph_source.glyph_position = 'center' g.glyph.glyph.vector_mode = 'use_normal' g.glyph.glyph.scale_factor = 0.5 g.actor.property.line_width = 1.0 v = VectorCutPlane() glyph = v.glyph gs = glyph.glyph_source gs.glyph_position = 'tail' gs.glyph_source = gs.glyph_list[1] script.add_module(v) v.implicit_plane.trait_set(normal=(0, 1, 0), origin=(0, 3, 0)) v = VectorCutPlane() glyph = v.glyph gs = glyph.glyph_source gs.glyph_source = gs.glyph_list[2] gs.glyph_position = 'head' script.add_module(v) v.implicit_plane.trait_set(normal=(0, 1, 0), origin=(0, -2, 0)) # Set the scene to a suitable view. self.set_view(s) self.check() ############################################################ # Test if the modules respond correctly when the components # are changed. g.actor = g.actor.__class__() glyph = g.glyph g.glyph = glyph.__class__() g.glyph = glyph glyph = v.glyph v.glyph = glyph.__class__() v.glyph = glyph v.actor = v.actor.__class__() v.cutter = v.cutter.__class__() ip = v.implicit_plane v.implicit_plane = ip.__class__() v.implicit_plane = ip s.render() self.check() ############################################################ # Test if saving a visualization and restoring it works. # Save visualization. f = BytesIO() f.name = abspath('test.mv2') # We simulate a file. script.save_visualization(f) f.seek(0) # So we can read this saved data. # Remove existing scene. engine = script.engine engine.close_scene(s) # Load visualization script.load_visualization(f) s = engine.current_scene # Set the scene to a suitable view. self.set_view(s) self.check() ############################################################ # Test if the MayaVi2 visualization can be deepcopied. # Pop the source object. sources = s.children s.children = [] # Add it back to see if that works without error. s.children.extend(sources) self.set_view(s) self.check() # Now deepcopy the source and replace the existing one with # the copy. This basically simulates cutting/copying the # object from the UI via the right-click menu on the tree # view, and pasting the copy back. sources1 = copy.deepcopy(sources) s.children[:] = sources self.set_view(s) self.check()