class_docstr: Internal class to contain picking utilities.
class_docstr_tok: ["Internal","class","to","contain","picking","utilities","."]
docstr: Enable rectangle based cell picking on visible surfaces.
  
  Parameters
  ----------
  callback : callable, optional
      When input, calls this callable after a selection is made.
      The picked cells is the only passed argument.
  
  show : bool, default: True
      Show the selection interactively.
  
  style : str, default: "wireframe"
      Visualization style of the selection frustum. One of the
      following: ``style='surface'``, ``style='wireframe'``, or
      ``style='points'``.
  
  line_width : float, default: 5.0
      Thickness of selected mesh edges.
  
  color : ColorLike, default: "pink"
      The color of the selected frustum when shown.
  
  show_message : bool | str, default: True
      Show the message about how to use the cell picking tool. If this
      is a string, that will be the message shown.
  
  font_size : int, default: 18
      Sets the font size of the message.
  
  start : bool, default: True
      Automatically start the cell selection tool.
  
  show_frustum : bool, default: False
      Show the frustum in the scene.
  
  **kwargs : dict, optional
      All remaining keyword arguments are used to control how
      the selection frustum is interactively displayed.
docstr_tok: ["Enable","rectangle","based","cell","picking","on","visible","surfaces",".","Parameters","--","--","--","--","--","callback",":","callable",",","optional","When","input",",","calls","this","callable","after","a","selection","is","made",".","The","picked","cells","is","the","only","passed","argument",".","show",":","bool",",","default",":","True","Show","the","selection","interactively",".","style",":","str",",","default",":","``","wireframe","''","Visualization","style","of","the","selection","frustum",".","One","of","the","following",":","``","style='surface","'","``",",","``","style='wireframe","'","``",",","or","``","style='points","'","``",".","line_width",":","float",",","default",":","5.0","Thickness","of","selected","mesh","edges",".","color",":","ColorLike",",","default",":","``","pink","''","The","color","of","the","selected","frustum","when","shown",".","show_message",":","bool","|","str",",","default",":","True","Show","the","message","about","how","to","use","the","cell","picking","tool",".","If","this","is","a","string",",","that","will","be","the","message","shown",".","font_size",":","int",",","default",":","18","Sets","the","font","size","of","the","message",".","start",":","bool",",","default",":","True","Automatically","start","the","cell","selection","tool",".","show_frustum",":","bool",",","default",":","False","Show","the","frustum","in","the","scene",".","*","*","kwargs",":","dict",",","optional","All","remaining","keyword","arguments","are","used","to","control","how","the","selection","frustum","is","interactively","displayed","."]
code: def enable_rectangle_visible_picking(
      self,
      callback=None,
      show=True,
      style="wireframe",
      line_width=5,
      color="pink",
      show_message=True,
      font_size=18,
      start=False,
      show_frustum=False,
      **kwargs,
  ):
      """Enable rectangle based cell picking on visible surfaces.
  
      Parameters
      ----------
      callback : callable, optional
          When input, calls this callable after a selection is made.
          The picked cells is the only passed argument.
  
      show : bool, default: True
          Show the selection interactively.
  
      style : str, default: "wireframe"
          Visualization style of the selection frustum. One of the
          following: ``style='surface'``, ``style='wireframe'``, or
          ``style='points'``.
  
      line_width : float, default: 5.0
          Thickness of selected mesh edges.
  
      color : ColorLike, default: "pink"
          The color of the selected frustum when shown.
  
      show_message : bool | str, default: True
          Show the message about how to use the cell picking tool. If this
          is a string, that will be the message shown.
  
      font_size : int, default: 18
          Sets the font size of the message.
  
      start : bool, default: True
          Automatically start the cell selection tool.
  
      show_frustum : bool, default: False
          Show the frustum in the scene.
  
      **kwargs : dict, optional
          All remaining keyword arguments are used to control how
          the selection frustum is interactively displayed.
  
      """
      self_ = weakref.ref(self)
  
      def finalize(picked):  # numpydoc ignore=GL08
          if picked is None:
              # Indicates invalid pick
              with self_().iren.poked_subplot():
                  self_()._clear_picking_representations()
              return
  
          if show:
              # Use try in case selection is empty
              with self_().iren.poked_subplot():
                  _kwargs = kwargs.copy()
                  self_().add_mesh(
                      picked,
                      name=_kwargs.pop(
                          "name", PICKED_REPRESENTATION_NAMES["visible"]
                      ),
                      style=style,
                      color=color,
                      line_width=line_width,
                      pickable=_kwargs.pop("pickable", False),
                      reset_camera=_kwargs.pop("reset_camera", False),
                      **_kwargs,
                  )
  
          if callback is not None:
              _poked_context_callback(self_(), callback, picked)
  
      def visible_pick_callback(selection):  # numpydoc ignore=GL08
          picked = pyvista.MultiBlock()
          renderer = self_().iren.get_poked_renderer()
          x0, y0, x1, y1 = renderer.get_pick_position()
          # x0, y0, x1, y1 = selection.viewport
          if x0 >= 0:  # initial pick position is (-1, -1, -1, -1)
              selector = _vtk.vtkOpenGLHardwareSelector()
              selector.SetFieldAssociation(
                  _vtk.vtkDataObject.FIELD_ASSOCIATION_CELLS
              )
              selector.SetRenderer(renderer)
              selector.SetArea(x0, y0, x1, y1)
              selection = selector.Select()
  
              for node in range(selection.GetNumberOfNodes()):
                  selection_node = selection.GetNode(node)
                  if selection_node is None:  # pragma: no cover
                      # No selection
                      continue
                  cids = pyvista.convert_array(
                      selection_node.GetSelectionList()
                  )
                  actor = selection_node.GetProperties().Get(
                      _vtk.vtkSelectionNode.PROP()
                  )
  
                  # TODO: this is too hacky - find better way to avoid non-dataset actors
                  if not actor.GetMapper() or not hasattr(
                      actor.GetProperty(), "GetRepresentation"
                  ):
                      continue
  
                  # if not a surface
                  if (
                      actor.GetProperty().GetRepresentation() != 2
                  ):  # pragma: no cover
                      warnings.warn(
                          "Display representations other than `surface` will result in incorrect results."
                      )
                  smesh = pyvista.wrap(
                      actor.GetMapper().GetInputAsDataSet()
                  )
                  smesh = smesh.copy()
                  smesh["original_cell_ids"] = np.arange(smesh.n_cells)
                  tri_smesh = smesh.extract_surface().triangulate()
                  cids_to_get = tri_smesh.extract_cells(cids)[
                      "original_cell_ids"
                  ]
                  picked.append(smesh.extract_cells(cids_to_get))
  
              # memory leak issues on vtk==9.0.20210612.dev0
              # See: https://gitlab.kitware.com/vtk/vtk/-/issues/18239#note_973826
              selection.UnRegister(selection)
  
          if len(picked) == 0:
              self_()._picked_cell = None
          elif picked.combine().n_cells < 1:
              self_()._picked_cell = None
          elif len(picked) == 1:
              self_()._picked_cell = picked[0]
          else:
              self_()._picked_cell = picked
  
          finalize(self_()._picked_cell)
  
      self.enable_rectangle_picking(
          callback=visible_pick_callback,
          show_message=show_message,
          font_size=font_size,
          start=start,
          show_frustum=show_frustum,
          style=style,
          color=color,
      )
  
imports: from functools import partial, wraps
  from typing import Tuple, cast
  import warnings
  import weakref
  import numpy
  import pyvista
  from pyvista.core.errors import PyVistaDeprecationWarning
  from pyvista.core.utilities.misc import try_callback
  from .None import _vtk
  from .composite_mapper import CompositePolyDataMapper
  from .errors import PyVistaPickingError
  from .opts import ElementType, PickerType
label_desc: Use image node_id 11 for calling the PickingMethods obj's underlying member method code with example usage: obj.enable_rectangle_visible_picking(callback, show, style, line_width, color, show_message, font_size, start, show_frustum) without return types