Skip to content

Commit

Permalink
Merge pull request #1355 from ChemicalXandco/allow_replace_edge
Browse files Browse the repository at this point in the history
Allow replacing edges
  • Loading branch information
fabiencastan authored Apr 13, 2021
2 parents 5b286c6 + 3ea721a commit 36d410e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 7 additions & 1 deletion meshroom/ui/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,14 @@ def addEdge(self, src, dst):
if isinstance(dst, ListAttribute) and not isinstance(src, ListAttribute):
with self.groupedGraphModification("Insert and Add Edge on {}".format(dst.getFullName())):
self.appendAttribute(dst)
self.push(commands.AddEdgeCommand(self._graph, src, dst.at(-1)))
self._addEdge(src, dst.at(-1))
else:
self._addEdge(src, dst)

def _addEdge(self, src, dst):
with self.groupedGraphModification("Connect '{}'->'{}'".format(src.getFullName(), dst.getFullName())):
if dst in self._graph.edges.keys():
self.removeEdge(self._graph.edge(dst))
self.push(commands.AddEdgeCommand(self._graph, src, dst))

@Slot(Edge)
Expand Down
6 changes: 2 additions & 4 deletions meshroom/ui/qml/GraphEditor/AttributePin.qml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ RowLayout {
|| drag.source.objectName != inputDragTarget.objectName // not an edge connector
|| drag.source.baseType != inputDragTarget.baseType // not the same base type
|| drag.source.nodeItem == inputDragTarget.nodeItem // connection between attributes of the same node
|| inputDragTarget.attribute.isLink // already connected attribute
|| (drag.source.isList && !inputDragTarget.isList) // connection between a list and a simple attribute
|| (drag.source.isList && childrenRepeater.count) // source/target are lists but target already has children
|| drag.source.connectorType == "input" // refuse to connect an "input pin" on another one (input attr can be connected to input attr, but not the graphical pin)
Expand Down Expand Up @@ -131,7 +130,7 @@ RowLayout {
MouseArea {
id: inputConnectMA
// If an input attribute is connected (isLink), we disable drag&drop
drag.target: (attribute.isLink || attribute.isReadOnly) ? undefined : inputDragTarget
drag.target: (attribute.isReadOnly) ? undefined : inputDragTarget
drag.threshold: 0
enabled: !root.readOnly
anchors.fill: parent
Expand Down Expand Up @@ -227,7 +226,6 @@ RowLayout {
if( drag.source.objectName != outputDragTarget.objectName // not an edge connector
|| drag.source.baseType != outputDragTarget.baseType // not the same base type
|| drag.source.nodeItem == outputDragTarget.nodeItem // connection between attributes of the same node
|| drag.source.attribute.isLink // already connected attribute
|| (!drag.source.isList && outputDragTarget.isList) // connection between a list and a simple attribute
|| (drag.source.isList && childrenRepeater.count) // source/target are lists but target already has children
|| drag.source.connectorType == "output" // refuse to connect an output pin on another one
Expand Down Expand Up @@ -295,7 +293,7 @@ RowLayout {
}
}

state: (inputConnectMA.pressed && !attribute.isLink) ? "DraggingInput" : outputConnectMA.pressed ? "DraggingOutput" : ""
state: (inputConnectMA.pressed) ? "DraggingInput" : outputConnectMA.pressed ? "DraggingOutput" : ""

states: [
State {
Expand Down

0 comments on commit 36d410e

Please sign in to comment.