[Panorama Viewer] make repeater working with c++

This commit is contained in:
Landrodie 2021-01-22 10:26:56 +01:00 committed by Fabien Castan
parent d8018191ed
commit edfcb2bb75

View file

@ -26,6 +26,7 @@ AliceVision.PanoramaViewer {
(root.sourceSize.width <= 0)) (root.sourceSize.width <= 0))
return Image.Null; return Image.Null;
root.defaultControlPoints(); root.defaultControlPoints();
updateSfmPath();
return Image.Ready; return Image.Ready;
} }
@ -60,28 +61,27 @@ AliceVision.PanoramaViewer {
root.setSfmPath(sfmPath); root.setSfmPath(sfmPath);
} }
property var paths: ["L:/IMAC/IMAC2/PTUT/22_190902_GDGM_F1_sph150/HDM_1306.JPG", "L:/IMAC/IMAC2/PTUT/22_190902_GDGM_F1_sph150/HDM_1313.JPG"] property var pathList : []
property var idList : []
Item { Item {
id: panoImages id: panoImages
width: root.width width: root.width
height: root.height height: root.height
function setSource() { // function setSource() {
if (repeater.model === 0) // if (repeater.model === 0)
return // return
// var width = repeater.itemAt(0).width; //// var width = repeater.itemAt(0).width;
// var height = repeater.itemAt(0).height; //// var height = repeater.itemAt(0).height;
for (let i = 0; i < repeater.model; i++) { // for (let i = 0; i < repeater.model; i++) {
console.warn(repeater.itemAt(i)) // console.warn(repeater.itemAt(i))
// repeater.itemAt(i).x = root.getVertex(i).x - (width / 2); //// repeater.itemAt(i).x = root.getVertex(i).x - (width / 2);
// repeater.itemAt(i).y = root.getVertex(i).y - (height / 2); //// repeater.itemAt(i).y = root.getVertex(i).y - (height / 2);
} // }
} // }
Component { Component {
id: imgPano id: imgPano
@ -90,7 +90,7 @@ AliceVision.PanoramaViewer {
active: root.status active: root.status
visible: (floatOneLoader.status === Loader.Ready) visible: (floatOneLoader.status === Loader.Ready)
//anchors.centerIn: parent //anchors.centerIn: parent
property string cSource: Filepath.stringToUrl(root.paths[index].toString()) property string cSource: Filepath.stringToUrl(root.pathList[index].toString())
onActiveChanged: { onActiveChanged: {
if(active) { if(active) {
setSource("FloatImage.qml", { setSource("FloatImage.qml", {
@ -98,7 +98,6 @@ AliceVision.PanoramaViewer {
'index' : index 'index' : index
}) })
console.warn(cSource) console.warn(cSource)
console.warn(root.source)
} else { } else {
// Force the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14 // Force the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14
setSource("", {}) setSource("", {})
@ -106,16 +105,46 @@ AliceVision.PanoramaViewer {
} }
onLoaded: { onLoaded: {
//console.warn(repeater.itemAt(index)) //console.warn(repeater.itemAt(index))
repeater.itemAt(index).x = repeater.itemAt(0).width + 50* index repeater.itemAt(index).x = repeater.itemAt(0).width + 100* index
} }
} }
} }
Repeater { Repeater {
id: repeater id: repeater
model: 2 model: 0
delegate: imgPano delegate: imgPano
} }
Connections {
target: root
onImagesDataChanged: {
//We receive the map<ImgPath, idView> from C++
console.warn("IMAGES DATA CHANGED ! " + imagesData)
//Resetting arrays to avoid problem with push
pathList = []
idList = []
//Iterating through the map
for (var path in imagesData) {
console.warn("Object item:", path, "=", imagesData[path])
root.pathList.push(path)
root.idList.push(imagesData[path])
}
console.warn(root.pathList.length)
//Changing the repeater model (number of elements)
panoImages.updateRepeater()
}
}
function updateRepeater() {
if(repeater.model !== root.pathList.length){
repeater.model = 0;
}
//console.warn(imagesData.length)
repeater.model = root.pathList.length;
}
} }