How to use the pyvista.utilities.try_callback function in pyvista

To help you get started, we’ve selected a few pyvista examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyvista / pyvista / pyvista / plotting / picking.py View on Github external
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)
github pyvista / pyvista / pyvista / plotting / widgets.py View on Github external
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
github pyvista / pyvista / pyvista / plotting / widgets.py View on Github external
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__'):
                if pass_widget:
                    try_callback(callback, polyline, widget)
                else:
                    try_callback(callback, polyline)
            return
github pyvista / pyvista / pyvista / plotting / picking.py View on Github external
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)
github pyvista / pyvista / pyvista / plotting / widgets.py View on Github external
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
github pyvista / pyvista / pyvista / plotting / widgets.py View on Github external
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
github pyvista / pyvista / pyvista / plotting / picking.py View on Github external
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
github pyvista / pyvista / pyvista / plotting / widgets.py View on Github external
def _the_callback(widget, event_id):
            the_plane = vtk.vtkPlane()
            widget.GetPlane(the_plane)
            normal = the_plane.GetNormal()
            origin = the_plane.GetOrigin()
            if hasattr(callback, '__call__'):
                if pass_widget:
                    try_callback(callback, normal, origin, widget)
                else:
                    try_callback(callback, normal, origin)
            return