diff --git a/meshroom/core/graph.py b/meshroom/core/graph.py index 8b7e8487..e2a75edd 100644 --- a/meshroom/core/graph.py +++ b/meshroom/core/graph.py @@ -241,7 +241,7 @@ class Graph(BaseObject): return Graph.IO.getFeaturesForVersion(self.header.get(Graph.IO.Keys.FileVersion, "0.0")) @Slot(str) - def load(self, filepath, setupProjectFile=True, importScene=False): + def load(self, filepath, setupProjectFile=True, importProject=False): """ Load a meshroom graph ".mg" file. @@ -250,7 +250,7 @@ class Graph(BaseObject): setupProjectFile: Store the reference to the project file and setup the cache directory. If false, it only loads the graph of the project file as a template. """ - if not importScene: + if not importProject: self.clear() with open(filepath) as jsonFile: fileData = json.load(jsonFile) @@ -258,9 +258,9 @@ class Graph(BaseObject): # older versions of Meshroom files only contained the serialized nodes graphData = fileData.get(Graph.IO.Keys.Graph, fileData) - if importScene: + if importProject: self._importedNodes.clear() - graphData = self.updateImportedScene(graphData) + graphData = self.updateImportedProject(graphData) if not isinstance(graphData, dict): raise RuntimeError('loadGraph error: Graph is not a dict. File: {}'.format(filepath)) @@ -289,7 +289,7 @@ class Graph(BaseObject): # Add node to the graph with raw attributes values self._addNode(n, nodeName) - if importScene: + if importProject: self._importedNodes.add(n) # Create graph edges by resolving attributes expressions @@ -302,12 +302,12 @@ class Graph(BaseObject): return True - def updateImportedScene(self, data): + def updateImportedProject(self, data): """ - Update the names and links of the scene to import so that it can fit + Update the names and links of the project to import so that it can fit correctly in the existing graph. - Parse all the nodes from the scene that is going to be imported. + Parse all the nodes from the project that is going to be imported. If their name already exists in the graph, replace them with new names, then parse all the nodes' inputs/outputs to replace the old names with the new ones in the links. @@ -336,7 +336,7 @@ class Graph(BaseObject): # First pass to get all the names that already exist in the graph, update them, and keep track of the changes for nodeName, nodeData in sorted(data.items(), key=lambda x: self.getNodeIndexFromName(x[0])): if not isinstance(nodeData, dict): - raise RuntimeError('updateImportedScene error: Node is not a dict.') + raise RuntimeError('updateImportedProject error: Node is not a dict.') if nodeName in self._nodes.keys() or nodeName in updatedData.keys(): newName = createUniqueNodeName(self._nodes.keys(), nodeData["nodeType"]) @@ -1403,7 +1403,7 @@ class Graph(BaseObject): @property def importedNodes(self): - """" Return the list of nodes that were added to the graph with the latest 'Import Scene' action. """ + """" Return the list of nodes that were added to the graph with the latest 'Import Project' action. """ return self._importedNodes @property diff --git a/meshroom/ui/commands.py b/meshroom/ui/commands.py index c34d674b..a5db90ae 100755 --- a/meshroom/ui/commands.py +++ b/meshroom/ui/commands.py @@ -206,7 +206,7 @@ class PasteNodesCommand(GraphCommand): self.nodeNames = [] def redoImpl(self): - data = self.graph.updateImportedScene(self.data) + data = self.graph.updateImportedProject(self.data) nodes = self.graph.pasteNodes(data, self.position) self.nodeNames = [node.name for node in nodes] self.setText("Paste Node{} ({})".format("s" if len(self.nodeNames) > 1 else "", ", ".join(self.nodeNames))) @@ -217,20 +217,20 @@ class PasteNodesCommand(GraphCommand): self.graph.removeNode(name) -class ImportSceneCommand(GraphCommand): +class ImportProjectCommand(GraphCommand): """ - Handle the import of a scene into a Graph. + Handle the import of a project into a Graph. """ def __init__(self, graph, filepath=None, yOffset=0, parent=None): - super(ImportSceneCommand, self).__init__(graph, parent) + super(ImportProjectCommand, self).__init__(graph, parent) self.filepath = filepath self.importedNames = [] self.yOffset = yOffset def redoImpl(self): - status = self.graph.load(self.filepath, setupProjectFile=False, importScene=True) + status = self.graph.load(self.filepath, setupProjectFile=False, importProject=True) importedNodes = self.graph.importedNodes - self.setText("Import Scene ({} nodes)".format(importedNodes.count)) + self.setText("Import Project ({} nodes)".format(importedNodes.count)) lowestY = 0 for node in self.graph.nodes: diff --git a/meshroom/ui/graph.py b/meshroom/ui/graph.py index c615137c..16c58dac 100644 --- a/meshroom/ui/graph.py +++ b/meshroom/ui/graph.py @@ -354,7 +354,7 @@ class UIGraph(QObject): return status @Slot(QUrl, result=bool) - def importScene(self, filepath): + def importProject(self, filepath): if isinstance(filepath, (QUrl)): # depending how the QUrl has been initialized, # toLocalFile() may return the local path or an empty string @@ -364,7 +364,7 @@ class UIGraph(QObject): else: localFile = filepath yOffset = self.layout.gridSpacing + self.layout.nodeHeight - return self.push(commands.ImportSceneCommand(self._graph, localFile, yOffset=yOffset)) + return self.push(commands.ImportProjectCommand(self._graph, localFile, yOffset=yOffset)) @Slot(QUrl) def saveAs(self, url): diff --git a/meshroom/ui/qml/main.qml b/meshroom/ui/qml/main.qml index eab3cc74..846605ad 100755 --- a/meshroom/ui/qml/main.qml +++ b/meshroom/ui/qml/main.qml @@ -322,12 +322,12 @@ ApplicationWindow { } FileDialog { - id: importSceneDialog - title: "Import Scene" + id: importProjectDialog + title: "Import Project" selectMultiple: false nameFilters: ["Meshroom Graphs (*.mg)"] onAccepted: { - graphEditor.uigraph.importScene(importSceneDialog.fileUrl) + graphEditor.uigraph.importProject(importProjectDialog.fileUrl) } } @@ -451,7 +451,7 @@ ApplicationWindow { Action { id: pasteAction - property string tooltip: "Paste the clipboard content to the scene if it contains valid nodes" + property string tooltip: "Paste the clipboard content to the project if it contains valid nodes" text: "Paste Node(s)" shortcut: "Ctrl+V" onTriggered: graphEditor.pasteNodes() @@ -570,12 +570,12 @@ ApplicationWindow { } } Action { - id: importSceneAction - text: "Import Scene" + id: importProjectAction + text: "Import Project" shortcut: "Ctrl+Shift+I" onTriggered: { - initFileDialogFolder(importSceneDialog); - importSceneDialog.open(); + initFileDialogFolder(importProjectDialog); + importProjectDialog.open(); } } Action {