From 3ea721a2ed7055884bd564825ae59a3b5dbc7f48 Mon Sep 17 00:00:00 2001 From: ChemicalXandco <32775248+ChemicalXandco@users.noreply.github.com> Date: Fri, 9 Apr 2021 16:28:15 +0100 Subject: [PATCH] [ui] GraphEditor: allow replacing edges --- meshroom/ui/graph.py | 8 +++++++- meshroom/ui/qml/GraphEditor/AttributePin.qml | 6 ++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/meshroom/ui/graph.py b/meshroom/ui/graph.py index 73aed58ca3..4689add75d 100644 --- a/meshroom/ui/graph.py +++ b/meshroom/ui/graph.py @@ -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) diff --git a/meshroom/ui/qml/GraphEditor/AttributePin.qml b/meshroom/ui/qml/GraphEditor/AttributePin.qml index 705c3e5f4a..3b8e1083c6 100755 --- a/meshroom/ui/qml/GraphEditor/AttributePin.qml +++ b/meshroom/ui/qml/GraphEditor/AttributePin.qml @@ -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) @@ -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 @@ -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 @@ -295,7 +293,7 @@ RowLayout { } } - state: (inputConnectMA.pressed && !attribute.isLink) ? "DraggingInput" : outputConnectMA.pressed ? "DraggingOutput" : "" + state: (inputConnectMA.pressed) ? "DraggingInput" : outputConnectMA.pressed ? "DraggingOutput" : "" states: [ State {