Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/alicevision/meshroom.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabien Castan <fabcastan@gmail.com>2022-09-29 00:06:54 +0300
committerGitHub <noreply@github.com>2022-09-29 00:06:54 +0300
commit243c278bccea56aaddbd7366b63fea6a4ce20456 (patch)
treea62803c3e952d17b5a58a24aaed83680b177bf15
parent5079bba633d3623e8fc9b559c3b598c9a8c3d31e (diff)
parentd0fcb67d1cfc5afe66b602a9e29d4bd746367086 (diff)
Merge pull request #1778 from alicevision/dev/lv/useLastPathForOpenSave
Use most recent project as base folder for file dialogs
-rw-r--r--meshroom/core/graph.py20
-rwxr-xr-xmeshroom/ui/commands.py12
-rw-r--r--meshroom/ui/graph.py4
-rwxr-xr-xmeshroom/ui/qml/main.qml57
4 files changed, 54 insertions, 39 deletions
diff --git a/meshroom/core/graph.py b/meshroom/core/graph.py
index 02c9d177..c20dd2b3 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"])
@@ -1404,7 +1404,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 42696ad6..db218e19 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)
}
}
@@ -450,7 +450,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)"
onTriggered: graphEditor.pasteNodes()
}
@@ -460,6 +460,20 @@ ApplicationWindow {
onTriggered: _PaletteManager.togglePalette()
}
+
+ // Utility functions for elements in the menubar
+
+ function initFileDialogFolder(dialog) {
+ if(_reconstruction.graph && _reconstruction.graph.filepath) {
+ dialog.folder = Filepath.stringToUrl(Filepath.dirname(_reconstruction.graph.filepath));
+ } else {
+ var projects = MeshroomApp.recentProjectFiles;
+ if (projects.length > 0 && Filepath.exists(projects[0])) {
+ dialog.folder = Filepath.stringToUrl(Filepath.dirname(projects[0]));
+ }
+ }
+ }
+
header: MenuBar {
palette.window: Qt.darker(activePalette.window, 1.15)
Menu {
@@ -509,10 +523,8 @@ ApplicationWindow {
text: "Open"
shortcut: "Ctrl+O"
onTriggered: ensureSaved(function() {
- if(_reconstruction.graph && _reconstruction.graph.filepath) {
- openFileDialog.folder = Filepath.stringToUrl(Filepath.dirname(_reconstruction.graph.filepath))
- }
- openFileDialog.open()
+ initFileDialogFolder(openFileDialog);
+ openFileDialog.open();
})
}
Menu {
@@ -556,16 +568,22 @@ ApplicationWindow {
}
}
Action {
- id: importSceneAction
- text: "Import Scene"
+ id: importProjectAction
+ text: "Import Project"
shortcut: "Ctrl+Shift+I"
- onTriggered: importSceneDialog.open()
+ onTriggered: {
+ initFileDialogFolder(importProjectDialog);
+ importProjectDialog.open();
+ }
}
Action {
id: importActionItem
text: "Import Images"
shortcut: "Ctrl+I"
- onTriggered: importFilesDialog.open()
+ onTriggered: {
+ initFileDialogFolder(importFilesDialog);
+ importFilesDialog.open();
+ }
}
Action {
@@ -602,7 +620,8 @@ ApplicationWindow {
}
else
{
- saveFileDialog.open()
+ initFileDialogFolder(saveFileDialog);
+ saveFileDialog.open();
}
}
}
@@ -611,10 +630,8 @@ ApplicationWindow {
text: "Save As..."
shortcut: "Ctrl+Shift+S"
onTriggered: {
- if(_reconstruction.graph && _reconstruction.graph.filepath) {
- saveFileDialog.folder = Filepath.stringToUrl(Filepath.dirname(_reconstruction.graph.filepath))
- }
- saveFileDialog.open()
+ initFileDialogFolder(saveFileDialog);
+ saveFileDialog.open();
}
}
Action {
@@ -622,10 +639,8 @@ ApplicationWindow {
text: "Save As Template..."
shortcut: "Ctrl+Shift+T"
onTriggered: {
- if(_reconstruction.graph && _reconstruction.graph.filepath) {
- saveTemplateDialog.folder = Filepath.stringToUrl(Filepath.dirname(_reconstruction.graph.filepath))
- }
- saveTemplateDialog.open()
+ initFileDialogFolder(saveTemplateDialog);
+ saveTemplateDialog.open();
}
}
MenuSeparator { }