From 516585c78fbd88d89d1a095da9514efcf27bc5f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Vital?= Date: Tue, 8 Aug 2023 17:06:15 +0200 Subject: [PATCH 1/5] [ui] FloatImage: read dimensions from source size to allow using downscaled images --- meshroom/ui/qml/Viewer/FloatImage.qml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/meshroom/ui/qml/Viewer/FloatImage.qml b/meshroom/ui/qml/Viewer/FloatImage.qml index dc63288a5e..4fc6b8b0fd 100644 --- a/meshroom/ui/qml/Viewer/FloatImage.qml +++ b/meshroom/ui/qml/Viewer/FloatImage.qml @@ -11,13 +11,13 @@ import AliceVision 1.0 as AliceVision AliceVision.FloatImageViewer { id: root - width: textureSize.width - height: textureSize.height + width: sourceSize.width + height: sourceSize.height visible: true // paintedWidth / paintedHeight / status for compatibility with standard Image - property int paintedWidth: textureSize.width - property int paintedHeight: textureSize.height + property int paintedWidth: sourceSize.width + property int paintedHeight: sourceSize.height property var status: { if(root.loading) return Image.Loading; From 9aab7b2b57a7bf7325574d8890e765e415554cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Vital?= Date: Tue, 8 Aug 2023 17:07:59 +0200 Subject: [PATCH 2/5] [ui] FloatImageViewer: compute target size --- meshroom/ui/qml/Viewer/Viewer2D.qml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/meshroom/ui/qml/Viewer/Viewer2D.qml b/meshroom/ui/qml/Viewer/Viewer2D.qml index ffa09285e9..b890e656d4 100644 --- a/meshroom/ui/qml/Viewer/Viewer2D.qml +++ b/meshroom/ui/qml/Viewer/Viewer2D.qml @@ -151,8 +151,6 @@ FocusScope { // make sure the image is ready for use if(!imgContainer.image) return; - if(imgContainer.image.status !== Image.Ready) - return; // for Exif orientation tags 5 to 8, a 90 degrees rotation is applied // therefore image dimensions must be inverted @@ -453,7 +451,7 @@ FocusScope { * group has already been auto-fitted. If we change the group of images (when another project is * opened, for example, and the images have a different size), then another auto-fit needs to be * performed */ - if ((!fittedOnce && imgContainer.image && imgContainer.image.status === Image.Ready && imgContainer.image.height > 0) || + if ((!fittedOnce && imgContainer.image && imgContainer.image.height > 0) || (fittedOnce && ((width > 1 && previousWidth != width) || (height > 1 && previousHeight != height)))) { fit(); fittedOnce = true; @@ -483,7 +481,8 @@ FocusScope { 'idView': Qt.binding(function() { return (_reconstruction ? _reconstruction.selectedViewId : -1); }), 'cropFisheye': false, 'sequence': Qt.binding(function() { return ((root.enableSequencePlayer && _reconstruction && _reconstruction.viewpoints.count > 0) ? getSequence() : []); }), - 'useSequence': Qt.binding(function() { return root.enableSequencePlayer && !useExternal && _reconstruction; }) + 'targetSize': Qt.binding(function() { return imgLayout.width * imgContainer.scale; }), + 'useSequence': Qt.binding(function() { return root.enableSequencePlayer && !useExternal && _reconstruction; }), }) } else { // Force the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14 From 78625705a37d7acc6ed0ac99151e8bf4e2cbaa46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Vital?= Date: Thu, 10 Aug 2023 10:10:24 +0200 Subject: [PATCH 3/5] [ui] float image viewer: refine target size management --- meshroom/ui/qml/Viewer/Viewer2D.qml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/meshroom/ui/qml/Viewer/Viewer2D.qml b/meshroom/ui/qml/Viewer/Viewer2D.qml index b890e656d4..05051d97a5 100644 --- a/meshroom/ui/qml/Viewer/Viewer2D.qml +++ b/meshroom/ui/qml/Viewer/Viewer2D.qml @@ -129,14 +129,15 @@ FocusScope { } } onWheel: { - var zoomFactor = wheel.angleDelta.y > 0 ? factor : 1/factor + var zoomFactor = wheel.angleDelta.y > 0 ? factor : 1/factor; if(Math.min(imgContainer.width, imgContainer.image.height) * imgContainer.scale * zoomFactor < 10) - return - var point = mapToItem(imgContainer, wheel.x, wheel.y) - imgContainer.x += (1-zoomFactor) * point.x * imgContainer.scale - imgContainer.y += (1-zoomFactor) * point.y * imgContainer.scale - imgContainer.scale *= zoomFactor + return; + var point = mapToItem(imgContainer, wheel.x, wheel.y); + imgContainer.x += (1-zoomFactor) * point.x * imgContainer.scale; + imgContainer.y += (1-zoomFactor) * point.y * imgContainer.scale; + imgContainer.scale *= zoomFactor; + floatImageViewerLoader.targetSize *= zoomFactor; } } @@ -167,6 +168,9 @@ FocusScope { // so that container center corresponds to image center imgContainer.x += (orientedWidth - imgContainer.image.width) * 0.5 * imgContainer.scale; imgContainer.y += (orientedHeight - imgContainer.image.height) * 0.5 * imgContainer.scale; + + // reset target size + floatImageViewerLoader.targetSize = Math.max(imgLayout.width, root.height); } function tryLoadNode(node) { @@ -439,6 +443,7 @@ FocusScope { property bool fittedOnce: false property int previousWidth: 0 property int previousHeight: 0 + property real targetSize: 1000 onHeightChanged: { /* Image size is not updated through a single signal with the floatImage viewer, unlike * the simple QML image viewer: instead of updating straight away the width and height to x and @@ -481,7 +486,7 @@ FocusScope { 'idView': Qt.binding(function() { return (_reconstruction ? _reconstruction.selectedViewId : -1); }), 'cropFisheye': false, 'sequence': Qt.binding(function() { return ((root.enableSequencePlayer && _reconstruction && _reconstruction.viewpoints.count > 0) ? getSequence() : []); }), - 'targetSize': Qt.binding(function() { return imgLayout.width * imgContainer.scale; }), + 'targetSize': Qt.binding(function() { return floatImageViewerLoader.targetSize; }), 'useSequence': Qt.binding(function() { return root.enableSequencePlayer && !useExternal && _reconstruction; }), }) } else { From 522d838f32cef6581b9615d127d1bf7d0c096216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Vital?= Date: Mon, 21 Aug 2023 11:45:04 +0200 Subject: [PATCH 4/5] [ui] SequencePlayer: improve playback --- meshroom/ui/qml/Viewer/SequencePlayer.qml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/meshroom/ui/qml/Viewer/SequencePlayer.qml b/meshroom/ui/qml/Viewer/SequencePlayer.qml index a87cc07124..b3be73a4b4 100644 --- a/meshroom/ui/qml/Viewer/SequencePlayer.qml +++ b/meshroom/ui/qml/Viewer/SequencePlayer.qml @@ -55,6 +55,7 @@ FloatingPane { onPlayingChanged: { syncSelected = !playing; + viewer.playback(m.playing); } } @@ -82,6 +83,10 @@ FloatingPane { interval: 1000 / m.fps onTriggered: { + if (viewer.status !== Image.Ready) { + // Wait for current image to be displayed before switching to next image + return; + } let nextIndex = m.frame + 1; if (nextIndex == sortedViewIds.length) { if (m.repeat) { @@ -166,6 +171,7 @@ FloatingPane { stepSize: 1 snapMode: Slider.SnapAlways live: true + enabled: !m.playing from: 0 to: sortedViewIds.length - 1 From 4d4d8176b7585b213d475b676f54f9b8f6fcd94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Vital?= Date: Mon, 21 Aug 2023 11:54:58 +0200 Subject: [PATCH 5/5] [ui] float image viewer: factorize targetSize computation --- meshroom/ui/qml/Viewer/Viewer2D.qml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/meshroom/ui/qml/Viewer/Viewer2D.qml b/meshroom/ui/qml/Viewer/Viewer2D.qml index 05051d97a5..9dfc0ad6bc 100644 --- a/meshroom/ui/qml/Viewer/Viewer2D.qml +++ b/meshroom/ui/qml/Viewer/Viewer2D.qml @@ -137,7 +137,6 @@ FocusScope { imgContainer.x += (1-zoomFactor) * point.x * imgContainer.scale; imgContainer.y += (1-zoomFactor) * point.y * imgContainer.scale; imgContainer.scale *= zoomFactor; - floatImageViewerLoader.targetSize *= zoomFactor; } } @@ -168,9 +167,6 @@ FocusScope { // so that container center corresponds to image center imgContainer.x += (orientedWidth - imgContainer.image.width) * 0.5 * imgContainer.scale; imgContainer.y += (orientedHeight - imgContainer.image.height) * 0.5 * imgContainer.scale; - - // reset target size - floatImageViewerLoader.targetSize = Math.max(imgLayout.width, root.height); } function tryLoadNode(node) { @@ -443,7 +439,7 @@ FocusScope { property bool fittedOnce: false property int previousWidth: 0 property int previousHeight: 0 - property real targetSize: 1000 + property real targetSize: Math.max(width, height) * imgContainer.scale; onHeightChanged: { /* Image size is not updated through a single signal with the floatImage viewer, unlike * the simple QML image viewer: instead of updating straight away the width and height to x and