Ignore:
Files:
11 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/annotationitem.py

    r11401 r11444  
    6262        return unicode(self.__placeholderText) 
    6363 
    64     placeholderText_ = Property(unicode, placeholderText, setPlaceholderText) 
     64    placeholderText_ = Property(unicode, placeholderText, setPlaceholderText, 
     65                                doc="Placeholder text") 
    6566 
    6667    def paint(self, painter, option, widget=None): 
     
    7374                     self.textInteractionFlags() & Qt.TextEditable): 
    7475            brect = self.boundingRect() 
     76            painter.setFont(self.font()) 
    7577            metrics = painter.fontMetrics() 
    7678            text = metrics.elidedText(self.__placeholderText, Qt.ElideRight, 
  • 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

    r11411 r11442  
    11""" 
    2 NodeItem 
     2========= 
     3Node Item 
     4========= 
    35 
    46""" 
     
    5254    Create and return a default palette for a node. 
    5355    """ 
    54     return create_palette(QColor(NAMED_COLORS["light-orange"]), 
    55                           QColor(NAMED_COLORS["orange"])) 
     56    return create_palette(QColor(NAMED_COLORS["light-yellow"]), 
     57                          QColor(NAMED_COLORS["yellow"])) 
    5658 
    5759 
     
    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 
  • Orange/OrangeCanvas/document/interactions.py

    r11401 r11443  
    11""" 
    2 User interaction handlers for CanvasScene. 
     2========================= 
     3User Interaction Handlers 
     4========================= 
     5 
     6User interaction handlers for a :class:`~.SchemeEditWidget`. 
     7 
     8User interactions encapsulate the logic of user interactions with the 
     9scheme document. 
     10 
     11All interactions are subclasses of :class:`UserInteraction`. 
     12 
    313 
    414""" 
     15 
    516import logging 
    617 
     
    2637 
    2738class UserInteraction(QObject): 
    28     # cancel reason flags 
    29     NoReason = 0  # No specified reason 
    30     UserCancelReason = 1  # User canceled the operation (e.g. pressing ESC) 
    31     InteractionOverrideReason = 3  # Another interaction was set 
    32     ErrorReason = 4  # An internal error occurred 
     39    """ 
     40    Base class for user interaction handlers. 
     41 
     42    Parameters 
     43    ---------- 
     44    document : :class:`~.SchemeEditWidget` 
     45        An scheme editor instance with which the user is interacting. 
     46    parent : :class:`QObject`, optional 
     47        A parent QObject 
     48    deleteOnEnd : bool, optional 
     49        Should the UserInteraction be deleted when it finishes (``True`` 
     50        by default). 
     51 
     52    """ 
     53    # Cancel reason flags 
     54 
     55    #: No specified reason 
     56    NoReason = 0 
     57    #: User canceled the operation (e.g. pressing ESC) 
     58    UserCancelReason = 1 
     59    #: Another interaction was set 
     60    InteractionOverrideReason = 3 
     61    #: An internal error occurred 
     62    ErrorReason = 4 
     63    #: Other (unspecified) reason 
    3364    OtherReason = 5 
    3465 
    35     # Emitted when the interaction is set on the scene. 
     66    #: Emitted when the interaction is set on the scene. 
    3667    started = Signal() 
    3768 
    38     # Emitted when the interaction finishes successfully. 
     69    #: Emitted when the interaction finishes successfully. 
    3970    finished = Signal() 
    4071 
    41     # Emitted when the interaction ends (canceled or finished) 
     72    #: Emitted when the interaction ends (canceled or finished) 
    4273    ended = Signal() 
    4374 
    44     # Emitted when the interaction is canceled. 
     75    #: Emitted when the interaction is canceled. 
    4576    canceled = Signal([], [int]) 
    4677 
     
    5990 
    6091    def start(self): 
    61         """Start the interaction. This is called by the scene when 
     92        """ 
     93        Start the interaction. This is called by the :class:`CanvasScene` when 
    6294        the interaction is installed. 
    6395 
    64         Must be called from subclass implementations. 
     96        .. note:: Must be called from subclass implementations. 
    6597 
    6698        """ 
     
    68100 
    69101    def end(self): 
    70         """Finish the interaction. Restore any leftover state in 
    71         this method. 
    72  
    73         .. note:: This gets called from the default `cancel` implementation. 
     102        """ 
     103        Finish the interaction. Restore any leftover state in this method. 
     104 
     105        .. note:: This gets called from the default :func:`cancel` 
     106                  implementation. 
    74107 
    75108        """ 
     
    91124 
    92125    def cancel(self, reason=OtherReason): 
    93         """Cancel the interaction for `reason`. 
     126        """ 
     127        Cancel the interaction with `reason`. 
    94128        """ 
    95129 
     
    100134 
    101135    def isFinished(self): 
    102         """Has the interaction finished. 
     136        """ 
     137        Is the interaction finished. 
    103138        """ 
    104139        return self.__finished 
    105140 
    106141    def isCanceled(self): 
    107         """Was the interaction canceled. 
     142        """ 
     143        Was the interaction canceled. 
    108144        """ 
    109145        return self.__canceled 
    110146 
    111147    def cancelReason(self): 
    112         """Return the reason the interaction was canceled. 
     148        """ 
     149        Return the reason the interaction was canceled. 
    113150        """ 
    114151        return self.__cancelReason 
    115152 
    116153    def mousePressEvent(self, event): 
     154        """ 
     155        Handle a `QGraphicsScene.mousePressEvent`. 
     156        """ 
    117157        return False 
    118158 
    119159    def mouseMoveEvent(self, event): 
     160        """ 
     161        Handle a `GraphicsScene.mouseMoveEvent`. 
     162        """ 
    120163        return False 
    121164 
    122165    def mouseReleaseEvent(self, event): 
     166        """ 
     167        Handle a `QGraphicsScene.mouseReleaseEvent`. 
     168        """ 
    123169        return False 
    124170 
    125171    def mouseDoubleClickEvent(self, event): 
     172        """ 
     173        Handle a `QGraphicsScene.mouseDoubleClickEvent`. 
     174        """ 
    126175        return False 
    127176 
    128177    def keyPressEvent(self, event): 
     178        """ 
     179        Handle a `QGraphicsScene.keyPressEvent` 
     180        """ 
    129181        if self.cancelOnEsc and event.key() == Qt.Key_Escape: 
    130182            self.cancel(self.UserCancelReason) 
     
    132184 
    133185    def keyReleaseEvent(self, event): 
     186        """ 
     187        Handle a `QGraphicsScene.keyPressEvent` 
     188        """ 
    134189        return False 
    135190 
     
    140195 
    141196def reversed_arguments(func): 
    142     """Return a function with reversed argument order. 
     197    """ 
     198    Return a function with reversed argument order. 
    143199    """ 
    144200    def wrapped(*args): 
     
    148204 
    149205class NewLinkAction(UserInteraction): 
    150     """User drags a new link from an existing node anchor item to create 
     206    """ 
     207    User drags a new link from an existing `NodeAnchorItem` to create 
    151208    a connection between two existing nodes or to a new node if the release 
    152209    is over an empty area, in which case a quick menu for new node selection 
     
    165222        self.direction = None 
    166223 
     224        # An `NodeItem` currently under the mouse as a possible 
     225        # link drop target. 
    167226        self.current_target_item = None 
     227        # A temporary `LinkItem` used while dragging. 
    168228        self.tmp_link_item = None 
     229        # An temporary `AnchorPoint` inserted into `current_target_item` 
    169230        self.tmp_anchor_point = None 
     231        # An `AnchorPoint` following the mouse cursor 
    170232        self.cursor_anchor_point = None 
    171233 
    172234    def remove_tmp_anchor(self): 
    173         """Remove a temp anchor point from the current target item. 
     235        """ 
     236        Remove a temporary anchor point from the current target item. 
    174237        """ 
    175238        if self.direction == self.FROM_SOURCE: 
     
    180243 
    181244    def create_tmp_anchor(self, item): 
    182         """Create a new tmp anchor at the item (`NodeItem`). 
     245        """ 
     246        Create a new tmp anchor at the `item` (:class:`NodeItem`). 
    183247        """ 
    184248        assert(self.tmp_anchor_point is None) 
     
    189253 
    190254    def can_connect(self, target_item): 
    191         """Is the connection between `self.from_item` (item where the drag 
    192         started) and `target_item`. 
     255        """ 
     256        Is the connection between `self.from_item` (item where the drag 
     257        started) and `target_item` possible. 
    193258 
    194259        """ 
     
    202267 
    203268    def set_link_target_anchor(self, anchor): 
    204         """Set the temp line target anchor 
     269        """ 
     270        Set the temp line target anchor. 
    205271        """ 
    206272        if self.direction == self.FROM_SOURCE: 
     
    210276 
    211277    def target_node_item_at(self, pos): 
    212         """Return a suitable NodeItem on which a link can be dropped. 
    213         """ 
    214         # Test for a suitable NodeAnchorItem or NodeItem at pos. 
     278        """ 
     279        Return a suitable :class:`NodeItem` at position `pos` on which 
     280        a link can be dropped. 
     281 
     282        """ 
     283        # Test for a suitable `NodeAnchorItem` or `NodeItem` at pos. 
    215284        if self.direction == self.FROM_SOURCE: 
    216285            anchor_type = items.SinkAnchorItem 
     
    347416 
    348417    def create_new(self, event): 
    349         """Create and return a new node with a QuickWidgetMenu. 
     418        """ 
     419        Create and return a new node with a `QuickMenu`. 
    350420        """ 
    351421        pos = event.screenPos() 
     
    391461 
    392462    def connect_existing(self, node): 
    393         """Connect anchor_item to `node`. 
     463        """ 
     464        Connect anchor_item to `node`. 
    394465        """ 
    395466        if self.direction == self.FROM_SOURCE: 
     
    495566    def end(self): 
    496567        self.cleanup() 
     568        # Remove the help tip set in mousePressEvent 
    497569        helpevent = QuickHelpTipEvent("", "") 
    498570        QCoreApplication.postEvent(self.document, helpevent) 
     
    504576 
    505577    def cleanup(self): 
    506         """Cleanup all temp items in the scene that are left. 
     578        """ 
     579        Cleanup all temporary items in the scene that are left. 
    507580        """ 
    508581        if self.tmp_link_item: 
     
    525598 
    526599class NewNodeAction(UserInteraction): 
    527     """Present the user with a quick menu for node selection and 
     600    """ 
     601    Present the user with a quick menu for node selection and 
    528602    create the selected node. 
    529603 
     
    536610 
    537611    def create_new(self, pos): 
    538         """Create a new widget with a QuickWidgetMenu at `pos` 
    539         (in screen coordinates). 
     612        """ 
     613        Create a new widget with a `QuickMenu` at `pos` (in screen 
     614        coordinates). 
    540615 
    541616        """ 
     
    558633 
    559634class RectangleSelectionAction(UserInteraction): 
    560     """Select items in the scene using a Rectangle selection 
     635    """ 
     636    Select items in the scene using a Rectangle selection 
    561637    """ 
    562638    def __init__(self, document, *args, **kwargs): 
    563639        UserInteraction.__init__(self, document, *args, **kwargs) 
     640        # The initial selection at drag start 
    564641        self.initial_selection = None 
     642        # Selection when last updated in a mouseMoveEvent 
    565643        self.last_selection = None 
     644        # A selection rect (`QRectF`) 
    566645        self.selection_rect = None 
     646        # Keyboard modifiers 
    567647        self.modifiers = 0 
    568648 
     
    603683    def mouseMoveEvent(self, event): 
    604684        if not self.rect_item.scene(): 
     685            # Add the rect item to the scene when the mouse moves. 
    605686            self.scene.addItem(self.rect_item) 
    606687        self.update_selection(event) 
     
    618699 
    619700    def update_selection(self, event): 
     701        """ 
     702        Update the selection rectangle from a QGraphicsSceneMouseEvent 
     703        `event` instance. 
     704 
     705        """ 
    620706        if self.initial_selection is None: 
    621707            self.initial_selection = set(self.scene.selectedItems()) 
     
    625711        self.selection_rect = QRectF(self.selection_rect.topLeft(), pos) 
    626712 
     713        # Make sure the rect_item does not cause the scene rect to grow. 
    627714        rect = self._bound_selection_rect(self.selection_rect.normalized()) 
    628715 
    629         # Need that constant otherwise the sceneRect will still grow 
     716        # Need that 0.5 constant otherwise the sceneRect will still 
     717        # grow (anti-aliasing correction by QGraphicsScene?) 
    630718        pw = self.rect_item.pen().width() + 0.5 
    631719 
     
    662750 
    663751    def viewport_rect(self): 
    664         """Return the bounding rect of the document's viewport on the 
    665         scene. 
    666  
     752        """ 
     753        Return the bounding rect of the document's viewport on the scene. 
    667754        """ 
    668755        view = self.document.view() 
     
    672759 
    673760    def _bound_selection_rect(self, rect): 
    674         """Bound the selection `rect` to a sensible size. 
     761        """ 
     762        Bound the selection `rect` to a sensible size. 
    675763        """ 
    676764        srect = self.scene.sceneRect() 
     
    681769 
    682770class EditNodeLinksAction(UserInteraction): 
     771    """ 
     772    Edit multiple links between two NodeItems using a :class:`EditLinksDialog` 
     773 
     774    Parameters 
     775    ---------- 
     776    document : :class:`SchemeEditWidget` 
     777        The editor widget. 
     778    source_node : :class:`SchemeNode` 
     779        The source (link start) node for the link editor. 
     780    sink_node : :class:`SchemeNode` 
     781        The sink (link end) node for the link editor. 
     782 
     783    """ 
    683784    def __init__(self, document, source_node, sink_node, *args, **kwargs): 
    684785        UserInteraction.__init__(self, document, *args, **kwargs) 
     
    689790        """ 
    690791        Show and execute the `EditLinksDialog`. 
    691         Optional `initial_links` list can provide the initial 
     792        Optional `initial_links` list can provide a list of initial 
    692793        `(source, sink)` channel tuples to show in the view, otherwise 
    693         the dialog is populated with existing links in the scheme 
    694         (pass an empty list to disable all initial links). 
     794        the dialog is populated with existing links in the scheme (passing 
     795        an empty list will disable all initial links). 
    695796 
    696797        """ 
     
    725826            stack.beginMacro("Edit Links") 
    726827 
    727             # First remove links into a single sink channel, 
     828            # First remove links into a 'Single' sink channel, 
    728829            # but only the ones that do not have self.source_node as 
    729830            # a source (they will be removed later from links_to_remove) 
     
    760861 
    761862def point_to_tuple(point): 
    762     return point.x(), point.y() 
     863    """ 
     864    Convert a QPointF into a (x, y) tuple. 
     865    """ 
     866    return (point.x(), point.y()) 
    763867 
    764868 
    765869class NewArrowAnnotation(UserInteraction): 
    766     """Create a new arrow annotation. 
     870    """ 
     871    Create a new arrow annotation handler. 
    767872    """ 
    768873    def __init__(self, document, *args, **kwargs): 
     
    789894 
    790895    def setColor(self, color): 
     896        """ 
     897        Set the color for the new arrow. 
     898        """ 
    791899        self.color = color 
    792900 
     
    852960 
    853961def rect_to_tuple(rect): 
     962    """ 
     963    Convert a QRectF into a (x, y, width, height) tuple. 
     964    """ 
    854965    return rect.x(), rect.y(), rect.width(), rect.height() 
    855966 
    856967 
    857968class NewTextAnnotation(UserInteraction): 
     969    """ 
     970    A New Text Annotation interaction handler 
     971    """ 
    858972    def __init__(self, document, *args, **kwargs): 
    859973        UserInteraction.__init__(self, document, *args, **kwargs) 
     
    884998 
    885999    def createNewAnnotation(self, rect): 
    886         """Create a new TextAnnotation at with `rect` as the geometry. 
     1000        """ 
     1001        Create a new TextAnnotation at with `rect` as the geometry. 
    8871002        """ 
    8881003        annot = scheme.SchemeTextAnnotation(rect_to_tuple(rect)) 
     
    9521067 
    9531068    def defaultTextGeometry(self, point): 
    954         """Return the default text geometry. Used in case the user 
    955         single clicked in the scene. 
     1069        """ 
     1070        Return the default text geometry. Used in case the user single 
     1071        clicked in the scene. 
    9561072 
    9571073        """ 
     
    9831099 
    9841100class ResizeTextAnnotation(UserInteraction): 
     1101    """ 
     1102    Resize a Text Annotation interaction handler. 
     1103    """ 
    9851104    def __init__(self, document, *args, **kwargs): 
    9861105        UserInteraction.__init__(self, document, *args, **kwargs) 
     
    10221141 
    10231142    def commit(self): 
    1024         """Commit the current item geometry state to the document. 
     1143        """ 
     1144        Commit the current item geometry state to the document. 
    10251145        """ 
    10261146        rect = self.item.geometry() 
     
    10681188 
    10691189class ResizeArrowAnnotation(UserInteraction): 
     1190    """ 
     1191    Resize an Arrow Annotation interaction handler. 
     1192    """ 
    10701193    def __init__(self, document, *args, **kwargs): 
    10711194        UserInteraction.__init__(self, document, *args, **kwargs) 
  • Orange/OrangeCanvas/gui/toolbox.py

    r11417 r11441  
    6262    def setNativeStyling(self, state): 
    6363        """ 
    64         Render tab buttons as native :class:`QToolButtons`. 
    65         If set to `False` (default) the button is pained using a 
    66         custom routine. 
     64        Render tab buttons as native (or css styled) :class:`QToolButtons`. 
     65        If set to `False` (default) the button is pained using a custom 
     66        paint routine. 
    6767 
    6868        """ 
     
    231231            self.__tabActionGroup.setExclusive(exclusive) 
    232232            checked = self.__tabActionGroup.checkedAction() 
     233            if checked is None: 
     234                # The action group can be out of sync with the actions state 
     235                # when switching between exclusive states. 
     236                actions_checked = [page.action for page in self.__pages 
     237                                   if page.action.isChecked()] 
     238                if actions_checked: 
     239                    checked = actions_checked[0] 
     240 
    233241            # Trigger/toggle remaining open pages 
    234242            if exclusive and checked is not None: 
  • Orange/OrangeCanvas/registry/__init__.py

    r11418 r11440  
    3838     "yellow": "#F0EC4F", 
    3939     } 
     40 
     41 
     42# default color when the category does not provide it 
     43DEFAULT_COLOR = "light-yellow" 
    4044 
    4145 
  • Orange/OrangeCanvas/registry/qt.py

    r11393 r11440  
    2121from ..resources import icon_loader 
    2222 
    23 from . import cache, NAMED_COLORS 
     23from . import cache, NAMED_COLORS, DEFAULT_COLOR 
    2424 
    2525 
     
    219219            background = desc.background 
    220220        else: 
    221             background = "light-yellow" 
     221            background = DEFAULT_COLOR 
    222222 
    223223        background = NAMED_COLORS.get(background, background) 
     
    254254        elif category.background: 
    255255            background = category.background 
     256        else: 
     257            background = DEFAULT_COLOR 
    256258 
    257259        if background is not None: 
  • 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.