mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-20 20:46:28 +02:00
[commands] use new Graph.attribute method
This commit is contained in:
parent
7f78fac119
commit
c004e2af91
1 changed files with 16 additions and 19 deletions
|
@ -106,11 +106,9 @@ class RemoveNodeCommand(GraphCommand):
|
||||||
), self.nodeName)
|
), self.nodeName)
|
||||||
assert (node.getName() == self.nodeName)
|
assert (node.getName() == self.nodeName)
|
||||||
# recreate out edges deleted on node removal
|
# recreate out edges deleted on node removal
|
||||||
for key, value in self.outEdges.items():
|
for dstAttr, srcAttr in self.outEdges.items():
|
||||||
dstNode, dstAttr = key.split(".")
|
self.graph.addEdge(self.graph.attribute(srcAttr),
|
||||||
srcNode, srcAttr = value.split(".")
|
self.graph.attribute(dstAttr))
|
||||||
self.graph.addEdge(self.graph.node(srcNode).attribute(srcAttr),
|
|
||||||
self.graph.node(dstNode).attribute(dstAttr))
|
|
||||||
|
|
||||||
node.updateInternals()
|
node.updateInternals()
|
||||||
|
|
||||||
|
@ -118,8 +116,7 @@ class RemoveNodeCommand(GraphCommand):
|
||||||
class SetAttributeCommand(GraphCommand):
|
class SetAttributeCommand(GraphCommand):
|
||||||
def __init__(self, graph, attribute, value, parent=None):
|
def __init__(self, graph, attribute, value, parent=None):
|
||||||
super(SetAttributeCommand, self).__init__(graph, parent)
|
super(SetAttributeCommand, self).__init__(graph, parent)
|
||||||
self.nodeName = attribute.node.getName()
|
self.attrName = attribute.fullName()
|
||||||
self.attrName = attribute.getName()
|
|
||||||
self.value = value
|
self.value = value
|
||||||
self.oldValue = attribute.value
|
self.oldValue = attribute.value
|
||||||
self.setText("Set Attribute '{}'".format(attribute.fullName()))
|
self.setText("Set Attribute '{}'".format(attribute.fullName()))
|
||||||
|
@ -137,33 +134,33 @@ class SetAttributeCommand(GraphCommand):
|
||||||
class AddEdgeCommand(GraphCommand):
|
class AddEdgeCommand(GraphCommand):
|
||||||
def __init__(self, graph, src, dst, parent=None):
|
def __init__(self, graph, src, dst, parent=None):
|
||||||
super(AddEdgeCommand, self).__init__(graph, parent)
|
super(AddEdgeCommand, self).__init__(graph, parent)
|
||||||
self.srcNode, self.srcAttr = src.fullName().split(".")
|
self.srcAttr = src.fullName()
|
||||||
self.dstNode, self.dstAttr = dst.fullName().split(".")
|
self.dstAttr = dst.fullName()
|
||||||
self.setText("Connect '{}'->'{}'".format(src.fullName(), dst.fullName()))
|
self.setText("Connect '{}'->'{}'".format(self.srcAttr, self.dstAttr))
|
||||||
|
|
||||||
def redoImpl(self):
|
def redoImpl(self):
|
||||||
try:
|
try:
|
||||||
self.graph.addEdge(self.graph.node(self.srcNode).attribute(self.srcAttr),
|
self.graph.addEdge(self.graph.attribute(self.srcAttr),
|
||||||
self.graph.node(self.dstNode).attribute(self.dstAttr))
|
self.graph.attribute(self.dstAttr))
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def undoImpl(self):
|
def undoImpl(self):
|
||||||
self.graph.removeEdge(self.graph.node(self.dstNode).attribute(self.dstAttr))
|
self.graph.removeEdge(self.graph.attribute(self.dstAttr))
|
||||||
|
|
||||||
|
|
||||||
class RemoveEdgeCommand(GraphCommand):
|
class RemoveEdgeCommand(GraphCommand):
|
||||||
def __init__(self, graph, edge, parent=None):
|
def __init__(self, graph, edge, parent=None):
|
||||||
super(RemoveEdgeCommand, self).__init__(graph, parent)
|
super(RemoveEdgeCommand, self).__init__(graph, parent)
|
||||||
self.srcNode, self.srcAttr = edge.src.fullName().split(".")
|
self.srcAttr = edge.src.fullName()
|
||||||
self.dstNode, self.dstAttr = edge.dst.fullName().split(".")
|
self.dstAttr = edge.dst.fullName()
|
||||||
self.setText("Disconnect '{}'->'{}'".format(edge.src.fullName(), edge.dst.fullName()))
|
self.setText("Disconnect '{}'->'{}'".format(self.srcAttr, self.dstAttr))
|
||||||
|
|
||||||
def redoImpl(self):
|
def redoImpl(self):
|
||||||
self.graph.removeEdge(self.graph.node(self.dstNode).attribute(self.dstAttr))
|
self.graph.removeEdge(self.graph.attribute(self.dstAttr))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def undoImpl(self):
|
def undoImpl(self):
|
||||||
self.graph.addEdge(self.graph.node(self.srcNode).attribute(self.srcAttr),
|
self.graph.addEdge(self.graph.attribute(self.srcAttr),
|
||||||
self.graph.node(self.dstNode).attribute(self.dstAttr))
|
self.graph.attribute(self.dstAttr))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue