Ignore:
Files:
11 edited

Legend:

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

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

    r11444 r11401  
    6262        return unicode(self.__placeholderText) 
    6363 
    64     placeholderText_ = Property(unicode, placeholderText, setPlaceholderText, 
    65                                 doc="Placeholder text") 
     64    placeholderText_ = Property(unicode, placeholderText, setPlaceholderText) 
    6665 
    6766    def paint(self, painter, option, widget=None): 
     
    7473                     self.textInteractionFlags() & Qt.TextEditable): 
    7574            brect = self.boundingRect() 
    76             painter.setFont(self.font()) 
    7775            metrics = painter.fontMetrics() 
    7876            text = metrics.elidedText(self.__placeholderText, Qt.ElideRight, 
  • Orange/OrangeCanvas/canvas/items/linkitem.py

    r11442 r11369  
    11""" 
    2 ========= 
    32Link Item 
    4 ========= 
    53 
    64""" 
     
    1816 
    1917class LinkCurveItem(QGraphicsPathItem): 
    20     """ 
    21     Link curve item. The main component of a :class:`LinkItem`. 
     18    """Link curve item. The main component of `LinkItem`. 
    2219    """ 
    2320    def __init__(self, parent): 
    2421        QGraphicsPathItem.__init__(self, parent) 
    25         if not isinstance(parent, LinkItem): 
    26             raise TypeError("'LinkItem' expected") 
    27  
     22        assert(isinstance(parent, LinkItem)) 
    2823        self.setAcceptedMouseButtons(Qt.NoButton) 
    2924        self.__canvasLink = parent 
     
    4439 
    4540    def linkItem(self): 
    46         """ 
    47         Return the :class:`LinkItem` instance this curve belongs to. 
     41        """Return the :class:`LinkItem` instance this curve belongs to. 
     42 
    4843        """ 
    4944        return self.__canvasLink 
     
    8883 
    8984class LinkAnchorIndicator(QGraphicsEllipseItem): 
    90     """ 
    91     A visual indicator of the link anchor point at both ends 
    92     of the :class:`LinkItem`. 
     85    """A visual indicator of the link anchor point at both ends 
     86    of the `LinkItem`. 
    9387 
    9488    """ 
     
    114108class LinkItem(QGraphicsObject): 
    115109    """ 
    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  
     110    A Link in the canvas. 
    126111    """ 
    127112 
    128     #: Z value of the item 
    129113    Z_VALUE = 0 
     114    """Z value of the item""" 
    130115 
    131116    def __init__(self, *args): 
     
    161146    def setSourceItem(self, item, anchor=None): 
    162147        """ 
    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()``). 
     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). 
    166151 
    167152        Setting item to ``None`` and a valid anchor is a valid operation 
     
    211196    def setSinkItem(self, item, anchor=None): 
    212197        """ 
    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()``). 
     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). 
    216201 
    217202        Setting item to ``None`` and a valid anchor is a valid operation 
     
    261246    def setFont(self, font): 
    262247        """ 
    263         Set the font for the channel names text item. 
     248        Set the font for the channel names text. 
    264249        """ 
    265250        if font != self.font(): 
     
    413398    def setEnabled(self, enabled): 
    414399        """ 
    415         Reimplemented from :class:`QGraphicsObject` 
    416  
    417400        Set link enabled state. When disabled the link is rendered with a 
    418401        dashed line. 
     
    442425    def setDynamic(self, dynamic): 
    443426        """ 
    444         Mark the link as dynamic (i.e. it responds to 
    445         :func:`setDynamicEnabled`). 
     427        Mark the link as dynamic (e.i. it responds to the 
     428        ``setDynamicEnabled``). 
    446429 
    447430        """ 
  • Orange/OrangeCanvas/canvas/items/nodeitem.py

    r11442 r11411  
    11""" 
    2 ========= 
    3 Node Item 
    4 ========= 
     2NodeItem 
    53 
    64""" 
     
    5452    Create and return a default palette for a node. 
    5553    """ 
    56     return create_palette(QColor(NAMED_COLORS["light-yellow"]), 
    57                           QColor(NAMED_COLORS["yellow"])) 
     54    return create_palette(QColor(NAMED_COLORS["light-orange"]), 
     55                          QColor(NAMED_COLORS["orange"])) 
    5856 
    5957 
     
    274272    """ 
    275273 
    276     #: Signal emitted when the item's scene position changes. 
     274    # Signal emitted when the item's scene position changes. 
    277275    scenePositionChanged = Signal(QPointF) 
    278276 
    279     #: Signal emitted when the item's `anchorDirection` changes. 
    280277    anchorDirectionChanged = Signal(QPointF) 
    281278 
     
    695692    """ 
    696693 
    697     #: Signal emitted when the scene position of the node has changed. 
     694    # Scene position of the node has changed. 
    698695    positionChanged = Signal() 
    699696 
    700     #: Signal emitted when the geometry of the channel anchors changes. 
     697    # Geometry of the channel anchors changed 
    701698    anchorGeometryChanged = Signal() 
    702699 
    703     #: Signal emitted when the item has been activated (by a mouse double 
    704     #: click or a keyboard) 
     700    # The item has been activated (by a mouse double click or a keyboard). 
    705701    activated = Signal() 
    706702 
    707     #: The item is under the mouse. 
     703    # The item is under the mouse. 
    708704    hovered = Signal() 
    709705 
     
    856852    def setIcon(self, icon): 
    857853        """ 
    858         Set the node item's icon (:class:`QIcon`). 
     854        Set the node item's icon. 
    859855        """ 
    860856        if isinstance(icon, QIcon): 
     
    997993    def newInputAnchor(self): 
    998994        """ 
    999         Create and return a new input :class:`AnchorPoint`. 
     995        Create and return a new input anchor point. 
    1000996        """ 
    1001997        if not (self.widget_description and self.widget_description.inputs): 
     
    10231019    def newOutputAnchor(self): 
    10241020        """ 
    1025         Create and return a new output :class:`AnchorPoint`. 
     1021        Create a new output anchor indicator. 
    10261022        """ 
    10271023        if not (self.widget_description and self.widget_description.outputs): 
     
    10491045    def inputAnchors(self): 
    10501046        """ 
    1051         Return a list of all input anchor points. 
     1047        Return a list of input anchor points. 
    10521048        """ 
    10531049        return self.inputAnchorItem.anchorPoints() 
     
    10551051    def outputAnchors(self): 
    10561052        """ 
    1057         Return a list of all output anchor points. 
     1053        Return a list of output anchor points. 
    10581054        """ 
    10591055        return self.outputAnchorItem.anchorPoints() 
  • Orange/OrangeCanvas/canvas/scene.py

    r11442 r11411  
    3636class CanvasScene(QGraphicsScene): 
    3737    """ 
    38     A Graphics Scene for displaying an :class:`~.scheme.Scheme` instance. 
     38    A Graphics Scene for displaying and editing an :class:`Scheme`. 
    3939    """ 
    4040 
    41     #: Signal emitted when a :class:`NodeItem` has been added to the scene. 
     41    #: An node item has been added to the scene. 
    4242    node_item_added = Signal(items.NodeItem) 
    4343 
    44     #: Signal emitted when a :class:`NodeItem` has been removed from the 
    45     #: scene. 
     44    #: An node item has been removed from the scene 
    4645    node_item_removed = Signal(items.LinkItem) 
    4746 
    48     #: Signal emitted when a new :class:`LinkItem` has been added to the 
    49     #: scene. 
     47    #: A new link item has been added to the scene 
    5048    link_item_added = Signal(items.LinkItem) 
    5149 
    52     #: Signal emitted when a :class:`LinkItem` has been removed. 
     50    #: Link item has been removed 
    5351    link_item_removed = Signal(items.LinkItem) 
    5452 
    55     #: Signal emitted when a :class:`Annotation` item has been added. 
     53    #: Annotation item has been added 
    5654    annotation_added = Signal(items.annotationitem.Annotation) 
    5755 
    58     #: Signal emitted when a :class:`Annotation` item has been removed. 
     56    #: Annotation item has been removed 
    5957    annotation_removed = Signal(items.annotationitem.Annotation) 
    6058 
    61     #: Signal emitted when the position of a :class:`NodeItem` has changed. 
     59    #: The position of a node has changed 
    6260    node_item_position_changed = Signal(items.NodeItem, QPointF) 
    6361 
    64     #: Signal emitted when an :class:`NodeItem` has been double clicked. 
     62    #: An node item has been double clicked 
    6563    node_item_double_clicked = Signal(items.NodeItem) 
    6664 
     
    124122 
    125123    def clear_scene(self): 
    126         """ 
    127         Clear (reset) the scene. 
    128         """ 
    129124        self.scheme = None 
    130125        self.__node_items = [] 
     
    143138 
    144139    def set_scheme(self, 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` 
     140        """Set the scheme to display and edit. Populates the scene 
     141        with nodes and links already in the scheme. 
    153142 
    154143        """ 
     
    205194 
    206195    def set_registry(self, registry): 
    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. 
     196        """Set the widget registry. 
     197        """ 
    212198        log.info("Setting registry '%s on '%s'." % (registry, self)) 
    213199        self.registry = registry 
    214200 
    215201    def set_anchor_layout(self, layout): 
    216         """ 
    217         Set an :class:`~.layout.AnchorLayout` 
    218         """ 
    219202        if self.__anchor_layout != layout: 
    220203            if self.__anchor_layout: 
     
    225208 
    226209    def anchor_layout(self): 
    227         """ 
    228         Return the anchor layout instance. 
    229         """ 
    230210        return self.__anchor_layout 
    231211 
    232212    def set_channel_names_visible(self, visible): 
    233         """ 
    234         Set the channel names visibility. 
    235         """ 
    236213        self.__channel_names_visible = visible 
    237214        for link in self.__link_items: 
     
    239216 
    240217    def channel_names_visible(self): 
    241         """ 
    242         Return the channel names visibility state. 
    243         """ 
    244218        return self.__channel_names_visible 
    245219 
    246220    def set_node_animation_enabled(self, enabled): 
    247         """ 
    248         Set node animation enabled state. 
    249         """ 
    250221        if self.__node_animation_enabled != enabled: 
    251222            self.__node_animation_enabled = enabled 
     
    255226 
    256227    def add_node_item(self, item): 
    257         """ 
    258         Add a :class:`.NodeItem` instance to the scene. 
     228        """Add a :class:`NodeItem` instance to the scene. 
    259229        """ 
    260230        if item in self.__node_items: 
     
    291261 
    292262    def add_node(self, node): 
    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. 
     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. 
    297266 
    298267        """ 
     
    321290 
    322291    def new_node_item(self, widget_desc, category_desc=None): 
    323         """ 
    324         Construct an new :class:`.NodeItem` from a `WidgetDescription`. 
     292        """Construct an new `NodeItem` from a `WidgetDescription`. 
    325293        Optionally also set `CategoryDescription`. 
    326294 
     
    345313 
    346314    def remove_node_item(self, item): 
    347         """ 
    348         Remove `item` (:class:`.NodeItem`) from the scene. 
     315        """Remove `item` (:class:`NodeItem`) from the scene. 
    349316        """ 
    350317        self.activated_mapper.removePyMappings(item) 
     
    360327 
    361328    def remove_node(self, node): 
    362         """ 
    363         Remove the :class:`.NodeItem` instance that was previously 
    364         constructed for a :class:`SchemeNode` `node` using the `add_node` 
    365         method. 
     329        """Remove the `NodeItem` instance that was previously constructed for 
     330        a `SchemeNode` node using the `add_node` method. 
    366331 
    367332        """ 
     
    376341 
    377342    def node_items(self): 
    378         """ 
    379         Return all :class:`.NodeItem` instances in the scene. 
     343        """Return all :class:`NodeItem` instances in the scene. 
    380344        """ 
    381345        return list(self.__node_items) 
    382346 
    383347    def add_link_item(self, item): 
    384         """ 
    385         Add a link (:class:`.LinkItem`) to the scene. 
     348        """Add a link (:class:`LinkItem`)to the scene. 
    386349        """ 
    387350        if item.scene() is not self: 
     
    401364 
    402365    def add_link(self, scheme_link): 
    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`. 
     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`. 
    407369 
    408370        """ 
     
    430392    def new_link_item(self, source_item, source_channel, 
    431393                      sink_item, sink_channel): 
    432         """ 
    433         Construct and return a new :class:`.LinkItem` 
     394        """Construct and return a new `LinkItem` 
    434395        """ 
    435396        item = items.LinkItem() 
     
    459420 
    460421    def remove_link_item(self, item): 
    461         """ 
    462         Remove a link (:class:`.LinkItem`) from the scene. 
     422        """Remove a link (:class:`LinkItem`) from the scene. 
    463423        """ 
    464424        # Invalidate the anchor layout. 
     
    483443 
    484444    def remove_link(self, scheme_link): 
    485         """ 
    486         Remove a :class:`.LinkItem` instance that was previously constructed 
    487         for a :class:`SchemeLink` instance `link` using the `add_link` method. 
     445        """ Remove a `LinkItem` instance that was previously constructed for 
     446        a `SchemeLink` node using the `add_link` method. 
    488447 
    489448        """ 
     
    493452 
    494453    def link_items(self): 
    495         """ 
    496         Return all :class:`.LinkItem`\s in the scene. 
     454        """Return all :class:`LinkItems` in the scene. 
     455 
    497456        """ 
    498457        return list(self.__link_items) 
    499458 
    500459    def add_annotation_item(self, annotation): 
    501         """ 
    502         Add an :class:`.Annotation` item to the scene. 
     460        """Add an `Annotation` item to the scene. 
     461 
    503462        """ 
    504463        self.__annotation_items.append(annotation) 
     
    508467 
    509468    def add_annotation(self, scheme_annot): 
    510         """ 
    511         Create a new item for :class:`SchemeAnnotation` and add it 
     469        """Create a new item for :class:`SchemeAnnotation` and add it 
    512470        to the scene. If the `scheme_annot` is already in the scene do 
    513471        nothing and just return its item. 
     
    546504 
    547505    def remove_annotation_item(self, annotation): 
    548         """ 
    549         Remove an :class:`.Annotation` instance from the scene. 
     506        """Remove an `Annotation` item from the scene. 
    550507 
    551508        """ 
     
    555512 
    556513    def remove_annotation(self, scheme_annotation): 
    557         """ 
    558         Remove an :class:`.Annotation` instance that was previously added 
    559         using :func:`add_anotation`. 
    560  
    561         """ 
    562514        item = self.__item_for_annotation.pop(scheme_annotation) 
    563515 
     
    574526 
    575527    def annotation_items(self): 
    576         """ 
    577         Return all :class:`.Annotation` items in the scene. 
     528        """Return all `Annotation` items in the scene. 
     529 
    578530        """ 
    579531        return self.__annotation_items 
     
    588540 
    589541    def commit_scheme_node(self, node): 
    590         """ 
    591         Commit the `node` into the scheme. 
     542        """Commit the `node` into the scheme. 
    592543        """ 
    593544        if not self.editable: 
     
    602553            self.scheme.add_node(node) 
    603554        except Exception: 
    604             log.error("An error occurred while committing node '%s'", 
     555            log.error("An unexpected error occurred while commiting node '%s'", 
    605556                      node, exc_info=True) 
    606557            # Cleanup (remove the node item) 
     
    612563 
    613564    def commit_scheme_link(self, link): 
    614         """ 
    615         Commit a scheme link. 
     565        """Commit a scheme link. 
    616566        """ 
    617567        if not self.editable: 
     
    626576 
    627577    def node_for_item(self, item): 
    628         """ 
    629         Return the `SchemeNode` for the `item`. 
     578        """Return the `SchemeNode` for the `item`. 
    630579        """ 
    631580        rev = dict([(v, k) for k, v in self.__item_for_node.items()]) 
     
    633582 
    634583    def item_for_node(self, node): 
    635         """ 
    636         Return the :class:`NodeItem` instance for a :class:`SchemeNode`. 
     584        """Return the :class:`NodeItem` instance for a :class:`SchemeNode`. 
    637585        """ 
    638586        return self.__item_for_node[node] 
    639587 
    640588    def link_for_item(self, item): 
    641         """ 
    642         Return the `SchemeLink for `item` (:class:`LinkItem`). 
     589        """Return the `SchemeLink for `item` (:class:`LinkItem`). 
    643590        """ 
    644591        rev = dict([(v, k) for k, v in self.__item_for_link.items()]) 
     
    646593 
    647594    def item_for_link(self, link): 
    648         """ 
    649         Return the :class:`LinkItem` for a :class:`SchemeLink` 
     595        """Return the :class:`LinkItem` for a :class:`SchemeLink` 
    650596        """ 
    651597        return self.__item_for_link[link] 
    652598 
    653599    def selected_node_items(self): 
    654         """ 
    655         Return the selected :class:`NodeItem`'s. 
     600        """Return the selected :class:`NodeItem`'s. 
    656601        """ 
    657602        return [item for item in self.__node_items if item.isSelected()] 
    658603 
    659604    def selected_annotation_items(self): 
    660         """ 
    661         Return the selected :class:`Annotation`'s 
     605        """Return the selected :class:`Annotation`'s 
    662606        """ 
    663607        return [item for item in self.__annotation_items if item.isSelected()] 
    664608 
    665609    def node_links(self, node_item): 
    666         """ 
    667         Return all links from the `node_item` (:class:`NodeItem`). 
     610        """Return all links from the `node_item` (:class:`NodeItem`). 
    668611        """ 
    669612        return self.node_output_links(node_item) + \ 
     
    671614 
    672615    def node_output_links(self, node_item): 
    673         """ 
    674         Return a list of all output links from `node_item`. 
     616        """Return a list of all output links from `node_item`. 
    675617        """ 
    676618        return [link for link in self.__link_items 
     
    678620 
    679621    def node_input_links(self, node_item): 
    680         """ 
    681         Return a list of all input links for `node_item`. 
     622        """Return a list of all input links for `node_item`. 
    682623        """ 
    683624        return [link for link in self.__link_items 
     
    685626 
    686627    def neighbor_nodes(self, node_item): 
    687         """ 
    688         Return a list of `node_item`'s (class:`NodeItem`) neighbor nodes. 
     628        """Return a list of `node_item`'s (class:`NodeItem`) neighbor nodes. 
    689629        """ 
    690630        neighbors = map(attrgetter("sourceItem"), 
     
    871811 
    872812def grab_svg(scene): 
    873     """ 
    874     Return a SVG rendering of the scene contents. 
    875  
    876     Parameters 
    877     ---------- 
    878     scene : :class:`CanvasScene` 
    879  
     813    """Return a SVG rendering of the scene contents. 
    880814    """ 
    881815    from PyQt4.QtSvg import QSvgGenerator 
  • Orange/OrangeCanvas/document/interactions.py

    r11443 r11401  
    11""" 
    2 ========================= 
    3 User Interaction Handlers 
    4 ========================= 
    5  
    6 User interaction handlers for a :class:`~.SchemeEditWidget`. 
    7  
    8 User interactions encapsulate the logic of user interactions with the 
    9 scheme document. 
    10  
    11 All interactions are subclasses of :class:`UserInteraction`. 
    12  
     2User interaction handlers for CanvasScene. 
    133 
    144""" 
    15  
    165import logging 
    176 
     
    3726 
    3827class UserInteraction(QObject): 
    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 
     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 
    6433    OtherReason = 5 
    6534 
    66     #: Emitted when the interaction is set on the scene. 
     35    # Emitted when the interaction is set on the scene. 
    6736    started = Signal() 
    6837 
    69     #: Emitted when the interaction finishes successfully. 
     38    # Emitted when the interaction finishes successfully. 
    7039    finished = Signal() 
    7140 
    72     #: Emitted when the interaction ends (canceled or finished) 
     41    # Emitted when the interaction ends (canceled or finished) 
    7342    ended = Signal() 
    7443 
    75     #: Emitted when the interaction is canceled. 
     44    # Emitted when the interaction is canceled. 
    7645    canceled = Signal([], [int]) 
    7746 
     
    9059 
    9160    def start(self): 
    92         """ 
    93         Start the interaction. This is called by the :class:`CanvasScene` when 
     61        """Start the interaction. This is called by the scene when 
    9462        the interaction is installed. 
    9563 
    96         .. note:: Must be called from subclass implementations. 
     64        Must be called from subclass implementations. 
    9765 
    9866        """ 
     
    10068 
    10169    def end(self): 
    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. 
     70        """Finish the interaction. Restore any leftover state in 
     71        this method. 
     72 
     73        .. note:: This gets called from the default `cancel` implementation. 
    10774 
    10875        """ 
     
    12491 
    12592    def cancel(self, reason=OtherReason): 
    126         """ 
    127         Cancel the interaction with `reason`. 
     93        """Cancel the interaction for `reason`. 
    12894        """ 
    12995 
     
    134100 
    135101    def isFinished(self): 
    136         """ 
    137         Is the interaction finished. 
     102        """Has the interaction finished. 
    138103        """ 
    139104        return self.__finished 
    140105 
    141106    def isCanceled(self): 
    142         """ 
    143         Was the interaction canceled. 
     107        """Was the interaction canceled. 
    144108        """ 
    145109        return self.__canceled 
    146110 
    147111    def cancelReason(self): 
    148         """ 
    149         Return the reason the interaction was canceled. 
     112        """Return the reason the interaction was canceled. 
    150113        """ 
    151114        return self.__cancelReason 
    152115 
    153116    def mousePressEvent(self, event): 
    154         """ 
    155         Handle a `QGraphicsScene.mousePressEvent`. 
    156         """ 
    157117        return False 
    158118 
    159119    def mouseMoveEvent(self, event): 
    160         """ 
    161         Handle a `GraphicsScene.mouseMoveEvent`. 
    162         """ 
    163120        return False 
    164121 
    165122    def mouseReleaseEvent(self, event): 
    166         """ 
    167         Handle a `QGraphicsScene.mouseReleaseEvent`. 
    168         """ 
    169123        return False 
    170124 
    171125    def mouseDoubleClickEvent(self, event): 
    172         """ 
    173         Handle a `QGraphicsScene.mouseDoubleClickEvent`. 
    174         """ 
    175126        return False 
    176127 
    177128    def keyPressEvent(self, event): 
    178         """ 
    179         Handle a `QGraphicsScene.keyPressEvent` 
    180         """ 
    181129        if self.cancelOnEsc and event.key() == Qt.Key_Escape: 
    182130            self.cancel(self.UserCancelReason) 
     
    184132 
    185133    def keyReleaseEvent(self, event): 
    186         """ 
    187         Handle a `QGraphicsScene.keyPressEvent` 
    188         """ 
    189134        return False 
    190135 
     
    195140 
    196141def reversed_arguments(func): 
    197     """ 
    198     Return a function with reversed argument order. 
     142    """Return a function with reversed argument order. 
    199143    """ 
    200144    def wrapped(*args): 
     
    204148 
    205149class NewLinkAction(UserInteraction): 
    206     """ 
    207     User drags a new link from an existing `NodeAnchorItem` to create 
     150    """User drags a new link from an existing node anchor item to create 
    208151    a connection between two existing nodes or to a new node if the release 
    209152    is over an empty area, in which case a quick menu for new node selection 
     
    222165        self.direction = None 
    223166 
    224         # An `NodeItem` currently under the mouse as a possible 
    225         # link drop target. 
    226167        self.current_target_item = None 
    227         # A temporary `LinkItem` used while dragging. 
    228168        self.tmp_link_item = None 
    229         # An temporary `AnchorPoint` inserted into `current_target_item` 
    230169        self.tmp_anchor_point = None 
    231         # An `AnchorPoint` following the mouse cursor 
    232170        self.cursor_anchor_point = None 
    233171 
    234172    def remove_tmp_anchor(self): 
    235         """ 
    236         Remove a temporary anchor point from the current target item. 
     173        """Remove a temp anchor point from the current target item. 
    237174        """ 
    238175        if self.direction == self.FROM_SOURCE: 
     
    243180 
    244181    def create_tmp_anchor(self, item): 
    245         """ 
    246         Create a new tmp anchor at the `item` (:class:`NodeItem`). 
     182        """Create a new tmp anchor at the item (`NodeItem`). 
    247183        """ 
    248184        assert(self.tmp_anchor_point is None) 
     
    253189 
    254190    def can_connect(self, target_item): 
    255         """ 
    256         Is the connection between `self.from_item` (item where the drag 
    257         started) and `target_item` possible. 
     191        """Is the connection between `self.from_item` (item where the drag 
     192        started) and `target_item`. 
    258193 
    259194        """ 
     
    267202 
    268203    def set_link_target_anchor(self, anchor): 
    269         """ 
    270         Set the temp line target anchor. 
     204        """Set the temp line target anchor 
    271205        """ 
    272206        if self.direction == self.FROM_SOURCE: 
     
    276210 
    277211    def target_node_item_at(self, 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. 
     212        """Return a suitable NodeItem on which a link can be dropped. 
     213        """ 
     214        # Test for a suitable NodeAnchorItem or NodeItem at pos. 
    284215        if self.direction == self.FROM_SOURCE: 
    285216            anchor_type = items.SinkAnchorItem 
     
    416347 
    417348    def create_new(self, event): 
    418         """ 
    419         Create and return a new node with a `QuickMenu`. 
     349        """Create and return a new node with a QuickWidgetMenu. 
    420350        """ 
    421351        pos = event.screenPos() 
     
    461391 
    462392    def connect_existing(self, node): 
    463         """ 
    464         Connect anchor_item to `node`. 
     393        """Connect anchor_item to `node`. 
    465394        """ 
    466395        if self.direction == self.FROM_SOURCE: 
     
    566495    def end(self): 
    567496        self.cleanup() 
    568         # Remove the help tip set in mousePressEvent 
    569497        helpevent = QuickHelpTipEvent("", "") 
    570498        QCoreApplication.postEvent(self.document, helpevent) 
     
    576504 
    577505    def cleanup(self): 
    578         """ 
    579         Cleanup all temporary items in the scene that are left. 
     506        """Cleanup all temp items in the scene that are left. 
    580507        """ 
    581508        if self.tmp_link_item: 
     
    598525 
    599526class NewNodeAction(UserInteraction): 
    600     """ 
    601     Present the user with a quick menu for node selection and 
     527    """Present the user with a quick menu for node selection and 
    602528    create the selected node. 
    603529 
     
    610536 
    611537    def create_new(self, pos): 
    612         """ 
    613         Create a new widget with a `QuickMenu` at `pos` (in screen 
    614         coordinates). 
     538        """Create a new widget with a QuickWidgetMenu at `pos` 
     539        (in screen coordinates). 
    615540 
    616541        """ 
     
    633558 
    634559class RectangleSelectionAction(UserInteraction): 
    635     """ 
    636     Select items in the scene using a Rectangle selection 
     560    """Select items in the scene using a Rectangle selection 
    637561    """ 
    638562    def __init__(self, document, *args, **kwargs): 
    639563        UserInteraction.__init__(self, document, *args, **kwargs) 
    640         # The initial selection at drag start 
    641564        self.initial_selection = None 
    642         # Selection when last updated in a mouseMoveEvent 
    643565        self.last_selection = None 
    644         # A selection rect (`QRectF`) 
    645566        self.selection_rect = None 
    646         # Keyboard modifiers 
    647567        self.modifiers = 0 
    648568 
     
    683603    def mouseMoveEvent(self, event): 
    684604        if not self.rect_item.scene(): 
    685             # Add the rect item to the scene when the mouse moves. 
    686605            self.scene.addItem(self.rect_item) 
    687606        self.update_selection(event) 
     
    699618 
    700619    def update_selection(self, event): 
    701         """ 
    702         Update the selection rectangle from a QGraphicsSceneMouseEvent 
    703         `event` instance. 
    704  
    705         """ 
    706620        if self.initial_selection is None: 
    707621            self.initial_selection = set(self.scene.selectedItems()) 
     
    711625        self.selection_rect = QRectF(self.selection_rect.topLeft(), pos) 
    712626 
    713         # Make sure the rect_item does not cause the scene rect to grow. 
    714627        rect = self._bound_selection_rect(self.selection_rect.normalized()) 
    715628 
    716         # Need that 0.5 constant otherwise the sceneRect will still 
    717         # grow (anti-aliasing correction by QGraphicsScene?) 
     629        # Need that constant otherwise the sceneRect will still grow 
    718630        pw = self.rect_item.pen().width() + 0.5 
    719631 
     
    750662 
    751663    def viewport_rect(self): 
    752         """ 
    753         Return the bounding rect of the document's viewport on the scene. 
     664        """Return the bounding rect of the document's viewport on the 
     665        scene. 
     666 
    754667        """ 
    755668        view = self.document.view() 
     
    759672 
    760673    def _bound_selection_rect(self, rect): 
    761         """ 
    762         Bound the selection `rect` to a sensible size. 
     674        """Bound the selection `rect` to a sensible size. 
    763675        """ 
    764676        srect = self.scene.sceneRect() 
     
    769681 
    770682class 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     """ 
    784683    def __init__(self, document, source_node, sink_node, *args, **kwargs): 
    785684        UserInteraction.__init__(self, document, *args, **kwargs) 
     
    790689        """ 
    791690        Show and execute the `EditLinksDialog`. 
    792         Optional `initial_links` list can provide a list of initial 
     691        Optional `initial_links` list can provide the initial 
    793692        `(source, sink)` channel tuples to show in the view, otherwise 
    794         the dialog is populated with existing links in the scheme (passing 
    795         an empty list will disable all initial links). 
     693        the dialog is populated with existing links in the scheme 
     694        (pass an empty list to disable all initial links). 
    796695 
    797696        """ 
     
    826725            stack.beginMacro("Edit Links") 
    827726 
    828             # First remove links into a 'Single' sink channel, 
     727            # First remove links into a single sink channel, 
    829728            # but only the ones that do not have self.source_node as 
    830729            # a source (they will be removed later from links_to_remove) 
     
    861760 
    862761def point_to_tuple(point): 
    863     """ 
    864     Convert a QPointF into a (x, y) tuple. 
    865     """ 
    866     return (point.x(), point.y()) 
     762    return point.x(), point.y() 
    867763 
    868764 
    869765class NewArrowAnnotation(UserInteraction): 
    870     """ 
    871     Create a new arrow annotation handler. 
     766    """Create a new arrow annotation. 
    872767    """ 
    873768    def __init__(self, document, *args, **kwargs): 
     
    894789 
    895790    def setColor(self, color): 
    896         """ 
    897         Set the color for the new arrow. 
    898         """ 
    899791        self.color = color 
    900792 
     
    960852 
    961853def rect_to_tuple(rect): 
    962     """ 
    963     Convert a QRectF into a (x, y, width, height) tuple. 
    964     """ 
    965854    return rect.x(), rect.y(), rect.width(), rect.height() 
    966855 
    967856 
    968857class NewTextAnnotation(UserInteraction): 
    969     """ 
    970     A New Text Annotation interaction handler 
    971     """ 
    972858    def __init__(self, document, *args, **kwargs): 
    973859        UserInteraction.__init__(self, document, *args, **kwargs) 
     
    998884 
    999885    def createNewAnnotation(self, rect): 
    1000         """ 
    1001         Create a new TextAnnotation at with `rect` as the geometry. 
     886        """Create a new TextAnnotation at with `rect` as the geometry. 
    1002887        """ 
    1003888        annot = scheme.SchemeTextAnnotation(rect_to_tuple(rect)) 
     
    1067952 
    1068953    def defaultTextGeometry(self, point): 
    1069         """ 
    1070         Return the default text geometry. Used in case the user single 
    1071         clicked in the scene. 
     954        """Return the default text geometry. Used in case the user 
     955        single clicked in the scene. 
    1072956 
    1073957        """ 
     
    1099983 
    1100984class ResizeTextAnnotation(UserInteraction): 
    1101     """ 
    1102     Resize a Text Annotation interaction handler. 
    1103     """ 
    1104985    def __init__(self, document, *args, **kwargs): 
    1105986        UserInteraction.__init__(self, document, *args, **kwargs) 
     
    11411022 
    11421023    def commit(self): 
    1143         """ 
    1144         Commit the current item geometry state to the document. 
     1024        """Commit the current item geometry state to the document. 
    11451025        """ 
    11461026        rect = self.item.geometry() 
     
    11881068 
    11891069class ResizeArrowAnnotation(UserInteraction): 
    1190     """ 
    1191     Resize an Arrow Annotation interaction handler. 
    1192     """ 
    11931070    def __init__(self, document, *args, **kwargs): 
    11941071        UserInteraction.__init__(self, document, *args, **kwargs) 
  • Orange/OrangeCanvas/gui/toolbox.py

    r11441 r11417  
    6262    def setNativeStyling(self, state): 
    6363        """ 
    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. 
     64        Render tab buttons as native :class:`QToolButtons`. 
     65        If set to `False` (default) the button is pained using a 
     66        custom 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  
    241233            # Trigger/toggle remaining open pages 
    242234            if exclusive and checked is not None: 
  • Orange/OrangeCanvas/registry/__init__.py

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

    r11440 r11393  
    2121from ..resources import icon_loader 
    2222 
    23 from . import cache, NAMED_COLORS, DEFAULT_COLOR 
     23from . import cache, NAMED_COLORS 
    2424 
    2525 
     
    219219            background = desc.background 
    220220        else: 
    221             background = DEFAULT_COLOR 
     221            background = "light-yellow" 
    222222 
    223223        background = NAMED_COLORS.get(background, background) 
     
    254254        elif category.background: 
    255255            background = category.background 
    256         else: 
    257             background = DEFAULT_COLOR 
    258256 
    259257        if background is not None: 
  • docs/canvas/canvas.items.nodeitem.rst

    r11442 r11369  
    1010.. autoclass:: NodeItem 
    1111   :members: 
    12    :exclude-members: 
    13       from_node, 
    14       from_node_meta, 
    15       setupGraphics, 
    16       setProgressMessage, 
    17       positionChanged, 
    18       anchorGeometryChanged, 
    19       activated, 
    20       hovered 
     12   :exclude-members: from_node, from_node_meta, setupGraphics,  setProgressMessage 
    2113   :member-order: bysource 
    2214   :show-inheritance: 
     
    2416   .. autoattribute:: positionChanged() 
    2517 
     18      Signal emitted when the scene position of the node has changes. 
     19 
    2620   .. autoattribute:: anchorGeometryChanged() 
     21 
     22      Signal emitted when the geometry of the channel anchors changes. 
    2723 
    2824   .. autoattribute:: activated() 
    2925 
    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) 
     26      Signal emitted when the item has been activated (by a mouse double 
     27      click or a keyboard) 
  • docs/canvas/canvas.scene.rst

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