a
    ¦¾de  ã                   @   sÀ  d dl mZmZmZ dAdd„ZdBdd„ZdCd	d
„ZG dd„ dƒZdd„ ZdDdd„Z	d dl
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dEd"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d-�	 eed.d/d)d0d,d,eed-�	 ejd1gd2d
d3� eeg d4¢g d5¢g d6¢gƒƒ eed7d8gd9d:ggƒƒ eed;d8gd<d:ggƒƒ eed=d>gd:d?ggƒƒ eeg d4¢d=d>gg d@¢gƒƒ dS )Fé    )ÚDrawingÚPolygonÚLineNçš™™™™™¹?c                 C   s*   |d u r&ddl m} | r&|| d| ƒ}|S )Nr   )ÚBlackeré   )Úreportlab.lib.colorsr   )ÚcolÚshdÚshadingr   © r   úZ/var/www/sistema_ama/venv/lib/python3.9/site-packages/reportlab/graphics/charts/utils3d.pyÚ
_getShaded   s    r   c                 C   s*   |d u r&ddl m} | r&|| d| ƒ}|S )Nr   )ÚWhiterr   )r   r   )r	   r
   Zlightingr   r   r   r   Ú_getLit	   s    r   r   c                 C   sÆ   t |d |ƒ}t |d |d ƒ}| |	|
|fdd„}t||ƒ}|s@|rt||kr^||||||||d� ||||||||d� |  t||||||||f|	|
|dd�¡ |s¤|rÂ|  t|||||
|	pº|d�¡ 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   Úy0ZyhighÚxdepthÚydepthr   ÚfillColorShadedr   r   r   ZfillColorShadedTopr   Zusdr   r   r   Ú_draw_3d_bar   s    ÿ

ÿr#   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   r&   r   r"   r   r   r   r   Ú__init__)   s
    z_YStrip.__init__N)r   )Ú__name__Ú
__module__Ú__qualname__r(   r   r   r   r   r$   (   s   r$   c                 C   s$   | || | || || || ||gS r%   r   )Úx0r   r   r   r   r   r   r   r   Ú_ystrip_poly0   s    r-   c           '   	   C   s²  t || ƒ}|| }|| }|dkr(dp4| t|ƒ }t|| ƒ}|dkrNdpX|| | }||krnt|	|
|ƒpp|	}|| }|| }d}|d u rš||fg}n¤|| d || d  d }||9 }||k rÒ||fg}nlt|t|ƒ ƒd }t|| ƒ| }t|| ƒ| }g }|j}td|ƒD ]"} ||||   |||   fƒ �q| j}|| }!|| }"|D ]T\}}#|| }$|#| }%tt|!|$|"|%||ƒ|||d�}&|d|||!|"|&fƒ |$}!|%}"�qXd S )Nr   g¯–P.5�_g333333ã?é   ç      à?r   )r   r   r   )	ÚabsÚfloatr   ÚintÚappendÚranger   r   r-   )'r   r,   r   r   r   Zz0Zz1Ztheta_xZtheta_yr   r"   Z	tileWidthr   r   ZstrokeDashArrayr   Zzwidthr    r!   Zdepth_slopeÚxr&   ÚcZzy0Zzx0ZtileStrokeWidthÚDÚTÚnÚdxÚdyÚaÚiZx_0Zy_0ÚyZx_1Zy_1ÚPr   r   r   Ú_make_3d_line_info4   sF     ÿr@   )Úpir/   r.   g     €f@c                 C   s   | t  S r%   ©Ú_180_pi)Zangler   r   r   Ú_2radg   s    rD   c                 C   s   | t  } | dk r| t 7 } | S )Nç�íµ ÷Æ°¾)Ú_2pi)Úradiansr   r   r   Úmod_2pij   s    rH   c                 C   s   | t  S r%   rB   )Úor   r   r   Ú_2dego   s    rJ   c                 C   s   | d; } | dk r| d7 } | S )Nih  rE   r   ©r<   r   r   r   Ú_360r   s    rL   ç:Œ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   )
r1   r<   Úbr,   r   r   r   Zseriesr=   Ús)	r'   rP   r=   ÚdataÚSr,   r   r   r   r   r   r   r(   z   s     z_Segment.__init__c                 C   s   d| j | j| j| jf S )Nz[(%s,%s),(%s,%s)])r,   r   r   r   )r'   r   r   r   Ú__str__�   s    z_Segment.__str__c                 C   s’  | j }|j }||ksJ ‚|| jkr&dS |j| jkrP|j| jd | jd fv rPdS | j}| j}|j}|j}|| ||  }	d|	  k rŒdk r”n ndS || }
| j|j }|| ||
  |	 }|| ||
  |	 }|dk sð|dksð|dk sð|dkrôdS |||  }| j||  }t|  k �r&tk �rNn n$| j| j||f}||v�rN| 	|¡ t|  k �rftk �rŽn n$|j|j||f}||v�rŽ| 	|¡ dS )z4try to find an intersection with _Segment o
        r   Ng:Œ0âŽyE¾rM   r   )
r,   r   rP   r=   r<   rO   r   Ú_ZEROÚ_ONEr3   )r'   rI   ÚIr,   Zox0r<   rO   ZoaÚobZdetr:   r;   ÚuZour5   r>   Útr   r   r   Ú	intersect”   s0    *$z_Segment.intersectN)r)   r*   r+   r(   rS   Ú__repr__rZ   r   r   r   r   rN   y   s   rN   c                 C   s   | j | j| j| j| j| jfS r%   )r,   r   r   r   rP   r=   rK   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rD||ƒ qDq|jtd� g }	t|ƒ}td|d ƒD ]8}|| }t|d |ƒD ]}
| 	||
 |	¡dkr´ qšq´qš|	 ¡  |	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   )
r3   r4   ÚlenrN   r<   r0   rO   Úsortr\   rZ   )rQ   ÚsmallrR   r<   rP   Zdsr9   r=   ÚsegrV   Újr   r   r   Úfind_intersections³   s&    
 rc   Ú__main__)r   )Ú	lightgreyÚpinki,  éÈ   é
   é   é2   é   )r   r   é   é(   é-   ZpdfÚ.)ÚformatsZoutDirZfnRoot))r   r/   )r   r/   )r/   r   )r/   r   ))g±:Ñ?çš™™™™™Ù?©r   rq   ©r   çš™™™™™É?©r   r   ©r   r   )©r   r   ©rq   r   ©r   r   rs   rr   rw   rx   )rt   rq   ©r   gš™™™™™é?ru   rv   ry   )rz   rx   ry   )Nr   )Nr   )NNNr   r   )Nr   NNNr   )r   )Zreportlab.graphics.shapesr   r   r   r   r   r#   r$   r-   r@   ÚmathrA   Z_pi_2rF   rC   rD   rH   rJ   rL   rT   rU   rN   r\   rc   r)   r   re   rf   r7   ÚsaveÚprintr   r   r   r   Ú<module>   sH   

  þ
   ü
.7
&

