
    e                     <    d dl mZmZ ddlmZ dgZ G d de      Zy)   )QtCoreQtGui   )GraphicsObjectUIGraphicsItemc                   J    e Zd ZdZddZd Zd Zd ZddZd Z	d	 Z
d
 Zd Zy)r   aU  
    Base class for graphics items with boundaries relative to a GraphicsView or ViewBox.
    The purpose of this class is to allow the creation of GraphicsItems which live inside 
    a scalable view, but whose boundaries will always stay fixed relative to the view's boundaries.
    For example: GridItem, InfiniteLine
    
    The view can be specified on initialization or it can be automatically detected when the item is painted.
    
    NOTE: Only the item's boundingRect is affected; the item is not transformed in any way. Use viewRangeChanged
    to respond to changes in the view.
    Nc                     t        j                  | |       | j                  | j                  j                         |t        j                  dddd      | _        n|| _        d| _        | j                          y)a  
        ============== =============================================================================
        **Arguments:**
        bounds         QRectF with coordinates relative to view box. The default is QRectF(0,0,1,1),
                       which means the item will have the same bounds as the view.
        ============== =============================================================================
        N    r   )
r   __init__setFlagGraphicsItemFlagItemSendsScenePositionChangesr   QRectF_bounds_boundingRect_updateView)selfboundsparents      H/usr/lib/python3/dist-packages/pyqtgraph/graphicsItems/UIGraphicsItem.pyr   zUIGraphicsItem.__init__   sb     	f-T**HHI>!==Aq!4DL!DL!    c                      y N r   argss     r   paintzUIGraphicsItem.paint'   s     	r   c                     t        j                  | ||      }|| j                  j                  k(  r| j	                          |S r   )r   
itemChangeGraphicsItemChangeItemScenePositionHasChangedsetNewBounds)r   changevaluerets       r   r   zUIGraphicsItem.itemChange,   s;    ''fe<T,,HHH
r   c                     | j                   -| j                         }|t        j                         S || _         t        j                  | j                         S r   )r   viewRectr   r   )r   brs     r   boundingRectzUIGraphicsItem.boundingRectM   sG    %Bz}}&%'"}}T//00r   c                      y)zyCalled by ViewBox for determining the auto-range bounds.
        By default, UIGraphicsItems are excluded from autoRange.Nr   )r   axisfrac
orthoRanges       r   
dataBoundszUIGraphicsItem.dataBoundsV   s     r   c                 D    | j                          | j                          y)z7Called when the view widget/viewbox is resized/rescaledN)r"   updater   s    r   viewRangeChangedzUIGraphicsItem.viewRangeChanged[   s    r   c                 2    d| _         | j                          y)z5Update the item's bounding rect to match the viewportN)r   prepareGeometryChanger1   s    r   r"   zUIGraphicsItem.setNewBounds`   s    !""$r   c                 P    t        j                  | g|  | j                          y r   )r   setPosr"   r   s     r   r6   zUIGraphicsItem.setPosf   s!    d*T*r   c                     | j                         }| j                  |      }t        j                         }|j	                  d       |j                  |      j                  |      }| j                  |      S )z9Return the shape of this item after expanding by 2 pixelsr   )shapemapToDevicer   QPainterPathStrokersetWidhcreateStrokeunitedmapFromDevice)r   r8   dsstrokerds2s        r   
mouseShapezUIGraphicsItem.mouseShapej   sc    

e$++-""2&--b1!!#&&r   )NN)g      ?N)__name__
__module____qualname____doc__r   r   r   r)   r.   r2   r"   r6   rB   r   r   r   r   r      s5    
&
B1

%'r   N)Qtr   r   r   __all__r   r   r   r   <module>rI      s!     *
l'^ l'r   