Skip to content

Commit 0586336

Browse files
authored
Merge pull request #2624 from alicevision/fix/NodeEditorTab
[ui] NodeEditor: Addressed Tab Retention when switching Node selection
2 parents faff99f + 3f47c54 commit 0586336

File tree

4 files changed

+222
-187
lines changed

4 files changed

+222
-187
lines changed

meshroom/core/graph.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ def __init__(self, name, parent=None):
215215
super(Graph, self).__init__(parent)
216216
self.name = name
217217
self._loading = False
218+
self._saving = False
218219
self._updateEnabled = True
219220
self._updateRequested = False
220221
self.dirtyTopology = False
@@ -251,6 +252,11 @@ def fileFeatures(self):
251252
def isLoading(self):
252253
""" Return True if the graph is currently being loaded. """
253254
return self._loading
255+
256+
@property
257+
def isSaving(self):
258+
""" Return True if the graph is currently being saved. """
259+
return self._saving
254260

255261
@Slot(str)
256262
def load(self, filepath, setupProjectFile=True, importProject=False, publishOutputs=False):
@@ -1347,6 +1353,23 @@ def asString(self):
13471353
return str(self.toDict())
13481354

13491355
def save(self, filepath=None, setupProjectFile=True, template=False):
1356+
"""
1357+
Save the current Meshroom graph as a serialized ".mg" file.
1358+
1359+
Args:
1360+
filepath: project filepath to save as.
1361+
setupProjectFile: Store the reference to the project file and setup the cache directory.
1362+
If false, it only saves the graph of the project file as a template.
1363+
template: If true, saves the current graph as a template.
1364+
"""
1365+
# Update the saving flag indicating that the current graph is being saved
1366+
self._saving = True
1367+
try:
1368+
self._save(filepath=filepath, setupProjectFile=setupProjectFile, template=template)
1369+
finally:
1370+
self._saving = False
1371+
1372+
def _save(self, filepath=None, setupProjectFile=True, template=False):
13501373
path = filepath or self._filepath
13511374
if not path:
13521375
raise ValueError("filepath must be specified for unsaved files.")
@@ -1636,6 +1659,7 @@ def setVerbose(self, v):
16361659
edges = Property(BaseObject, edges.fget, constant=True)
16371660
filepathChanged = Signal()
16381661
filepath = Property(str, lambda self: self._filepath, notify=filepathChanged)
1662+
isSaving = Property(bool, isSaving.fget, constant=True)
16391663
fileReleaseVersion = Property(str, lambda self: self.header.get(Graph.IO.Keys.ReleaseVersion, "0.0"),
16401664
notify=filepathChanged)
16411665
fileDateVersion = Property(float, fileDateVersion.fget, fileDateVersion.fset, notify=filepathChanged)

meshroom/ui/qml/Application.qml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ Page {
2020
property alias unsavedDialog: unsavedDialog
2121
property alias workspaceView: workspaceView
2222

23+
readonly property var scenefile: _reconstruction ? _reconstruction.graph.filepath : "";
24+
25+
onScenefileChanged: {
26+
// Check if we're not currently saving and emit the currentProjectChanged signal
27+
if (! _reconstruction.graph.isSaving) {
28+
// Refresh the NodeEditor
29+
nodeEditor.refresh();
30+
}
31+
}
32+
2333
Settings {
2434
id: settingsUILayout
2535
category: "UILayout"

meshroom/ui/qml/GraphEditor/NodeEditor.qml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ Panel {
4242
}
4343
}
4444

45+
function refresh() {
46+
/**
47+
* Refresh properties of the Node Editor.
48+
*/
49+
// Reset tab bar's current index
50+
tabBar.currentIndex = 0;
51+
}
52+
4553
headerBar: RowLayout {
4654
Label {
4755
id: computationInfo
@@ -372,6 +380,9 @@ Panel {
372380

373381
property bool isComputable: root.node !== null && root.node.isComputable
374382

383+
// The indices of the tab bar which can be shown for incomputable nodes
384+
readonly property var nonComputableTabIndices: [0, 4, 5];
385+
375386
Layout.fillWidth: true
376387
width: childrenRect.width
377388
position: TabBar.Footer
@@ -415,9 +426,11 @@ Panel {
415426
rightPadding: leftPadding
416427
}
417428

418-
onIsComputableChanged: {
419-
if (!isComputable) {
420-
tabBar.currentIndex = 0
429+
onVisibleChanged: {
430+
// If we have a node selected and the node is not Computable
431+
// Reset the currentIndex to 0, if the current index is not allowed for an incomputable node
432+
if ((root.node && !root.node.isComputable) && (nonComputableTabIndices.indexOf(tabBar.currentIndex) === -1)) {
433+
tabBar.currentIndex = 0;
421434
}
422435
}
423436
}

0 commit comments

Comments
 (0)