.. include:: ../substitutions

.. oe:namespace:: OEDepict

.. meta::
   :keywords: OEGetNearestAtom

.. _OEDepict_OEGetNearestAtom:


.. oe:function:: OEGetNearestAtom


   .. oe:language:: c++ java csharp

      .. oe:api::

         OENearestAtom OEGetNearestAtom(const OE2DMolDisplay& disp,
                                        const OE2DPoint& point)

   .. oe:language:: python

      .. oe:api:: python

         OEGetNearestAtom(disp: OE2DMolDisplay, p: OE2DPoint) -> OENearestAtom

   Returns an :ref:`OENearestAtom <OEDepict_OENearestAtom>` object that stores a pointer
   of the atom which is depicted nearest to a given 2D display coordinates.

   .. figure:: ../images/OEGetNearestAtom.*
      :align:  center

      **Example of using the OEGetNearestAtom function
      to determine the nearest atom to a specific 2D point on the canvas**

   *disp*
      The :ref:`OE2DMolDisplay <OEDepict_OE2DMolDisplay>` object of which atoms are being
      considered.
      Only atoms of which atom display is visible are examined
      (:oe:meth:`OEDepict::OEAtomDisplayBase::IsVisible`)

   *point*
      Specifies the 2D display coordinates.

   .. seealso::

      * :ref:`OENearestAtom <OEDepict_OENearestAtom>` class
      * :oe:func:`OEDepict::OEGetNearbyAtom` function
