From ad3e67ee892ce687561ea6c46fca7fe79aec2f4c Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Wed, 21 Apr 2021 18:52:23 +0200 Subject: [PATCH] [ui] ColorCheckerViewer: allow to display the ColorChecker without sfmData If we have used a single image in input of the ColorCheckerDetection, still allow to display it. In this particular case, there is no notion of viewId. --- meshroom/ui/qml/Viewer/ColorCheckerViewer.qml | 47 ++++++++++--------- meshroom/ui/qml/Viewer/Viewer2D.qml | 2 +- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/meshroom/ui/qml/Viewer/ColorCheckerViewer.qml b/meshroom/ui/qml/Viewer/ColorCheckerViewer.qml index 8e4fcb5f..c3d44a19 100644 --- a/meshroom/ui/qml/Viewer/ColorCheckerViewer.qml +++ b/meshroom/ui/qml/Viewer/ColorCheckerViewer.qml @@ -4,10 +4,9 @@ Item { id: root property url source: undefined - property var sourceLastModified: null property var json: null property var image: null - property var viewId: null + property var viewpoint: null property real zoom: 1.0 // required for perspective transform @@ -21,10 +20,8 @@ Item { property var ccheckers: [] property int selectedCChecker: -1 - - onVisibleChanged: { readSourceFile(); } onSourceChanged: { readSourceFile(); } - onViewIdChanged: { loadCCheckers(); } + onViewpointChanged: { loadCCheckers(); } property var updatePane: null @@ -40,39 +37,42 @@ Item { function readSourceFile() { var xhr = new XMLHttpRequest; + // console.warn("readSourceFile: " + root.source) xhr.open("GET", root.source); xhr.onreadystatechange = function() { if (xhr.readyState === XMLHttpRequest.DONE && xhr.status == 200) { - - if(root.sourceLastModified === null - || root.sourceLastModified < xhr.getResponseHeader('Last-Modified') - ) { - try { - root.json = JSON.parse(xhr.responseText); - } - catch(exc) - { - console.warn("Failed to parse ColorCheckerDetection JSON file: " + source); - return; - } - root.sourceLastModified = xhr.getResponseHeader('Last-Modified'); - loadCCheckers(); + try { + root.json = null; + // console.warn("readSourceFile: update json from " + root.source) + root.json = JSON.parse(xhr.responseText); + // console.warn("readSourceFile: root.json.checkers.length=" + root.json.checkers.length) + } + catch(exc) + { + console.warn("Failed to parse ColorCheckerDetection JSON file: " + source); + return; } } + loadCCheckers(); }; xhr.send(); } function loadCCheckers() { - if (root.json === null) - return; - emptyCCheckers(); + if (root.json === null) + { + return; + } + var currentImagePath = (root.viewpoint && root.viewpoint.attribute && root.viewpoint.attribute.childAttribute("path")) ? root.viewpoint.attribute.childAttribute("path").value : null + var viewId = (root.viewpoint && root.viewpoint.attribute && root.viewpoint.attribute.childAttribute("viewId")) ? root.viewpoint.attribute.childAttribute("viewId").value : null for (var i = 0; i < root.json.checkers.length; i++) { // Only load ccheckers for the current view - if (root.viewId == root.json.checkers[i].viewId) { + var checker = root.json.checkers[i] + if (checker.viewId == viewId || + checker.imagePath == currentImagePath) { var cpt = Qt.createComponent("ColorCheckerEntity.qml"); var obj = cpt.createObject(root, { @@ -83,6 +83,7 @@ Item { obj.transform(root.json.checkers[i].transform); ccheckers.push(obj); selectedCChecker = ccheckers.length-1; + break; } } updatePane(); diff --git a/meshroom/ui/qml/Viewer/Viewer2D.qml b/meshroom/ui/qml/Viewer/Viewer2D.qml index f8c7e3f2..705760fd 100644 --- a/meshroom/ui/qml/Viewer/Viewer2D.qml +++ b/meshroom/ui/qml/Viewer/Viewer2D.qml @@ -356,7 +356,7 @@ FocusScope { visible: activeNode.isComputed && json !== undefined && imgContainer.image.status === Image.Ready source: Filepath.stringToUrl(activeNode.attribute("outputData").value) image: imgContainer.image - viewId: _reconstruction.selectedViewId + viewpoint: _reconstruction.selectedViewpoint zoom: imgContainer.scale updatePane: function() {