Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ui] FloatImageViewer: adapt resolution to zoom #2148

Merged
merged 5 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions meshroom/ui/qml/Viewer/FloatImage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions meshroom/ui/qml/Viewer/SequencePlayer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ FloatingPane {

onPlayingChanged: {
syncSelected = !playing;
viewer.playback(m.playing);
}
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -166,6 +171,7 @@ FloatingPane {
stepSize: 1
snapMode: Slider.SnapAlways
live: true
enabled: !m.playing

from: 0
to: sortedViewIds.length - 1
Expand Down
20 changes: 10 additions & 10 deletions meshroom/ui/qml/Viewer/Viewer2D.qml
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ 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;
}
}

Expand All @@ -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
Expand Down Expand Up @@ -441,6 +439,7 @@ FocusScope {
property bool fittedOnce: false
property int previousWidth: 0
property int previousHeight: 0
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
Expand All @@ -453,7 +452,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;
Expand Down Expand Up @@ -483,7 +482,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 floatImageViewerLoader.targetSize; }),
'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
Expand Down