mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-09 21:07:20 +02:00
[ui][commands] expose UpgradeNode command
This commit is contained in:
parent
1d309136ec
commit
a18d75c0f9
2 changed files with 34 additions and 1 deletions
|
@ -229,6 +229,34 @@ class ListAttributeRemoveCommand(GraphCommand):
|
||||||
listAttribute.insert(self.index, self.value)
|
listAttribute.insert(self.index, self.value)
|
||||||
|
|
||||||
|
|
||||||
|
class UpgradeNodeCommand(GraphCommand):
|
||||||
|
"""
|
||||||
|
Perform node upgrade on a CompatibilityNode.
|
||||||
|
"""
|
||||||
|
def __init__(self, graph, node, parent=None):
|
||||||
|
super(UpgradeNodeCommand, self).__init__(graph, parent)
|
||||||
|
self.nodeDict = node.toDict()
|
||||||
|
self.nodeName = node.getName()
|
||||||
|
self.outEdges = {}
|
||||||
|
self.setText("Upgrade Node {}".format(self.nodeName))
|
||||||
|
|
||||||
|
def redoImpl(self):
|
||||||
|
inEdges, self.outEdges = self.graph.upgradeNode(self.nodeName)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def undoImpl(self):
|
||||||
|
# delete upgraded node
|
||||||
|
self.graph.removeNode(self.nodeName)
|
||||||
|
# recreate compatibility node
|
||||||
|
with GraphModification(self.graph):
|
||||||
|
node = node_factory(self.nodeDict)
|
||||||
|
self.graph.addNode(node, self.nodeName)
|
||||||
|
# recreate out edges
|
||||||
|
for dstAttr, srcAttr in self.outEdges.items():
|
||||||
|
self.graph.addEdge(self.graph.attribute(srcAttr),
|
||||||
|
self.graph.attribute(dstAttr))
|
||||||
|
|
||||||
|
|
||||||
class EnableGraphUpdateCommand(GraphCommand):
|
class EnableGraphUpdateCommand(GraphCommand):
|
||||||
""" Command to enable/disable graph update.
|
""" Command to enable/disable graph update.
|
||||||
Should not be used directly, use GroupedGraphModification context manager instead.
|
Should not be used directly, use GroupedGraphModification context manager instead.
|
||||||
|
|
|
@ -9,7 +9,7 @@ from PySide2.QtCore import Slot, QJsonValue, QObject, QUrl, Property, Signal
|
||||||
from meshroom.common.qt import QObjectListModel
|
from meshroom.common.qt import QObjectListModel
|
||||||
from meshroom.core.attribute import Attribute, ListAttribute
|
from meshroom.core.attribute import Attribute, ListAttribute
|
||||||
from meshroom.core.graph import Graph, Edge, submitGraph, executeGraph
|
from meshroom.core.graph import Graph, Edge, submitGraph, executeGraph
|
||||||
from meshroom.core.node import NodeChunk, Node, Status
|
from meshroom.core.node import NodeChunk, Node, Status, CompatibilityNode
|
||||||
from meshroom.ui import commands
|
from meshroom.ui import commands
|
||||||
|
|
||||||
|
|
||||||
|
@ -353,6 +353,11 @@ class UIGraph(QObject):
|
||||||
"""
|
"""
|
||||||
return self.duplicateNodesFromNode(fromNode).values()
|
return self.duplicateNodesFromNode(fromNode).values()
|
||||||
|
|
||||||
|
@Slot(CompatibilityNode)
|
||||||
|
def upgradeNode(self, node):
|
||||||
|
""" Upgrade a CompatibilityNode. """
|
||||||
|
self.push(commands.UpgradeNodeCommand(self._graph, node))
|
||||||
|
|
||||||
@Slot(Attribute, QJsonValue)
|
@Slot(Attribute, QJsonValue)
|
||||||
def appendAttribute(self, attribute, value=QJsonValue()):
|
def appendAttribute(self, attribute, value=QJsonValue()):
|
||||||
if isinstance(value, QJsonValue):
|
if isinstance(value, QJsonValue):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue