def end_pick_helper(picker, event_id): # Merge the selection into a single mesh picked = self_().picked_cells if isinstance(picked, pyvista.MultiBlock): if picked.n_blocks > 0: picked = picked.combine() else: picked = pyvista.UnstructuredGrid() # Check if valid is_valid_selection = picked.n_cells > 0 if show and is_valid_selection: # Use try in case selection is empty self_().add_mesh(picked, name='_cell_picking_selection', style=style, color=color, line_width=line_width, pickable=False, reset_camera=False, **kwargs) # render here prior to running the callback self_().render() elif not is_valid_selection: self.remove_actor('_cell_picking_selection') self_().picked_cells = None if callback is not None: try_callback(callback, self_().picked_cells) # TODO: Deactivate selection tool return
def _the_callback(mesh, idx): if mesh is None: return point = mesh.points[idx] if self._last_picked_idx is None: self.picked_geodesic = pyvista.PolyData(point) else: surface = mesh.extract_surface().triangulate() locator = vtk.vtkPointLocator() locator.SetDataSet(surface) locator.BuildLocator() start_idx = locator.FindClosestPoint( mesh.points[self._last_picked_idx]) end_idx = locator.FindClosestPoint(point) self.picked_geodesic = self.picked_geodesic + surface.geodesic( start_idx, end_idx) self._last_picked_idx = idx if show_path: self.add_mesh(self.picked_geodesic, color=color, name='_picked_path', line_width=line_width, point_size=point_size, reset_camera=False, **kwargs) if hasattr(callback, '__call__'): try_callback(callback, self.picked_geodesic) return
def _the_callback(widget, event_id): polyline = pyvista.PolyData() widget.GetPolyData(polyline) ribbon.shallow_copy(polyline.ribbon(normal=(0, 0, 1), angle=90.0)) if hasattr(callback, '__call__'): try_callback(callback, polyline) return
def _the_callback(mesh, idx): if mesh is None: return point = mesh.points[idx] if self._last_picked_idx is None: self.picked_geodesic = pyvista.PolyData(point) self.picked_geodesic['vtkOriginalPointIds'] = [idx] else: surface = mesh.extract_surface().triangulate() locator = _vtk.vtkPointLocator() locator.SetDataSet(surface) locator.BuildLocator() start_idx = locator.FindClosestPoint(mesh.points[self._last_picked_idx]) end_idx = locator.FindClosestPoint(point) self.picked_geodesic += surface.geodesic(start_idx, end_idx, keep_order=keep_order) if keep_order: # it makes sense to remove adjacent duplicate points self.picked_geodesic.clean(inplace=True, lines_to_points=False, polys_to_lines=False, strips_to_polys=False) self._last_picked_idx = idx if show_path: self.add_mesh(self.picked_geodesic, color=color, name='_picked_path', line_width=line_width, point_size=point_size, reset_camera=False, **kwargs) if callable(callback): try_callback(callback, self.picked_geodesic)
def _the_callback(widget, event): value = widget.GetRepresentation().GetValue() if hasattr(callback, '__call__'): if pass_widget: try_callback(callback, value, widget) else: try_callback(callback, value) return
def _the_callback(plane_widget, event_id): the_plane = vtk.vtkPlane() plane_widget.GetPlane(the_plane) normal = the_plane.GetNormal() origin = the_plane.GetOrigin() if hasattr(callback, '__call__'): try_callback(callback, normal, origin) return
def _the_callback(widget, event_id): point = widget.GetCenter() index = widget.WIDGET_INDEX if hasattr(callback, '__call__'): if num > 1: try_callback(callback, point, index) else: try_callback(callback, point) return
def _the_callback(box_widget, event_id): the_box = pyvista.PolyData() box_widget.GetPolyData(the_box) planes = vtk.vtkPlanes() box_widget.GetPlanes(planes) if hasattr(callback, '__call__'): if use_planes: try_callback(callback, planes) else: try_callback(callback, the_box) return
def _the_callback(widget, event_id): point = widget.GetCenter() index = widget.WIDGET_INDEX if hasattr(callback, '__call__'): if num > 1: args = [point, index] else: args = [point] if pass_widget: args.append(widget) try_callback(callback, *args) return
def _the_callback(widget, event_id): pointa = widget.GetPoint1() pointb = widget.GetPoint2() if hasattr(callback, '__call__'): if use_vertices: try_callback(callback, pointa, pointb) else: the_line = pyvista.Line(pointa, pointb, resolution=resolution) try_callback(callback, the_line) return
def _the_callback(path): if path.n_points < 2: self.remove_actor(name) return self.picked_horizon = path.ribbon(normal=normal, width=width) if show_horizon: self.add_mesh(self.picked_horizon, name=name, color=color, opacity=opacity, pickable=False, reset_camera=False) if hasattr(callback, '__call__'): try_callback(callback, path)
def _the_callback(mesh, idx): if mesh is None: return the_ids.append(idx) the_points.append(mesh.points[idx]) self.picked_path = pyvista.PolyData(np.array(the_points)) self.picked_path.lines = make_line_cells(len(the_points)) if show_path: self.add_mesh(self.picked_path, color=color, name='_picked_path', line_width=line_width, point_size=point_size, reset_camera=False, **kwargs) if callable(callback): try_callback(callback, self.picked_path)
def _end_pick_event(picker, event): self.picked_point = np.array(picker.GetPickPosition()) self.picked_mesh = picker.GetDataSet() self.picked_point_id = picker.GetPointId() if show_point: self.add_mesh(self.picked_point, color=color, point_size=point_size, name='_picked_point', pickable=False, reset_camera=False, **kwargs) if hasattr(callback, '__call__'): if use_mesh: try_callback(callback, self.picked_mesh, self.picked_point_id) else: try_callback(callback, self.picked_point)
def _the_callback(widget, event_id): pointa = widget.GetPoint1() pointb = widget.GetPoint2() if hasattr(callback, '__call__'): if use_vertices: args = [pointa, pointb] else: the_line = pyvista.Line(pointa, pointb, resolution=resolution) args = [the_line] if pass_widget: args.append(widget) try_callback(callback, *args) return
def _the_callback(box_widget, event_id): the_box = pyvista.PolyData() box_widget.GetPolyData(the_box) planes = vtk.vtkPlanes() box_widget.GetPlanes(planes) if hasattr(callback, '__call__'): if use_planes: args = [planes] else: args = [the_box] if pass_widget: args.append(box_widget) try_callback(callback, *args) return
def end_pick_helper(picker, event_id): # Merge the selection into a single mesh picked = self_().picked_cells if isinstance(picked, pyvista.MultiBlock): if picked.n_blocks > 0: picked = picked.combine() else: picked = pyvista.UnstructuredGrid() # Check if valid is_valid_selection = picked.n_cells > 0 if show and is_valid_selection: # Select the renderer where the mesh is added. active_renderer_index = self_()._active_renderer_index for index in range(len(self.renderers)): renderer = self.renderers[index] for actor in renderer._actors.values(): mapper = actor.GetMapper() if isinstance(mapper, vtk.vtkDataSetMapper ) and mapper.GetInput() == mesh: loc = self_().index_to_loc(index) self_().subplot(*loc) break # Use try in case selection is empty self_().add_mesh(picked, name='_cell_picking_selection', style=style, color=color, line_width=line_width, pickable=False, reset_camera=False, **kwargs) # Reset to the active renderer. loc = self_().index_to_loc(active_renderer_index) self_().subplot(*loc) # render here prior to running the callback self_().render() elif not is_valid_selection: self.remove_actor('_cell_picking_selection') self_().picked_cells = None if callback is not None: try_callback(callback, self_().picked_cells) # TODO: Deactivate selection tool return
def end_pick_helper(picker, event_id): if show: # Use try in case selection is empty try: self.add_mesh(self.picked_cells, name='_cell_picking_selection', style=style, color=color, line_width=line_width, pickable=False, reset_camera=False, **kwargs) except RuntimeError: pass if callback is not None and self.picked_cells.n_cells > 0: try_callback(callback, self.picked_cells) # TODO: Deactivate selection tool return
def _the_callback(slider, event): value = slider.GetRepresentation().GetValue() if hasattr(callback, '__call__'): try_callback(callback, value) return
def _the_callback(*args): click_point = self.pick_mouse_position() self.fly_to(click_point) if callable(callback): try_callback(callback, click_point)
def _the_callback(*args): click_point = self.pick_mouse_position() self.fly_to(click_point) if hasattr(callback, '__call__'): try_callback(callback, click_point)