[Panorama Viewer] Load images one by one

This commit is contained in:
Thomas Zorroche 2021-06-18 16:49:08 +02:00 committed by Fabien Castan
parent 4a7912c0ff
commit 1dfe96c74b
3 changed files with 36 additions and 29 deletions

View file

@ -16,7 +16,7 @@ FloatingPane {
property bool displayGrid: displayGrid.checked property bool displayGrid: displayGrid.checked
property int downscaleValue: downscaleSpinBox.value property int downscaleValue: downscaleSpinBox.value
property int downscaleDefaultValue: 3 property int downscaleDefaultValue: 4
property int subdivisionsDefaultValue: 12 property int subdivisionsDefaultValue: 12
property int subdivisionsValue: subdivisionsCtrl.value property int subdivisionsValue: subdivisionsCtrl.value
@ -159,7 +159,7 @@ FloatingPane {
id: downscaleSpinBox id: downscaleSpinBox
from: 0 from: 0
value: downscaleDefaultValue value: downscaleDefaultValue
to: 3 to: 5
stepSize: 1 stepSize: 1
Layout.fillWidth: false Layout.fillWidth: false
Layout.maximumWidth: 50 Layout.maximumWidth: 50

View file

@ -20,15 +20,9 @@ AliceVision.PanoramaViewer {
property int paintedWidth: sourceSize.width property int paintedWidth: sourceSize.width
property int paintedHeight: sourceSize.height property int paintedHeight: sourceSize.height
property var status: { property var status: {
if (readyToLoad === Image.Ready && root.imagesLoaded === root.pathList.length) { if (readyToLoad === Image.Ready) {
for (var i = 0; i < repeater.model; i++) {
if (repeater.itemAt(i).item.status !== Image.Ready) return Image.Loading;
}
return Image.Ready; return Image.Ready;
} }
else if (readyToLoad === Image.Ready) {
return Image.Loading;
}
else { else {
return Image.Null; return Image.Null;
} }
@ -91,6 +85,7 @@ AliceVision.PanoramaViewer {
id: mouseAreaPano id: mouseAreaPano
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
enabled: allImagesLoaded
cursorShape: { cursorShape: {
if (isEditable) if (isEditable)
isRotating ? Qt.ClosedHandCursor : Qt.OpenHandCursor isRotating ? Qt.ClosedHandCursor : Qt.OpenHandCursor
@ -196,6 +191,16 @@ AliceVision.PanoramaViewer {
property var pathList : [] property var pathList : []
property var idList : [] property var idList : []
property int imagesLoaded: 0 property int imagesLoaded: 0
property bool allImagesLoaded: false
function loadRepeaterImages(index)
{
if (index < repeater.model)
repeater.itemAt(index).loadItem();
else
allImagesLoaded = true;
}
Item { Item {
id: panoImages id: panoImages
@ -212,29 +217,32 @@ AliceVision.PanoramaViewer {
//anchors.centerIn: parent //anchors.centerIn: parent
property string cSource: Filepath.stringToUrl(root.pathList[index].toString()) property string cSource: Filepath.stringToUrl(root.pathList[index].toString())
property int cId: root.idList[index] property int cId: root.idList[index]
onActiveChanged: {
if(active) { property bool imageLoaded: false
onImageLoadedChanged: {
imagesLoaded++;
loadRepeaterImages(imagesLoaded);
}
function loadItem() {
if(active && index == imagesLoaded) {
setSource("FloatImage.qml", { setSource("FloatImage.qml", {
'viewerTypeString' : 'panorama', 'surface.viewerType': AliceVision.Surface.EViewerType.PANORAMA,
'viewerTypeString': 'panorama',
'surface.subdivisions': Qt.binding(function() { return subdivisionsPano; }), 'surface.subdivisions': Qt.binding(function() { return subdivisionsPano; }),
'source': Qt.binding(function() { return cSource; }),
'index' : index, 'index' : index,
'idView': Qt.binding(function() { return cId; }), 'idView': Qt.binding(function() { return cId; }),
'gamma': Qt.binding(function() { return hdrImageToolbar.gammaValue; }), 'gamma': Qt.binding(function() { return hdrImageToolbar.gammaValue; }),
'gain': Qt.binding(function() { return hdrImageToolbar.gainValue; }), 'gain': Qt.binding(function() { return hdrImageToolbar.gainValue; }),
'channelModeString': Qt.binding(function() { return hdrImageToolbar.channelModeValue; }), 'channelModeString': Qt.binding(function() { return hdrImageToolbar.channelModeValue; }),
'downscaleLevel' : Qt.binding(function() { return downscale; }) 'downscaleLevel' : Qt.binding(function() { return downscale; }),
'source': Qt.binding(function() { return cSource; })
}) })
imageLoaded = Qt.binding(function() { return repeater.itemAt(index).item.status === Image.Ready ? true : false; })
} else {
// Force the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14
setSource("", {})
} }
} }
onLoaded: {
imagesLoaded++;
}
} }
} }
Repeater { Repeater {
@ -262,6 +270,7 @@ AliceVision.PanoramaViewer {
panoImages.updateRepeater() panoImages.updateRepeater()
root.readyToLoad = Image.Ready; root.readyToLoad = Image.Ready;
loadRepeaterImages(0);
} }
} }

View file

@ -1060,18 +1060,16 @@ FocusScope {
anchors.centerIn: parent anchors.centerIn: parent
// running property binding seems broken, only dynamic binding assignment works // running property binding seems broken, only dynamic binding assignment works
Component.onCompleted: { Component.onCompleted: {
if (root.usePanoramaViewer) { running = Qt.binding(function() {
running = Qt.binding(function() { return imgContainer.panoramaViewerLoader.status === Image.Loading }) return (root.usePanoramaViewer === true && imgContainer.image.allImagesLoaded === false)
} else { || (imgContainer.image && imgContainer.image.status === Image.Loading)
running = Qt.binding(function() { return imgContainer.image && imgContainer.image.status === Image.Loading }) })
}
} }
// disable the visibility when unused to avoid stealing the mouseEvent to the image color picker // disable the visibility when unused to avoid stealing the mouseEvent to the image color picker
visible: running visible: running
onVisibleChanged: { onVisibleChanged: {
if (panoramaViewerLoader.active && panoramaViewerLoader.item.status === Image.Ready) if (panoramaViewerLoader.active)
fit(); fit();
} }
} }