Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] canvas: Fix link runtime state modeling #2591

Merged
merged 1 commit into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Orange/canvas/canvas/items/linkitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ class LinkItem(QGraphicsObject):
#: These are pulled from SchemeLink.State for ease of binding to it's
#: state
State = SchemeLink.State
#: The link has no associated state.
NoState = SchemeLink.NoState
#: Link is empty; the source node does not have any value on output
Empty = SchemeLink.Empty
#: Link is active; the source node has a valid value on output
Expand Down Expand Up @@ -326,7 +328,7 @@ def __init__(self, *args):

self.__dynamic = False
self.__dynamicEnabled = False
self.__state = LinkItem.Empty
self.__state = LinkItem.NoState
self.hover = False

self.prepareGeometryChange()
Expand Down Expand Up @@ -707,10 +709,10 @@ def __updatePen(self):
normal = QPen(QBrush(QColor("#9CACB4")), 2.0)
hover = QPen(QBrush(QColor("#7D7D7D")), 2.1)

if self.__state & LinkItem.Active:
pen_style = Qt.SolidLine
else:
if self.__state & LinkItem.Empty:
pen_style = Qt.DashLine
else:
pen_style = Qt.SolidLine

normal.setStyle(pen_style)
hover.setStyle(pen_style)
Expand Down
12 changes: 7 additions & 5 deletions Orange/canvas/scheme/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ class State(enum.IntEnum):
"""
Flags indicating the runtime state of a link
"""
#: The link has no associated state.
NoState = 0
#: A link is empty when it has no value on it
Empty = 0
Empty = 1
#: A link is active when the source node provides a value on output
Active = 1
Active = 2
#: A link is pending when it's sink node has not yet been notified
#: of a change (note that Empty|Pending is a valid state)
Pending = 2
Pending = 4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Pending a valid state or is it always Empty|Pending or Active|Pending?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's say it is valid.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked because it used to be marked with a dashed line (it was not active), but it is marked with a solid line in this PR (it is not empty). If the state does not occur normally by itself, it is not a problem.


Empty, Active, Pending = State
NoState, Empty, Active, Pending = State

def __init__(self, source_node, source_channel,
sink_node, sink_channel, enabled=True, properties=None,
Expand Down Expand Up @@ -125,7 +127,7 @@ def __init__(self, source_node, source_channel,

self.__enabled = enabled
self.__dynamic_enabled = False
self.__state = SchemeLink.Empty
self.__state = SchemeLink.NoState
self.__tool_tip = ""
self.properties = properties or {}

Expand Down