o
    Ê53SÃ  ã                   @   s
  d dl mZ d dlT d dlmZ d dlmZmZmZm	Z	m
Z
mZmZmZ dDdd„ZdDd	d
„Z		dEdd„ZG dd„ dƒZdd„ Z			dFdd„Zd dlmZmZmZ ed Zde Zde Zdd„ Zdd„ Zdd„ Zdd„ Zd Zde Z G d!d"„ d"ƒZ!d#d$„ Z"dGd%d&„Z#e$d'k�rd d(lmZ d d)l%m&Z&m'Z' ed*d+ƒZ(ee(d,d-d,d.d/d/e&e'd0�	 ee(d1d2d,d3d/d/e&e'd0�	 e(j)d4gd5dd6� e*e#g d7¢g d8¢g d9¢gƒƒ e*e#d:d;gd<d=ggƒƒ e*e#d>d;gd?d=ggƒƒ e*e#d@dAgd=dBggƒƒ e*e#g d7¢d@dAgg dC¢gƒƒ dS dS )Hé    )Úcolors)Ú*)ÚCanvas)ÚGroupÚDrawingÚEllipseÚWedgeÚStringÚSTATE_DEFAULTSÚPolygonÚLineNçš™™™™™¹?c                 C   ó*   |d u rddl m} | r|| d| ƒ}|S )Nr   )ÚBlackeré   )Úreportlab.lib.colorsr   )ÚcolÚshdÚshadingr   © r   úS/var/www/html/env/lib/python3.10/site-packages/reportlab/graphics/charts/utils3d.pyÚ
_getShaded   ó   r   c                 C   r   )Nr   )ÚWhiterr   )r   r   )r   r   Úlightingr   r   r   r   Ú_getLit   r   r   r   c                 C   sÊ   t |d |ƒ}t |d |d ƒ}| |	|
|fdd„}t||ƒ}|s |r:||kr/||||||||d� ||||||||d� |  t||||||||f|	|
|dd�¡ |sR|rc|  t|||||
|	p]|d�¡ d S d S )Ng       @c
           
      S   s<   |  t| || | || || || ||f|||	dd�¡ d S )Nr   )ÚstrokeWidthÚstrokeColorÚ	fillColorÚstrokeLineJoin)Úaddr   )
Úx1Úx2Úy1Úy2ÚxoffÚyoffÚGr   r   r   r   r   r   Ú_add_3d_bar   s   (ÿz!_draw_3d_bar.<locals>._add_3d_bar)r   r   )r   r   r   r   )r   r   )r   Úmaxr    r   r   )r'   r!   r"   Úy0ÚyhighÚxdepthÚydepthr   ÚfillColorShadedr   r   r   ÚfillColorShadedTopr(   Úusdr   r   r   Ú_draw_3d_bar   s   
ÿ
ÿ"ÿr1   c                   @   s   e Zd Zddd„ZdS )Ú_YStripr   c                 C   s*   || _ || _|| _|| _t|||ƒ| _d S ©N)r*   r#   Úsloper   r   r.   )Úselfr*   r#   r4   r   r.   r   r   r   r   Ú__init__,   s
   z_YStrip.__init__N)r   )Ú__name__Ú
