Skip to content

Commit

Permalink
[ui] Graph: Add clearSelectedNodesData method
Browse files Browse the repository at this point in the history
Convenient function to directly work on the current node selection.
  • Loading branch information
yann-lty committed Nov 25, 2024
1 parent 1e4c731 commit 3e77ebc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions meshroom/ui/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,21 +813,24 @@ def collapseForLoop(self, currentEdge):
# update the edges from allSrc
allSrc = [e.src for e in self._graph.edges.values()]

@Slot()
def clearSelectedNodesData(self):
"""Clear data from all selected nodes."""
self.clearData(self.iterSelectedNodes())

@Slot(QObject)
def clearData(self, nodes):
@Slot(list)
def clearData(self, nodes: list[Node]):
""" Clear data from 'nodes'. """
nodes = self.filterNodes(nodes)
for n in nodes:
n.clearData()

@Slot(QObject)
def clearDataFrom(self, nodes):
@Slot(list)
def clearDataFrom(self, nodes: list[Node]):
"""
Clear data from all nodes starting from 'nodes' to graph leaves.
Args:
nodes (list[Node]): the nodes to start from.
nodes: The nodes to start from.
"""
self.clearData(self._graph.dfsOnDiscover(startNodes=nodes, reverse=True, dependenciesOnly=True)[0])

Expand Down
2 changes: 1 addition & 1 deletion meshroom/ui/qml/GraphEditor/GraphEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ Item {
if (deleteFollowing)
uigraph.clearDataFrom(uigraph.selectedNodes);
else
uigraph.clearData(uigraph.selectedNodes);
uigraph.clearSelectedNodesData();
dataDeleted();
}
onClosed: destroy()
Expand Down

0 comments on commit 3e77ebc

Please sign in to comment.