mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-13 00:57:08 +02:00
[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.
This commit is contained in:
parent
2f4c73610c
commit
ad3e67ee89
2 changed files with 25 additions and 24 deletions
|
@ -4,10 +4,9 @@ Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property url source: undefined
|
property url source: undefined
|
||||||
property var sourceLastModified: null
|
|
||||||
property var json: null
|
property var json: null
|
||||||
property var image: null
|
property var image: null
|
||||||
property var viewId: null
|
property var viewpoint: null
|
||||||
property real zoom: 1.0
|
property real zoom: 1.0
|
||||||
|
|
||||||
// required for perspective transform
|
// required for perspective transform
|
||||||
|
@ -21,10 +20,8 @@ Item {
|
||||||
property var ccheckers: []
|
property var ccheckers: []
|
||||||
property int selectedCChecker: -1
|
property int selectedCChecker: -1
|
||||||
|
|
||||||
|
|
||||||
onVisibleChanged: { readSourceFile(); }
|
|
||||||
onSourceChanged: { readSourceFile(); }
|
onSourceChanged: { readSourceFile(); }
|
||||||
onViewIdChanged: { loadCCheckers(); }
|
onViewpointChanged: { loadCCheckers(); }
|
||||||
property var updatePane: null
|
property var updatePane: null
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,39 +37,42 @@ Item {
|
||||||
|
|
||||||
function readSourceFile() {
|
function readSourceFile() {
|
||||||
var xhr = new XMLHttpRequest;
|
var xhr = new XMLHttpRequest;
|
||||||
|
// console.warn("readSourceFile: " + root.source)
|
||||||
xhr.open("GET", root.source);
|
xhr.open("GET", root.source);
|
||||||
|
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function() {
|
||||||
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status == 200) {
|
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status == 200) {
|
||||||
|
try {
|
||||||
if(root.sourceLastModified === null
|
root.json = null;
|
||||||
|| root.sourceLastModified < xhr.getResponseHeader('Last-Modified')
|
// console.warn("readSourceFile: update json from " + root.source)
|
||||||
) {
|
root.json = JSON.parse(xhr.responseText);
|
||||||
try {
|
// console.warn("readSourceFile: root.json.checkers.length=" + root.json.checkers.length)
|
||||||
root.json = JSON.parse(xhr.responseText);
|
}
|
||||||
}
|
catch(exc)
|
||||||
catch(exc)
|
{
|
||||||
{
|
console.warn("Failed to parse ColorCheckerDetection JSON file: " + source);
|
||||||
console.warn("Failed to parse ColorCheckerDetection JSON file: " + source);
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
root.sourceLastModified = xhr.getResponseHeader('Last-Modified');
|
|
||||||
loadCCheckers();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
loadCCheckers();
|
||||||
};
|
};
|
||||||
xhr.send();
|
xhr.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadCCheckers() {
|
function loadCCheckers() {
|
||||||
if (root.json === null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
emptyCCheckers();
|
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++) {
|
for (var i = 0; i < root.json.checkers.length; i++) {
|
||||||
// Only load ccheckers for the current view
|
// 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 cpt = Qt.createComponent("ColorCheckerEntity.qml");
|
||||||
|
|
||||||
var obj = cpt.createObject(root, {
|
var obj = cpt.createObject(root, {
|
||||||
|
@ -83,6 +83,7 @@ Item {
|
||||||
obj.transform(root.json.checkers[i].transform);
|
obj.transform(root.json.checkers[i].transform);
|
||||||
ccheckers.push(obj);
|
ccheckers.push(obj);
|
||||||
selectedCChecker = ccheckers.length-1;
|
selectedCChecker = ccheckers.length-1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updatePane();
|
updatePane();
|
||||||
|
|
|
@ -356,7 +356,7 @@ FocusScope {
|
||||||
visible: activeNode.isComputed && json !== undefined && imgContainer.image.status === Image.Ready
|
visible: activeNode.isComputed && json !== undefined && imgContainer.image.status === Image.Ready
|
||||||
source: Filepath.stringToUrl(activeNode.attribute("outputData").value)
|
source: Filepath.stringToUrl(activeNode.attribute("outputData").value)
|
||||||
image: imgContainer.image
|
image: imgContainer.image
|
||||||
viewId: _reconstruction.selectedViewId
|
viewpoint: _reconstruction.selectedViewpoint
|
||||||
zoom: imgContainer.scale
|
zoom: imgContainer.scale
|
||||||
|
|
||||||
updatePane: function() {
|
updatePane: function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue