[ui] GraphEditor: Improved node status computable/submitable checks

This commit is contained in:
Fabien Castan 2025-04-13 12:55:55 +02:00
parent 38e82b926f
commit c01aefc4f3
2 changed files with 15 additions and 16 deletions

View file

@ -330,7 +330,7 @@ class TaskManager(BaseObject):
def checkNodesDependencies(self, graph, toNodes, context): def checkNodesDependencies(self, graph, toNodes, context):
""" """
Check dependencies of nodes to process. Check dependencies of nodes to process.
Update toNodes with computable/submittable nodes only. Update toNodes with computable/submitable nodes only.
Returns: Returns:
bool: True if all the nodes can be processed. False otherwise. bool: True if all the nodes can be processed. False otherwise.

View file

@ -574,35 +574,34 @@ Item {
}); });
} }
readonly property bool isSelectionOnlyComputableNodes: { readonly property bool selectionContainsComputableNodes: {
return uigraph.nodeSelection.selectedIndexes.every(function(idx) { return uigraph.nodeSelection.selectedIndexes.some(function(idx) {
const node = uigraph.graph.nodes.at(idx.row); const node = uigraph.graph.nodes.at(idx.row);
return ( return node.isComputable;
node.isComputable
&& uigraph.graph.canComputeTopologically(node)
);
}); });
} }
readonly property bool canSelectionBeComputed: { readonly property bool canSelectionBeComputed: {
if(!isSelectionOnlyComputableNodes) if(!selectionContainsComputableNodes)
return false; return false;
if(isSelectionFullyComputed) if(isSelectionFullyComputed)
return true; return true;
return uigraph.nodeSelection.selectedIndexes.every(function(idx) { var b = uigraph.nodeSelection.selectedIndexes.every(function(idx) {
const node = uigraph.graph.nodes.at(idx.row); const node = uigraph.graph.nodes.at(idx.row);
return ( return (
node.isComputed node.isComputed ||
(uigraph.graph.canComputeTopologically(node) &&
// canCompute if canSubmitOrCompute == 1(can compute) or 3(can compute & submit) // canCompute if canSubmitOrCompute == 1(can compute) or 3(can compute & submit)
|| nodeSubmitOrComputeStatus[node] % 2 == 1 nodeSubmitOrComputeStatus[node] % 2 == 1)
); );
}); });
return b
} }
readonly property bool isSelectionSubmittable: uigraph.canSubmit && isSelectionOnlyComputableNodes readonly property bool isSelectionSubmitable: uigraph.canSubmit && selectionContainsComputableNodes
readonly property bool canSelectionBeSubmitted: { readonly property bool canSelectionBeSubmitted: {
if(!isSelectionOnlyComputableNodes) if(!selectionContainsComputableNodes)
return false; return false;
if(isSelectionFullyComputed) if(isSelectionFullyComputed)
return true; return true;
@ -624,7 +623,7 @@ Item {
MenuItem { MenuItem {
id: computeMenuItem id: computeMenuItem
text: nodeMenu.isSelectionFullyComputed ? "Recompute" : "Compute" text: nodeMenu.isSelectionFullyComputed ? "Recompute" : "Compute"
visible: nodeMenu.isSelectionOnlyComputableNodes visible: nodeMenu.selectionContainsComputableNodes
height: visible ? implicitHeight : 0 height: visible ? implicitHeight : 0
enabled: nodeMenu.canSelectionBeComputed enabled: nodeMenu.canSelectionBeComputed
@ -645,7 +644,7 @@ Item {
id: submitMenuItem id: submitMenuItem
text: nodeMenu.isSelectionFullyComputed ? "Re-Submit" : "Submit" text: nodeMenu.isSelectionFullyComputed ? "Re-Submit" : "Submit"
visible: nodeMenu.isSelectionSubmittable visible: nodeMenu.isSelectionSubmitable
height: visible ? implicitHeight : 0 height: visible ? implicitHeight : 0
enabled: nodeMenu.canSelectionBeSubmitted enabled: nodeMenu.canSelectionBeSubmitted