o
    7 h'                     @  sX   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZ G dd deZd	S )
zConnector (line) shape and related objects.

A connector is a line shape having end-points that can be connected to other
objects (but not to other connectors). A connector can be straight, have
elbows, or can be curved.
    )annotations
LineFormat)MSO_SHAPE_TYPE)	BaseShape)Emulazypropertyc                   @  s   e Zd ZdZdd Zedd Zejdd Zedd Zejd	d Zd
d Z	edd Z
e
jdd Z
edd Zejdd Zdd Zedd Zedd Zedd Zdd Zdd Zdd Zd d! Zd"S )#	ConnectorzConnector (line) shape.

    A connector is a linear shape having end-points that can be connected to
    other objects (but not to other connectors). A connector can be straight,
    have elbows, or can be curved.
    c                 C     |  || | || dS )a  
        **EXPERIMENTAL** - *The current implementation only works properly
        with rectangular shapes, such as pictures and rectangles. Use with
        other shape types may cause unexpected visual alignment of the
        connected end-point and could lead to a load error if cxn_pt_idx
        exceeds the connection point count available on the connected shape.
        That said, a quick test should reveal what to expect when using this
        method with other shape types.*

        Connect the beginning of this connector to *shape* at the connection
        point specified by *cxn_pt_idx*. Each shape has zero or more
        connection points and they are identified by index, starting with 0.
        Generally, the first connection point of a shape is at the top center
        of its bounding box and numbering proceeds counter-clockwise from
        there. However this is only a convention and may vary, especially
        with non built-in shapes.
        N)_connect_begin_to_move_begin_to_cxnselfshape
cxn_pt_idx r   ]/var/www/html/figdemos/bartoux_crm/venv/lib/python3.10/site-packages/pptx/shapes/connector.pybegin_connect   s   zConnector.begin_connectc                 C  4   | j }|j|j|j}}}|r|| n|}t|S )z
        Return the X-position of the begin point of this connector, in
        English Metric Units (as a |Length| object).
        _elementxcxflipHr   )r   cxnSpr   r   r   begin_xr   r   r   r   -      zConnector.begin_xc           	      C     | j }|j|j|jt|f\}}}}|rA|| }t|| }||kr)|| |_d S ||kr4|| |_d S d|_||_|| |_d S t|| }||krU||_|| |_d S ||krc||_|| |_d S d|_|| |_|| |_d S NFTr   r   r   r   intabs)	r   valuer   r   r   r   new_xold_xdxr   r   r   r   8   ,   
c                 C  r   )z
        Return the Y-position of the begin point of this connector, in
        English Metric Units (as a |Length| object).
        r   ycyflipVr   )r   r   r(   r)   r*   begin_yr   r   r   r+   U   r   zConnector.begin_yc           	      C  r   r   r   r(   r)   r*   r    r!   )	r   r"   r   r(   r)   r*   new_yold_ydyr   r   r   r+   `   r&   c                 C  r
   )ae  
        **EXPERIMENTAL** - *The current implementation only works properly
        with rectangular shapes, such as pictures and rectangles. Use with
        other shape types may cause unexpected visual alignment of the
        connected end-point and could lead to a load error if cxn_pt_idx
        exceeds the connection point count available on the connected shape.
        That said, a quick test should reveal what to expect when using this
        method with other shape types.*

        Connect the ending of this connector to *shape* at the connection
        point specified by *cxn_pt_idx*.
        N)_connect_end_to_move_end_to_cxnr   r   r   r   end_connect}   s   zConnector.end_connectc                 C  4   | j }|j|j|j}}}|r|n|| }t|S )z
        Return the X-position of the end point of this connector, in English
        Metric Units (as a |Length| object).
        r   )r   r   r   r   r   end_xr   r   r   r4      r   zConnector.end_xc           	      C     | j }|j|j|jt|f\}}}}|rEt|| }||kr(||_|| |_d S ||kr6||_|| |_d S d|_|| |_|| |_d S || }t|| }||krZ|| |_d S ||kre|| |_d S d|_||_|| |_d S r   r   )	r   r"   r   r   r   r   r#   r%   r$   r   r   r   r4      ,   
c                 C  r3   )z
        Return the Y-position of the end point of this connector, in English
        Metric Units (as a |Length| object).
        r'   )r   r   r(   r)   r*   end_yr   r   r   r7      r   zConnector.end_yc           	      C  r5   r   r,   )	r   r"   r   r(   r)   r*   r-   r/   r.   r   r   r   r7      r6   c                 C  s   | j j S )z'Helper method required by |LineFormat|.)r   spPrget_or_add_lnr   r   r   r   r9      s   zConnector.get_or_add_lnc                 C  s   t | S )z|LineFormat| instance for this connector.

        Provides access to line properties such as line color, width, and
        line style.
        r   r:   r   r   r   line   s   zConnector.linec                 C  s
   | j jjS )zHelper method required by |LineFormat|.

        The ``<a:ln>`` element containing the line format properties such as
        line color and width. |None| if no `<a:ln>` element is present.
        )r   r8   lnr:   r   r   r   r<      s   
zConnector.lnc                 C  s   t jS )zMember of `MSO_SHAPE_TYPE` identifying the type of this shape.

        Unconditionally `MSO_SHAPE_TYPE.LINE` for a `Connector` object.
        )r   LINEr:   r   r   r   
shape_type   s   zConnector.shape_typec                 C  $   | j jj}| }|j|_||_dS )z
        Add or update a stCxn element for this connector that connects its
        begin point to the connection point of *shape* specified by
        *cxn_pt_idx*.
        N)r   	nvCxnSpPr
cNvCxnSpPrget_or_add_stCxnshape_idididx)r   r   r   rA   stCxnr   r   r   r         

zConnector._connect_begin_toc                 C  r?   )z
        Add or update an endCxn element for this connector that connects its
        end point to the connection point of *shape* specified by
        *cxn_pt_idx*.
        N)r   r@   rA   get_or_add_endCxnrC   rD   rE   )r   r   r   rA   endCxnr   r   r   r0     rG   zConnector._connect_end_toc                 C     |j |j|j|jf\}}}}t||d  |f|t||d  ft||d  || f|| t||d  fd| \| _| _dS )z
        Move the begin point of this connector to coordinates of the
        connection point of *shape* specified by *cxn_pt_idx*.
           r      rK      N)lefttopwidthheightr    r   r+   r   r   r   r   r(   r   r)   r   r   r   r        zConnector._move_begin_to_cxnc                 C  rJ   )z
        Move the end point of this connector to the coordinates of the
        connection point of *shape* specified by *cxn_pt_idx*.
        rK   rL   N)rO   rP   rQ   rR   r    r4   r7   rS   r   r   r   r1     rT   zConnector._move_end_to_cxnN)__name__
__module____qualname____doc__r   propertyr   setterr+   r2   r4   r7   r9   r   r;   r<   r>   r   r0   r   r1   r   r   r   r   r	      s>    














r	   N)rX   
__future__r   pptx.dml.liner   pptx.enum.shapesr   pptx.shapes.baser   	pptx.utilr   r   r	   r   r   r   r   <module>   s    