Conversation
5909b36 to
57380e0
Compare
Codecov Report
@@ Coverage Diff @@
## master #3179 +/- ##
=========================================
+ Coverage 82.54% 82.64% +0.1%
=========================================
Files 337 342 +5
Lines 58431 59016 +585
=========================================
+ Hits 48229 48776 +547
- Misses 10202 10240 +38 |
| super().setPath(path) | ||
|
|
||
| def parent(self): | ||
| return self.__parent |
There was a problem hiding this comment.
This is the same as parentItem()
Orange/canvas/document/schemeedit.py
Outdated
| else: | ||
| pos = event.scenePos() | ||
| self.createNewNode(desc, position=(pos.x(), pos.y())) | ||
| item = self.__scene.item_at(event.scenePos()) |
There was a problem hiding this comment.
You can use self.__scene.item_at(event.scenePos(), items.LinkItem) for better and easier hit detection (you also would not need the new LinkCurveItem.parent method).
Orange/canvas/document/commands.py
Outdated
| SchemeLink(link.source_node, link.source_channel, | ||
| new_node, possible_links[0][0][1]), # first link, first entry, output (1) | ||
| SchemeLink(new_node, possible_links[1][0][0], # second link, first entry, input (0) | ||
| link.sink_node, link.sink_channel)) |
There was a problem hiding this comment.
This logic in __init__ should be moved out of the command class. Parameterize the command with the new node, old link and new link pairs.
Orange/canvas/document/commands.py
Outdated
|
|
||
| class InsertNodeCommand(QUndoCommand): | ||
| def __init__(self, scheme, link, new_node, parent=None): | ||
| QUndoCommand.__init__(self, "Remove link", parent) |
There was a problem hiding this comment.
Change the command name/text to 'Insert widget on link' or something similar.
5f8e5dc to
da8c2c0
Compare
da8c2c0 to
28fe821
Compare
Orange/canvas/document/schemeedit.py
Outdated
| sink_node = link.sink_node | ||
|
|
||
| if nodes_are_compatible(source_node.description, new_node_desc) and \ | ||
| nodes_are_compatible(new_node_desc, sink_node.description): |
There was a problem hiding this comment.
The test here should also be constrained on the existing link.source_channel and link.sink_channel.
E.g. If I use:
and drop an Impute widget on the link, I get a
------------------- IncompatibleChannelTypeError Exception --------------------
Traceback (most recent call last):
File "/Users/aleserjavec/workspace/orange3/Orange/canvas/document/schemeedit.py", line 1102, in eventFilter
self.tryInsertNode(link, desc, pos)
File "/Users/aleserjavec/workspace/orange3/Orange/canvas/document/schemeedit.py", line 1066, in tryInsertNode
new_node, possible_links[0][0][1]), # first link, first entry, output
File "/Users/aleserjavec/workspace/orange3/Orange/canvas/scheme/link.py", line 125, in __init__
% (source_channel.type, sink_channel.type)
Orange.canvas.scheme.errors.IncompatibleChannelTypeError: Cannot connect 'Orange.base.Model' to 'Orange.base.Learner'
-------------------------------------------------------------------------------
The set of possible links below should also be filtered correspondingly.
P.S.
The same also applies to the 'Insert widget` context menu action.
|
Can you also implement drop target detection in diff --git a/Orange/canvas/document/schemeedit.py b/Orange/canvas/document/schemeedit.py
index 840ece304..ddf453fa6 100644
--- a/Orange/canvas/document/schemeedit.py
+++ b/Orange/canvas/document/schemeedit.py
@@ -132,6 +132,7 @@ class SchemeEditWidget(QWidget):
self.__possibleMouseItemsMove = False
self.__itemsMoving = {}
self.__contextMenuTarget = None
+ self.__dropTarget = None
self.__quickMenu = None
self.__quickTip = ""
@@ -1066,18 +1067,43 @@ class SchemeEditWidget(QWidget):
def eventFilter(self, obj, event):
# Filter the scene's drag/drop events.
+ MIME_TYPE = "application/vnv.orange-canvas.registry.qualified-name"
if obj is self.scene():
etype = event.type()
if etype == QEvent.GraphicsSceneDragEnter or \
etype == QEvent.GraphicsSceneDragMove:
mime_data = event.mimeData()
- if mime_data.hasFormat(
- "application/vnv.orange-canvas.registry.qualified-name"
- ):
+ droptarget = None
+ accept = True
+ if mime_data.hasFormat(MIME_TYPE):
+ qname = bytes(mime_data.data(MIME_TYPE)).decode("ascii")
+ try:
+ desc = self.__registry.widget(qname)
+ except KeyError:
+ pass
+ else:
+ item = self.__scene.item_at(event.scenePos(),
+ items.LinkItem)
+ link = self.__scene.link_for_item(item) if item else None
+ if link is not None:
+ droptarget = item
+ droptarget.setHoverState(True)
+ accept = can_insert_node(desc, link)
+ if accept:
event.acceptProposedAction()
else:
event.ignore()
+ if self.__dropTarget is not None and \
+ self.__dropTarget is not droptarget:
+ self.__dropTarget.setHoverState(False)
+ self.__dropTarget = None
+
+ self.__dropTarget = droptarget
return True
+ elif etype == QEvent.GraphicsSceneDragLeave:
+ if self.__dropTarget is not None:
+ self.__dropTarget.setHoverState(False)
+ self.__dropTarget = None |
|
Dragging the widget no longer works for me...? |
|
Are you dragging a compatible widget to the link? If the widget is incompatible, it's simply added as if dragged to empty canvas. |
|
Yes. File - Select Columns - Data Table. |
|
Resolved. |

Feature
Insert a widget in-between two already connected widgets by either:
Description of changes
Includes