__module__Ú__qualname__r6   r   r   r   r   r2   +   s    r2   c                 C   s$   | || | || || || ||gS r3   r   )Úx0r!   r*   r#   r%   r&   r   r   r   Ú_ystrip_poly3   s   $r;   c           '   	   C   s®  t || ƒ}|| }|| }|dkrdp| t|ƒ }t|| ƒ}|dkr'dp,|| | }||kr7t|	|
|ƒp8|	}|| }|| }d}|d u rM||fg}nQ|| d || d  d }||9 }||k ri||fg}n5t|t|ƒ ƒd }t|| ƒ| }t|| ƒ| }g }|j}td|ƒD ]} ||||   |||   fƒ q�| j}|| }!|| }"|D ])\}}#|| }$|#| }%tt|!|$|"|%||ƒ|||d�}&|d|||!|"|&fƒ |$}!|%}"q«d S )Nr   g¯–P.5�_g333333ã?é   ç      à?r   )r   r   r   )	ÚabsÚfloatr   ÚintÚappendÚranger    r   r;   )'r'   r:   r!   r*   r#   Úz0Úz1Útheta_xÚtheta_yr   r.   Ú	tileWidthr   r   ÚstrokeDashArrayr   Úzwidthr,   r-   Údepth_slopeÚxr4   ÚcÚzy0Úzx0ÚtileStrokeWidthÚDÚTÚnÚdxÚdyÚaÚiÚx_0Úy_0ÚyÚx_1Úy_1ÚPr   r   r   Ú_make_3d_line_info7   sH   ÿùr]   )ÚpiÚsinÚcosr=   r<   g     €f@c                 C   s   | t  S r3   ©Ú_180_pi)Úangler   r   r   Ú_2radj   ó   rd   c                 C   s   | t  } | dk r| t 7 } | S )Nç�íµ ÷Æ°¾)Ú_2pi)Úradiansr   r   r   Úmod_2pim   ó   ri   c                 C   s   | t  S r3   ra   )Úor   r   r   Ú_2degr   re   rl   c                 C   s   | d; } | dk r| d7 } | S )Nih  rf   r   ©rU   r   r   r   Ú_360u   rj   rn   ç:Œ0âŽyE>c                   @   s(   e Zd Zdd„ Zdd„ ZeZdd„ ZdS )Ú_Segmentc           	      C   s¦   || }||d  d }||d  d }|| d }|| d }||k r.||||f\}}}}t || ƒ| _t || ƒ| _|| _|| _|| _|| _|| _|| _|| _	d S )Nr   r   )
r?   rU   Úbr:   r!   r*   r#   ÚseriesrV   Ús)	r5   rs   rV   ÚdataÚSr:   r*   r!   r#   r   r   r   r6   }   s    
z_Segment.__init__c                 C   s   d| j | j| j| jf S )Nz[(%s,%s),(%s,%s)])r:   r*   r!   r#   )r5   r   r   r   Ú__str__’   s   z_Segment.__str__c                 C   sŒ  | j }|j }||ksJ ‚|| jkrdS |j| jkr(|j| jd | jd fv r(dS | j}| j}|j}|j}|| ||  }	d|	  k rGdk rHdS  || }
| j|j }|| ||
  |	 }|| ||
  |	 }|dk sv|dksv|dk sv|dkrxdS |||  }| j||  }t|  k r�tk r¢n n| j| j||f}||vr¢| 	|¡ t|  k r¬tk rÂn dS |j|j||f}||vrÄ| 	|¡ dS dS dS )z4try to find an intersection with _Segment o
        r   Ng:Œ0âŽyE¾ro   r   )
r:   r!   rs   rV   rU   rq   r*   Ú_ZEROÚ_ONErA   )r5   rk   ÚIr:   Úox0rU   rq   ÚoaÚobÚdetrS   rT   ÚuÚourK   rY   Útr   r   r   Ú	intersect—   s4   *$þz_Segment.intersectN)r7   r8   r9   r6   rv   Ú__repr__r�   r   r   r   r   rp   |   s
    rp   c                 C   s   | j | j| j| j| j| jfS r3   )r:   r!   r*   r#   rs   rV   rm   r   r   r   Ú_segKey³   s   rƒ   c                 C   sà   g }|j }tt| ƒƒD ].}| | }|sqt|ƒ}|dkrqtd|ƒD ]}t||| ƒ}|jt|jƒ |kr8||ƒ q"q|jtd� g }	t|ƒ}td|d ƒD ]}|| }t|d |ƒD ]}
| 	||
 |	¡dkrh nqZqM|	 ¡  |	S )aV  
    data is a sequence of series
    each series is a list of (x,y) coordinates
    where x & y are ints or floats

    find_intersections returns a sequence of 4-tuples
        i, j, x, y

    where i is a data index j is an insertion position for data[i]
    and x, y are coordinates of an intersection of series data[i]
    with some other series. If correctly implemented we get all such
    intersections. We don't count endpoint intersections and consider
    parallel lines as non intersecting (even when coincident).
    We ignore segments that have an estimated size less than small.
    r   )Úkeyr   )
rA   rB   Úlenrp   rU   r>   rq   Úsortrƒ   r�   )rt   Úsmallru   rU   rs   ÚdsrR   rV   Úsegry   Újr   r   r   Úfind_intersections¶   s,   
€þ€r‹   Ú__main__)r   )Ú	lightgreyÚpinki,  éÈ   é
   é   é2   é   )r   r   é   é(   é-   ÚpdfÚ.)ÚformatsÚoutDirÚfnRoot))r   r=   )r   r=   )r=   r   )r=   r   ))g±:Ñ?çš™™™™™Ù?©r   rœ   ©r   çš™™™™™É?©r   r   ©r   r   )©r   r   ©rœ   r   ©r   r   rž   r�   r¢   r£   )rŸ   rœ   ©r   gš™™™™™é?r    r¡   r¤   )r¥   r£   r¤   )Nr   )NNNr   r   )Nr   NNNr   )r   )+Úreportlab.libr   Úreportlab.lib.attrmapÚreportlab.pdfgen.canvasr   Úreportlab.graphics.shapesr   r   r   r   r	   r
   r   r   r   r   r1   r2   r;   r]   Úmathr^   r_   r`   Ú_pi_2rg   rb   rd   ri   rl   rn   rw   rx   rp   rƒ   r‹   r7   r   r�   rŽ   rP   ÚsaveÚprintr   r   r   r   Ú<module>   sR    (


þ
ü.7

&
"ó