Skip to content

Commit

Permalink
Merge pull request #2250 from alicevision/dev/catchMissingFile
Browse files Browse the repository at this point in the history
[Viewer] Display error labels when an image cannot be loaded
  • Loading branch information
fabiencastan authored Dec 19, 2023
2 parents 35b69f1 + 64c56e0 commit 8c297cb
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 13 deletions.
17 changes: 10 additions & 7 deletions meshroom/ui/qml/Viewer/FloatImage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ AliceVision.FloatImageViewer {
height: sourceSize.height
visible: true

// paintedWidth / paintedHeight / status for compatibility with standard Image
// paintedWidth / paintedHeight / imageStatus for compatibility with standard Image
property int paintedWidth: sourceSize.width
property int paintedHeight: sourceSize.height
property var status: {
if (root.loading)
return Image.Loading;
else if ((root.source === "") ||
(root.sourceSize.height <= 0) ||
(root.sourceSize.width <= 0))
property var imageStatus: {
if (root.status === AliceVision.FloatImageViewer.EStatus.LOADING) {
return Image.Loading
} else if (root.status === AliceVision.FloatImageViewer.EStatus.ERROR ||
root.status === AliceVision.FloatImageViewer.EStatus.MISSING_FILE ||
root.status === AliceVision.FloatImageViewer.EStatus.OUTDATED_LOADING) {
return Image.Error
} else if ((root.source === "") || (root.sourceSize.height <= 0) || (root.sourceSize.width <= 0)) {
return Image.Null
}

return Image.Ready
}
Expand Down
45 changes: 39 additions & 6 deletions meshroom/ui/qml/Viewer/Viewer2D.qml
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,11 @@ FocusScope {
'gamma': Qt.binding(function() { return hdrImageToolbar.gammaValue }),
'gain': Qt.binding(function() { return hdrImageToolbar.gainValue }),
'channelModeString': Qt.binding(function() { return hdrImageToolbar.channelModeValue }),
'isPrincipalPointsDisplayed' : Qt.binding(function() { return lensDistortionImageToolbar.displayPrincipalPoint }),
'surface.displayGrid' : Qt.binding(function() { return lensDistortionImageToolbar.visible && lensDistortionImageToolbar.displayGrid }),
'surface.gridOpacity' : Qt.binding(function() { return lensDistortionImageToolbar.opacityValue }),
'surface.gridColor' : Qt.binding(function() { return lensDistortionImageToolbar.color }),
'surface.subdivisions' : Qt.binding(function() { return root.useFloatImageViewer ? 1 : lensDistortionImageToolbar.subdivisionsValue }),
'isPrincipalPointsDisplayed': Qt.binding(function() { return lensDistortionImageToolbar.displayPrincipalPoint }),
'surface.displayGrid': Qt.binding(function() { return lensDistortionImageToolbar.visible && lensDistortionImageToolbar.displayGrid }),
'surface.gridOpacity': Qt.binding(function() { return lensDistortionImageToolbar.opacityValue }),
'surface.gridColor': Qt.binding(function() { return lensDistortionImageToolbar.color }),
'surface.subdivisions': Qt.binding(function() { return root.useFloatImageViewer ? 1 : lensDistortionImageToolbar.subdivisionsValue }),
'viewerTypeString': Qt.binding(function() { return displayLensDistortionViewer.checked ? "distortion" : "hdr" }),
'sfmRequired': Qt.binding(function() { return displayLensDistortionViewer.checked ? true : false }),
'surface.msfmData': Qt.binding(function() { return (msfmDataLoader.status === Loader.Ready && msfmDataLoader.item != null && msfmDataLoader.item.status === 2) ? msfmDataLoader.item : null }),
Expand All @@ -476,7 +476,7 @@ FocusScope {
'cropFisheye': false,
'sequence': Qt.binding(function() { return ((root.enableSequencePlayer && _reconstruction && _reconstruction.viewpoints.count > 0) ? getSequence() : []) }),
'targetSize': Qt.binding(function() { return floatImageViewerLoader.targetSize }),
'useSequence': Qt.binding(function() { return root.enableSequencePlayer && !useExternal && _reconstruction }),
'useSequence': Qt.binding(function() { return root.enableSequencePlayer && !useExternal && _reconstruction })
})
} else {
// Forcing the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14
Expand Down Expand Up @@ -745,6 +745,39 @@ FocusScope {
}
}
}

FloatingPane {
Layout.fillWidth: true
Layout.fillHeight: false
Layout.preferredHeight: childrenRect.height
visible: floatImageViewerLoader.item.imageStatus === Image.Error
Layout.alignment: Qt.AlignHCenter

RowLayout {
anchors.fill: parent

Label {
font.pointSize: 8
text: {
switch (floatImageViewerLoader.item.status) {
case 2: // AliceVision.FloatImageViewer.EStatus.OUTDATED_LOADING
return "Outdated Loading"
case 3: // AliceVision.FloatImageViewer.EStatus.MISSING_FILE
return "Missing File"
case 4: // AliceVision.FloatImageViewer.EStatus.ERROR
return "Error"
default:
return ""
}
}
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
}
}
}

Item {
id: imgPlaceholder
Layout.fillWidth: true
Expand Down

0 comments on commit 8c297cb

Please sign in to comment.