mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-06 04:41:58 +02:00
[core] Graph: add importGraphContent API
Extract the logic of importing the content of a graph within a graph instance from the graph loading logic. Add `Graph.importGraphContent` and `Graph.importGraphContentFromFile` methods. Use the deserialization API to load the content in another temporary graph instance, to handle the renaming of nodes using the Graph API, rather than manipulating entries in a raw dictionnary.
This commit is contained in:
parent
7eab289d30
commit
4aec741a89
4 changed files with 258 additions and 26 deletions
|
@ -6,9 +6,10 @@ from PySide6.QtGui import QUndoCommand, QUndoStack
|
|||
from PySide6.QtCore import Property, Signal
|
||||
|
||||
from meshroom.core.attribute import ListAttribute, Attribute
|
||||
from meshroom.core.graph import GraphModification
|
||||
from meshroom.core.graph import Graph, GraphModification
|
||||
from meshroom.core.node import Position
|
||||
from meshroom.core.nodeFactory import nodeFactory
|
||||
from meshroom.core.typing import PathLike
|
||||
|
||||
|
||||
class UndoCommand(QUndoCommand):
|
||||
|
@ -232,7 +233,8 @@ class ImportProjectCommand(GraphCommand):
|
|||
"""
|
||||
Handle the import of a project into a Graph.
|
||||
"""
|
||||
def __init__(self, graph, filepath=None, position=None, yOffset=0, parent=None):
|
||||
|
||||
def __init__(self, graph: Graph, filepath: PathLike, position=None, yOffset=0, parent=None):
|
||||
super(ImportProjectCommand, self).__init__(graph, parent)
|
||||
self.filepath = filepath
|
||||
self.importedNames = []
|
||||
|
@ -240,9 +242,8 @@ class ImportProjectCommand(GraphCommand):
|
|||
self.yOffset = yOffset
|
||||
|
||||
def redoImpl(self):
|
||||
status = self.graph.load(self.filepath, setupProjectFile=False, importProject=True)
|
||||
importedNodes = self.graph.importedNodes
|
||||
self.setText("Import Project ({} nodes)".format(importedNodes.count))
|
||||
importedNodes = self.graph.importGraphContentFromFile(self.filepath)
|
||||
self.setText(f"Import Project ({len(importedNodes)} nodes)")
|
||||
|
||||
lowestY = 0
|
||||
for node in self.graph.nodes:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue