§
    èƒñjÝ<  ã                  óR  — 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 dd	lmZmZmZ dd
lmZ dZdZ G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        ZdS )z5 Twoport elements made from groups of other elements é    )Úannotations)Úpartialé   )ÚElementCompoundé   )Úelements)ÚPointÚ	Linestyle)ÚSegmentÚSegmentTextr   )ÚOptionalç      à?c                  ó2   ‡ — e Zd ZdZ	 	 	 ddˆ fd„Zd„ Zˆ xZS )ÚElementTwoporta~   Compound twoport element

        Args:
            input_element: The element forming the input branch of the twoport
            output_element: The element forming the output branch of the twoport
            bpadx: Horizontal padding from edge of either component
            bpady: Vertical padding from edge of either component
            minw: Margin around component if smaller than minw
            terminals: Draw with terminals extending past box
            unit: Length of input and output element
            width: Width of the twoport box
            box: Draw twoport outline
            boxfill: Color to fill the twoport if not None
            boxlw: Line width of twoport outline
            boxls: Line style of twoport outline '-', '--', ':', etc.

        Anchors:
            * in_p
            * in_n
            * out_p
            * out_n
            * center
    çš™™™™™É?r   Tç      ø?ç333333@NÚinput_elementútype[elm.Element2Term]Úoutput_elementÚboxpadxÚfloatÚboxpadyÚminwÚ	terminalsÚboolÚunitÚwidthÚboxÚboxfillúOptional[str]ÚboxlwúOptional[float]ÚboxlsúOptional[Linestyle]c                óæ   •— || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        || _         t          ¦   «         j        dd|i|¤Ž d S )Nr   © )r   r   r   r   r   r   r   r   r   r    r"   r$   ÚsuperÚ__init__)Úselfr   r   r   r   r   r   r   r   r   r    r"   r$   ÚkwargsÚ	__class__s                 €úZ/data/share/cad/hardware/.venv/lib/python3.11/site-packages/schemdraw/elements/twoports.pyr)   zElementTwoport.__init__(   sƒ   ø€ ð
 +ˆÔØ,ˆÔØˆŒØˆŒØˆŒ	Ø"ˆŒØˆŒ	ØˆŒ
ØˆŒØˆŒØˆŒ
ØˆŒ
Ø�‰ŒÔÐ-Ð-˜dÐ- fÐ-Ð-Ð-Ð-Ð-ó    c                óè  — |                       ¦   «                              ¦   «         | _        |                      ¦   «                              ¦   «         | _        | j                             ¦   «         }| j                             ¦   «         }t          |j        |j        z
  dz  | j	        dz  ¦  «        }t          |j        |j        z
  dz  | j	        dz  ¦  «        }|  
                    | j                             | j        |z   df¦  «        ¦  «         |  
                    | j                             | j        | j        z
  |z
  df¦  «        ¦  «         |                      ¦   «         }| j        rc|  
                    t          j        dddgd|j        | j        z
  f| j        |j        | j        z   f| j        | j        | j        d¬¦  «        ¦  «         |                      ¦   «         }|  
                    t          j        ¦   «                              | j        j        ¦  «                             |j        ¦  «                             ¦   «         ¦  «        }|  
                    t          j        ¦   «                              | j        j        ¦  «                             |j        ¦  «                             ¦   «         ¦  «        }|  
                    t          j        ¦   «                              | j        j        ¦  «                             |j        ¦  «                             ¦   «         ¦  «        }|  
                    t          j        ¦   «                              | j        j        ¦  «                             |j        ¦  «                             ¦   «         ¦  «        }	|j        | j        d<   |	j        | j        d<   |j        | j        d<   |j        | j        d<   |j        |j        z   dz  |j        |j        z   dz  f| j        d<   | j        rld	D ]k}
d
|
v r	t>           }nt>          }| j        |
         }|d         |z   |d         f}|| j        |
<   | j          !                    tE          ||g¦  «        ¦  «         Œjd S d S )Nr   r   )ÚthetaÚatÚcorner1Úcorner2ÚfillÚlwÚlsÚzorderÚin_pÚin_nÚout_pÚout_nÚcenter)r8   r9   r:   r;   Úinr   )#r   ÚdownÚinput_componentr   Úoutput_componentÚget_bboxÚmaxÚymaxÚyminr   Úaddr1   r   r   r   ÚelmÚRectr   r    r"   r$   ÚLineÚstartÚtoxÚxmaxÚrightÚendÚxminÚleftÚanchorsr   Ú
tp_termlenÚsegmentsÚappendr   )r*   Ú
bbox_inputÚbbox_outputÚin_wÚout_wÚbboxr:   r;   r8   r9   ÚanchorÚxadjustÚprevious_anchorÚ
new_anchors                 r-   ÚsetupzElementTwoport.setup;   sÌ  € Ø#×1Ò1Ñ3Ô3×8Ò8Ñ:Ô:ˆÔØ $× 3Ò 3Ñ 5Ô 5× :Ò :Ñ <Ô <ˆÔàÔ)×2Ò2Ñ4Ô4ˆ
ØÔ+×4Ò4Ñ6Ô6ˆõ �J”O j¤oÑ5°qÑ8¸4¼9Àq¹=ÑIÔIˆÝ�[Ô%¨Ô(8Ñ8¸!Ñ;¸T¼YÈ¹]ÑKÔKˆà�Š�Ô%×(Ò(¨$¬,¸Ñ*=¸qÐ)AÑBÔBÑCÔCÐCØ�Š�Ô&×)Ò)¨4¬:°d´lÑ+BÀUÑ+JÈAÐ*NÑOÔOÑPÔPÐPð �}Š}‰ŒˆØŒ8ð 	ZØ�HŠH•S”X A¨1¨a¨&Ø'(¨$¬)°d´lÑ*BÐ&CÈdÌjÐZ^ÔZcÐfjÔfrÑZrÐMsØ#'¤<°D´JÀ4Ä:ÐVWðYñ Yô Yñ Zô Zð Zð �}Š}‰Œˆà—’�œ™œŸš tÔ'<Ô'BÑCÔC×GÒGÈÌ	ÑRÔR×XÒXÑZÔZÑ[Ô[ˆØ—’�œ™œŸš tÔ'<Ô'@ÑAÔA×EÒEÀdÄiÑPÔP×VÒVÑXÔXÑYÔYˆØ�xŠx�œ™
œ
Ÿš dÔ&:Ô&@ÑAÔA×EÒEÀdÄiÑPÔP×UÒUÑWÔWÑXÔXˆØ�xŠx�œ™
œ
Ÿš dÔ&:Ô&>Ñ?Ô?×CÒCÀDÄIÑNÔN×SÒSÑUÔUÑVÔVˆà#œxˆŒ�VÑØ#œxˆŒ�VÑØ %¤	ˆŒ�WÑØ %¤	ˆŒ�WÑØ#'¤9¨t¬yÑ#8¸AÑ"=ÀÄ	ÈDÌIÑ@UÐYZÑ?ZÐ![ˆŒ�XÑàŒ>ð 	MØ<ð 
Mð 
M�Ø˜6�>�>Ý)˜k�G�Gå(�Gà"&¤,¨vÔ"6�Ø-¨aÔ0°7Ñ:¸OÈAÔ<NÐO�
Ø'1�”˜VÑ$à”×$Ò$¥W¨o¸zÐ-JÑ%KÔ%KÑLÔLÐLÐLð	Mð 	Mð
Mð 
Mr.   )
r   r   r   Tr   r   TNNN)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r)   r]   Ú__classcell__©r,   s   @r-   r   r      ss   ø€ € € € € ðð ð2 JLØKOð Cð	.ð .ð .ð .ð .ð .ð .ð&.Mð .Mð .Mð .Mð .Mð .Mð .Mr.   r   c                  ó0   ‡ — e Zd ZdZd
dˆ fd„Zˆ fd	„Zˆ xZS )ÚTwoPorta%   Generic Twoport

        Args:
            bpadx: Horizontal padding from edge of either component
            bpady: Vertical padding from edge of either component
            minw: Margin around component if smaller than minw
            terminals: Draw with terminals extending past box
            component_offset: Offset between input and output element
            box: Draw twoport outline
            boxfill: Color to fill the twoport if not None
            boxlw: Line width of twoport outline
            boxls: Line style of twoport outline '-', '--', ':', etc.
            sign: Draw input and output terminal labels
            arrow: Draw arrow from input to output

        Anchors:
            * in_p
            * in_n
            * out_p
            * out_n
            * center
    TFÚsignr   ÚarrowÚreverse_outputc           	     ó˜   •— || _         || _        || _         t          ¦   «         j        dt
          j        t
          j        ddddœ|¤Ž d S )Nr   r   )r   r   r   r   Úcomponent_offsetr'   )rg   rh   ri   r(   r)   rF   ÚGap)r*   rg   rh   ri   r+   r,   s        €r-   r)   zTwoPort.__init__ƒ   sg   ø€ ØˆŒ	ØˆŒ
Ø,ˆÔØ�‰ŒÔð 	J¥s¤w½s¼wØ!"¨¸Qð	Jð 	JØBHð	Jð 	Jð 	Jð 	Jð 	Jr.   c           
     ó°  •— t          ¦   «                              ¦   «          | j        �r¦| j                             t          t          d¦  «        | j        j        z   ddd¬¦  «        ¦  «         | j                             t          t          d¦  «        | j        j	        z   ddd¬¦  «        ¦  «         | j
        s‹| j                             t          t          d¦  «        | j        j        z   dd	d¬¦  «        ¦  «         | j                             t          t          d
¦  «        | j        j	        z   dd	d¬¦  «        ¦  «         nŠ| j                             t          t          d¦  «        | j        j        z   dd	d¬¦  «        ¦  «         | j                             t          t          d
¦  «        | j        j	        z   dd	d¬¦  «        ¦  «         | j        rt          | j        d         ¦  «        }| j                             t          |t          t           dz  df¦  «        z   |t          t          dz  df¦  «        z   fdddd¬¦  «        ¦  «         d S d S )N)çš™™™™™¹?rn   õ   âˆ’)rO   r<   F©ÚposÚlabelÚalignÚrotation_global)rn   çš™™™™™¹¿ú+)ru   rn   )rL   r<   )ru   ru   r<   r   r   z->ç333333Ó?)rh   r5   Ú
arrowwidthÚarrowlength)r(   r]   rg   rR   rS   r   r	   r?   rM   rI   ri   r@   rh   rP   r   Útp_arrowlen)r*   Úcenter_pointr,   s     €r-   r]   zTwoPort.setupŠ   s¼  ø€ Ý‰Œ�Š‰ŒˆØŒ9ñ 	SàŒM× Ò Ý¥ jÑ 1Ô 1°DÔ4HÔ4LÑ LÐTYØ"4ÀeðMñ Mô MñNô Nð Nð ŒM× Ò Ý¥ kÑ 2Ô 2°TÔ5IÔ5OÑ OÐWZØ"4ÀeðMñ Mô MñNô Nð Nð Ô&ð SØ”×$Ò$Ý¥E¨+Ñ$6Ô$6¸Ô9NÔ9RÑ$RÐZ_Ø&9È5ðRñ Rô RñSô Sð Sð ”×$Ò$Ý¥E¨,Ñ$7Ô$7¸$Ô:OÔ:UÑ$UÐ]`Ø&9È5ðRñ Rô RñSô Sð Sð Sð ”×$Ò$Ý¥E¨+Ñ$6Ô$6¸Ô9NÔ9RÑ$RÐZ]Ø&9È5ðRñ Rô RñSô Sð Sð ”×$Ò$Ý¥E¨,Ñ$7Ô$7¸$Ô:OÔ:UÑ$UÐ]bØ&9È5ðRñ Rô RñSô Sð Sð Œ:ð 	Ý  ¤¨hÔ!7Ñ8Ô8ˆLØŒM× Ò Ý˜­µ¨|¸aÑ/?ÀÐ.CÑ(DÔ(DÑDÀlÕUZÕ\gÐjkÑ\kÐmnÐ[oÑUpÔUpÑFpÐqØ"ØØ#&Ø$'ð	ñ ô ñô ð ð ð ð	ð 	r.   )TTF)rg   r   rh   r   ri   r   r^   rd   s   @r-   rf   rf   l   sl   ø€ € € € € ðð ð,Jð Jð Jð Jð Jð Jð Jð"ð "ð "ð "ð "ð "ð "ð "ð "r.   rf   c                  ó0   ‡ — e Zd ZdZddˆ fd„Zˆ fd„Zˆ xZS )	ÚVoltageTransactora   Voltage transactor

        Args:
            bpadx: Horizontal padding from edge of either component
            bpady: Vertical padding from edge of either component
            minw: Margin around component if smaller than minw
            terminals: Draw with terminals extending past box
            component_offset: Offset between input and output element
            box: Draw twoport outline
            boxfill: Color to fill the twoport if not None
            boxlw: Line width of twoport outline
            boxls: Line style of twoport outline '-', '--', ':', etc.
            reverse_output: Switch direction of output source, defaults to False

        Anchors:
            * in_p
            * in_n
            * out_p
            * out_n
            * center
    Fri   r   c                ó’   •— t           j        }|st          |d¬¦  «        } t          ¦   «         j        dt           j        |dœ|¤Ž d S ©NT)Úreverse)r   r   r'   )rF   ÚSourceControlledVr   r(   r)   rl   ©r*   ri   r+   r   r,   s       €r-   r)   zVoltageTransactor.__init__Å   sS   ø€ Ý14Ô1FˆØð 	Cå$ ^¸TÐBÑBÔBˆNØ�‰ŒÔÐX¥s¤w¸~ÐXÐXÐQWÐXÐXÐXÐXÐXr.   c                ó\  •— t          ¦   «                              ¦   «          | j                             t	          t          d¦  «        | j        j        z   ddd¬¦  «        ¦  «         | j                             t	          t          d¦  «        | j        j        z   ddd¬¦  «        ¦  «         d S ©	N)r   gš™™™™™©?ro   )rL   ÚbottomFrp   )r   gš™™™™™©¿rv   )rL   Útop©	r(   r]   rR   rS   r   r	   r?   rM   rI   ©r*   r,   s    €r-   r]   zVoltageTransactor.setupÌ   ó¿   ø€ Ý‰Œ�Š‰ŒˆØŒ×ÒÝ�E )Ñ,Ô,¨tÔ/CÔ/GÑGÈuØ1À5ðJñ Jô Jñ	Kô 	Kð 	Kð 	Œ×ÒÝ�E *Ñ-Ô-°Ô0DÔ0JÑJÐRUØ.ÀðGñ Gô Gñ	Hô 	Hð 	Hð 	Hð 	Hr.   ©F©ri   r   r^   rd   s   @r-   r}   r}   ¯   su   ø€ € € € € ðð ð*Yð Yð Yð Yð Yð Yð YðHð Hð Hð Hð Hð Hð Hð Hð Hr.   r}   c                  ó0   ‡ — e Zd ZdZddˆ fd„Zˆ fd„Zˆ xZS )	ÚTransimpedanceTransactora   Transimpedance transactor

        Args:
            bpadx: Horizontal padding from edge of either component
            bpady: Vertical padding from edge of either component
            minw: Margin around component if smaller than minw
            terminals: Draw with terminals extending past box
            component_offset: Offset between input and output element
            box: Draw twoport outline
            boxfill: Color to fill the twoport if not None
            boxlw: Line width of twoport outline
            boxls: Line style of twoport outline '-', '--', ':', etc.
            reverse_output: Switch direction of output source, defaults to False

        Anchors:
            * in_p
            * in_n
            * out_p
            * out_n
            * center
    Fri   r   c                ó’   •— t           j        }|st          |d¬¦  «        } t          ¦   «         j        dt           j        |dœ|¤Ž d S r   )rF   r�   r   r(   r)   rH   r‚   s       €r-   r)   z!TransimpedanceTransactor.__init__ì   óS   ø€ Ý14Ô1FˆØð 	Cå$ ^¸TÐBÑBÔBˆNØ�‰ŒÔÐY¥s¤xÀÐYÐYÐRXÐYÐYÐYÐYÐYr.   c                óÒ   •— t          ¦   «                              ¦   «          t          j        dd¬¦  «        }|                     | j        ¦  «         |                      |¦  «         d S ©Ng333333Ã¿rw   )ÚofstÚ
headlength©r(   r]   rF   ÚCurrentLabelInliner1   r?   rE   ©r*   Úcurrent_label_inliner,   s     €r-   r]   zTransimpedanceTransactor.setupó   óZ   ø€ Ý‰Œ�Š‰ŒˆÝ"Ô5¸5ÈSÐQÑQÔQÐØ×Ò Ô 4Ñ5Ô5Ð5Ø�ŠÐ%Ñ&Ô&Ð&Ð&Ð&r.   rŠ   r‹   r^   rd   s   @r-   r�   r�   Ö   sl   ø€ € € € € ðð ð*Zð Zð Zð Zð Zð Zð Zð'ð 'ð 'ð 'ð 'ð 'ð 'ð 'ð 'r.   r�   c                  ó0   ‡ — e Zd ZdZddˆ fd„Zˆ fd„Zˆ xZS )	ÚCurrentTransactora   Current transactor

        Args:
            bpadx: Horizontal padding from edge of either component
            bpady: Vertical padding from edge of either component
            minw: Margin around component if smaller than minw
            terminals: Draw with terminals extending past box
            component_offset: Offset between input and output element
            box: Draw twoport outline
            boxfill: Color to fill the twoport if not None
            boxlw: Line width of twoport outline
            boxls: Line style of twoport outline '-', '--', ':', etc.
            reverse_output: Switch direction of output source, defaults to False

        Anchors:
            * in_p
            * in_n
            * out_p
            * out_n
            * center
    Fri   r   c                ó’   •— t           j        }|st          |d¬¦  «        } t          ¦   «         j        dt           j        |dœ|¤Ž d S r   )rF   ÚSourceControlledIr   r(   r)   rH   r‚   s       €r-   r)   zCurrentTransactor.__init__  r�   r.   c                óÒ   •— t          ¦   «                              ¦   «          t          j        dd¬¦  «        }|                     | j        ¦  «         |                      |¦  «         d S r‘   r”   r–   s     €r-   r]   zCurrentTransactor.setup  r˜   r.   rŠ   r‹   r^   rd   s   @r-   rš   rš   ú   sl   ø€ € € € € ðð ð,Zð Zð Zð Zð Zð Zð Zð'ð 'ð 'ð 'ð 'ð 'ð 'ð 'ð 'r.   rš   c                  ó0   ‡ — e Zd ZdZddˆ fd„Zˆ fd„Zˆ xZS )	ÚTransadmittanceTransactora   Transadmittance transactor

        Args:
            bpadx: Horizontal padding from edge of either component
            bpady: Vertical padding from edge of either component
            minw: Margin around component if smaller than minw
            terminals: Draw with terminals extending past box
            component_offset: Offset between input and output element
            box: Draw twoport outline
            boxfill: Color to fill the twoport if not None
            boxlw: Line width of twoport outline
            boxls: Line style of twoport outline '-', '--', ':', etc.
            reverse_output: Switch direction of output source, defaults to False

        Anchors:
            * in_p
            * in_n
            * out_p
            * out_n
            * center
    Fri   r   c                ó    •— t           j        }|| _        |st          |d¬¦  «        } t	          ¦   «         j        dt           j        |dœ|¤Ž d S r   )rF   rœ   ri   r   r(   r)   rl   r‚   s       €r-   r)   z"TransadmittanceTransactor.__init__6  s[   ø€ Ý14Ô1FˆØ,ˆÔØð 	Cå$ ^¸TÐBÑBÔBˆNØ�‰ŒÔÐX¥s¤w¸~ÐXÐXÐQWÐXÐXÐXÐXÐXr.   c                ó\  •— t          ¦   «                              ¦   «          | j                             t	          t          d¦  «        | j        j        z   ddd¬¦  «        ¦  «         | j                             t	          t          d¦  «        | j        j        z   ddd¬¦  «        ¦  «         d S r„   r‡   rˆ   s    €r-   r]   zTransadmittanceTransactor.setup>  r‰   r.   rŠ   r‹   r^   rd   s   @r-   rŸ   rŸ     su   ø€ € € € € ðð ð,Yð Yð Yð Yð Yð Yð YðHð Hð Hð Hð Hð Hð Hð Hð Hr.   rŸ   c                  ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )ÚNullorá±   Nullor

        Args:
            bpadx: Horizontal padding from edge of either component
            bpady: Vertical padding from edge of either component
            minw: Margin around component if smaller than minw
            terminals: Draw with terminals extending past box
            component_offset: Offset between input and output element
            box: Draw twoport outline
            boxfill: Color to fill the twoport if not None
            boxlw: Line width of twoport outline
            boxls: Line style of twoport outline '-', '--', ':', etc.

        Anchors:
            * in_p
            * in_n
            * out_p
            * out_n
            * center
    c                ój   •—  t          ¦   «         j        dt          j        t          j        ddœ|¤Ž d S ©Nrw   )r   r   r   r'   )r(   r)   rF   ÚNullatorÚNorator©r*   r+   r,   s     €r-   r)   zNullor.__init__]  s5   ø€ Ø�‰ŒÔÐg¥s¤|ÅCÄKÐY\ÐgÐgÐ`fÐgÐgÐgÐgÐgr.   ©r_   r`   ra   rb   r)   rc   rd   s   @r-   r£   r£   H  sK   ø€ € € € € ðð ð(hð hð hð hð hð hð hð hð hr.   r£   c                  ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )ÚVMCMPairr¤   c                ój   •—  t          ¦   «         j        dt          j        t          j        ddœ|¤Ž d S r¦   )r(   r)   rF   ÚVoltageMirrorÚCurrentMirrorr©   s     €r-   r)   zVMCMPair.__init__v  sG   ø€ Ø�‰ŒÔð 	0¥sÔ'8ÍÔIZØ!$ð	0ð 	0Ø(.ð	0ð 	0ð 	0ð 	0ð 	0r.   rª   rd   s   @r-   r¬   r¬   a  sB   ø€ € € € € ðð ð(0ð 0ð 0ð 0ð 0ð 0ð 0ð 0ð 0r.   r¬   N)rb   Ú
__future__r   Ú	functoolsr   Úcompoundr   Ú r   rF   Útypesr	   r
   rR   r   r   Útypingr   rz   rQ   r   rf   r}   r�   rš   rŸ   r£   r¬   r'   r.   r-   ú<module>r¶      s7  ðØ ;Ð ;Ø "Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð Ð Ð à %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð Ø $Ð $Ð $Ð $Ð $Ð $Ð $Ð $Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø Ð Ð Ð Ð Ð ð €Ø€
ðYMð YMð YMð YMð YM�_ñ YMô YMð YMðx@ð @ð @ð @ð @ˆnñ @ô @ð @ðF$Hð $Hð $Hð $Hð $H˜ñ $Hô $Hð $HðN!'ð !'ð !'ð !'ð !'˜~ñ !'ô !'ð !'ðH"'ð "'ð "'ð "'ð "'˜ñ "'ô "'ð "'ðJ&Hð &Hð &Hð &Hð &H ñ &Hô &Hð &HðRhð hð hð hð hˆ^ñ hô hð hð20ð 0ð 0ð 0ð 0ˆ~ñ 0ô 0ð 0ð 0ð 0r.   