U
    Ñtœd  ã                   @   sL   d Z ddlmZ ddlmZ ddlmZ G dd„ deƒZG dd„ deƒZd	S )
z2
Coordinate systems and related plotting routines
é    )Úabstractmethod)ÚAbstractCairoDrawer)ÚBoundingBoxc                   @   s(   e Zd ZdZedd„ ƒZedd„ ƒZdS )ÚCoordinateSystemav  Class implementing a coordinate system object.

    Coordinate system objects are used when drawing plots which
    2D or 3D coordinate system axes. This is an abstract class
    which must be extended in order to use it. In general, you'll
    only need the documentation of this class if you intend to
    implement an own coordinate system not present in igraph yet.
    c                 C   s   t ‚dS )zaDraws the coordinate system.

        This method must be overridden in derived classes.
        N©ÚNotImplementedError©Úself© r
   úS/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/igraph/drawing/cairo/coord.pyÚdraw   s    zCoordinateSystem.drawc                 C   s   t ‚dS )zœConverts local coordinates to the context coordinate system (given
        by the bounding box).

        This method must be overridden in derived classes.Nr   ©r	   ÚxÚyr
   r
   r   Úlocal_to_context   s    z!CoordinateSystem.local_to_contextN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r
   r
   r
   r   r      s
   	
r   c                       sl   e Zd ZdZ‡ fdd„Zedd„ ƒZejdd„ ƒZedd„ ƒZejd	d„ ƒZd
d„ Z	dd„ Z
dd„ Z‡  ZS )ÚDescartesCoordinateSystemz;Class implementing a 2D Descartes coordinate system object.c                    sJ   d\| _ | _d\| _| _d\| _| _| _| _tƒ  	||¡ || _
|| _dS )a)  Initializes the coordinate system.

        @param context: the context on which the coordinate system will
          be drawn.
        @param bbox: the bounding box that will contain the coordinate
          system.
        @param bounds: minimum and maximum X and Y values in a 4-tuple.
        )NN)NNNNN)Ú_boundsÚ_bboxÚ_sxÚ_syÚ_oxÚ_oyÚ_ox2Ú_oy2ÚsuperÚ__init__ÚbboxÚbounds)r	   Úcontextr    r!   ©Ú	__class__r
   r   r   +   s    	z"DescartesCoordinateSystem.__init__c                 C   s   t | jjƒS )z1Returns the bounding box of the coordinate system)r   r   Úcoordsr   r
   r
   r   r    =   s    zDescartesCoordinateSystem.bboxc                 C   s   || _ |  ¡  dS )z.Sets the bounding box of the coordinate systemN)r   Ú_recalc_scale_factors)r	   r    r
   r
   r   r    B   s    c                 C   s   | j jS )z8Returns the lower and upper bounds of the X and Y values)r   r%   r   r
   r
   r   r!   H   s    z DescartesCoordinateSystem.boundsc                 C   s   t |ƒ| _|  ¡  dS )z5Sets the lower and upper bounds of the X and Y valuesN)r   r   r&   )r	   r!   r
   r
   r   r!   M   s    
c                 C   s^   | j dkrdS | jj| j j | _| jj| j j | _| j j| _| j j| _	| jj| _
| jj| _dS )z<Recalculates some cached scale factors used within the classN)r   r   Úwidthr   Úheightr   Úleftr   Útopr   r   Úbottomr   r   r
   r
   r   r&   S   s    



z/DescartesCoordinateSystem._recalc_scale_factorsc                 C   sd   | j j}| j ddd¡ | j d¡ | j |d |d |d |d  |d |d  ¡ | j ¡  dS )zDraws the coordinate system.g        é   r   é   é   N)r    r%   r"   Zset_source_rgbZset_line_widthZ	rectangleÚstroke)r	   r%   r
   r
   r   r   ^   s       ÿzDescartesCoordinateSystem.drawc                 C   s,   || j  | j | j | j|| j | j  fS )ziConverts local coordinates to the context coordinate system (given
        by the bounding box).
        )r   r   r   r   r   r   r   r
   r
   r   r   i   s    þz*DescartesCoordinateSystem.local_to_context)r   r   r   r   r   Úpropertyr    Úsetterr!   r&   r   r   Ú__classcell__r
   r
   r#   r   r   (   s   



r   N)	r   Úabcr   Zigraph.drawing.cairo.baser   Zigraph.drawing.utilsr   r   r   r
   r
   r
   r   Ú<module>   s
   