Changeset 11442:279d7a51ea1d in orange


Ignore:
Timestamp:
03/25/13 14:39:50 (13 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Fixes to canvas package documentation.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/canvas/__init__.py

    r11369 r11442  
    44====== 
    55 
    6 The :mod:`canvas` package contains classes for visualizing the 
    7 contents of a :class:`.scheme.Scheme`, based on the Qt's Graphics view 
    8 framework. 
     6The :mod:`.canvas` package contains classes for visualizing the 
     7contents of a :class:`~.scheme.Scheme`, utilizing the Qt's `Graphics View 
     8Framework`_. 
     9 
     10.. _`Graphics View Framework`: http://qt-project.org/doc/qt-4.8/graphicsview.html 
    911 
    1012""" 
  • Orange/OrangeCanvas/canvas/items/linkitem.py

    r11369 r11442  
    11""" 
     2========= 
    23Link Item 
     4========= 
    35 
    46""" 
     
    1618 
    1719class LinkCurveItem(QGraphicsPathItem): 
    18     """Link curve item. The main component of `LinkItem`. 
     20    """ 
     21    Link curve item. The main component of a :class:`LinkItem`. 
    1922    """ 
    2023    def __init__(self, parent): 
    2124        QGraphicsPathItem.__init__(self, parent) 
    22         assert(isinstance(parent, LinkItem)) 
     25        if not isinstance(parent, LinkItem): 
     26            raise TypeError("'LinkItem' expected") 
     27 
    2328        self.setAcceptedMouseButtons(Qt.NoButton) 
    2429        self.__canvasLink = parent 
     
    3944 
    4045    def linkItem(self): 
    41         """Return the :class:`LinkItem` instance this curve belongs to. 
    42  
     46        """ 
     47        Return the :class:`LinkItem` instance this curve belongs to. 
    4348        """ 
    4449        return self.__canvasLink 
     
    8388 
    8489class LinkAnchorIndicator(QGraphicsEllipseItem): 
    85     """A visual indicator of the link anchor point at both ends 
    86     of the `LinkItem`. 
     90    """ 
     91    A visual indicator of the link anchor point at both ends 
     92    of the :class:`LinkItem`. 
    8793 
    8894    """ 
     
    108114class LinkItem(QGraphicsObject): 
    109115    """ 
    110     A Link in the canvas. 
    111     """ 
    112  
     116    A Link item in the canvas that connects two :class:`.NodeItem`\s in the 
     117    canvas. 
     118 
     119    The link curve connects two `Anchor` items (see :func:`setSourceItem` 
     120    and :func:`setSinkItem`). Once the anchors are set the curve 
     121    automatically adjusts its end points whenever the anchors move. 
     122 
     123    An optional source/sink text item can be displayed above the curve's 
     124    central point (:func:`setSourceName`, :func:`setSinkName`) 
     125 
     126    """ 
     127 
     128    #: Z value of the item 
    113129    Z_VALUE = 0 
    114     """Z value of the item""" 
    115130 
    116131    def __init__(self, *args): 
     
    146161    def setSourceItem(self, item, anchor=None): 
    147162        """ 
    148         Set the source `item` (:class:`NodeItem`). Use `anchor` 
    149         (:class:`AnchorPoint`) as the curve start point (if ``None`` a new 
    150         output anchor will be created). 
     163        Set the source `item` (:class:`.NodeItem`). Use `anchor` 
     164        (:class:`.AnchorPoint`) as the curve start point (if ``None`` a new 
     165        output anchor will be created using ``item.newOutputAnchor()``). 
    151166 
    152167        Setting item to ``None`` and a valid anchor is a valid operation 
     
    196211    def setSinkItem(self, item, anchor=None): 
    197212        """ 
    198         Set the sink `item` (:class:`NodeItem`). Use `anchor` 
    199         (:class:`AnchorPoint`) as the curve end point (if ``None`` a new 
    200         input anchor will be created). 
     213        Set the sink `item` (:class:`.NodeItem`). Use `anchor` 
     214        (:class:`.AnchorPoint`) as the curve end point (if ``None`` a new 
     215        input anchor will be created using ``item.newInputAnchor()``). 
    201216 
    202217        Setting item to ``None`` and a valid anchor is a valid operation 
     
    246261    def setFont(self, font): 
    247262        """ 
    248         Set the font for the channel names text. 
     263        Set the font for the channel names text item. 
    249264        """ 
    250265        if font != self.font(): 
     
    398413    def setEnabled(self, enabled): 
    399414        """ 
     415        Reimplemented from :class:`QGraphicsObject` 
     416 
    400417        Set link enabled state. When disabled the link is rendered with a 
    401418        dashed line. 
     
    425442    def setDynamic(self, dynamic): 
    426443        """ 
    427         Mark the link as dynamic (e.i. it responds to the 
    428         ``setDynamicEnabled``). 
     444        Mark the link as dynamic (i.e. it responds to 
     445        :func:`setDynamicEnabled`). 
    429446 
    430447        """ 
  • Orange/OrangeCanvas/canvas/items/nodeitem.py

    r11440 r11442  
    11""" 
    2 NodeItem 
     2========= 
     3Node Item 
     4========= 
    35 
    46""" 
     
    272274    """ 
    273275 
    274     # Signal emitted when the item's scene position changes. 
     276    #: Signal emitted when the item's scene position changes. 
    275277    scenePositionChanged = Signal(QPointF) 
    276278 
     279    #: Signal emitted when the item's `anchorDirection` changes. 
    277280    anchorDirectionChanged = Signal(QPointF) 
    278281 
     
    692695    """ 
    693696 
    694     # Scene position of the node has changed. 
     697    #: Signal emitted when the scene position of the node has changed. 
    695698    positionChanged = Signal() 
    696699 
    697     # Geometry of the channel anchors changed 
     700    #: Signal emitted when the geometry of the channel anchors changes. 
    698701    anchorGeometryChanged = Signal() 
    699702 
    700     # The item has been activated (by a mouse double click or a keyboard). 
     703    #: Signal emitted when the item has been activated (by a mouse double 
     704    #: click or a keyboard) 
    701705    activated = Signal() 
    702706 
    703     # The item is under the mouse. 
     707    #: The item is under the mouse. 
    704708    hovered = Signal() 
    705709 
     
    852856    def setIcon(self, icon): 
    853857        """ 
    854         Set the node item's icon. 
     858        Set the node item's icon (:class:`QIcon`). 
    855859        """ 
    856860        if isinstance(icon, QIcon): 
     
    993997    def newInputAnchor(self): 
    994998        """ 
    995         Create and return a new input anchor point. 
     999        Create and return a new input :class:`AnchorPoint`. 
    9961000        """ 
    9971001        if not (self.widget_description and self.widget_description.inputs): 
     
    10191023    def newOutputAnchor(self): 
    10201024        """ 
    1021         Create a new output anchor indicator. 
     1025        Create and return a new output :class:`AnchorPoint`. 
    10221026        """ 
    10231027        if not (self.widget_description and self.widget_description.outputs): 
     
    10451049    def inputAnchors(self): 
    10461050        """ 
    1047         Return a list of input anchor points. 
     1051        Return a list of all input anchor points. 
    10481052        """ 
    10491053        return self.inputAnchorItem.anchorPoints() 
     
    10511055    def outputAnchors(self): 
    10521056        """ 
    1053         Return a list of output anchor points. 
     1057        Return a list of all output anchor points. 
    10541058        """ 
    10551059        return self.outputAnchorItem.anchorPoints() 
  • Orange/OrangeCanvas/canvas/scene.py

    r11411 r11442  
    3636class CanvasScene(QGraphicsScene): 
    3737    """ 
    38     A Graphics Scene for displaying and editing an :class:`Scheme`. 
     38    A Graphics Scene for displaying an :class:`~.scheme.Scheme` instance. 
    3939    """ 
    4040 
    41     #: An node item has been added to the scene. 
     41    #: Signal emitted when a :class:`NodeItem` has been added to the scene. 
    4242    node_item_added = Signal(items.NodeItem) 
    4343 
    44     #: An node item has been removed from the scene 
     44    #: Signal emitted when a :class:`NodeItem` has been removed from the 
     45    #: scene. 
    4546    node_item_removed = Signal(items.LinkItem) 
    4647 
    47     #: A new link item has been added to the scene 
     48    #: Signal emitted when a new :class:`LinkItem` has been added to the 
     49    #: scene. 
    4850    link_item_added = Signal(items.LinkItem) 
    4951 
    50     #: Link item has been removed 
     52    #: Signal emitted when a :class:`LinkItem` has been removed. 
    5153    link_item_removed = Signal(items.LinkItem) 
    5254 
    53     #: Annotation item has been added 
     55    #: Signal emitted when a :class:`Annotation` item has been added. 
    5456    annotation_added = Signal(items.annotationitem.Annotation) 
    5557 
    56     #: Annotation item has been removed 
     58    #: Signal emitted when a :class:`Annotation` item has been removed. 
    5759    annotation_removed = Signal(items.annotationitem.Annotation) 
    5860 
    59     #: The position of a node has changed 
     61    #: Signal emitted when the position of a :class:`NodeItem` has changed. 
    6062    node_item_position_changed = Signal(items.NodeItem, QPointF) 
    6163 
    62     #: An node item has been double clicked 
     64    #: Signal emitted when an :class:`NodeItem` has been double clicked. 
    6365    node_item_double_clicked = Signal(items.NodeItem) 
    6466 
     
    122124 
    123125    def clear_scene(self): 
     126        """ 
     127        Clear (reset) the scene. 
     128        """ 
    124129        self.scheme = None 
    125130        self.__node_items = [] 
     
    138143 
    139144    def set_scheme(self, scheme): 
    140         """Set the scheme to display and edit. Populates the scene 
    141         with nodes and links already in the scheme. 
     145        """ 
     146        Set the scheme to display. Populates the scene with nodes and links 
     147        already in the scheme. Any further change to the scheme will be 
     148        reflected in the scene. 
     149 
     150        Parameters 
     151        ---------- 
     152        scheme : :class:`~.scheme.Scheme` 
    142153 
    143154        """ 
     
    194205 
    195206    def set_registry(self, registry): 
    196         """Set the widget registry. 
    197         """ 
     207        """ 
     208        Set the widget registry. 
     209        """ 
     210        # TODO: Remove/Deprecate. Is used only to get the category/background 
     211        # color. That should be part of the SchemeNode/WidgetDescription. 
    198212        log.info("Setting registry '%s on '%s'." % (registry, self)) 
    199213        self.registry = registry 
    200214 
    201215    def set_anchor_layout(self, layout): 
     216        """ 
     217        Set an :class:`~.layout.AnchorLayout` 
     218        """ 
    202219        if self.__anchor_layout != layout: 
    203220            if self.__anchor_layout: 
     
    208225 
    209226    def anchor_layout(self): 
     227        """ 
     228        Return the anchor layout instance. 
     229        """ 
    210230        return self.__anchor_layout 
    211231 
    212232    def set_channel_names_visible(self, visible): 
     233        """ 
     234        Set the channel names visibility. 
     235        """ 
    213236        self.__channel_names_visible = visible 
    214237        for link in self.__link_items: 
     
    216239 
    217240    def channel_names_visible(self): 
     241        """ 
     242        Return the channel names visibility state. 
     243        """ 
    218244        return self.__channel_names_visible 
    219245 
    220246    def set_node_animation_enabled(self, enabled): 
     247        """ 
     248        Set node animation enabled state. 
     249        """ 
    221250        if self.__node_animation_enabled != enabled: 
    222251            self.__node_animation_enabled = enabled 
     
    226255 
    227256    def add_node_item(self, item): 
    228         """Add a :class:`NodeItem` instance to the scene. 
     257        """ 
     258        Add a :class:`.NodeItem` instance to the scene. 
    229259        """ 
    230260        if item in self.__node_items: 
     
    261291 
    262292    def add_node(self, node): 
    263         """Add and return a default constructed `NodeItem` for a 
    264         `SchemeNode` instance. If the node is already in the scene 
    265         do nothing and just return its item. 
     293        """ 
     294        Add and return a default constructed :class:`.NodeItem` for a 
     295        :class:`SchemeNode` instance `node`. If the `node` is already in 
     296        the scene do nothing and just return its item. 
    266297 
    267298        """ 
     
    290321 
    291322    def new_node_item(self, widget_desc, category_desc=None): 
    292         """Construct an new `NodeItem` from a `WidgetDescription`. 
     323        """ 
     324        Construct an new :class:`.NodeItem` from a `WidgetDescription`. 
    293325        Optionally also set `CategoryDescription`. 
    294326 
     
    313345 
    314346    def remove_node_item(self, item): 
    315         """Remove `item` (:class:`NodeItem`) from the scene. 
     347        """ 
     348        Remove `item` (:class:`.NodeItem`) from the scene. 
    316349        """ 
    317350        self.activated_mapper.removePyMappings(item) 
     
    327360 
    328361    def remove_node(self, node): 
    329         """Remove the `NodeItem` instance that was previously constructed for 
    330         a `SchemeNode` node using the `add_node` method. 
     362        """ 
     363        Remove the :class:`.NodeItem` instance that was previously 
     364        constructed for a :class:`SchemeNode` `node` using the `add_node` 
     365        method. 
    331366 
    332367        """ 
     
    341376 
    342377    def node_items(self): 
    343         """Return all :class:`NodeItem` instances in the scene. 
     378        """ 
     379        Return all :class:`.NodeItem` instances in the scene. 
    344380        """ 
    345381        return list(self.__node_items) 
    346382 
    347383    def add_link_item(self, item): 
    348         """Add a link (:class:`LinkItem`)to the scene. 
     384        """ 
     385        Add a link (:class:`.LinkItem`) to the scene. 
    349386        """ 
    350387        if item.scene() is not self: 
     
    364401 
    365402    def add_link(self, scheme_link): 
    366         """Create and add a `LinkItem` instance for a `SchemeLink` 
    367         instance. If the link is already in the scene do nothing 
    368         and just return its `LinkItem`. 
     403        """ 
     404        Create and add a :class:`.LinkItem` instance for a 
     405        :class:`SchemeLink` instance. If the link is already in the scene 
     406        do nothing and just return its :class:`.LinkItem`. 
    369407 
    370408        """ 
     
    392430    def new_link_item(self, source_item, source_channel, 
    393431                      sink_item, sink_channel): 
    394         """Construct and return a new `LinkItem` 
     432        """ 
     433        Construct and return a new :class:`.LinkItem` 
    395434        """ 
    396435        item = items.LinkItem() 
     
    420459 
    421460    def remove_link_item(self, item): 
    422         """Remove a link (:class:`LinkItem`) from the scene. 
     461        """ 
     462        Remove a link (:class:`.LinkItem`) from the scene. 
    423463        """ 
    424464        # Invalidate the anchor layout. 
     
    443483 
    444484    def remove_link(self, scheme_link): 
    445         """ Remove a `LinkItem` instance that was previously constructed for 
    446         a `SchemeLink` node using the `add_link` method. 
     485        """ 
     486        Remove a :class:`.LinkItem` instance that was previously constructed 
     487        for a :class:`SchemeLink` instance `link` using the `add_link` method. 
    447488 
    448489        """ 
     
    452493 
    453494    def link_items(self): 
    454         """Return all :class:`LinkItems` in the scene. 
    455  
     495        """ 
     496        Return all :class:`.LinkItem`\s in the scene. 
    456497        """ 
    457498        return list(self.__link_items) 
    458499 
    459500    def add_annotation_item(self, annotation): 
    460         """Add an `Annotation` item to the scene. 
    461  
     501        """ 
     502        Add an :class:`.Annotation` item to the scene. 
    462503        """ 
    463504        self.__annotation_items.append(annotation) 
     
    467508 
    468509    def add_annotation(self, scheme_annot): 
    469         """Create a new item for :class:`SchemeAnnotation` and add it 
     510        """ 
     511        Create a new item for :class:`SchemeAnnotation` and add it 
    470512        to the scene. If the `scheme_annot` is already in the scene do 
    471513        nothing and just return its item. 
     
    504546 
    505547    def remove_annotation_item(self, annotation): 
    506         """Remove an `Annotation` item from the scene. 
     548        """ 
     549        Remove an :class:`.Annotation` instance from the scene. 
    507550 
    508551        """ 
     
    512555 
    513556    def remove_annotation(self, scheme_annotation): 
     557        """ 
     558        Remove an :class:`.Annotation` instance that was previously added 
     559        using :func:`add_anotation`. 
     560 
     561        """ 
    514562        item = self.__item_for_annotation.pop(scheme_annotation) 
    515563 
     
    526574 
    527575    def annotation_items(self): 
    528         """Return all `Annotation` items in the scene. 
    529  
     576        """ 
     577        Return all :class:`.Annotation` items in the scene. 
    530578        """ 
    531579        return self.__annotation_items 
     
    540588 
    541589    def commit_scheme_node(self, node): 
    542         """Commit the `node` into the scheme. 
     590        """ 
     591        Commit the `node` into the scheme. 
    543592        """ 
    544593        if not self.editable: 
     
    553602            self.scheme.add_node(node) 
    554603        except Exception: 
    555             log.error("An unexpected error occurred while commiting node '%s'", 
     604            log.error("An error occurred while committing node '%s'", 
    556605                      node, exc_info=True) 
    557606            # Cleanup (remove the node item) 
     
    563612 
    564613    def commit_scheme_link(self, link): 
    565         """Commit a scheme link. 
     614        """ 
     615        Commit a scheme link. 
    566616        """ 
    567617        if not self.editable: 
     
    576626 
    577627    def node_for_item(self, item): 
    578         """Return the `SchemeNode` for the `item`. 
     628        """ 
     629        Return the `SchemeNode` for the `item`. 
    579630        """ 
    580631        rev = dict([(v, k) for k, v in self.__item_for_node.items()]) 
     
    582633 
    583634    def item_for_node(self, node): 
    584         """Return the :class:`NodeItem` instance for a :class:`SchemeNode`. 
     635        """ 
     636        Return the :class:`NodeItem` instance for a :class:`SchemeNode`. 
    585637        """ 
    586638        return self.__item_for_node[node] 
    587639 
    588640    def link_for_item(self, item): 
    589         """Return the `SchemeLink for `item` (:class:`LinkItem`). 
     641        """ 
     642        Return the `SchemeLink for `item` (:class:`LinkItem`). 
    590643        """ 
    591644        rev = dict([(v, k) for k, v in self.__item_for_link.items()]) 
     
    593646 
    594647    def item_for_link(self, link): 
    595         """Return the :class:`LinkItem` for a :class:`SchemeLink` 
     648        """ 
     649        Return the :class:`LinkItem` for a :class:`SchemeLink` 
    596650        """ 
    597651        return self.__item_for_link[link] 
    598652 
    599653    def selected_node_items(self): 
    600         """Return the selected :class:`NodeItem`'s. 
     654        """ 
     655        Return the selected :class:`NodeItem`'s. 
    601656        """ 
    602657        return [item for item in self.__node_items if item.isSelected()] 
    603658 
    604659    def selected_annotation_items(self): 
    605         """Return the selected :class:`Annotation`'s 
     660        """ 
     661        Return the selected :class:`Annotation`'s 
    606662        """ 
    607663        return [item for item in self.__annotation_items if item.isSelected()] 
    608664 
    609665    def node_links(self, node_item): 
    610         """Return all links from the `node_item` (:class:`NodeItem`). 
     666        """ 
     667        Return all links from the `node_item` (:class:`NodeItem`). 
    611668        """ 
    612669        return self.node_output_links(node_item) + \ 
     
    614671 
    615672    def node_output_links(self, node_item): 
    616         """Return a list of all output links from `node_item`. 
     673        """ 
     674        Return a list of all output links from `node_item`. 
    617675        """ 
    618676        return [link for link in self.__link_items 
     
    620678 
    621679    def node_input_links(self, node_item): 
    622         """Return a list of all input links for `node_item`. 
     680        """ 
     681        Return a list of all input links for `node_item`. 
    623682        """ 
    624683        return [link for link in self.__link_items 
     
    626685 
    627686    def neighbor_nodes(self, node_item): 
    628         """Return a list of `node_item`'s (class:`NodeItem`) neighbor nodes. 
     687        """ 
     688        Return a list of `node_item`'s (class:`NodeItem`) neighbor nodes. 
    629689        """ 
    630690        neighbors = map(attrgetter("sourceItem"), 
     
    811871 
    812872def grab_svg(scene): 
    813     """Return a SVG rendering of the scene contents. 
     873    """ 
     874    Return a SVG rendering of the scene contents. 
     875 
     876    Parameters 
     877    ---------- 
     878    scene : :class:`CanvasScene` 
     879 
    814880    """ 
    815881    from PyQt4.QtSvg import QSvgGenerator 
  • docs/canvas/canvas.items.nodeitem.rst

    r11369 r11442  
    1010.. autoclass:: NodeItem 
    1111   :members: 
    12    :exclude-members: from_node, from_node_meta, setupGraphics,  setProgressMessage 
     12   :exclude-members: 
     13      from_node, 
     14      from_node_meta, 
     15      setupGraphics, 
     16      setProgressMessage, 
     17      positionChanged, 
     18      anchorGeometryChanged, 
     19      activated, 
     20      hovered 
    1321   :member-order: bysource 
    1422   :show-inheritance: 
     
    1624   .. autoattribute:: positionChanged() 
    1725 
    18       Signal emitted when the scene position of the node has changes. 
    19  
    2026   .. autoattribute:: anchorGeometryChanged() 
    21  
    22       Signal emitted when the geometry of the channel anchors changes. 
    2327 
    2428   .. autoattribute:: activated() 
    2529 
    26       Signal emitted when the item has been activated (by a mouse double 
    27       click or a keyboard) 
     30 
     31.. autoclass:: AnchorPoint 
     32   :members: 
     33   :exclude-members: 
     34      scenePositionChanged, 
     35      anchorDirectionChanged 
     36   :member-order: bysource 
     37   :show-inheritance: 
     38 
     39   .. autoattribute:: scenePositionChanged(QPointF) 
     40 
     41   .. autoattribute:: anchorDirectionChanged(QPointF) 
  • docs/canvas/canvas.scene.rst

    r11369 r11442  
    4646 
    4747   .. autoattribute:: link_item_hovered(LinkItem) 
     48 
     49 
     50.. autofunction:: grab_svg 
Note: See TracChangeset for help on using the changeset viewer.