mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-29 18:27:23 +02:00
[core][io] store nodes position in graph file
* increment file minor version (no incompatibility) * nodeFactory: reload file position if available
This commit is contained in:
parent
dfb0934ef4
commit
e2155ba962
2 changed files with 10 additions and 3 deletions
|
@ -162,7 +162,7 @@ class Graph(BaseObject):
|
||||||
|
|
||||||
class IO(object):
|
class IO(object):
|
||||||
""" Centralize Graph file keys and IO version. """
|
""" Centralize Graph file keys and IO version. """
|
||||||
__version__ = "1.0"
|
__version__ = "1.1"
|
||||||
|
|
||||||
class Keys(object):
|
class Keys(object):
|
||||||
""" File Keys. """
|
""" File Keys. """
|
||||||
|
@ -179,6 +179,7 @@ class Graph(BaseObject):
|
||||||
Header = "header"
|
Header = "header"
|
||||||
NodesVersions = "nodesVersions"
|
NodesVersions = "nodesVersions"
|
||||||
PrecomputedOutputs = "precomputedOutputs"
|
PrecomputedOutputs = "precomputedOutputs"
|
||||||
|
NodesPositions = "nodesPositions"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getFeaturesForVersion(fileVersion):
|
def getFeaturesForVersion(fileVersion):
|
||||||
|
@ -199,6 +200,8 @@ class Graph(BaseObject):
|
||||||
Graph.IO.Features.NodesVersions,
|
Graph.IO.Features.NodesVersions,
|
||||||
Graph.IO.Features.PrecomputedOutputs,
|
Graph.IO.Features.PrecomputedOutputs,
|
||||||
]
|
]
|
||||||
|
if fileVersion >= Version("1.1"):
|
||||||
|
features += [Graph.IO.Features.NodesPositions]
|
||||||
return features
|
return features
|
||||||
|
|
||||||
def __init__(self, name, parent=None):
|
def __init__(self, name, parent=None):
|
||||||
|
|
|
@ -669,6 +669,7 @@ class Node(BaseNode):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'nodeType': self.nodeType,
|
'nodeType': self.nodeType,
|
||||||
|
'position': self._position,
|
||||||
'parallelization': {
|
'parallelization': {
|
||||||
'blockSize': self.nodeDesc.parallelization.blockSize if self.isParallelized else 0,
|
'blockSize': self.nodeDesc.parallelization.blockSize if self.isParallelized else 0,
|
||||||
'size': self.size,
|
'size': self.size,
|
||||||
|
@ -883,6 +884,8 @@ class CompatibilityNode(BaseNode):
|
||||||
"""
|
"""
|
||||||
# update inputs to get up-to-date connections
|
# update inputs to get up-to-date connections
|
||||||
self.nodeDict.update({"inputs": self.inputs})
|
self.nodeDict.update({"inputs": self.inputs})
|
||||||
|
# update position
|
||||||
|
self.nodeDict.update({"position": self.position})
|
||||||
return self.nodeDict
|
return self.nodeDict
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -931,6 +934,7 @@ def nodeFactory(nodeDict, name=None):
|
||||||
outputs = nodeDict.get("outputs", {})
|
outputs = nodeDict.get("outputs", {})
|
||||||
version = nodeDict.get("version", None)
|
version = nodeDict.get("version", None)
|
||||||
internalFolder = nodeDict.get("internalFolder", None)
|
internalFolder = nodeDict.get("internalFolder", None)
|
||||||
|
position = Position(*nodeDict.get("position", []))
|
||||||
|
|
||||||
compatibilityIssue = None
|
compatibilityIssue = None
|
||||||
|
|
||||||
|
@ -956,11 +960,11 @@ def nodeFactory(nodeDict, name=None):
|
||||||
|
|
||||||
# no compatibility issues: instantiate a Node
|
# no compatibility issues: instantiate a Node
|
||||||
if compatibilityIssue is None:
|
if compatibilityIssue is None:
|
||||||
n = Node(nodeType, **inputs)
|
n = Node(nodeType, position, **inputs)
|
||||||
# otherwise, instantiate a CompatibilityNode
|
# otherwise, instantiate a CompatibilityNode
|
||||||
else:
|
else:
|
||||||
logging.warning("Compatibility issue detected for node '{}': {}".format(name, compatibilityIssue.name))
|
logging.warning("Compatibility issue detected for node '{}': {}".format(name, compatibilityIssue.name))
|
||||||
n = CompatibilityNode(nodeType, nodeDict, compatibilityIssue)
|
n = CompatibilityNode(nodeType, nodeDict, position, compatibilityIssue)
|
||||||
# retro-compatibility: no internal folder saved
|
# retro-compatibility: no internal folder saved
|
||||||
# can't spawn meaningful CompatibilityNode with precomputed outputs
|
# can't spawn meaningful CompatibilityNode with precomputed outputs
|
||||||
# => automatically try to perform node upgrade
|
# => automatically try to perform node upgrade
|
||||||
|
|
Loading…
Add table
Reference in a new issue