U
    e»{j2  ã                   @   sP   d dl mZ d dlZd dlmZ d dlmZmZ d dl	m
Z
 G dd„ deƒZdS )é    )ÚdefaultdictN)ÚrcParams)ÚLine2DÚPath)ÚAffine2Dc                   @   sÂ   e Zd ZdZ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d„ Zedd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zed%d%gd&d%ggƒZd'd(„ Zd)d*„ ZdS ),ÚTicksa  
    Ticks are derived from Line2D, and note that ticks themselves
    are markers. Thus, you should use set_mec, set_mew, etc.

    To change the tick size (length), you need to use
    set_ticksize. To change the direction of the ticks (ticks are
    in opposite direction of ticklabels by default), use
    set_tick_out(False).

    Note that Matplotlib's defaults dictionary :data:`~matplotlib.rcParams`
    contains default settings (color, size, width) of the form `xtick.*` and
    `ytick.*`. In a WCS projection, there may not be a clear relationship
    between axes of the projection and 'x' or 'y' axes. For this reason,
    we read defaults from `xtick.*`. The following settings affect the
    default appearance of ticks:

    * `xtick.direction`
    * `xtick.major.size`
    * `xtick.major.width`
    * `xtick.minor.size`
    * `xtick.color`

    Attributes
    ----------
    ticks_locs : dict
        This is set when the ticks are drawn, and is a mapping from axis to
        the locations of the ticks for that axis.
    Nc                 K   sˆ   |d krt d }|  |¡ |  t d ¡ |  t d dk¡ |  ¡  t d t d dœ}| |¡ tj| dgdgf|Ž |  d	¡ d
| _	d S )Nzxtick.major.sizezxtick.minor.sizezxtick.directionÚoutzxtick.colorzxtick.major.width)ÚcolorZ	linewidthç        ÚallF)
r   Úset_ticksizeÚset_minor_ticksizeÚset_tick_outÚclearÚupdater   Ú__init__Úset_visible_axesÚ_display_minor_ticks)ÚselfÚticksizeÚtick_outÚkwargsZline2d_kwargs© r   úb/var/www/html/bwave/python/venv/lib/python3.8/site-packages/astropy/visualization/wcsaxes/ticks.pyr   )   s    
þ

zTicks.__init__c                 C   s
   || _ d S ©N©r   )r   Údisplay_minor_ticksr   r   r   r   9   s    zTicks.display_minor_ticksc                 C   s   | j S r   r   ©r   r   r   r   Úget_display_minor_ticks<   s    zTicks.get_display_minor_ticksc                 C   s
   || _ dS )zD
        set True if tick need to be rotated by 180 degree.
        N©Ú	_tick_out)r   r   r   r   r   r   ?   s    zTicks.set_tick_outc                 C   s   | j S )zH
        Return True if the tick will be rotated by 180 degree.
        r   r   r   r   r   Úget_tick_outE   s    zTicks.get_tick_outc                 C   s
   || _ dS )z4
        set length of the ticks in points.
        N©Ú	_ticksize©r   r   r   r   r   r   K   s    zTicks.set_ticksizec                 C   s   | j S )z7
        Return length of the ticks in points.
        r"   r   r   r   r   Úget_ticksizeQ   s    zTicks.get_ticksizec                 C   s
   || _ dS )z:
        set length of the minor ticks in points.
        N©Z_minor_ticksizer$   r   r   r   r   W   s    zTicks.set_minor_ticksizec                 C   s   | j S )z=
        Return length of the minor ticks in points.
        r&   r   r   r   r   Úget_minor_ticksize]   s    zTicks.get_minor_ticksizec                 C   s   | j r| jS dS d S )Nr
   )r    r#   r   r   r   r   Úout_sizec   s    zTicks.out_sizec                 C   s
   || _ d S r   )Ú_visible_axes)r   Zvisible_axesr   r   r   r   j   s    zTicks.set_visible_axesc                    s,   ˆ j dkrˆ j ¡ S ‡ fdd„ˆ j D ƒS d S )Nr   c                    s   g | ]}|ˆ j kr|‘qS r   )Úworld)Ú.0Úxr   r   r   Ú
<listcomp>q   s     
 z*Ticks.get_visible_axes.<locals>.<listcomp>)r)   r*   Úkeysr   r   r   r   Úget_visible_axesm   s    

zTicks.get_visible_axesc                 C   sT   t tƒ| _t tƒ| _t tƒ| _t tƒ| _t tƒ| _t tƒ| _t tƒ| _t tƒ| _	d S r   )
r   Úlistr*   ÚpixelÚangleÚdispÚminor_worldÚminor_pixelÚminor_angleÚ
minor_dispr   r   r   r   r   s   s    






zTicks.clearc                 C   sD   | j |  |¡ | j|  |¡ | j|  |¡ | j|  |¡ d S r   )r*   Úappendr1   r2   r3   )r   Úaxisr*   r1   r2   Zaxis_displacementr   r   r   Úadd}   s    z	Ticks.addc                 C   s   | j S r   )r4   r   r   r   r   Úget_minor_worldƒ   s    zTicks.get_minor_worldc                 C   sD   | j |  |¡ | j|  |¡ | j|  |¡ | j|  |¡ d S r   )r4   r8   r5   r6   r7   )r   Z
minor_axisr4   r5   r6   Zminor_axis_displacementr   r   r   Ú	add_minor†   s    zTicks.add_minorc                 C   s
   t | jƒS r   )Úlenr*   r   r   r   r   Ú__len__Ž   s    zTicks.__len__r
   g      ð?c                 C   sd   t tƒ| _|  ¡ sdS | |  ¡ ¡}|  || j| j|¡ | j	r`| |  
¡ ¡}|  || j| j|¡ dS )z!
        Draw the ticks.
        N)r   r0   Ú
ticks_locsZget_visibleZpoints_to_pixelsr%   Ú_draw_ticksr1   r2   r   r'   r5   r6   )r   ÚrendererÚoffsetr   r   r   Údraw“   s    
z
Ticks.drawc              
   C   sü   |   ¡ }| ¡ }| |  ¡ ¡ | |  ¡ ¡ | |  ¡ ¡ tƒ  	||¡}tƒ }|| }	|  
¡ rbdnd}
|  ¡ D ]€}||kr|qnt|| || ƒD ]^\}}| |
| ¡ | t ||g¡¡}| || j|	t|ƒ| ¡ ¡ | ¡  | j|  |¡ qŽqn| ¡  dS )z'
        Draw the minor ticks.
        g     €f@r
   N)Zget_transformZnew_gcZset_foregroundÚ	get_colorZ	set_alphaZ	get_alphaZset_linewidthZget_linewidthr   Úscaler!   r/   ÚzipZ
rotate_degZtransform_non_affineÚnpÚarrayZdraw_markersÚ_tickvert_pathr   Z
get_affiner   r?   r8   Zrestore)r   rA   Zpixel_arrayZangle_arrayrB   Z
path_transÚgcZmarker_scaleZmarker_rotationZmarker_transformZinitial_angler9   Úlocr2   Zlocsr   r   r   r@   ¢   s2    û	zTicks._draw_ticks)NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r!   r   r%   r   r'   Úpropertyr(   r   r/   r   r:   r;   r<   r>   r   rI   rC   r@   r   r   r   r   r      s,   


r   )Úcollectionsr   ÚnumpyrG   Z
matplotlibr   Zmatplotlib.linesr   r   Zmatplotlib.transformsr   r   r   r   r   r   Ú<module>   s
   