def create_fn(): e = NullEngine() e.start() e.new_scene() e.new_scene() e.new_scene() return e
def setUp(self): # Create dataset with multiple scalars. arr1 = zeros(27, 'f') for n in range(27): arr1[n] = (1+float(n))/10.0 arr2 = (arr1 + 1).astype('d') arr3 = arr1 + 2.0*(0.5 - random.random(27)) arr3 = arr3.astype('f') p = tvtk.ImageData(dimensions=[3,3,3],spacing=[1,1,1], scalar_type='int') p.point_data.scalars = arr1 p.point_data.scalars.name = 'first' j2 = p.point_data.add_array(arr2) p.point_data.get_array(j2).name='second' j3 = p.point_data.add_array(arr3) p.point_data.get_array(j3).name='third' p.update() self.img = p self.first = arr1 self.second = arr2 self.third = arr3 # Setup the mayavi pipeline. e = NullEngine() e.start() e.new_scene() self.e = e src = VTKDataSource(data=p) e.add_source(src) self.src = src ipw = ImagePlaneWidget() e.add_module(ipw) self.ipw = ipw
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() e.new_scene() self.e = e # Read the multi-block plot3d file. r = PLOT3DReader() r.reader.trait_set(has_byte_count=True, multi_grid=True, byte_order='little_endian') r.initialize(get_example_data('tiny.xyz'), get_example_data('tiny.q'), configure=False) e.add_source(r) # Add the filter. f = SelectOutput() e.add_filter(f) # Create an outline for the data. o = Outline() e.add_module(o) o.render() self.o = o self.r = r self.e = e 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() e.new_scene() self.e=e r = VTKXMLFileReader() r.initialize(get_example_data('pyramid_ug.vtu')) e.add_source(r) r.point_scalars_name = 'temperature' o = Outline() e.add_module(o) c = Contour() e.add_filter(c) n = PolyDataNormals() e.add_filter(n) aa = SetActiveAttribute() e.add_filter(aa) aa.point_scalars_name = 'pressure' s = Surface() e.add_module(s) 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() e.new_scene() self.e=e # Read the multi-block plot3d file. r = PLOT3DReader() r.reader.set(has_byte_count=True, multi_grid=True, byte_order='little_endian') r.initialize(get_example_data('tiny.xyz'), get_example_data('tiny.q'), configure=False) e.add_source(r) # Add the filter. f = SelectOutput() e.add_filter(f) # Create an outline for the data. o = Outline() e.add_module(o) o.render() self.o=o self.r=r self.e=e 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() e.new_scene() self.e = e # Read a VTK (old style) data file. r = VTKXMLFileReader() r.initialize(get_example_data('pyramid_ug.vtu')) e.add_source(r) # Create the filters. # CellDerivatives cd = tvtk.CellDerivatives() ud = UserDefined(filter=cd) e.add_filter(ud) ctp = CellToPointData() ctp.filter.pass_cell_data = False e.add_filter(ctp) evn = ExtractVectorNorm() e.add_filter(evn) evc = ExtractVectorComponents(component='y-component') o = Optional(filter=evc) e.add_filter(o) e.add_module(ScalarCutPlane()) self.scene = e.current_scene s = self.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() e.new_scene() self.e = e # Read a VTK (old style) data file. r = VTKXMLFileReader() r.initialize(get_example_data("pyramid_ug.vtu")) e.add_source(r) # Create the filters. # CellDerivatives cd = tvtk.CellDerivatives() ud = UserDefined(filter=cd) e.add_filter(ud) ctp = CellToPointData() ctp.filter.pass_cell_data = False e.add_filter(ctp) evn = ExtractVectorNorm() e.add_filter(evn) evc = ExtractVectorComponents(component="y-component") o = Optional(filter=evc) e.add_filter(o) e.add_module(ScalarCutPlane()) self.scene = e.current_scene s = self.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() e.new_scene() self.e = e r = VTKXMLFileReader() r.initialize(get_example_data('pyramid_ug.vtu')) e.add_source(r) r.point_scalars_name = 'temperature' o = Outline() e.add_module(o) c = Contour() e.add_filter(c) n = PolyDataNormals() e.add_filter(n) aa = SetActiveAttribute() e.add_filter(aa) aa.point_scalars_name = 'pressure' s = Surface() e.add_module(s) 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() e.new_scene() self.e=e 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. #from mayavi.core.engine import Engine #e = Engine() e.start() e.new_scene() self.e = e
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() e.new_scene() self.e = e 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() e.new_scene() self.e = e sgrid = datasets.generateStructuredGrid() src = VTKDataSource(data=sgrid) e.add_source(src) # Create an outline for the data. o = Outline() e.add_module(o) # Create one ContourGridPlane normal to the 'x' axis. cgp1 = ContourGridPlane() e.add_module(cgp1) # Set the position to the middle of the data. cgp1.grid_plane.position = 15 # Another with filled contours normal to 'y' axis. cgp2 = ContourGridPlane() cgp2.contour.filled_contours = True # Set the axis and position to the middle of the data. cgp2.grid_plane.axis = 'y' cgp2.grid_plane.position = 15 e.add_module(cgp2) # An isosurface module. iso = IsoSurface(compute_normals=True) e.add_module(iso) iso.contour.contours = [5] # An interactive scalar cut plane. cp = ScalarCutPlane() e.add_module(cp) ip = cp.implicit_plane ip.normal = 0, 0, 1 ip.origin = 0.5, 0.5, 1.0 # Since this is running offscreen this seems necessary. ip.widget.origin = 0.5, 0.5, 1.0 ip.widget.enabled = False self.scene = e.current_scene self.cgp2 = cgp2 self.iso = iso self.cp = cp 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() e.new_scene() self.e=e sgrid=datasets.generateStructuredGrid() src = VTKDataSource(data = sgrid) e.add_source(src) # Create an outline for the data. o = Outline() e.add_module(o) # Create one ContourGridPlane normal to the 'x' axis. cgp1 = ContourGridPlane() e.add_module(cgp1) # Set the position to the middle of the data. cgp1.grid_plane.position = 15 # Another with filled contours normal to 'y' axis. cgp2 = ContourGridPlane() cgp2.contour.filled_contours = True # Set the axis and position to the middle of the data. cgp2.grid_plane.axis = 'y' cgp2.grid_plane.position = 15 e.add_module(cgp2) # An isosurface module. iso = IsoSurface(compute_normals=True) e.add_module(iso) iso.contour.contours = [5] # An interactive scalar cut plane. cp = ScalarCutPlane() e.add_module(cp) ip = cp.implicit_plane ip.normal = 0,0,1 ip.origin = 0.5, 0.5, 1.0 # Since this is running offscreen this seems necessary. ip.widget.origin = 0.5, 0.5, 1.0 ip.widget.enabled = False self.scene = e.current_scene self.cgp2=cgp2 self.iso=iso self.cp=cp return
def setUp(self): e = NullEngine() # Uncomment to see visualization for debugging etc. # e = Engine() e.start() s = e.new_scene() image_data = BuiltinImage() e.add_source(image_data) outline = Outline() e.add_module(outline) surface = Surface() e.add_module(surface) image_data.data_source.radius = array([80.0, 80.0, 80.0]) image_data.data_source.center = array([150.0, 150.0, 0.0]) image_data.data_source.whole_extent = array([10, 245, 10, 245, 0, 0]) if is_old_pipeline(): image_data.data_source.update_whole_extent() else: image_data.data_source.set_update_extent_to_whole_extent() self.e = e 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() poly_data = BuiltinSurface() e.add_source(poly_data) outline = Outline() e.add_module(outline) surface = Surface() e.add_module(surface) poly_data.data_source.shaft_radius = 0.05 poly_data.data_source.shaft_resolution = 7 poly_data.data_source.tip_radius = 0.1 self.e = e 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() poly_data = BuiltinSurface() e.add_source(poly_data) outline = Outline() e.add_module(outline) surface = Surface() e.add_module(surface) poly_data.data_source.shaft_radius = 0.05 poly_data.data_source.shaft_resolution = 7 poly_data.data_source.tip_radius = 0.1 self.e = e self.scene = e.current_scene return
def setUp(self): e = NullEngine() # Uncomment to see visualization for debugging etc. #e = Engine() e.start() s=e.new_scene() image_data = BuiltinImage() e.add_source(image_data) outline = Outline() e.add_module(outline) surface = Surface() e.add_module(surface) image_data.data_source.radius = array([ 80., 80., 80.]) image_data.data_source.center = array([ 150., 150., 0.]) image_data.data_source.whole_extent = array([ 10, 245, 10, 245, 0, 0]) if is_old_pipeline(): image_data.data_source.update_whole_extent() else: image_data.data_source.set_update_extent_to_whole_extent() self.e=e self.scene = e.current_scene return
def setUp(self): e = NullEngine() e.start() e.new_scene() scene = e.scenes[-1] s = ParametricSurface() e.add_source(s) o = Outline() s.add_child(o) o1 = Outline() s.add_child(o1) self.scene = scene self.e = e self.s = s self.o = o self.o1 = o1 return
def setUp(self): e = NullEngine() e.start() registry.register_engine(e) engine_manager.current_engine = e self.e = e self.s = e.new_scene() self.s.scene = DummyScene()
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): e = NullEngine() # Uncomment to see visualization for debugging etc. #e = Engine() e.start() e.new_scene() self.e=e # Read a VTK XML data file. r = VTKXMLFileReader() r.initialize(get_example_data('cube.vti')) e.add_source(r) # Create an outline for the data. o = Outline() e.add_module(o) # Create one ContourGridPlane normal to the 'x' axis. cgp1 = ContourGridPlane() e.add_module(cgp1) # Set the position to the middle of the data. cgp1.grid_plane.position = 1 # Another with filled contours normal to 'y' axis. cgp2 = ContourGridPlane() cgp2.contour.filled_contours = True # Set the axis and position to the middle of the data. cgp2.grid_plane.axis = 'y' cgp2.grid_plane.position = 1 e.add_module(cgp2) # An interactive scalar cut plane. cp = ScalarCutPlane() e.add_module(cp) ip = cp.implicit_plane ip.normal = 0,0,1 ip.origin = 0.5, 0.5, 1.0 # Since this is running offscreen this seems necessary. ip.widget.origin = 0.5, 0.5, 1.0 ip.widget.enabled = False self.scene = e.current_scene self.cgp2=cgp2 self.cp=cp 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. #Make the grid grid = self.make_grid4scatter() e.add_source(grid) eg = ExtractGrid() e.add_filter(eg) nb_ticks = 6 eg.x_ratio = eg.y_ratio = eg.z_ratio = 100 / (nb_ticks - 1) / 2 gpx = GridPlane() e.add_module(gpx) gpx.grid_plane.axis = 'x' gpy = GridPlane() e.add_module(gpy) gpy.grid_plane.axis = 'y' gpz = GridPlane() e.add_module(gpz) gpz.grid_plane.axis = 'z' #Add the scatter d = VTKDataSource() d.data = self.make_scatter() e.add_source(d) if is_old_pipeline(): a = Axes() e.add_module(a) a.axes.number_of_labels = nb_ticks self.eg = eg self.gpx = gpx self.gpy = gpy self.gpz = gpz 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. #Make the grid grid = self.make_grid4scatter() e.add_source(grid) eg = ExtractGrid() e.add_filter(eg) nb_ticks = 6 eg.x_ratio = eg.y_ratio = eg.z_ratio = 100/(nb_ticks-1)/2 gpx = GridPlane() e.add_module(gpx) gpx.grid_plane.axis = 'x' gpy = GridPlane() e.add_module(gpy) gpy.grid_plane.axis = 'y' gpz = GridPlane() e.add_module(gpz) gpz.grid_plane.axis = 'z' #Add the scatter d = VTKDataSource() d.data = self.make_scatter() e.add_source(d) if is_old_pipeline(): a = Axes() e.add_module(a) a.axes.number_of_labels = nb_ticks self.eg = eg self.gpx = gpx self.gpy = gpy self.gpz = gpz 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 setUp(self): e = NullEngine() # Uncomment to see visualization for debugging etc. #e = Engine() e.start() self.e = e s = e.new_scene() self.scene = e.current_scene self.setup_reader() self.setup_viz() return
def setUp(self): self.root = tempfile.mkdtemp() abc1 = os.path.join(self.root, "abc_1.vti") abc2 = os.path.join(self.root, "abc_2.vti") def1 = os.path.join(self.root, "def_1.vti") def2 = os.path.join(self.root, "def_2.vti") xyz1 = os.path.join(self.root, "xyz_1.vti") cube = get_example_data("cube.vti") self.abc1, self.abc2 = abc1, abc2 self.def1, self.def2 = def1, def2 self.xyz1 = xyz1 self.cube = cube for i in (abc1, abc2, def1, def2, xyz1): shutil.copy(cube, i) e = NullEngine() # Uncomment to see visualization for debugging etc. # e = Engine() e.start() e.new_scene() self.engine = e
def setUp(self): self.root = tempfile.mkdtemp() abc1 = os.path.join(self.root, 'abc_1.vti') abc2 = os.path.join(self.root, 'abc_2.vti') def1 = os.path.join(self.root, 'def_1.vti') def2 = os.path.join(self.root, 'def_2.vti') xyz1 = os.path.join(self.root, 'xyz_1.vti') cube = get_example_data('cube.vti') self.abc1, self.abc2 = abc1, abc2 self.def1, self.def2 = def1, def2 self.xyz1 = xyz1 self.cube = cube for i in (abc1, abc2, def1, def2, xyz1): shutil.copy(cube, i) e = NullEngine() # Uncomment to see visualization for debugging etc. #e = Engine() e.start() e.new_scene() self.engine = e
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() e.new_scene() self.e=e sgrid = datasets.generateStructuredGrid() src = VTKDataSource(data = sgrid) e.add_source(src) # Create an outline for the data. o = Outline() e.add_module(o) # Create three simple grid plane modules. # First normal to 'x' axis. gp1 = GridPlane() e.add_module(gp1) # Second normal to 'y' axis. gp2 = GridPlane() # We'll test how robust things are by setting attributes gp2.grid_plane.axis = 'y' gp2.grid_plane.position = 16 e.add_module(gp2) # Third normal to 'z' axis. gp3 = GridPlane() e.add_module(gp3) gp3.grid_plane.axis = 'z' gp3.grid_plane.position = 6 for gp in (gp1, gp2, gp3): gp.actor.property.set(ambient=1.0) 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() e.new_scene() self.e = e sgrid = datasets.generateStructuredGrid() src = VTKDataSource(data=sgrid) e.add_source(src) # Create an outline for the data. o = Outline() e.add_module(o) # Create three simple grid plane modules. # First normal to 'x' axis. gp1 = GridPlane() e.add_module(gp1) # Second normal to 'y' axis. gp2 = GridPlane() # We'll test how robust things are by setting attributes gp2.grid_plane.axis = 'y' gp2.grid_plane.position = 16 e.add_module(gp2) # Third normal to 'z' axis. gp3 = GridPlane() e.add_module(gp3) gp3.grid_plane.axis = 'z' gp3.grid_plane.position = 6 for gp in (gp1, gp2, gp3): gp.actor.property.trait_set(ambient=1.0) 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() e.new_scene() self.e=e sgrid=datasets.generateStructuredGrid() src = VTKDataSource(data = sgrid) e.add_source(src) c = Contour() # `name` is used for the notebook tabs. n = PolyDataNormals(name='Normals') o = Optional(filter=n, label_text='Compute normals') coll = Collection(filters=[c, o], name='IsoSurface') e.add_filter(coll) s = Surface() e.add_module(s) self.coll = coll 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() e.new_scene() self.e=e # Read a VTK (old style) data file. r = VTKXMLFileReader() r.initialize(get_example_data('pyramid_ug.vtu')) e.add_source(r) # Create the filters. idp = ImageDataProbe() idp.rescale_scalars = True e.add_filter(idp) cgp = ContourGridPlane(enable_contours=False) e.add_module(cgp) cgp.grid_plane.axis = 'z' cgp.grid_plane.position = 1 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 = self.make_data() d.scalar_data = sc e.add_source(d) self.t = Text3D() e.add_module(self.t) 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 = self.make_data() d.scalar_data = sc e.add_source(d) # Create an outline for the data. o = Outline() e.add_module(o) # ImagePlaneWidgets for the scalars ipw = ImagePlaneWidget() e.add_module(ipw) ipw_y = ImagePlaneWidget() e.add_module(ipw_y) ipw_y.ipw.plane_orientation = 'y_axes' ipw_z = ImagePlaneWidget() e.add_module(ipw_z) ipw_z.ipw.plane_orientation = 'z_axes' self.scene = e.current_scene return
def test_script_recording(self): "Does script recording work correctly." # Create a mayavi pipeline and record it. tape = self.tape e = NullEngine() e.start() # Start recording. tape.recording = True tape.register(e, known=True, script_id='engine') e.new_scene() #print tape.script self.assertEqual(tape.lines[-1], "dummy_viewer = engine.new_scene()") src = ParametricSurface() e.add_source(src) expect = 'from mayavi.sources.parametric_surface '\ 'import ParametricSurface' self.assertEqual(tape.lines[-3], expect) self.assertEqual(tape.lines[-2], "parametric_surface = ParametricSurface()") self.assertEqual(tape.lines[-1], "engine.add_source(parametric_surface)") src.function = 'dini' self.assertEqual(tape.lines[-1], "parametric_surface.function = 'dini'") o = Outline() e.add_module(o) expect = 'from mayavi.modules.outline import Outline' self.assertEqual(tape.lines[-3], expect) self.assertEqual(tape.lines[-2], "outline = Outline()") self.assertEqual(tape.lines[-1], "engine.add_module(outline)") o.actor.property.color = (1,0,0) self.assertEqual(tape.lines[-1], "outline.actor.property.color = (1.0, 0.0, 0.0)") s = Surface() e.add_module(s) expect = 'from mayavi.modules.surface import Surface' self.assertEqual(tape.lines[-3], expect) self.assertEqual(tape.lines[-2], "surface = Surface()") self.assertEqual(tape.lines[-1], "engine.add_module(surface)") s.actor.property.representation = 'wireframe' self.assertEqual(tape.lines[-1], "surface.actor.property.representation = 'wireframe'") o.actor.property.representation = 'wireframe' self.assertEqual(tape.lines[-1], "outline.actor.property.representation = 'wireframe'") s.actor.property.opacity = 0.5 self.assertEqual(tape.lines[-1], "surface.actor.property.opacity = 0.5") s.actor.mapper.scalar_visibility = False self.assertEqual(tape.lines[-1], "surface.actor.mapper.scalar_visibility = False") #print tape.script # Stop recording and test. tape.unregister(e) tape.record('#end') # Placeholder o.actor.property.opacity = 0.5 self.assertEqual(tape.lines[-1], '#end') s.actor.property.color = (1,0,0) self.assertEqual(tape.lines[-1], '#end') s.enable_contours = True self.assertEqual(tape.lines[-1], '#end') src.function = 'klein' self.assertEqual(tape.lines[-1], '#end')
def test_script_recording(self): "Does script recording work correctly." # Create a mayavi pipeline and record it. tape = self.tape e = NullEngine() e.start() # Start recording. tape.recording = True tape.register(e, known=True, script_id='engine') e.new_scene() self.assertEqual(tape.lines[-1], "dummy_viewer = engine.new_scene()") src = ParametricSurface() e.add_source(src) expect = 'from mayavi.sources.parametric_surface '\ 'import ParametricSurface' self.assertEqual(tape.lines[-3], expect) self.assertEqual(tape.lines[-2], "parametric_surface = ParametricSurface()") self.assertEqual(tape.lines[-1], "engine.add_source(parametric_surface)") src.function = 'dini' self.assertEqual(tape.lines[-1], "parametric_surface.function = 'dini'") o = Outline() e.add_module(o) expect = 'from mayavi.modules.outline import Outline' self.assertEqual(tape.lines[-3], expect) self.assertEqual(tape.lines[-2], "outline = Outline()") self.assertEqual(tape.lines[-1], "engine.add_module(outline)") o.actor.property.color = (1, 0, 0) self.assertEqual(tape.lines[-1], "outline.actor.property.color = (1.0, 0.0, 0.0)") s = Surface() e.add_module(s) expect = 'from mayavi.modules.surface import Surface' self.assertEqual(tape.lines[-3], expect) self.assertEqual(tape.lines[-2], "surface = Surface()") self.assertEqual(tape.lines[-1], "engine.add_module(surface)") s.actor.property.representation = 'wireframe' self.assertEqual( tape.lines[-1], "surface.actor.property.representation = 'wireframe'") o.actor.property.representation = 'wireframe' self.assertEqual( tape.lines[-1], "outline.actor.property.representation = 'wireframe'") s.actor.property.opacity = 0.5 self.assertEqual(tape.lines[-1], "surface.actor.property.opacity = 0.5") s.actor.mapper.scalar_visibility = False self.assertEqual(tape.lines[-1], "surface.actor.mapper.scalar_visibility = False") # Stop recording and test. tape.unregister(e) tape.record('#end') # Placeholder o.actor.property.opacity = 0.5 self.assertEqual(tape.lines[-1], '#end') s.actor.property.color = (1, 0, 0) self.assertEqual(tape.lines[-1], '#end') s.enable_contours = True self.assertEqual(tape.lines[-1], '#end') src.function = 'klein' self.assertEqual(tape.lines[-1], '#end')