mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-19 17:47:25 +02:00
[ui] fix drag and drop external images on Viewer2D
This commit is contained in:
parent
b91d0b372e
commit
88e822a9de
2 changed files with 29 additions and 6 deletions
|
@ -10,6 +10,10 @@ FocusScope {
|
|||
clip: true
|
||||
|
||||
property var displayedNode: _reconstruction.cameraInit
|
||||
|
||||
property bool useExternal: false
|
||||
property url sourceExternal
|
||||
|
||||
property url source
|
||||
property var metadata
|
||||
property var viewIn3D
|
||||
|
@ -155,6 +159,8 @@ FocusScope {
|
|||
}
|
||||
|
||||
function tryLoadNode(node) {
|
||||
useExternal = false;
|
||||
|
||||
// safety check
|
||||
if (!node) {
|
||||
return false;
|
||||
|
@ -182,15 +188,33 @@ FocusScope {
|
|||
return true;
|
||||
}
|
||||
|
||||
function loadExternal(path) {
|
||||
useExternal = true;
|
||||
sourceExternal = path;
|
||||
displayedNode = null;
|
||||
metadata = {};
|
||||
}
|
||||
|
||||
function getImageFile() {
|
||||
// entry point for getting the image file URL that corresponds to
|
||||
// the displayed node, selected output attribute and selected viewId
|
||||
// entry point for getting the image file URL
|
||||
if (useExternal) {
|
||||
return sourceExternal;
|
||||
}
|
||||
if (!displayedNode || outputAttribute.name == "" || outputAttribute.name == "gallery") {
|
||||
return getViewpointPath(_reconstruction.selectedViewId);
|
||||
}
|
||||
return getFileAttributePath(displayedNode, outputAttribute.name, _reconstruction.selectedViewId);
|
||||
}
|
||||
|
||||
function getMetadata() {
|
||||
// entry point for getting the image metadata
|
||||
if (useExternal) {
|
||||
return {};
|
||||
} else {
|
||||
return getViewpointMetadata(_reconstruction.selectedViewId);
|
||||
}
|
||||
}
|
||||
|
||||
function getFileAttributePath(node, attrName, viewId) {
|
||||
// get output attribute with matching name
|
||||
// and parse its value to get the image filepath
|
||||
|
@ -226,7 +250,7 @@ FocusScope {
|
|||
return vp.childAttribute("metadata").value;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
return {};
|
||||
}
|
||||
|
||||
onDisplayedNodeChanged: {
|
||||
|
@ -252,7 +276,7 @@ FocusScope {
|
|||
target: _reconstruction
|
||||
onSelectedViewIdChanged: {
|
||||
root.source = getImageFile();
|
||||
root.metadata = getViewpointMetadata(_reconstruction.selectedViewId);
|
||||
root.metadata = getMetadata();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -152,8 +152,7 @@ Item {
|
|||
anchors.fill: parent
|
||||
keys: ["text/uri-list"]
|
||||
onDropped: {
|
||||
viewer2D.source = drop.urls[0]
|
||||
viewer2D.metadata = {}
|
||||
viewer2D.loadExternal(drop.urls[0]);
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue