
    e                         d dl Z d dlZd dlZd dlZ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 dd	lmZ dd
lmZ dgZ G d de      Z G d de      Zd Zd Zy)    N   )debug)	functions)getConfigOption)QtCore   )GraphicsObject)PlotCurveItem)ScatterPlotItemPlotDataItemc                   L     e Zd ZdZd fd	Zed        Zd Zd Zd Z	d Z
 xZS )	PlotDataseta  
    :orphan:
    .. warning:: This class is intended for internal use. The interface may change without warning.

    Holds collected information for a plotable dataset. 
    Numpy arrays containing x and y coordinates are available as ``dataset.x`` and ``dataset.y``.
    
    After a search has been performed, typically during a call to :func:`dataRect() <pyqtgraph.PlotDataset.dataRect>`, 
    ``dataset.containsNonfinite`` is `True` if any coordinate values are nonfinite (e.g. NaN or inf) or `False` if all 
    values are finite. If no search has been performed yet, ``dataset.containsNonfinite`` is `None`.

    For internal use in :class:`PlotDataItem <pyqtgraph.PlotDataItem>`, this class should not be instantiated when no data is available. 
    c                 P   t         |           || _        || _        || _        || _        d| _        t        |t        j                        r|j                  j                  dv rd| _        t        |t        j                        r!|j                  j                  dv rd| _        yyy)z 
        Parameters
        ----------
        x: array
            x coordinates of data points. 
        y: array
            y coordinates of data points. 
        NiuT)super__init__xy
xAllFinite
yAllFinite	_dataRect
isinstancenpndarraydtypekind)selfr   r   r   r   	__class__s        F/usr/lib/python3/dist-packages/pyqtgraph/graphicsItems/PlotDataItem.pyr   zPlotDataset.__init__   s     	$$a$)="DOa$)="DO *>$    c                 j    | j                   | j                  y | j                   xr | j                   S N)r   r   r   s    r   containsNonfinitezPlotDataset.containsNonfinite4   s.    ??"doo&=OO788r    c                 x   | j                   | j                  y| j                  | j                  | j                        \  }}| _        | j                  | j                   | j                        \  }}| _        t        j                  t        j                  ||      t        j                  ||            | _        y)z 
        Finds bounds of plotable data and stores them as ``dataset._dataRect``, 
        stores information about the presence of nonfinite data points.
            N)	r   r   _getArrayBoundsr   r   r   QRectFQPointFr   )r   xminxmaxyminymaxs        r   _updateDataRectzPlotDataset._updateDataRect;   s    
 66>TVV^&*&:&:4664??&S#dDO&*&:&:4664??&S#dDOtD(A6>>RVW[C\^r    c                    |s,t        j                  |      }|j                         }|s||   }	 t        j                  |      }t        j                  |      }|||fS # t
        $ r# t         j                  }t         j                  }Y 0w xY wr"   )r   isfiniteallminmax
ValueErrornan)r   arr
all_finite	selectionaminamaxs         r   r&   zPlotDataset._getArrayBoundsF   s{    C(I"J)n	663=D663=D T:%%  	66D66D	s   *A )B
Bc                 R    | j                   | j                          | j                   S )a4  
        Returns a bounding rectangle (as :class:`QtCore.QRectF`) for the finite subset of data.
        If there is an active mapping function, such as logarithmic scaling, then bounds represent the mapped data. 
        Will return `None` if there is no data or if all values (`x` or `y`) are NaN.
        )r   r-   r#   s    r   dataRectzPlotDataset.dataRectW   s$     >>!  "~~r    c                    |d   rt        j                         5  t        j                  dt               t	        j
                  | j                        | _        ddd       t	        j                  | j                         }|j                         r t        j                  | j                  |<   d}nd}|| _
        |d   rt        j                         5  t        j                  dt               t	        j
                  | j                        | _        ddd       t	        j                  | j                         }|j                         r t        j                  | j                  |<   d}nd}|| _        yy# 1 sw Y   xY w# 1 sw Y   qxY w)a  
        Applies a logarithmic mapping transformation (base 10) if requested for the respective axis.
        This replaces the internal data. Values of ``-inf`` resulting from zeros in the original dataset are
        replaced by ``np.nan``.
        
        Parameters
        ----------
        logmode: tuple or list of two bool
            A `True` value requests log-scale mapping for the x and y axis (in this order).
        r   ignoreNFTr   )warningscatch_warningssimplefilterRuntimeWarningr   log10r   r/   anyr4   r   r   r   )r   logMode
nonfinitesall_x_finiteall_y_finites        r   applyLogMappingzPlotDataset.applyLogMappinga   s)    1:((* *%%h?$&&)* ++tvv//J~~%'VVz"$#*DO1:((* *%%h?$&&)* ++tvv//J~~%'VVz"$#*DO * ** *s   ?E5?F5E?FNN)__name__
__module____qualname____doc__r   propertyr$   r-   r&   r;   rH   __classcell__)r   s   @r   r   r      s6    #* 9 9	_&"!+r    r   c                      e Zd ZdZ ej
                  e      Z ej
                  ee      Z ej
                  eee      Z	 ej
                  eee      Z
d Zed        Zed        Zd-dZd Zd-dZd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d.dZ#d Z$d/dZ%d Z&d Z'd0dZ(d  Z)d! Z*d" Z+d# Z,d1d$Z-d% Z.d& Z/d' Z0d( Z1d) Z2d* Z3d.d+Z4d, Z5y)2r   a  
    **Bases:** :class:`GraphicsObject <pyqtgraph.GraphicsObject>`

    :class:`PlotDataItem` provides a unified interface for displaying plot curves, scatter plots, or both.
    It also contains methods to transform or decimate the original data before it is displayed. 

    As pyqtgraph's standard plotting object, ``plot()`` methods such as :func:`pyqtgraph.plot` and
    :func:`PlotItem.plot() <pyqtgraph.PlotItem.plot>` create instances of :class:`PlotDataItem`.

    While it is possible to use :class:`PlotCurveItem <pyqtgraph.PlotCurveItem>` or
    :class:`ScatterPlotItem <pyqtgraph.ScatterPlotItem>` individually, this is recommended only
    where performance is critical and the limited functionality of these classes is sufficient.

    ==================================  ==============================================
    **Signals:**
    sigPlotChanged(self)                Emitted when the data in this item is updated.
    sigClicked(self, ev)                Emitted when the item is clicked.
    sigPointsClicked(self, points, ev)  Emitted when a plot point is clicked
                                        Sends the list of points under the mouse.
    sigPointsHovered(self, points, ev)  Emitted when a plot point is hovered over.
                                        Sends the list of points under the mouse.
    ==================================  ==============================================
    c                    t        j                  |        | j                  | j                  j                         d| _        d| _        d| _        t               | _	        t               | _        | j                  j                  |        | j                  j                  |        | j                  j                  j                  | j                         | j                  j                  j                  | j                          | j                  j"                  j                  | j$                         | j'                  dd       | j'                  dd       | j'                  dd       d| _        i dd	d
ddddddgddddddddddddddddddddddddddddt+        d      ddddd d!dd"d#dd$| _        | j/                  |j1                  d%d              | j2                  |i | y)&a&  
        There are many different ways to create a PlotDataItem.

        **Data initialization arguments:** (x,y data only)

            ========================== =========================================
            PlotDataItem(x, y)         x, y: array_like coordinate values
            PlotDataItem(y)            y values only -- x will be
                                       automatically set to ``range(len(y))``
            PlotDataItem(x=x, y=y)     x and y given by keyword arguments
            PlotDataItem(ndarray(N,2)) single numpy array with shape (N, 2),
                                       where ``x=data[:,0]`` and ``y=data[:,1]``
            ========================== =========================================

        **Data initialization arguments:** (x,y data AND may include spot style)

            ============================ ===============================================
            PlotDataItem(recarray)       numpy record array with ``dtype=[('x', float),
                                         ('y', float), ...]``
            PlotDataItem(list-of-dicts)  ``[{'x': x, 'y': y, ...},   ...]``
            PlotDataItem(dict-of-lists)  ``{'x': [...], 'y': [...],  ...}``
            ============================ ===============================================
        
        **Line style keyword arguments:**

            ============ ==============================================================================
            connect      Specifies how / whether vertexes should be connected. See below for details.
            pen          Pen to use for drawing the lines between points.
                         Default is solid grey, 1px width. Use None to disable line drawing.
                         May be a ``QPen`` or any single argument accepted by 
                         :func:`mkPen() <pyqtgraph.mkPen>`
            shadowPen    Pen for secondary line to draw behind the primary line. Disabled by default.
                         May be a ``QPen`` or any single argument accepted by 
                         :func:`mkPen() <pyqtgraph.mkPen>`
            fillLevel    If specified, the area between the curve and fillLevel is filled.
            fillOutline  (bool) If True, an outline surrounding the *fillLevel* area is drawn.
            fillBrush    Fill to use in the *fillLevel* area. May be any single argument accepted by 
                         :func:`mkBrush() <pyqtgraph.mkBrush>`
            stepMode     (str or None) If specified and not None, a stepped curve is drawn.
                         For 'left' the specified points each describe the left edge of a step.
                         For 'right', they describe the right edge. 
                         For 'center', the x coordinates specify the location of the step boundaries.
                         This mode is commonly used for histograms. Note that it requires an additional
                         x value, such that len(x) = len(y) + 1 .

            ============ ==============================================================================
        
        ``connect`` supports the following arguments:
        
        - 'all' connects all points.  
        - 'pairs' generates lines between every other point.
        - 'finite' creates a break when a nonfinite points is encountered. 
        - If an ndarray is passed, it should contain `N` int32 values of 0 or 1.
          Values of 1 indicate that the respective point will be connected to the next.
        - In the default 'auto' mode, PlotDataItem will normally use 'all', but if any
          nonfinite data points are detected, it will automatically switch to 'finite'.
          
        See :func:`arrayToQPath() <pyqtgraph.arrayToQPath>` for more details.
        
        **Point style keyword arguments:**  (see :func:`ScatterPlotItem.setData() <pyqtgraph.ScatterPlotItem.setData>` for more information)

            ============ ======================================================
            symbol       Symbol to use for drawing points, or a list of symbols
                         for each. The default is no symbol.
            symbolPen    Outline pen for drawing points, or a list of pens, one
                         per point. May be any single argument accepted by
                         :func:`mkPen() <pyqtgraph.mkPen>`.
            symbolBrush  Brush for filling points, or a list of brushes, one 
                         per point. May be any single argument accepted by
                         :func:`mkBrush() <pyqtgraph.mkBrush>`.
            symbolSize   Diameter of symbols, or list of diameters.
            pxMode       (bool) If True, then symbolSize is specified in
                         pixels. If False, then symbolSize is
                         specified in data coordinates.
            ============ ======================================================
            
        Any symbol recognized by :class:`ScatterPlotItem <pyqtgraph.ScatterPlotItem>` can be specified,
        including 'o' (circle), 's' (square), 't', 't1', 't2', 't3' (triangles of different orientation),
        'd' (diamond), '+' (plus sign), 'x' (x mark), 'p' (pentagon), 'h' (hexagon) and 'star'.
        
        Symbols can also be directly given in the form of a :class:`QtGui.QPainterPath` instance.

        **Optimization keyword arguments:**

            ================= =======================================================================
            useCache          (bool) By default, generated point graphics items are cached to
                              improve performance. Setting this to False can improve image quality
                              in certain situations.
            antialias         (bool) By default, antialiasing is disabled to improve performance.
                              Note that in some cases (in particular, when ``pxMode=True``), points
                              will be rendered antialiased even if this is set to `False`.
            downsample        (int) Reduce the number of samples displayed by the given factor.
            downsampleMethod  'subsample': Downsample by taking the first of N samples.
                              This method is fastest and least accurate.
                              'mean': Downsample by taking the mean of N samples.
                              'peak': Downsample by drawing a saw wave that follows the min
                              and max of the original data. This method produces the best
                              visual representation of the data but is slower.
            autoDownsample    (bool) If `True`, resample the data before plotting to avoid plotting
                              multiple line segments per pixel. This can improve performance when
                              viewing very high-density data, but increases the initial overhead
                              and memory usage.
            clipToView        (bool) If `True`, only data visible within the X range of the containing
                              :class:`ViewBox` is plotted. This can improve performance when plotting
                              very large data sets where only a fraction of the data is visible
                              at any time.
            dynamicRangeLimit (float or `None`) Limit off-screen y positions of data points. 
                              `None` disables the limiting. This can increase performance but may
                              cause plots to disappear at high levels of magnification.
                              The default of 1e6 limits data to approximately 1,000,000 times the 
                              :class:`ViewBox` height.
            dynamicRangeHyst  (float) Permits changes in vertical zoom up to the given hysteresis
                              factor (the default is 3.0) before the limit calculation is repeated.
            skipFiniteCheck   (bool, default `False`) Optimization flag that can speed up plotting by not 
                              checking and compensating for NaN values.  If set to `True`, and NaN 
                              values exist, unpredictable behavior will occur. The data may not be
                              displayed or the plot may take a significant performance hit.
                              
                              In the default 'auto' connect mode, `PlotDataItem` will automatically
                              override this setting.
            ================= =======================================================================

        **Meta-info keyword arguments:**

            ==========   ================================================
            name         (string) Name of item for use in the plot legend
            ==========   ================================================

        **Notes on performance:**
        
        Plotting lines with the default single-pixel width is the fastest available option. For such lines,
        translucent colors (`alpha` < 1) do not result in a significant slowdown.
        
        Wider lines increase the complexity due to the overlap of individual line segments. Translucent colors
        require merging the entire plot into a single entity before the alpha value can be applied. For plots with more
        than a few hundred points, this can result in excessive slowdown.

        Since version 0.12.4, this slowdown is automatically avoided by an algorithm that draws line segments
        separately for fully opaque lines. Setting `alpha` < 1 reverts to the previous, slower drawing method.
        
        For lines with a width of more than 4 pixels, :func:`pyqtgraph.mkPen() <pyqtgraph.mkPen>` will automatically
        create a ``QPen`` with `Qt.PenCapStyle.RoundCap` to ensure a smooth connection of line segments. This incurs a
        small performance penalty.

        NxViewRangeWasChangedFyViewRangeWasChangedstyleWasChangedT)        rU   connectautoskipFiniteCheckfftModerD   derivativeModephasemapMode	alphaHint      ?	alphaModepen)   r`   r`   	shadowPen	fillLevelfillOutline	fillBrushstepModesymbol
symbolSize
   	symbolPen)2   rj      	antialiasr   peakg      @    .A      @)symbolBrushpxModerl   	pointModeuseCache
downsampleautoDownsampledownsampleMethodautoDownsampleFactor
clipToViewdynamicRangeLimitdynamicRangeHystdata	clickable)r	   r   setFlagGraphicsItemFlagItemHasNoContents_dataset_datasetMapped_datasetDisplayr
   curver   scattersetParentItem
sigClickedrV   curveClickedscatterClicked
sigHoveredscatterHoveredsetProperty_drlLastClipr   optssetCurveClickablegetsetDatar   argskargss      r   r   zPlotDataItem.__init__   sJ   d 	%T**<<=  $##"_
&(

  &""4(

%%d&7&78''(;(;<''(;(;< 	/7/7*D1&#
v#
u#
 u#
 u~	#

 e#
 E#
 #
 #
 =#
 #
 #
 5#
 #
 #
" d##
$ "%#
& '#
( )(5# &$&!$ #E#
	H 	uyye<=d$e$r    c                 H    | j                   y | j                   j                  S r"   )r   r   r#   s    r   xDatazPlotDataItem.xDataz      == }}r    c                 H    | j                   y | j                   j                  S r"   )r   r   r#   s    r   yDatazPlotDataItem.yData  r   r    Nc                     dg}||S ||v S )NplotData )r   	interfaceintss      r   
implementszPlotDataItem.implements  s    |KD  r    c                 :    | j                   j                  dd      S )z; Returns the name that represents this item in the legend. nameN)r   r   r#   s    r   r   zPlotDataItem.name  s    yy}}VT**r    c                 <    | j                   j                  ||       y)z` ``state=True`` sets the curve to be clickable, with a tolerance margin represented by `width`. N)r   setClickable)r   statewidths      r   r   zPlotDataItem.setCurveClickable  s    

u-r    c                 .    | j                   j                  S )z5 Returns `True` if the curve is set to be clickable. )r   r|   r#   s    r   curveClickablezPlotDataItem.curveClickable  s    zz###r    c                 *    t        j                         S r"   )r   r'   r#   s    r   boundingRectzPlotDataItem.boundingRect  s    }}r    c                 r    t        j                  | ||       | j                          | j                          y r"   )r	   setPosviewTransformChangedviewRangeChanged)r   r   r   s      r   r   zPlotDataItem.setPos  s,    dAq)!!#r    c                     | j                   d   |k(  r| j                   d   |k(  ry || j                   d<   || j                   d<   | j                  |       y )Nr\   r^   )r   
setOpacity)r   alpharW   s      r   setAlphazPlotDataItem.setAlpha  sN    99[!U*tyy/E/M!&		+!%		+r    c                     | j                   d   |k(  ry|| j                   d<   d| _        d| _        | j                  d       | j	                          y)z
        ``state = True`` enables mapping the data by a fast Fourier transform.
        If the `x` values are not equidistant, the data set is resampled at
        equal intervals. 
        rY   NFstyleUpdate)r   r   r   updateItemsinformViewBoundsChangedr   r   s     r   
setFftModezPlotDataItem.setFftMode  sS     99Y5($		)##U+$$&r    c                     | j                   d   ||gk(  ry||g| j                   d<   d| _        d| _        d| _        | j	                  d       | j                          y)a  
        When log mode is enabled for the respective axis by setting ``xState`` or 
        ``yState`` to `True`, a mapping according to ``mapped = np.log10( value )``
        is applied to the data. For negative or zero values, this results in a 
        `NaN` value.
        rD   Nr   Fr   r   r   r   _adsLastValuer   r   )r   xStateyStates      r   
setLogModezPlotDataItem.setLogMode  se     99YFF#33 &/		)## U+$$&r    c                     | j                   d   |k(  ry|| j                   d<   d| _        d| _        d| _        | j	                  d       | j                          y)z
        ``state = True`` enables derivative mode, where a mapping according to
        ``y_mapped = dy / dx`` is applied, with `dx` and `dy` representing the 
        differences between adjacent `x` and `y` values.
        rZ   Nr   Fr   r   r   s     r   setDerivativeModezPlotDataItem.setDerivativeMode  s]     99%&%/&+		"### U+$$&r    c                     | j                   d   |k(  ry|| j                   d<   d| _        d| _        d| _        | j	                  d       | j                          y)z
        ``state = True`` enables phase map mode, where a mapping 
        according to ``x_mappped = y`` and ``y_mapped = dy / dx``
        is applied, plotting the numerical derivative of the data over the 
        original `y` values.
        r[   Nr   Fr   r   r   s     r   setPhasemapModezPlotDataItem.setPhasemapMode  s[     99^$-$)		.!## U+$$&r    c                 p    t        j                  |i |}|| j                  d<   | j                  d       y)z
        Sets the pen used to draw lines between points.
        The argument can be a :class:`QtGui.QPen` or any combination of arguments accepted by 
        :func:`pyqtgraph.mkPen() <pyqtgraph.mkPen>`.
        r_   Tr   NfnmkPenr   r   r   r   r   r_   s       r   setPenzPlotDataItem.setPen  s8     hh&&		%
 	T*r    c                     |r|d   d}nt        j                  |i |}|| j                  d<   | j                  d       y)a  
        Sets the shadow pen used to draw lines between points (this is for enhancing contrast or
        emphasizing data). This line is drawn behind the primary pen and should generally be assigned 
        greater width than the primary pen.
        The argument can be a :class:`QtGui.QPen` or any combination of arguments accepted by 
        :func:`pyqtgraph.mkPen() <pyqtgraph.mkPen>`.
        r   Nra   Tr   r   r   s       r   setShadowPenzPlotDataItem.setShadowPen  sH     DGOC((D*E*C!$		+ 	T*r    c                     |r|d   d}nt        j                  |i |}| j                  d   |k(  ry|| j                  d<   | j                  d       y)z 
        Sets the :class:`QtGui.QBrush` used to fill the area under the curve.
        See :func:`mkBrush() <pyqtgraph.mkBrush>`) for arguments.
        r   Nrd   Tr   r   mkBrushr   r   r   r   r   brushs       r   setFillBrushzPlotDataItem.setFillBrush  sZ    
 DGOEJJ..E99[!U*!&		+T*r    c                 &     | j                   |i |S )zB
        See :func:`~pyqtgraph.PlotDataItem.setFillBrush`
        )r   r   s      r   setBrushzPlotDataItem.setBrush  s     !t  $0%00r    c                 l    | j                   d   |k(  ry|| j                   d<   | j                  d       y)z
        Enables filling the area under the curve towards the value specified by 
        `level`. `None` disables the filling. 
        rb   NTr   r   r   )r   levels     r   setFillLevelzPlotDataItem.setFillLevel  s7    
 99[!U*!&		+T*r    c                 l    | j                   d   |k(  ry|| j                   d<   | j                  d       y)z `symbol` can be any string recognized by 
        :class:`ScatterPlotItem <pyqtgraph.ScatterPlotItem>` or a list that
        specifies a symbol for each point.
        rf   NTr   r   )r   rf   s     r   	setSymbolzPlotDataItem.setSymbol#  s7    
 99X&($		(T*r    c                     t        j                  |i |}| j                  d   |k(  ry|| j                  d<   | j                  d       y)z 
        Sets the :class:`QtGui.QPen` used to draw symbol outlines.
        See :func:`mkPen() <pyqtgraph.mkPen>`) for arguments.
        ri   NTr   r   r   s       r   setSymbolPenzPlotDataItem.setSymbolPen.  sJ    
 hh&&99[!S(!$		+T*r    c                     t        j                  |i |}| j                  d   |k(  ry|| j                  d<   | j                  d       y)z
        Sets the :class:`QtGui.QBrush` used to fill symbols.
        See :func:`mkBrush() <pyqtgraph.mkBrush>`) for arguments.
        rp   NTr   r   r   s       r   setSymbolBrushzPlotDataItem.setSymbolBrush:  sJ    
 

D*E*99]#u,#(		- T*r    c                 l    | j                   d   |k(  ry|| j                   d<   | j                  d       y)z'
        Sets the symbol size.
        rg   NTr   r   )r   sizes     r   setSymbolSizezPlotDataItem.setSymbolSizeF  s7     99\"d*"&		,T*r    c                 :   d}|#| j                   d   |k7  rd}|| j                   d<   |#| j                   d   |k7  r|| j                   d<   d}|#| j                   d   |k7  rd}|| j                   d<   |r(d| _        d| _        d| _        | j	                  d       yy)	a  
        Sets the downsampling mode of this item. Downsampling reduces the number
        of samples drawn to increase performance.

        ==============  =================================================================
        **Arguments:**
        ds              (int) Reduce visible plot samples by this factor. To disable,
                        set ds=1.
        auto            (bool) If True, automatically pick *ds* based on visible range
        mode            'subsample': Downsample by taking the first of N samples.
                        This method is fastest and least accurate.
                        'mean': Downsample by taking the mean of N samples.
                        'peak': Downsample by drawing a saw wave that follows the min
                        and max of the original data. This method produces the best
                        visual representation of the data but is slower.
        ==============  =================================================================
        FNrt   Tru   rv   r   r   )r   r   r   r   r   )r   dsrW   methodchangeds        r   setDownsamplingzPlotDataItem.setDownsamplingP  s    $ >yy&",*,		,'		*: ;t C*.DII&'Gyy+,606		,-#'D#'D #$D/	 r    c                 z    | j                   d   |k(  ry|| j                   d<   d| _        | j                  d       y)zm
        ``state=True`` enables clipping the displayed data set to the
        visible x-axis range.
        rx   NFr   r   r   r   r   s     r   setClipToViewzPlotDataItem.setClipToVieww  s?    
 99\"e+"'		,#U+r    c                     |dk  rd}|| j                   d<   || j                   d   k(  ry|| j                   d<   d| _        | j                  d       y)uB  
        Limit the off-screen positions of data points at large magnification
        This avoids errors with plots not displaying because their visibility is incorrectly determined. 
        The default setting repositions far-off points to be within ±10^6 times the viewport height.

        =============== ================================================================
        **Arguments:**
        limit           (float or None) Any data outside the range of limit * hysteresis
                        will be constrained to the limit value limit.
                        All values are relative to the viewport height.
                        'None' disables the check for a minimal increase in performance.
                        Default is 1E+06.
                        
        hysteresis      (float) Hysteresis factor that controls how much change
                        in zoom level (vertical height) is allowed before recalculating
                        Default is 3.0
        =============== ================================================================
        r]   rz   ry   NFr   r   )r   limit
hysteresiss      r   setDynamicRangeLimitz!PlotDataItem.setDynamicRangeLimit  s]    & J)3		$%DII122).		%&#U+r    c                 4    t        |      | j                  d<   y)a  
        When it is known that the plot data passed to ``PlotDataItem`` contains only finite numerical values,
        the ``skipFiniteCheck`` property can help speed up plotting. If this flag is set and the data contains 
        any non-finite values (such as `NaN` or `Inf`), unpredictable behavior will occur. The data might not
        be plotted, or there migth be significant performance impact.
        
        In the default 'auto' connect mode, ``PlotDataItem`` will apply this setting automatically.
        rX   N)boolr   )r   rX   s     r   setSkipFiniteCheckzPlotDataItem.setSkipFiniteCheck  s     )-_(=		#$r    c                     |j                  dd      du rt        j                  dt        d       d|j	                         v rt        j                  dt        d	       d
|j	                         v rt        j                  dt        d	       t        j                         }d}d}t        |      dk(  r|d   }t        |      }|dk(  rn|dk(  rt        j                  |      }n|dk(  r|dddf   }|dddf   }n|dk(  s|dk(  r;d|v rt        j                  |d         }d|v rt        j                  |d         }nt|dk(  rd|d   v r3t        j                  |D cg c]  }|j                  dd       c}      }d|d   v r3t        j                  |D cg c]  }|j                  dd       c}      }dD ]*  }	|	|v s|D cg c]  }|j                  |	d       c}||	<   , n|dk(  rO|j                  t        j                        }|j                  d      j                  t        j                        }nvt        dt        |      z        t        |      d	k(  rPd}
t        |d         t        |d         f}|d   |
vs|d   |
vr<t        dt!        t        |d               dt!        t        |d               d      t#        |d   t        j                        s5|d   dk(  r|d   j%                         }n;t        j                  |d         }n"|d   j                  t        j                        }t#        |d   t        j                        s5|d   dk(  r|d   j%                         }n;t        j                  |d         }n"|d   j                  t        j                        }d|v r#|d   }t        |      dk(  r|j%                         }d|v r#|d   }t        |      dk(  r|j%                         } |d       d|v r$|d   | j&                  d<   | j)                  dd       d |v r$|d    | j&                  d <   | j)                  dd       d!|v r|d!   | j&                  d!<   d"|vr d#|v sd$|v sd%|v r| j&                  d"   d&|d"<   d'|v r|d'   |d(<   t+        | j&                  j	                               D ]+  }	|	|v s||	   | j&                  |	<   | j)                  dd       - |t        |      dk(  rd}nnt#        |t        j                        st        j                  |      }|j                  t        j                        }|t        j,                  t        |            }|t        |      dk(  rd}nNt#        |t        j                        st        j                  |      }|j                  t        j                        }||d| _        nt1        ||      | _        d| _        d| _        d| _         |d)       | j9                  | j;                  d      *       | j)                  dd+        |d,       | j=                          | j>                  jA                  |         |d-       yc c}w c c}w c c}w ).z
        Clear any data displayed by this item and display new data.
        See :func:`__init__() <pyqtgraph.PlotDataItem.__init__>` for details; it accepts the same arguments.
        re   NTzjstepMode=True is deprecated and will result in an error after October 2022. Use stepMode="center" instead.   )
stackleveldecimatezvThe decimate keyword has been deprecated. It has no effect and may result in an error in releases after October 2022. r   	identicalzsThe identical keyword has been deprecated. It has no effect may result in an error in releases after October 2022. r   r   emptylistOfValuesNx2arrayrecarraydictOfListsr   r   listOfDicts)r{   rg   ri   rp   symbolShape	MetaArrayzInvalid data type %s)r   r   r   zQWhen passing two unnamed arguments, both must be a list or array of values. (got z, )zinterpret datar   rT   rV   rX   rf   ri   rp   rg   or   rd   zset datar   Fzupdate itemsemit)!r   r>   warnDeprecationWarningkeysr   ProfilerlendataTyper   arrayviewr   xvals	TypeErrortypestrr   asarrayr   r   listaranger   r   r   r   r   r   rN   r   sigPlotChangedr   )r   r   r   profilerr   r   r{   dtdkseqdtypr   r   s                 r   r   zPlotDataItem.setData  s%    99Z&$.MM|"q %MM I"q
 %**,&MM F"q >>#t9>7D$BW}~%HHTNz!1I1Iz!R=%8$;c+A$;c+A}$$q'>4!@a!%%D/!@AA$q'>4!@a!%%D/!@AAZ BADy<@#AqAEE!TN#AaB {"IIbjj)JJqM&&rzz2 6d CDDY!^8CDG$htAw&77DAwc!T!WC%7  B  CG  HL  MN  HO  CP  Q  SV  W[  \`  ab  \c  Wd  Se  !f  g  gd1grzz27k)Q)Aa)AGLL,d1grzz27k)Q)Aa)AGLL,%<c
A{k)IIK%<c
A{k)IIK!" U? %fDIIf.5#(#3DIIi .5%+01B+CDII'( 5 kU&:mu>TXdhmXmyy"*"%he!&wE+diinn&' 	:AEz$Qx		!  !2D9	:  9A!Ea,HHQKFF2::&EyIIc!f%9A	Ea,HHQKFF2::&E=EM DM'7DM## 6G(HJ*E2 $$&  &g "A!@ $Bs   $ZZZc                    d}i }i }|rVdD ]&  \  }}|| j                   v s| j                   |   ||<   ( dD ]&  \  }}|| j                   v s| j                   |   ||<   ( | j                         }|5| j                  j                          | j                  j                          y |j
                  }|j                  }| j                   d   | j                   d   | j                   d   xt        |d   t              r+|d   dk(  r#|j                  d	u rd
|d<   d|d<   n
d|d<   d	|d<    | j                  j                  d||d| | j                  j                          n| j                  j                          | j                   d   f| j                   j                  dd	      dv rd|d d |dd  z   z  } | j                  j                  d||d| | j                  j                          y | j                  j                          y )NT)	)r_   r_   )ra   ra   )rb   rb   )rc   rc   )rd   r   rl   rl   )rV   rV   )re   re   )rX   rX   ))ri   r_   )rp   r   )rf   rf   )rg   r   )r{   r{   )rq   rq   r  )rs   rs   r_   rd   rb   rV   rW   Fr0   rX   finite)r   r   rf   re   )centerTg      ?r   r   )r   _getDisplayDatasetr   hider   r   r   r   r	  r$   r   showr   )	r   r   	curveArgsscatterArgsr  vdatasetr   r   s	            r   r   zPlotDataItem.updateItemsJ  s    	
 01 		>#'99Q<IaL0	 21 		>%)YYq\KN2 ))+?JJOOLLIIII IIe(		+&2tyy7M7Y )I.499MQW9W,,5+0Ii(37I/0 ,4Ii(38I/0DJJ5a595JJOOJJOO99X*yy}}Z/3CC1Sb6AabE>* DLL  919[9LLLLr    c                 P    | j                   }|y|j                  |j                  fS )z^
            Returns the original, unmapped data as the tuple (`xData`, `yData`).
            rI   )r   r   r   r   r  s     r   getOriginalDatasetzPlotDataItem.getOriginalDataset  s(     mmG#99gii''r    c           	      R   | j                   y| j                  l| j                  d      r| j                  d   sL| j                  d      r| j                  d   s,| j                  d      r| j                  d   | j                  S | j                  | j                   j
                  }| j                   j                  }|j                  t        k(  r|j                  t        j                        }|j                  t        k(  r|j                  t        j                        }| j                  d   r1| j                  ||      \  }}| j                  d   d	   r
|d
d }|d
d }| j                  d   rXt        j                  | j                   j                        t        j                  | j                   j
                        z  }|dd }| j                  d   rl| j                   j                  dd }t        j                  | j                   j                        t        j                  | j                   j
                        z  }t        ||| j                   j                  | j                   j                         }d| j                  d   v r|j#                  | j                  d          || _        | j                  j
                  }| j                  j                  }| j                  j                  }| j                  j                   }| j%                         }|d}n|j'                         }|| j'                         }| j                  d   }t)        |t*              sd
}| j                  d   r|r|}	n|t        j,                  |         }	|t/        |	      d
kD  rt1        |	d   |	d	   z
        t/        |	      d
z
  z  }
|
dk7  r|| j%                         j3                         }|dk7  rYt5        dt7        |j3                         |
z  || j                  d   z  z              }t9        j,                  |      rt+        |      }t9        j:                  || j<                  d      r| j<                  }|| _        | j                  d   r||j?                         d	   rn|t/        |      d
kD  rtA        jB                  ||jE                               |z
  }tG        jH                  |d	t/        |            }tA        jB                  ||jK                               |z   }tG        jH                  ||t/        |            }||| }||| }|d
kD  rg| j                  d   dk(  r|dd|   }|dd|   }nC| j                  d   dk(  rJt/        |      |z  }|dz  }|||||z  z   |   }|d||z   jM                  ||      jO                  d
      }n| j                  d   dk(  rt/        |      |z  }t        jP                  |df      }|dz  }|||||z  z   |t        jR                  f   |dd |jM                  |dz        }t        jP                  |df      }|d||z   jM                  ||f      }|j5                  d
      |ddd	f<   |jU                  d
      |ddd
f<   |jM                  |dz        }| j                  d   || j                  jW                         }||jY                         }| j                  d   }| j                  d   }|d	kD  rQ|j[                         |j]                         k  s/|j]                         |j[                         kD  s|jY                         d|z  |z  |z  kD  rd}| j                  | j^                  d	   |j[                         z
   |z  }| j^                  d
   |j]                         z
  |z  }|||z  k\  rF|||z  k  r>|||z  k\  r6|||z  k  r.| j                  j
                  }| j                  j                  }d}|sL|j[                         ||z  z
  }|j]                         ||z  z   }tG        j`                  |||      }||f| _/        t        ||||      | _        | jc                  dd       | jc                  dd       | j                  S )z
        Returns a :class:`~.PlotDataset` object that contains data suitable for display 
        (after mapping and data reduction) as ``dataset.x`` and ``dataset.y``.
        Intended for internal use.
        NrR   rx   ru   rS   ry   rY   rD   r   r   rZ   r  r[   Trt   rU   r]   rw   g{Gz?)rel_tolrv   	subsamplemeanr   )axisrm   rz   F)2r   r   rN   r   r   r   r   r   r   astyper   uint8_fourierTransformdiffr   r   r   rH   
getViewBoxviewRectr   intr/   r  floatr   r2   absmathiscloser   autoRangeEnabledbisectbisect_leftleftr   clip_scalarrightreshaper&  r   newaxisr1   r;   heightbottomtopr   
clip_arrayr   )r   r   r   r  r   r   r  
view_ranger   finite_xdxr   ds_floatx0x1nstxy1y2
data_rangeview_heightr   hystcache_is_goodtop_excbot_excmin_valmax_vals                               r   r  zPlotDataItem._getDisplayDataset  s    ==   ,56499\;R56499EU;V56499EX;Y;e''' &AAww$HHRXX&ww$HHRXX&yy#,,Q2!99Y'*eAeAyy)*GGDMMOO,RWWT]]__-EEcrFyy(MMOOCR(GGDMMOO,RWWT]]__-EE!!Q(@(@$--BZBZ[Gtyy++''9)=?")D !!!!((33
((33
 <JJJYY|$"c"B99%&  R[[^,%#h-!*;8B<34HaH9 OO-335E|#&sC
0@0@0BR0G5SWS\S\]sStKt0u,v#w==2!$XB
 ||B 2 2DA''!#D99\"|t446q9 )c!fqj  ++Az/@ABFBAs1v6B  ++Az/?/?/ABRGBBA7B "RA"RA6yy+,;ddGddG-.&8FbL!ec#ad(2o&eqtH$$Qr*//Q/7-.&8FbLXXqe_!e#c!B$hr/"**451JJqsOXXqe_u"X%%q"g.&&a&.1Q3&&a&.1Q3JJqsO99()5%!0099;
)","3"3"5K II&9:E II&89D $a * 1 1 3jnn6F F * 0:3D3D3F F&--/!d(U2B[2PP(-//;'+'8'8';J<M<M<O'O%PS^%^G'+'8'8';JNN<L'LS^&^G$+ut|$;5SW<@W$+ut|$;5SW<@W$($8$8$:$:$($8$8$:$:04,&0&7&7&9EK<O&OG&0nn&6EK<O&OG !#a' BA18'0BD-*1aZH/7/7###r    c                 X    | j                         }|y|j                  |j                  fS )zn
        Returns the displayed data as the tuple (`xData`, `yData`) after mapping and data reduction.
        rI   )r  r   r   r!  s     r   getDatazPlotDataItem.getDataM  s-     ))+?yy'))##r    c                 P    | j                   y| j                   j                         S )z
        Returns a bounding rectangle (as :class:`QtCore.QRectF`) for the full set of data.
        Will return `None` if there is no data or if all values (x or y) are NaN.
        N)r   r;   r#   s    r   r;   zPlotDataItem.dataRectW  s$    
 == }}%%''r    c                    ddg}| j                   j                         r| j                   j                  |||      }|S | j                  j                         ri| j                  j                  |||      }|d   |d   n|d   |d   nt	        |d   |d         |d   |d   n|d   |d   nt	        |d   |d         g}|S )ab  
        Returns the range occupied by the data (along a specific axis) in this item.
        This method is called by :class:`ViewBox` when auto-scaling.

        =============== ====================================================================
        **Arguments:**
        ax              (0 or 1) the axis for which to return this item's data range
        frac            (float 0.0-1.0) Specifies what fraction of the total data
                        range to return. By default, the entire range is returned.
                        This allows the :class:`ViewBox` to ignore large spikes in the data
                        when auto-scaling.
        orthoRange      ([min,max] or None) Specifies that only the data within the
                        given range (orthogonal to *ax*) should me measured when
                        returning the data range. (For example, a ViewBox might ask
                        what is the y-range of all data with x-values between min
                        and max)
        =============== ====================================================================
        Nr   r   )r   	isVisible
dataBoundsr   r1   )r   axfrac
orthoRangeranger2s         r   rV  zPlotDataItem.dataBounds`  s    & t::!JJ))"dJ?E  \\##%((T:>Bq)1BqEMasSUVWSXZ_`aZbOcq)1BqEMasSUVWSXZ_`aZbOcE r    c                    d}| j                   j                         r&t        || j                   j                               }|S | j                  j                         r$t        || j                  j                               }|S )z
        Returns the size in pixels that this item may draw beyond the values returned by dataBounds().
        This method is called by :class:`ViewBox` when auto-scaling.
        r   )r   rU  r2   pixelPaddingr   )r   pads     r   r]  zPlotDataItem.pixelPadding~  si    
 ::!c4::2245C 
 \\##%c4<<4467C
r    c                     d | _         d | _        d | _        | j                  j	                          | j
                  j	                          y r"   )r   r   r   r   clearr   r#   s    r   r`  zPlotDataItem.clear  s9    ###

r    c                      y r"   r   r   s      r   
appendDatazPlotDataItem.appendData  s    r    c                 <    | j                   j                  | |       y r"   )r   r   )r   r   evs      r   r   zPlotDataItem.curveClicked  s    T2&r    c                 v    | j                   j                  | |       | j                  j                  | ||       y r"   )r   r   sigPointsClickedr   pltpointsrd  s       r   r   zPlotDataItem.scatterClicked  s.    T2&""44r    c                 >    | j                   j                  | ||       y r"   )sigPointsHoveredr   rg  s       r   r   zPlotDataItem.scatterHovered  s    ""44r    c                    d}||d   r9| j                  dd       | j                  d   s| j                  d   r	d | _        d}||d   r#| j                  dd       | j                  d	   d}|r| j                  d
       y y )NFr   rR   Trx   ru   r   rS   ry   r   )r   r   r   r   )r   vbrangesr   update_neededs        r   r   zPlotDataItem.viewRangeChanged  s    ?gaj 3T:		,'99-.'+$ $?gaj 3T:yy,-9 $/ r    c                 D   t        j                  |      }t        j                  t        j                  ||d   z
        t        |d         dz  kD         }|s?t        j                  |d   |d   t        |            }t        j                  |||      }|}|j                  }t         j                  j                  |      |z  }t        |d   |d   z
        t        |      dz
  z  }t         j                  j                  ||      }t        j                  |      }||fS )Nr   g     @@r  r   )r   r+  rC   r0  linspacer  interpr   fftrfftr/  rfftfreq)	r   r   r   rA  uniformx2rE  fr  s	            r   r*  zPlotDataItem._fourierTransform  s     WWQZffRVVBr!uH-RUe1CDEEQqT1R5#a&1B		"a#AAFFFFKKNQ!B%!*Q*FFOOAq!FF1I!tr    r"   )NNN)rn   ro   )T)r]   N)6rJ   rK   rL   rM   r   Signalobjectr  r   rf  rk  r   rN   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r"  r  rR  r;   rV  r]  r`  rb  r   r   r   r   r*  r   r    r   r   r      sN   0 #V]]6*Nvv.J$v}}VVV<$v}}VVV<S%l    !+.$ '' '' ++$+1+	+
+
++%0N	,,<	>]~K Z(k$Z$(<
'550,r    c                    t        | d      rt        |       dk(  ryt        | t              ryt	        |       r| d   }t        | d      r| j                  d      ryt        | t        j                        r| j                  dk(  r| j                  j                  yy	| j                  d
k(  r)| j                  j                  | j                  d   d
k(  ryt        dt        | j                        z        t        |t              ryyy )N__len__r   r   r   r   r   r   r   r   r   r   z1array shape must be (N,) or (N,2); got %s insteadr   )hasattrr  r   dict
isSequencer   r   r   ndimr   namesshaper3   r	  )objfirsts     r   r  r    s    sI3s8q=#t	CAC&3>>++FRZZ(xx1}99??*)%Q399??#:syy|q?P! !TWZ[^[d[dWe!efft$ !% 
r    c                     t        | d      xs; t        | t        j                        xs t        | d      xr | j	                  d      S )N__iter__r   r   )r}  r   r   r   r   )r  s    r   r  r    sS    3
#  Cz#rzz'B  CwsT`Ga  HBfiftft  vA  gB  Cr    )r1  r>   r4  numpyr    r   r   r   r   Qtr   r	   r
   r   __all__rz  r   r   r  r  r   r    r   <module>r     sW            * ( ,
q+& q+fE> EP""4Cr    