Skip to content

Commit

Permalink
Merge pull request #2148 from alicevision/mug/multiResImg
Browse files Browse the repository at this point in the history
[ui] FloatImageViewer: adapt resolution to zoom
  • Loading branch information
cbentejac authored Sep 6, 2023
2 parents ea26d89 + 4d4d817 commit 6a0cd25
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
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

0 comments on commit 6a0cd25

Please sign in to comment.