mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-19 20:16:30 +02:00
[ui] rename Import Scene to Import Project for coherent naming
This commit is contained in:
parent
f4352e5254
commit
d0fcb67d1c
4 changed files with 26 additions and 26 deletions
|
@ -241,7 +241,7 @@ class Graph(BaseObject):
|
||||||
return Graph.IO.getFeaturesForVersion(self.header.get(Graph.IO.Keys.FileVersion, "0.0"))
|
return Graph.IO.getFeaturesForVersion(self.header.get(Graph.IO.Keys.FileVersion, "0.0"))
|
||||||
|
|
||||||
@Slot(str)
|
@Slot(str)
|
||||||
def load(self, filepath, setupProjectFile=True, importScene=False):
|
def load(self, filepath, setupProjectFile=True, importProject=False):
|
||||||
"""
|
"""
|
||||||
Load a meshroom graph ".mg" file.
|
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.
|
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 false, it only loads the graph of the project file as a template.
|
||||||
"""
|
"""
|
||||||
if not importScene:
|
if not importProject:
|
||||||
self.clear()
|
self.clear()
|
||||||
with open(filepath) as jsonFile:
|
with open(filepath) as jsonFile:
|
||||||
fileData = json.load(jsonFile)
|
fileData = json.load(jsonFile)
|
||||||
|
@ -258,9 +258,9 @@ class Graph(BaseObject):
|
||||||
# older versions of Meshroom files only contained the serialized nodes
|
# older versions of Meshroom files only contained the serialized nodes
|
||||||
graphData = fileData.get(Graph.IO.Keys.Graph, fileData)
|
graphData = fileData.get(Graph.IO.Keys.Graph, fileData)
|
||||||
|
|
||||||
if importScene:
|
if importProject:
|
||||||
self._importedNodes.clear()
|
self._importedNodes.clear()
|
||||||
graphData = self.updateImportedScene(graphData)
|
graphData = self.updateImportedProject(graphData)
|
||||||
|
|
||||||
if not isinstance(graphData, dict):
|
if not isinstance(graphData, dict):
|
||||||
raise RuntimeError('loadGraph error: Graph is not a dict. File: {}'.format(filepath))
|
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
|
# Add node to the graph with raw attributes values
|
||||||
self._addNode(n, nodeName)
|
self._addNode(n, nodeName)
|
||||||
|
|
||||||
if importScene:
|
if importProject:
|
||||||
self._importedNodes.add(n)
|
self._importedNodes.add(n)
|
||||||
|
|
||||||
# Create graph edges by resolving attributes expressions
|
# Create graph edges by resolving attributes expressions
|
||||||
|
@ -302,12 +302,12 @@ class Graph(BaseObject):
|
||||||
|
|
||||||
return True
|
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.
|
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,
|
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
|
then parse all the nodes' inputs/outputs to replace the old names with
|
||||||
the new ones in the links.
|
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
|
# 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])):
|
for nodeName, nodeData in sorted(data.items(), key=lambda x: self.getNodeIndexFromName(x[0])):
|
||||||
if not isinstance(nodeData, dict):
|
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():
|
if nodeName in self._nodes.keys() or nodeName in updatedData.keys():
|
||||||
newName = createUniqueNodeName(self._nodes.keys(), nodeData["nodeType"])
|
newName = createUniqueNodeName(self._nodes.keys(), nodeData["nodeType"])
|
||||||
|
@ -1403,7 +1403,7 @@ class Graph(BaseObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def importedNodes(self):
|
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
|
return self._importedNodes
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -206,7 +206,7 @@ class PasteNodesCommand(GraphCommand):
|
||||||
self.nodeNames = []
|
self.nodeNames = []
|
||||||
|
|
||||||
def redoImpl(self):
|
def redoImpl(self):
|
||||||
data = self.graph.updateImportedScene(self.data)
|
data = self.graph.updateImportedProject(self.data)
|
||||||
nodes = self.graph.pasteNodes(data, self.position)
|
nodes = self.graph.pasteNodes(data, self.position)
|
||||||
self.nodeNames = [node.name for node in nodes]
|
self.nodeNames = [node.name for node in nodes]
|
||||||
self.setText("Paste Node{} ({})".format("s" if len(self.nodeNames) > 1 else "", ", ".join(self.nodeNames)))
|
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)
|
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):
|
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.filepath = filepath
|
||||||
self.importedNames = []
|
self.importedNames = []
|
||||||
self.yOffset = yOffset
|
self.yOffset = yOffset
|
||||||
|
|
||||||
def redoImpl(self):
|
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
|
importedNodes = self.graph.importedNodes
|
||||||
self.setText("Import Scene ({} nodes)".format(importedNodes.count))
|
self.setText("Import Project ({} nodes)".format(importedNodes.count))
|
||||||
|
|
||||||
lowestY = 0
|
lowestY = 0
|
||||||
for node in self.graph.nodes:
|
for node in self.graph.nodes:
|
||||||
|
|
|
@ -354,7 +354,7 @@ class UIGraph(QObject):
|
||||||
return status
|
return status
|
||||||
|
|
||||||
@Slot(QUrl, result=bool)
|
@Slot(QUrl, result=bool)
|
||||||
def importScene(self, filepath):
|
def importProject(self, filepath):
|
||||||
if isinstance(filepath, (QUrl)):
|
if isinstance(filepath, (QUrl)):
|
||||||
# depending how the QUrl has been initialized,
|
# depending how the QUrl has been initialized,
|
||||||
# toLocalFile() may return the local path or an empty string
|
# toLocalFile() may return the local path or an empty string
|
||||||
|
@ -364,7 +364,7 @@ class UIGraph(QObject):
|
||||||
else:
|
else:
|
||||||
localFile = filepath
|
localFile = filepath
|
||||||
yOffset = self.layout.gridSpacing + self.layout.nodeHeight
|
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)
|
@Slot(QUrl)
|
||||||
def saveAs(self, url):
|
def saveAs(self, url):
|
||||||
|
|
|
@ -322,12 +322,12 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDialog {
|
FileDialog {
|
||||||
id: importSceneDialog
|
id: importProjectDialog
|
||||||
title: "Import Scene"
|
title: "Import Project"
|
||||||
selectMultiple: false
|
selectMultiple: false
|
||||||
nameFilters: ["Meshroom Graphs (*.mg)"]
|
nameFilters: ["Meshroom Graphs (*.mg)"]
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
graphEditor.uigraph.importScene(importSceneDialog.fileUrl)
|
graphEditor.uigraph.importProject(importProjectDialog.fileUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,7 +451,7 @@ ApplicationWindow {
|
||||||
Action {
|
Action {
|
||||||
id: pasteAction
|
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)"
|
text: "Paste Node(s)"
|
||||||
shortcut: "Ctrl+V"
|
shortcut: "Ctrl+V"
|
||||||
onTriggered: graphEditor.pasteNodes()
|
onTriggered: graphEditor.pasteNodes()
|
||||||
|
@ -570,12 +570,12 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
id: importSceneAction
|
id: importProjectAction
|
||||||
text: "Import Scene"
|
text: "Import Project"
|
||||||
shortcut: "Ctrl+Shift+I"
|
shortcut: "Ctrl+Shift+I"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
initFileDialogFolder(importSceneDialog);
|
initFileDialogFolder(importProjectDialog);
|
||||||
importSceneDialog.open();
|
importProjectDialog.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue