{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Picking points on a mesh {#point_picking_example}\n\nThis example demonstrates how to pick points on meshes using\n`enable_point_picking() <pyvista.Plotter.enable_point_picking>`{.interpreted-text\nrole=\"func\"}.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import pyvista as pv"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Pick points on a sphere\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "sphere = pv.Sphere()\n\np = pv.Plotter()\np.add_mesh(sphere, pickable=True)\np.enable_point_picking()\np.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Ignore the 3D window\n\nIn the above example, both points on the mesh and points in the 3d\nwindow can be selected. It is possible instead pick only points on the\nmesh.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "sphere = pv.Sphere()\n\np = pv.Plotter()\np.add_mesh(sphere, pickable=True)\np.enable_point_picking(pickable_window=False)  # Make the 3D window unpickable\np.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Modify which actors are pickable\n\nAfter enabling point picking, we can modify which actors are pickable.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "sphere = pv.Sphere()\ncube = pv.Cube().translate([10, 10, 0])\n\np = pv.Plotter()\nsphere_actor = p.add_mesh(sphere, pickable=True)  # initially pickable\ncube_actor = p.add_mesh(cube, pickable=False)  # initially unpickable\np.enable_point_picking(pickable_window=False)\n\np.pickable_actors = [sphere_actor, cube_actor]  # now both are pickable\np.view_xy()\np.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Pick using the left-mouse button\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "sphere = pv.Sphere()\n\np = pv.Plotter()\np.add_mesh(sphere, pickable=True)\np.enable_point_picking(left_clicking=True)\np.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.12.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}