
    e$                     \    d dl mZ ddlmZ ddlmZmZ dgZ G d dej                        Z
y)    )hypot   )	functions)QtGui	QtWidgets	ArrowItemc                   D     e Zd ZdZddZd Z fdZd ZddZd Z	 xZ
S )	r   zv
    For displaying scale-invariant arrows.
    For arrows pointing to a location on a curve, see CurveArrow
    
    c                 $   i | _         t        j                  j                  | |       d|v r|d   |d<   d|v r|d   |d<   |j	                  dd      }ddd	d
ddd
dddd
}|j                  |        | j                  di |  | j                  |  y
)zr
        Arrows can be initialized with any keyword arguments accepted by 
        the setStyle() method.
        sizeheadLenwidth	headWidthpos)r   r   Tij   N   r      )   r   r   )2   r   r   )
pxModeangler   r   tipAngle	baseAngletailLen	tailWidthpenbrush )optsr   QGraphicsPathItem__init__popupdatesetStylesetPos)selfparentr   r   defaultOptss        C/usr/lib/python3/dist-packages/pyqtgraph/graphicsItems/ArrowItem.pyr    zArrowItem.__init__   s    
 	##,,T6:T>"6lDOd? $WDhhuf%   
 	4 $$ 	S    c                    g d}g d|z   }d}|j                         D ]F  \  }}||vrt        d|z        | j                  j                  |      |k7  rd}|| j                  |<   H |syt	        |D cg c]"  }|| j                  v s|| j                  |   f$ c}      }t        j                         }|j                  | j                  d          |j                  t        j                  di |      | _        | j                  | j                         | j                  t        j                  | j                  d                | j                  t        j                   | j                  d	                | j                  d
   r7| j#                  | j%                         | j&                  j(                  z         y| j#                  | j%                         | j&                  j(                   z         yc c}w )a  
        Changes the appearance of the arrow.
        All arguments are optional:
        
        ======================  =================================================
        **Keyword Arguments:**
        angle                   Orientation of the arrow in degrees. Default is
                                0; arrow pointing to the left.
        headLen                 Length of the arrow head, from tip to base.
                                default=20
        headWidth               Width of the arrow head at its base. If
                                headWidth is specified, it overrides tipAngle.
        tipAngle                Angle of the tip of the arrow in degrees. Smaller
                                values make a 'sharper' arrow. default=25
        baseAngle               Angle of the base of the arrow head. Default is
                                0, which means that the base of the arrow head
                                is perpendicular to the arrow tail.
        tailLen                 Length of the arrow tail, measured from the base
                                of the arrow head to the end of the tail. If
                                this value is None, no tail will be drawn.
                                default=None
        tailWidth               Width of the tail. default=3
        pen                     The pen used to draw the outline of the arrow.
        brush                   The brush used to fill the arrow.
        pxMode                  If True, then the arrow is drawn as a fixed size
                                regardless of the scale of its parents (including
                                the ViewBox zoom level). 
        ======================  =================================================
        )r   r   r   r   r   r   )r   r   r   r   FzInvalid arrow style option "%s"TNr   r   r   r   r   )itemsKeyErrorr   getdictr   
QTransformrotatemapfnmakeArrowPathpathsetPathsetPenmkPensetBrushmkBrushsetFlagsflagsGraphicsItemFlagItemIgnoresTransformations)	r%   r   	arrowOptsallowedOpts
needUpdatekvopttrs	            r(   r#   zArrowItem.setStyle1   s   < ^	9IE
::< 	CAa#@1DEEyy}}Q1$!
DIIaL	 iJ1		>Qtyy|$JK
		$))G$%FF2++2c23	TYYBHHTYYu-./bjj7!34599XMM$**,)>)>)Y)YYZMM$**,$*?*?*Z*Z)ZZ[ Ks   3G7G7c                     |j                  t        j                  j                  j                         t        |   |g|  y N)setRenderHintr   QPainter
RenderHintAntialiasingsuperpaint)r%   pargs	__class__s      r(   rL   zArrowItem.paintk   s0    	11>>?a$r)   c                     | j                   S rF   )r4   )r%   s    r(   shapezArrowItem.shapes   s     yyr)   c                 T   d}| j                         }|j                         s|j                         dz  }| j                  d   rddgS | j	                         }|dk(  r&|j                         |z
  |j                         |z   gS |j                         |z
  |j                         |z   gS )Nr   ea?r   )	r   
isCosmeticr   r   boundingRectleftrighttopbottom)r%   axfrac
orthoRangepwr   brs          r(   
dataBoundszArrowItem.dataBoundsz   s    hhj~~v%B99Xa5L""$BQw	"bhhjm44RYY[^44r)   c                    d}| j                   d   r;| j                         }|t        |j                         |j	                               z  }| j                         }|j                         r |t        d|j                               dz  z  }|S )Nr   r      rS   )r   rU   r   r   heightr   rT   max)r%   padr^   r   s       r(   pixelPaddingzArrowItem.pixelPadding   st    99X""$B5RYY[11Chhj>>3q#))+&//C
r)   rF   )__name__
__module____qualname____doc__r    r#   rL   rQ   r_   re   __classcell__)rO   s   @r(   r   r      s)    B8\t 5r)   N)mathr    r   r2   Qtr   r   __all__r   r   r   r)   r(   <module>ro      s)      !-H	++ Hr)   