
    hi'                    f    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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                  V   e Zd ZdZd Zed             Zej        d             Zed             Zej        d             Zd Z	ed             Z
e
j        d	             Z
ed
             Zej        d             Zd Zed             Zed             Zed             Zd Zd Zd Z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                ^    |                      ||           |                     ||           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_idxs      m/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/pptx/shapes/connector.pybegin_connectzConnector.begin_connect   s6    $ 	uj111z22222    c                j    | j         }|j        |j        |j        }}}|r||z   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_xs         r   r   zConnector.begin_x-   <     w%+u2!(!b&&q7||r   c                   | j         }|j        |j        |j        t	          |          f\  }}}}|rU||z   }t          ||z
            }||k    r||z   |_        d S ||k    r||z
  |_        d S d|_        ||_        ||z
  |_        d S t          ||z
            }||k    r||_        ||z   |_        d S ||k    r||_        ||z
  |_        d S d|_        ||z   |_        ||z
  |_        d S NFTr   r   r   r   intabs)	r   valuer   r   r   r   new_xold_xdxs	            r   r   zConnector.begin_x8   	   #guxc%jjH2ue 	#FEUU]##B~~7r7#7UQYBzz7r7"b&7r   c                j    | j         }|j        |j        |j        }}}|r||z   n|}t	          |          S )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_ys         r   r.   zConnector.begin_yU   r   r   c                   | j         }|j        |j        |j        t	          |          f\  }}}}|rU||z   }t          ||z
            }||k    r||z   |_        d S ||k    r||z
  |_        d S d|_        ||_        ||z
  |_        d S t          ||z
            }||k    r||_        ||z   |_        d S ||k    r||_        ||z
  |_        d S d|_        ||z   |_        ||z
  |_        d S r    r   r+   r,   r-   r"   r#   )	r   r$   r   r+   r,   r-   new_yold_ydys	            r   r.   zConnector.begin_y`   r(   r   c                ^    |                      ||           |                     ||           dS )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   s      r   end_connectzConnector.end_connect}   s6     	UJ///eZ00000r   c                j    | j         }|j        |j        |j        }}}|r|n||z   }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_xs         r   r9   zConnector.end_x   <     w%+u2&B5zzr   c                   | j         }|j        |j        |j        t	          |          f\  }}}}|rat          ||z
            }||k    r||_        ||z   |_        d S ||k    r||_        ||z
  |_        d S d|_        ||z   |_        ||z
  |_        d S ||z   }t          ||z
            }||k    r||z   |_        d S ||k    r||z
  |_        d S d|_        ||_        ||z
  |_        d S r    r!   )	r   r$   r   r   r   r   r%   r'   r&   s	            r   r9   zConnector.end_x   	   #guxc%jjH2ue 	#UQYBzz7r7#b&7FEUU]##B~~7r7"7r   c                j    | j         }|j        |j        |j        }}}|r|n||z   }t	          |          S )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_ys         r   r>   zConnector.end_y   r:   r   c                   | j         }|j        |j        |j        t	          |          f\  }}}}|rat          ||z
            }||k    r||_        ||z   |_        d S ||k    r||_        ||z
  |_        d S d|_        ||z   |_        ||z
  |_        d S ||z   }t          ||z
            }||k    r||z   |_        d S ||k    r||z
  |_        d S d|_        ||_        ||z
  |_        d S r    r0   )	r   r$   r   r+   r,   r-   r1   r3   r2   s	            r   r>   zConnector.end_y   r<   r   c                >    | j         j                                        S )z'Helper method required by |LineFormat|.)r   spPrget_or_add_lnr   s    r   rB   zConnector.get_or_add_ln   s    }!//111r   c                     t          |           S )z|LineFormat| instance for this connector.

        Provides access to line properties such as line color, width, and
        line style.
        r   rC   s    r   linezConnector.line   s     $r   c                $    | 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   rA   lnrC   s    r   rG   zConnector.ln   s     }!$$r   c                    t           j        S )zMember of `MSO_SHAPE_TYPE` identifying the type of this shape.

        Unconditionally `MSO_SHAPE_TYPE.LINE` for a `Connector` object.
        )r   LINErC   s    r   
shape_typezConnector.shape_type   s     ""r   c                v    | 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   rM   stCxns        r   r   zConnector._connect_begin_to   s6     ],7
++-->			r   c                v    | j         j        j        }|                                }|j        |_        ||_        dS )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   rL   rM   get_or_add_endCxnrO   rP   rQ   )r   r   r   rM   endCxns        r   r5   zConnector._connect_end_to  s6     ],7
--//N	


r   c           	     ,   |j         |j        |j        |j        f\  }}}}t	          ||dz  z             |f|t	          ||dz  z             ft	          ||dz  z             ||z   f||z   t	          ||dz  z             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      rW      N)lefttopwidthheightr"   r   r.   r   r   r   r   r+   r   r,   s          r   r   zConnector._move_begin_to_cxn  s    
 z59ek5<G1b"AQJ#3q26z??#AQJR(BAQJ(	&
 &

 &"dlllr   c           	     ,   |j         |j        |j        |j        f\  }}}}t	          ||dz  z             |f|t	          ||dz  z             ft	          ||dz  z             ||z   f||z   t	          ||dz  z             fd|         \  | _        | _        dS )z
        Move the end point of this connector to the coordinates of the
        connection point of *shape* specified by *cxn_pt_idx*.
        rW   rX   N)r[   r\   r]   r^   r"   r9   r>   r_   s          r   r6   zConnector._move_end_to_cxn  s    
 z59ek5<G1b"AQJ#3q26z??#AQJR(BAQJ(	"
 "

 "
DJJJr   N)__name__
__module____qualname____doc__r   propertyr   setterr.   r7   r9   r>   rB   r	   rE   rG   rJ   r   r5   r   r6    r   r   r   r      s        3 3 3*   X ^# # ^#8   X ^# # ^#81 1 1    X \# # \#8   X \# # \#82 2 2     \  % % X% # # X#	 	 		  	  	       r   r   N)rd   
__future__r   pptx.dml.liner   pptx.enum.shapesr   pptx.shapes.baser   	pptx.utilr   r	   r   rg   r   r   <module>rm      s     # " " " " " $ $ $ $ $ $ + + + + + + & & & & & & ' ' ' ' ' ' ' 'Y Y Y Y Y	 Y Y Y Y Yr   