mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-28 17:57:16 +02:00
[ui] GraphEditor: Centralize node selection computability status
Re-write the computability status of the current node selection as properties within the node menu component. Note that this should be further improved to better scale with the size of the selection, as it requires to traverse the graph for each node.
This commit is contained in:
parent
b5836d96ed
commit
ade1f87b8f
1 changed files with 54 additions and 75 deletions
|
@ -571,20 +571,50 @@ Item {
|
||||||
id: nodeMenu
|
id: nodeMenu
|
||||||
|
|
||||||
property var currentNode: nodeMenuLoader.currentNode
|
property var currentNode: nodeMenuLoader.currentNode
|
||||||
property bool canComputeNode: uigraph.graph.canComputeTopologically(currentNode)
|
|
||||||
// canSubmitOrCompute: return int n : 0 >= n <= 3 | n=0 cannot submit or compute | n=1 can compute | n=2 can submit | n=3 can compute & submit
|
readonly property bool isSelectionFullyComputed: {
|
||||||
property int canSubmitOrCompute: uigraph.graph.canSubmitOrCompute(currentNode)
|
return uigraph.nodeSelection.selectedIndexes.every(function(idx) {
|
||||||
property bool isComputed: {
|
return uigraph.graph.nodes.at(idx.row).isComputed;
|
||||||
var count = 0
|
});
|
||||||
for (var i = 0; i < uigraph.selectedNodes.count; ++i) {
|
}
|
||||||
var node = uigraph.selectedNodes.at(i)
|
readonly property bool isSelectionOnlyComputableNodes: {
|
||||||
if (!node)
|
return uigraph.nodeSelection.selectedIndexes.every(function(idx) {
|
||||||
continue
|
const node = uigraph.graph.nodes.at(idx.row);
|
||||||
if (!node.isComputed)
|
return (
|
||||||
return false
|
node.isComputable
|
||||||
count += 1
|
&& uigraph.graph.canComputeTopologically(node)
|
||||||
}
|
);
|
||||||
return count > 0
|
});
|
||||||
|
}
|
||||||
|
readonly property bool canSelectionBeComputed: {
|
||||||
|
if(!isSelectionOnlyComputableNodes)
|
||||||
|
return false;
|
||||||
|
if(isSelectionFullyComputed)
|
||||||
|
return true;
|
||||||
|
return uigraph.nodeSelection.selectedIndexes.every(function(idx) {
|
||||||
|
const node = uigraph.graph.nodes.at(idx.row);
|
||||||
|
return (
|
||||||
|
node.isComputed
|
||||||
|
// canCompute if canSubmitOrCompute == 1(can compute) or 3(can compute & submit)
|
||||||
|
|| uigraph.graph.canSubmitOrCompute(node) % 2 == 1
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
readonly property bool isSelectionSubmittable: uigraph.canSubmit && isSelectionOnlyComputableNodes
|
||||||
|
|
||||||
|
readonly property bool canSelectionBeSubmitted: {
|
||||||
|
if(!isSelectionOnlyComputableNodes)
|
||||||
|
return false;
|
||||||
|
if(isSelectionFullyComputed)
|
||||||
|
return true;
|
||||||
|
return uigraph.nodeSelection.selectedIndexes.every(function(idx) {
|
||||||
|
const node = uigraph.graph.nodes.at(idx.row);
|
||||||
|
return (
|
||||||
|
node.isComputed
|
||||||
|
// canSubmit if canSubmitOrCompute == 2(can submit) or 3(can compute & submit)
|
||||||
|
|| uigraph.graph.canSubmitOrCompute(node) > 1
|
||||||
|
)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
width: 220
|
width: 220
|
||||||
|
@ -594,40 +624,13 @@ Item {
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
id: computeMenuItem
|
id: computeMenuItem
|
||||||
text: nodeMenu.isComputed ? "Recompute" : "Compute"
|
text: nodeMenu.isSelectionFullyComputed ? "Recompute" : "Compute"
|
||||||
visible: {
|
visible: nodeMenu.isSelectionOnlyComputableNodes
|
||||||
var count = 0
|
|
||||||
for (var i = 0; i < uigraph.selectedNodes.count; ++i) {
|
|
||||||
var node = uigraph.selectedNodes.at(i)
|
|
||||||
if (!node)
|
|
||||||
continue
|
|
||||||
if (!node.isComputable)
|
|
||||||
return false
|
|
||||||
count += 1
|
|
||||||
}
|
|
||||||
return count > 0
|
|
||||||
}
|
|
||||||
height: visible ? implicitHeight : 0
|
height: visible ? implicitHeight : 0
|
||||||
|
enabled: nodeMenu.canSelectionBeComputed
|
||||||
enabled: {
|
|
||||||
var canCompute = false
|
|
||||||
for (var i = 0; i < uigraph.selectedNodes.count; ++i) {
|
|
||||||
var node = uigraph.selectedNodes.at(i)
|
|
||||||
if (!node)
|
|
||||||
continue
|
|
||||||
if (uigraph.graph.canComputeTopologically(node)) {
|
|
||||||
if (nodeMenu.isComputed) {
|
|
||||||
canCompute = true
|
|
||||||
} else if (uigraph.graph.canSubmitOrCompute(node) % 2 == 1) {
|
|
||||||
canCompute = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return canCompute // canSubmit if canSubmitOrCompute == 1(can compute) or 3(can compute & submit)
|
|
||||||
}
|
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (nodeMenu.isComputed) {
|
if (nodeMenu.isSelectionFullyComputed) {
|
||||||
nodeMenuLoader.showDataDeletionDialog(
|
nodeMenuLoader.showDataDeletionDialog(
|
||||||
false,
|
false,
|
||||||
function(request, uigraph) {
|
function(request, uigraph) {
|
||||||
|
@ -641,38 +644,14 @@ Item {
|
||||||
}
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
id: submitMenuItem
|
id: submitMenuItem
|
||||||
property bool resubmit: false
|
|
||||||
text: nodeMenu.isComputed ? "Re-Submit" : "Submit"
|
|
||||||
visible: {
|
|
||||||
var count = 0
|
|
||||||
for (var i = 0; i < uigraph.selectedNodes.count; ++i) {
|
|
||||||
var node = uigraph.selectedNodes.at(i)
|
|
||||||
if (node && !node.isComputable)
|
|
||||||
return false
|
|
||||||
count += 1
|
|
||||||
}
|
|
||||||
return count > 0 || uigraph.canSubmit
|
|
||||||
}
|
|
||||||
height: visible ? implicitHeight : 0
|
|
||||||
|
|
||||||
enabled: {
|
text: nodeMenu.isSelectionFullyComputed ? "Re-Submit" : "Submit"
|
||||||
var canSubmit = false
|
visible: nodeMenu.isSelectionSubmittable
|
||||||
for (var i = 0; i < uigraph.selectedNodes.count; ++i) {
|
height: visible ? implicitHeight : 0
|
||||||
var node = uigraph.selectedNodes.at(i)
|
enabled: nodeMenu.canSelectionBeSubmitted
|
||||||
if (!node)
|
|
||||||
continue
|
|
||||||
if (uigraph.graph.canComputeTopologically(node)) {
|
|
||||||
if (nodeMenu.isComputed) {
|
|
||||||
canSubmit = true
|
|
||||||
} else if (uigraph.graph.canSubmitOrCompute(node) > 1) {
|
|
||||||
canSubmit = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return canSubmit
|
|
||||||
}
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (nodeMenu.isComputed) {
|
if (nodeMenu.isSelectionFullyComputed) {
|
||||||
nodeMenuLoader.showDataDeletionDialog(
|
nodeMenuLoader.showDataDeletionDialog(
|
||||||
false,
|
false,
|
||||||
function(request, uigraph) {
|
function(request, uigraph) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue