.. oe:namespace:: OEDepict

.. include:: ../substitutions

.. meta::
   :keywords: OE2DPath, 2DPath


.. _OEDepict_OE2DPath:

.. oe:class:: OE2DPath

   .. oe:api::

      class OE2DPath

   A sequence of lines and curves.

   .. _figure_OE2DPath:

   .. figure:: ../images/OEImageBase-DrawPath.*
      :align:  center
      :scale:  100

      **Example of path**

   .. seealso::

      * :oe:meth:`OEDepict::OEImageBase::DrawPath`


   .. ################################################################
      # Constructors
      ################################################################

   .. oe:method:: Constructors

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

         .. oe:api::

            OE2DPath()

      .. oe:language:: python

         .. oe:api:: python

            OE2DPath() -> OE2DPath

      Default constructor.
      The starting point of the path have to be defined using the
      :oe:meth:`OEDepict::OE2DPath::AddStartPoint` method.

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

         .. oe:api::

            OE2DPath(const OE2DPoint& start, bool closed = true)

      .. oe:language:: python

         .. oe:api:: python

            OE2DPath(start: OE2DPoint, closed: bool = True) -> OE2DPath

      Create a new path with a starting point.

      *start*
        The **current point** that will be starting point of the first
        line or curve.

      *closed*
        If true, than a line segment will be added from the starting point to
        the end point of the last line or curve segment of the path.
        See examples in :ref:`Table: Examples of closed and open paths<table_OE2DPath_ClosedOpen>`.

      .. note::

         The starting point of the path will be associated with the
         :oe:const:`OEDepict::OE2DPathPointType::Start`
         type when returned by the :oe:meth:`OEDepict::OE2DPath::GetPoints` method.

      .. _table_OE2DPath_ClosedOpen:

      .. list-table:: **Examples of closed and open paths**
         :widths: 10 10
         :header-rows: 1

         * - closed paths
           - open paths
         * - .. image:: ../images/OE2DPath-closed.*
           - .. image:: ../images/OE2DPath-open.*

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

         .. oe:api::

            OE2DPath(const OE2DPath& rhs)

      .. oe:language:: python

         .. oe:api:: python

            OE2DPath(rhs: OE2DPath) -> OE2DPath

      Copy constructor.

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

         .. oe:api::

            OE2DPath(const OE2DPath& rhs, double scale)

      .. oe:language:: python

         .. oe:api:: python

            OE2DPath(rhs: OE2DPath, scale: float) -> OE2DPath

      Copy constructor with scaling.

      *scale*
         The scaling factor is used to create a new image from the given one.
         The scaling factor has to be a positive (non-zero) number.

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

         .. oe:api::

            OE2DPath(const OE2DPath& rhs, const OE2DPoint& offset)

      .. oe:language:: python

         .. oe:api:: python

            OE2DPath(rhs: OE2DPath, offset: OE2DPoint) -> OE2DPath

      Copy constructor with offset.

      *offset*
        The offset of new path relative to the copied one.

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

         .. oe:api::

            OE2DPath(const OE2DPath& rhs, const OE2DPoint& center,
                     double degrees)

      .. oe:language:: python

         .. oe:api:: python

            OE2DPath(rhs: OE2DPath, center: OE2DPoint, degree: float) -> OE2DPath

      Copy constructor with rotation.

      *center*
        The center of the rotation.

      *degree*
        The rotation in degrees.


   .. ################################################################
      # operator=
      ################################################################

   .. oe:method:: operator=
      :language: c++

      .. oe:api::

         OE2DPath &operator=(const OE2DPath &rhs)

      Assignment operator.


   .. oe:method:: AddCurveSegment

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

         .. oe:api::

            void AddCurveSegment(const OE2DPoint& c1, const OE2DPoint& c2,
                                 const OE2DPoint& end)

      .. oe:language:: python

         .. oe:api:: python

            AddCurveSegment(c1: OE2DPoint, c2: OE2DPoint, end: OE2DPoint) -> None

      Adds a cubic |Bezier| curve to the path from the end point of the last line or curve
      segment of the path to the position **end** using **c1** and **c2** control points.

      *c1, c2*
        The control points of the curve.

      *end*
        The end point of the curve segment.

      .. _figure_OE2DPath_AddCurveSegment:

      .. figure:: ../images/OE2DPoint_AddCurveSegment.*
         :align:  center
         :scale:  100

         **Example of adding a curve segment to a path**

      .. note::

         Points added to the path with the :oe:meth:`OEDepict::OE2DPath::AddCurveSegment`
         method will be associated with the following types when returned by the
         :oe:meth:`OEDepict::OE2DPath::GetPoints` method:

         * :oe:const:`OEDepict::OE2DPathPointType::CurveC1`
         * :oe:const:`OEDepict::OE2DPathPointType::CurveC2`
         * :oe:const:`OEDepict::OE2DPathPointType::CurveEnd`

      .. seealso::

         * :ref:`OE2DPoint <OEDepict_OE2DPoint>` class
         * :oe:meth:`OEDepict::OEImageBase::DrawCubicBezier` method
         * :oe:meth:`OEDepict::OE2DPath::GetPoints` method


   .. oe:method:: AddLineSegment

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

         .. oe:api::

            void AddLineSegment(const OE2DPoint& end)

      .. oe:language:: python

         .. oe:api:: python

            AddLineSegment(end: OE2DPoint) -> None

      Adds a line to the path from the end point of the last line or curve
      segment of the path to the position **end**.

      *end*
        The end point of the line segment.

      .. _figure_OE2DPath_AddLineSegment:

      .. figure:: ../images/OE2DPoint_AddLineSegment.*
         :align:  center
         :scale:  100

         **Example of adding a line segment to a path**

      .. note::

         Points added to the path with the :oe:meth:`OEDepict::OE2DPath::AddLineSegment`
         method will be associated with the :oe:const:`OEDepict::OE2DPathPointType::LineEnd`
         type when returned by the :oe:meth:`OEDepict::OE2DPath::GetPoints` method.

      .. seealso::

         * :ref:`OE2DPoint <OEDepict_OE2DPoint>` class
         * :oe:meth:`OEDepict::OEImageBase::DrawLine` method


   .. oe:method:: AddStartPoint

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

         .. oe:api::

            void AddStartPoint(const OE2DPoint& start)

      .. oe:language:: python

         .. oe:api:: python

            AddStartPoint(start: OE2DPoint) -> None

      Adds the starting point of the path. If clears all previously added
      line or curve segments.

   .. oe:method:: GetEnd

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

         .. oe:api::

            OE2DPoint GetEnd() const

      .. oe:language:: python

         .. oe:api:: python

            GetEnd() -> OE2DPoint

      Returns the end position of the path.

      .. seealso::

         * :oe:meth:`OEDepict::OE2DPath::GetStart` method


   .. oe:method:: GetPoints

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

         .. oe:api::

            OESystem::OEIterBase<OE2DPathPoint>* GetPoints() const

      .. oe:language:: python

         .. oe:api:: python

            GetPoints() -> Iterable[OE2DPathPoint]

      Returns an iterator over all points of the path.
      Each point is associated with a type from the
      :oe:constns:`OEDepict::OE2DPathPointType` namespace.

      **Example:**

      .. oe:source:: DrawObjects.py
         :language: python
         :noindent:
         :frag:     SNIPPET-GET-PATH-POINTS

      .. oe:source:: DrawObjects.cpp
         :language: c++
         :noindent:
         :frag:     SNIPPET-GET-PATH-POINTS

      .. oe:source:: DrawObjects.java
         :language: java
         :noindent:
         :frag:     SNIPPET-GET-PATH-POINTS

      .. oe:source:: DrawObjects.cs
         :language: csharp
         :noindent:
         :frag:     SNIPPET-GET-PATH-POINTS

      .. seealso::

         * :ref:`OE2DPathPoint <OEDepict_OE2DPathPoint>` class
         * :oe:constns:`OEDepict::OE2DPathPointType` namespace


   .. oe:method:: GetStart

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

         .. oe:api::

            OE2DPoint GetStart() const

      .. oe:language:: python

         .. oe:api:: python

            GetStart() -> OE2DPoint

      Returns the starting position of the path.

      .. seealso::

         * :oe:meth:`OEDepict::OE2DPath::GetEnd` method

   .. oe:method:: IsClosed

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

         .. oe:api::

            bool IsClosed() const

      .. oe:language:: python

         .. oe:api:: python

            IsClosed() -> bool

      Returns whether a line segment will be added from the starting point to
      the end point of the last line or curve segment of the path.
      See examples in :ref:`Table: Examples of closed and open paths<table_OE2DPath_ClosedOpen>`.

      .. seealso::

         * :oe:meth:`OEDepict::OE2DPath::SetClosed` method

   .. oe:method:: IsValid

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

         .. oe:api::

            bool IsValid() const

      .. oe:language:: python

         .. oe:api:: python

            IsValid() -> bool

      Returns whether the :ref:`OE2DPath <OEDepict_OE2DPath>` object is valid.
      A path is considered valid if it has a starting point.


   .. oe:method:: SetClosed

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

         .. oe:api::

            void SetClosed(bool closed)

      .. oe:language:: python

         .. oe:api:: python

            SetClosed(closed: bool) -> None

      Sets whether a line segment will be added from the starting point to
      the end point of the last line or curve segment of the path.
