mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-01 15:58:36 +02:00
[ui] Refactor node pasting using graph partial serialization
Re-implement node pasting by relying on the graph partial serializer, to serialize only the subset of selected nodes. On pasting, use standard graph deserialization and import the content of the serialized graph in the active graph instance. Simplify the positioning of pasted nodes to only consider mouse position or center of the graph, which works well for the major variety of use-cases. Compute the offset to apply to imported nodes by using the de-serialized graph content's bounding box.
This commit is contained in:
parent
f8f03b0bd5
commit
d54ba012a0
4 changed files with 63 additions and 158 deletions
|
@ -82,25 +82,18 @@ Item {
|
|||
|
||||
/// Paste content of clipboard to graph editor and create new node if valid
|
||||
function pasteNodes() {
|
||||
var finalPosition = undefined
|
||||
var centerPosition = false
|
||||
let finalPosition = undefined;
|
||||
if (mouseArea.containsMouse) {
|
||||
if (uigraph.hoveredNode !== null) {
|
||||
var node = nodeDelegate(uigraph.hoveredNode)
|
||||
finalPosition = Qt.point(node.mousePosition.x + node.x, node.mousePosition.y + node.y)
|
||||
} else {
|
||||
finalPosition = mapToItem(draggable, mouseArea.mouseX, mouseArea.mouseY)
|
||||
}
|
||||
finalPosition = mapToItem(draggable, mouseArea.mouseX, mouseArea.mouseY);
|
||||
} else {
|
||||
finalPosition = getCenterPosition()
|
||||
centerPosition = true
|
||||
finalPosition = getCenterPosition();
|
||||
}
|
||||
|
||||
var copiedContent = Clipboard.getText()
|
||||
var nodes = uigraph.pasteNodes(copiedContent, finalPosition, centerPosition)
|
||||
const copiedContent = Clipboard.getText();
|
||||
const nodes = uigraph.pasteNodes(copiedContent, finalPosition);
|
||||
if (nodes.length > 0) {
|
||||
uigraph.selectedNode = nodes[0]
|
||||
uigraph.selectNodes(nodes)
|
||||
uigraph.selectedNode = nodes[0];
|
||||
uigraph.selectNodes(nodes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue