Changeset 8720:d4a49f02c554 in orange


Ignore:
Timestamp:
08/16/11 11:53:51 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
5ab56f77d094b1539acf3118d91e0c6b3ef0fc9b
Message:

Expand OWCurve documentation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/plot/owcurve.py

    r8670 r8720  
    44############################## 
    55 
    6 .. class:: orangeqt.PlotItem 
     6.. class:: OWPlotItem 
    77 
    88    This class represents a base for any item than can be added to a plot.  
     
    8585        Returns if item is in the background, set with :meth:`set_in_background`.  
    8686         
     87    **Subclassing** 
     88     
     89        Often you will want to create a custom curve class that inherits from OWCurve.  
     90        For this purpose, OWPlotItem provides two virtual methods: :meth:`paint` and :meth:`update_properties`.  
     91         
     92        * ``update_properties()`` is called whenever a curve or the plot is changed and needs to be updated.  
     93          In this method, child items and other members should be recalculated and updated.  
     94          The OWCurve even provides a number of methods for asynchronous (threaded) updating.  
     95           
     96        * `paint()` is called whenever the item needs to be painted on the scene.  
     97          This method is called more often, so it's advisable to avoid long operation in the method.  
     98           
     99        Most provided plot items, including :obj:`OWCurve`, :obj:`OWMultiCurve` and utility curves in :mod:`.owtools` 
     100        only reimplement the first method, because they are optimized for performance with large data sets.  
     101         
    87102.. autoclass:: OWCurve 
    88     :members: 
    89     :show-inheritance: 
     103     
     104.. class:: OWMultiCurve 
     105 
     106    A multi-curve is a curve in which each point can have its own properties.  
     107    The point coordinates can be set by calling :meth:`.OWCurve.set_data`, just like in a normal curve.  
     108     
     109    In addition, OWMultiCurve provides methods for setting properties for individual points.  
     110    Each of this methods take a list as a parameter. If the list has less elements that the curve's data,  
     111    the first element is used for all points.  
     112     
     113    .. method:: set_point_colors(lst) 
     114         
     115        :param lst: The list of colors to assign to points 
     116        :type lst: list of QColor 
     117         
     118        .. seealso:: :meth:`.OWPoint.set_color` 
     119         
     120    .. method:: set_point_sizes(lst) 
     121         
     122        :param lst: The list of sizes to assign to points 
     123        :type lst: list of int 
     124         
     125        .. seealso:: :meth:`.OWPoint.set_size` 
     126     
     127    .. method:: set_point_symbols(lst) 
     128         
     129        :param lst: The list of symbols to assign to points 
     130        :type lst: list of int 
     131         
     132        .. seealso:: :meth:`.OWPoint.set_symbol` 
     133     
    90134''' 
    91135 
     
    94138import orangeqt 
    95139from Orange.misc import deprecated_members 
     140 
     141OWPlotItem = orangeqt.PlotItem 
    96142 
    97143@deprecated_members({ 
     
    101147class OWCurve(orangeqt.Curve): 
    102148    """  
    103         This class represents a curve on a plot. 
    104          
    105        :param xData: list of x coordinates 
    106        :type xData: list of float 
    107         
    108        :param yData: list of y coordinates 
    109        :type yData: list of float 
    110         
    111        :param x_axis_key: The x axis of this curve 
    112        :type x_axis_key: int 
    113         
    114        :param y_axis_key: The y axis of this curve 
    115        :type y_axis_key: int 
    116         
    117        :param tooltip: The curve's tooltip 
    118        :type tooltip: str 
    119          
     149        This class represents a curve on a plot.  
     150        It is essentially a plot item with a series of data points or a continuous line.  
     151         
     152        :param xData: list of x coordinates 
     153        :type xData: list of float 
     154         
     155        :param yData: list of y coordinates 
     156        :type yData: list of float 
     157         
     158        :param x_axis_key: The x axis of this curve 
     159        :type x_axis_key: int 
     160         
     161        :param y_axis_key: The y axis of this curve 
     162        :type y_axis_key: int 
     163         
     164        :param tooltip: The curve's tooltip 
     165        :type tooltip: str 
     166         
     167        .. note:: 
     168             
     169            All the points or line segments in an OWCurve have the same properties.  
     170            Different points in one curve are supported by the :obj:`.OWMultiCurve` class.  
     171         
     172             
    120173        .. method:: point_item(x, y, size=0, parent=None) 
    121174         
     
    129182            :type y: float 
    130183             
    131             :param size: If nonzero, this argument determines the size of the resulting point. Otherwise, the point is created with the curve's :meth:`OWCurve.point_size` 
     184            :param size: If nonzero, this argument determines the size of the resulting point.  
     185                         Otherwise, the point is created with the curve's :meth:`OWCurve.point_size` 
    132186            :type size: int 
    133187                          
     
    147201            :returns: The curve's data as a list of data points. 
    148202            :rtype: list of tuple of float float 
     203             
     204        .. method:: set_style(style) 
     205         
     206            Sets the curve's style to ``style``.  
     207             
     208            The curve's style specified how its lines are drawn. If the style is OWCurve.Lines, then  
     209            data points are connected with a continuous line with the curve's :meth:`pen`. Otherwise,  
     210            no such lines are drawn.  
     211             
     212            Points are drawn regardless of this setting, so it's possible to have both lines and points 
     213            on the same curve.  
     214             
     215            Curve subclasses can use this value for different drawing modes.  
     216            Values up to OWCurve.UserCurve are reserved, so use only higher numbers, like the following example:: 
     217             
     218                class MyCurve(OWCurve): 
     219                    PonyStyle = OWCurve.UserCurve + 42 
     220                     
     221                    def draw_ponies() 
     222                        # Draw type-specific things here 
     223                     
     224                    def update_properties(self): 
     225                        if self.style() == PonyStyle: 
     226                            self.draw_ponies() 
     227                        else: 
     228                            OWCurve.update_properties(self) 
     229             
     230        .. method:: style() 
     231         
     232            :return: The curve's style, set with :meth:`set_style` 
     233            :rtype: int 
     234             
     235        .. method:: cancel_all_updates() 
     236         
     237            Cancel all pending threaded updates and block until they are finished.  
     238            This is usually called before starting a new round of updates. 
     239             
     240        .. method:: update_number_of_items() 
     241         
     242            Resizes the point list so that it matches the number of data points in :meth:`data` 
     243             
     244        .. method:: update_point_coordinates() 
     245         
     246            Sets the coordinates of each point to match :meth:`data`.  
     247             
     248        .. method:: update_point_positions() 
     249         
     250            Sets the scene positions of the points to match their data coordinates.  
    149251    """ 
    150252    def __init__(self, xData=[], yData=[], x_axis_key=xBottom, y_axis_key=yLeft, tooltip=None): 
Note: See TracChangeset for help on using the changeset viewer.