o
    GZh!                     @   s   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mZmZmZmZ d dlmZ G dd deZG d	d
 d
eZG dd deZG dd deZdS )    N)font)S)
PlotObject)billboard_matrixdot_productget_direction_vectorsstrided_rangevec_magvec_sub)is_sequencec                   @   sl   e Zd Zddddddddddddddddd	Zd
d Zdd Zdd Zdd Zdd Zdd Z	dd Z
dS )PlotAxes Ng      ?皙?ZArial   )stylenoneframeboxordinatestridevisibleoverlaycolored
label_axeslabel_tickstick_length	font_face	font_sizec                O   sD  |  }|d ur
d}|d urd}|d urd}|d urd}|dv r&t| | _n|dv r0t| | _n|dv r8d | _ntd| zt|}W n	 tyM   Y nw t|r`t|d	kr\td
|| _	n|||g| _	t
|| _g d| _|   dd }||d| _||d| _||	d| _||
d| _||d| _|| _|| _|   d S )Nr   r   r   r   )r   r   )r   r   )r   zUnrecognized axes style %s.   zlength should be equal to 3r   r   r   c                 S   s(   | dv r| S | dv rdS | dv rdS |S )N)TF)fFfalseFalseF)tTtrueTrueT )inputdefaultr(   r(   R/var/www/auris/lib/python3.10/site-packages/sympy/plotting/pygletplot/plot_axes.pyflexible_boolean;   s   z+PlotAxes.__init__.<locals>.flexible_booleanTF)lowerPlotAxesOrdinate_render_objectPlotAxesFrame
ValueErroreval	TypeErrorr   len_stridefloat_tick_length_originreset_bounding_boxr   _overlay_colored_label_axesZ_label_ticksr   r   reset_resources)selfr   r   r   r   r   r   r   r   r   r   r   r   r   r   argskwargsr,   r(   r(   r+   __init__   sL   


zPlotAxes.__init__c                 C   s
   d | _ d S N)
label_fontr>   r(   r(   r+   r=   S      
zPlotAxes.reset_resourcesc                 C   s(   d d gd d gd d gg| _ g g g g| _d S rB   )_bounding_box_axis_ticksrD   r(   r(   r+   r9   V   s   zPlotAxes.reset_bounding_boxc                 C   sJ   | j r#ttjtjB tjB  | jrttj | j 	  t
  d S d S rB   )r/   pglZglPushAttribZGL_ENABLE_BITZGL_POLYGON_BITZGL_DEPTH_BUFFER_BITr:   Z	glDisableZGL_DEPTH_TESTdrawZglPopAttribrD   r(   r(   r+   rI   Z   s   
zPlotAxes.drawc                 C   s   | j }|}tdD ]a}t|| d tju s!t|| d tju r"q	|| d d u r0|| d nt|| d || d g|| d< || d d u rP|| d nt|| d || d g|| d< || _ | | q	d S )Nr   r      )rF   rangeabsr   Infinityminmax_recalculate_axis_ticks)r>   Zchild_boundsbcir(   r(   r+   adjust_boundsb   s   ,@@zPlotAxes.adjust_boundsc                 C   s`   | j }|| d d u s|| d d u rg | j|< d S t|| d || d | j| | j|< d S )Nr   rJ   )rF   rG   r   r5   )r>   axisrQ   r(   r(   r+   rP   m   s    z PlotAxes._recalculate_axis_ticksc                 C      | j  | _ d S rB   )r   rD   r(   r(   r+   toggle_visibleu      zPlotAxes.toggle_visiblec                 C   rV   rB   )r;   rD   r(   r(   r+   toggle_colorsx   rX   zPlotAxes.toggle_colors)__name__
__module____qualname__rA   r=   r9   rI   rT   rP   rW   rY   r(   r(   r(   r+   r      s    

Fr   c                   @   s>   e Zd Zdd Zdd Zdd Zdd Zdd
dZdd ZdS )PlotAxesBasec                 C   s
   || _ d S rB   )_pr>   Zparent_axesr(   r(   r+   rA   ~   rE   zPlotAxesBase.__init__c                 C   sr   g dg dg dfg dg dg dfg| j j }| | | d|d  | d|d  | d|d  d S )N)g?r   333333?)?r`         ?)rb         ?rb   )r`   r`   ra      rJ   r   )r^   r;   draw_background	draw_axisr>   colorr(   r(   r+   rI      s   
zPlotAxesBase.drawc                 C      d S rB   r(   rg   r(   r(   r+   re         zPlotAxesBase.draw_backgroundc                 C      t  rB   NotImplementedErrorr>   rU   rh   r(   r(   r+   rf         zPlotAxesBase.draw_axisrc   c                 C   s   t |dkr|d |d |d df}| jjd u r'tj| jj| jjddd| j_tj| jj||tjjtjj	d	}t
  t
j|  t  d
| }t
||| t
dddd |  t
  d S )Nr   r   rJ   rd   rc   TF)bolditalic)rh   ZvalignZhaligng{Gzt?)r4   r^   rC   r   loadr   r   TextZBASELINEZCENTERrH   ZglPushMatrixZglTranslatefr   ZglScalefZ	glColor4frI   ZglPopMatrix)r>   textpositionrh   scalelabelZscale_factorr(   r(   r+   	draw_text   s(   


zPlotAxesBase.draw_textc                 C   s   | j j}ttj tj|  t|d d |d  |d d |d  |d d |d   t|d d |d  |d d |d  |d d |d   t  d S )Nr   rJ   rd   )r^   r8   rH   ZglBeginZGL_LINESZ	glColor3fZ
glVertex3fZglEnd)r>   vrh   or(   r(   r+   	draw_line   s   
>>zPlotAxesBase.draw_lineN)rc   )	rZ   r[   r\   rA   rI   re   rf   rx   r{   r(   r(   r(   r+   r]   |   s    
r]   c                       sD   e Zd Z fddZdd Zdd Zdd Zd	d
 Zdd Z  Z	S )r.   c                       t  | d S rB   superrA   r_   	__class__r(   r+   rA         zPlotAxesOrdinate.__init__c                 C   s   | j j| }| j jd }t|dk rd S g dg dg}|d |d |d |< |d |< t|d |d }t d }tt||}|t| }t|d dk}	|D ]}
| 	||||
|	 qR| 
|||d |d |	 d S )	Ng       @rd   r   r   rJ   rc   g{Gz?)r^   rG   r7   r4   r
   r   rL   r   r	   draw_tick_linedraw_axis_line)r>   rU   rh   ZticksradiusZ
axis_linesZaxis_vectorZpos_zdlabels_visibletickr(   r(   r+   rf      s   "
zPlotAxesOrdinate.draw_axisc                 C   sP   g dg dg}|||d |< |d |< |  || |r&| ||| d S d S )Nr   r   rJ   )r{   draw_axis_line_labels)r>   rU   rh   Za_minZa_maxr   	axis_liner(   r(   r+   r      s   zPlotAxesOrdinate.draw_axis_linec                 C   s   | j jsd S |d d d  |d d d  g}|d |  d8  < |d |  d7  < g d| }| d| |d | | d| |d | d S )Nr   rJ   r`   )XYZ-+)r^   r<   rx   )r>   rU   rh   r   Zaxis_labelsZa_strr(   r(   r+   r      s    z&PlotAxesOrdinate.draw_axis_line_labelsc                 C   s|   dddd| }g dg dg}| |d |< |d |< | ||d |< |d |< |  || |r<| |||| d S d S )NrJ   r   r   rJ   rd   r   )r{   draw_tick_line_label)r>   rU   rh   r   r   r   Z	tick_axisZ	tick_liner(   r(   r+   r      s   zPlotAxesOrdinate.draw_tick_linec                 C   sZ   | j jsd S g d}|||< g d| | d |dddd| < | jt|||dd d S )	Nr   )r   rJ   rJ   g      @rJ   r   r   rb   )rv   )r^   r<   rx   str)r>   rU   rh   r   r   Ztick_label_vectorr(   r(   r+   r      s   z%PlotAxesOrdinate.draw_tick_line_label)
rZ   r[   r\   rA   rf   r   r   r   r   __classcell__r(   r(   r   r+   r.      s    
	r.   c                       s,   e Zd Z fddZdd Zdd Z  ZS )r0   c                    r|   rB   r}   r_   r   r(   r+   rA      r   zPlotAxesFrame.__init__c                 C   ri   rB   r(   rg   r(   r(   r+   re      rj   zPlotAxesFrame.draw_backgroundc                 C   rk   rB   rl   rn   r(   r(   r+   rf      ro   zPlotAxesFrame.draw_axis)rZ   r[   r\   rA   re   rf   r   r(   r(   r   r+   r0      s    r0   )Z	pyglet.glglrH   Zpygletr   Z
sympy.corer   Z%sympy.plotting.pygletplot.plot_objectr   Zsympy.plotting.pygletplot.utilr   r   r   r   r	   r
   Zsympy.utilities.iterablesr   r   r]   r.   r0   r(   r(   r(   r+   <module>   s     q3C