def test_background_plotter_export_vtkjs(qtbot, tmpdir): plotter = vtki.BackgroundPlotter(show=False, title='Testing Window') plotter.add_mesh(vtki.Sphere()) filename = str(tmpdir.mkdir("tmpdir").join('tmp')) dlg = plotter._qt_export_vtkjs(show=False) dlg.selectFile(filename) dlg.accept() plotter.close() assert os.path.isfile(filename + '.vtkjs')
def test_background_plotting_camera(qtbot): plotter = vtki.BackgroundPlotter(show=False, title='Testing Window') plotter.add_mesh(vtki.Sphere()) cpos = [(0.0, 0.0, 1.0), (0.0, 0.0, 0.0), (0.0, 1.0, 0.0)] plotter.camera_position = cpos plotter.save_camera_position() plotter.camera_position = [(0.0, 0.0, 3.0), (0.0, 0.0, 0.0), (0.0, 1.0, 0.0)] # load existing position plotter.saved_camera_menu.actions()[0].trigger() assert plotter.camera_position == cpos plotter.clear_camera_positions() assert not len(plotter.saved_camera_menu.actions()) plotter.close()
def test_background_plotting_axes_scale(qtbot): sphere = vtki.Sphere() plotter = vtki.BackgroundPlotter(show=False, title='Testing Window') plotter.add_mesh(sphere) assert np.any(plotter.mesh.points) dlg = plotter.scale_axes_dialog(show=False) value = 2.0 dlg.x_slider_group.value = value assert plotter.scale[0] == value dlg.x_slider_group.spinbox.setValue(-1) assert dlg.x_slider_group.value == 0 dlg.x_slider_group.spinbox.setValue(1000.0) assert dlg.x_slider_group.value < 100 plotter._last_update_time = 0.0 plotter.update_app_icon() assert plotter.quit() is None
def img2D(points): #三角形片面重建模型 sg.Popup('渲染正在进行中,请您耐心等候一段时间~~~', button_color=('white', 'blue'), background_color='white', keep_on_top=True) gif(gifpath2) cloud = vtki.PolyData(points) # bcloud = vtki.PolyData(blist) # roicloud = vtki.PolyData(roilist) surf = cloud.delaunay_2d(tol=1e-08, alpha=1, offset=100.0, bound=False, inplace=False) # surf1 = bcloud.delaunay_2d(tol = 1e-08,alpha = 0.3,offset = 100.0,bound = False,inplace =False ) # surf2 = roicloud.delaunay_2d(tol = 1e-08,alpha = 0.1,offset = 100.0,bound = False,inplace =False ) print(type(surf)) plotter = vtki.BackgroundPlotter() plotter.add_mesh(surf) # plotter.add_mesh(surf1) # plotter.add_mesh(surf2) plotter.show()
def __init__(self, dataset, plotter=None, scalars=None, preference='cell', show_bounds=False, reset_camera=True, outline=None, display_params=None, default_params=None, continuous_update=False, clean=True, **kwargs): if not run_from_ipython() or not IPY_AVAILABLE: logging.warning( 'Interactive plotting tools require IPython and the ``ipywidgets`` package.' ) # Check the input dataset to make sure its compatible if not is_vtki_obj(dataset): dataset = wrap(dataset) if not is_vtki_obj(dataset): raise RuntimeError( 'Object not supported for plotting in vtki.') # Make the input/output of this tool available self.input_dataset = dataset self.output_dataset = None self.continuous_update = continuous_update if plotter is None: plotter = vtki.BackgroundPlotter(**kwargs) plotter.setWindowTitle(type(self).__name__) self._plotter = plotter self._loc = plotter.index_to_loc(plotter._active_renderer_index) # This is the actor that will be removed and re-added to the plotter self._data_to_update = None self._last_scalars = None # Intialize plotting parameters self.valid_range = self.input_dataset.get_data_range( arr=scalars, preference=preference) if display_params is None: display_params = {} if default_params is None: default_params = {} display_params.setdefault('rng', self.valid_range) display_params.setdefault('scalars', scalars) display_params.setdefault('preference', preference) display_params.setdefault('show_edges', False) # Make sure to remove the reset_camera parameter if present display_params.pop('reset_camera', None) # Make a name display_params.setdefault( 'name', '{}({})'.format(type(self).__name__, str(hex(id(self))))) self.display_params = display_params self.clean = clean # Set the tool status self._need_to_update = True # Add some intital plotting stuff to the scene self._initialize(show_bounds, reset_camera, outline) # Run the tool self.tool(default_params=default_params, **kwargs)
def test_background_plotting(qtbot): sphere = vtki.Sphere() plotter = vtki.BackgroundPlotter(show=False) plotter.add_mesh(sphere) assert np.any(plotter.mesh.points) assert plotter.close()
def test_background_plotting_orbit(qtbot): plotter = vtki.BackgroundPlotter(show=False, title='Testing Window') plotter.add_mesh(vtki.Sphere()) # perfrom the orbit: plotter.orbit_on_path(bkg=False, step=0.0) plotter.close()