[ui] Viewer2D: Enable HDR viewer by default if it is available

If the HDR viewer is unavailable, load the classic 8bit image viewer,
but do not allow the user to switch to it anymore if the HDR viewer
is available unless a specific environment variable has been provided.
This commit is contained in:
Candice Bentéjac 2022-10-10 18:22:46 +02:00
parent 243c278bcc
commit ff4620dc2f
2 changed files with 48 additions and 13 deletions

View file

@ -344,8 +344,13 @@ class MeshroomApp(QApplication):
}
]
def _default8bitViewerEnabled(self):
return bool(os.environ.get("MESHROOM_USE_8BIT_VIEWER", False))
licensesModel = Property("QVariantList", _licensesModel, constant=True)
pipelineTemplateFilesChanged = Signal()
recentProjectFilesChanged = Signal()
pipelineTemplateFiles = Property("QVariantList", _pipelineTemplateFiles, notify=pipelineTemplateFilesChanged)
recentProjectFiles = Property("QVariantList", _recentProjectFiles, notify=recentProjectFilesChanged)
default8bitViewerEnabled = Property(bool, _default8bitViewerEnabled, constant=True)

View file

@ -15,12 +15,13 @@ FocusScope {
property Component floatViewerComp: Qt.createComponent("FloatImage.qml")
property Component panoramaViewerComp: Qt.createComponent("PanoramaViewer.qml")
property alias useFloatImageViewer: displayHDR.checked
property var useFloatImageViewer: displayHDR.checked
property alias useLensDistortionViewer: displayLensDistortionViewer.checked
property alias usePanoramaViewer: displayPanoramaViewer.checked
property var activeNodeFisheye: _reconstruction.activeNodes.get("PanoramaInit").node
property bool cropFisheye : activeNodeFisheye ? activeNodeFisheye.attribute("useFisheye").value : false
property bool enable8bitViewer: MeshroomApp.default8bitViewerEnabled
QtObject {
id: m
@ -57,8 +58,10 @@ FocusScope {
readonly property bool oiioPluginAvailable: oiioPluginLoader.status === Component.Ready
Component.onCompleted: {
if(!aliceVisionPluginAvailable)
if(!aliceVisionPluginAvailable) {
console.warn("Missing plugin qtAliceVision.")
displayHDR.checked = false
}
if(!oiioPluginAvailable)
console.warn("Missing plugin qtOIIO.")
}
@ -254,12 +257,35 @@ FocusScope {
active: root.aliceVisionPluginAvailable && (root.useFloatImageViewer || root.useLensDistortionViewer) && !panoramaViewerLoader.active
visible: (floatImageViewerLoader.status === Loader.Ready) && active
anchors.centerIn: parent
property var fittedOnce: false
property var previousWidth: 0
property var previousHeight: 0
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
* y, the emitted signals look like:
* - width = -1, height = -1
* - width = x, height = -1
* - width = x, height = y
* We want to do the auto-fit on the first display of an image from the group, and then keep its
* scale when displaying another image from the group, so we need to know if an image in the
* 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.status == Image.Ready && imgContainer.image.height > 0) ||
(fittedOnce && ((width > 1 && previousWidth != width) || (height > 1 && previousHeight != height)))) {
fit();
fittedOnce = true;
previousWidth = width;
previousHeight = height;
}
}
// handle rotation/position based on available metadata
rotation: {
var orientation = m.imgMetadata ? m.imgMetadata["Orientation"] : 0
switch(orientation) {
switch (orientation) {
case "6": return 90;
case "8": return -90;
default: return 0;
@ -267,7 +293,7 @@ FocusScope {
}
onActiveChanged: {
if(active) {
if (active) {
// instantiate and initialize a FeaturesViewer component dynamically using Loader.setSource
// Note: It does not work to use previously created component, so we re-create it with setSource.
// floatViewerComp.createObject(floatImageViewerLoader, {
@ -291,6 +317,7 @@ FocusScope {
} else {
// Force the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14
setSource("", {})
fittedOnce = false
}
}
@ -359,7 +386,6 @@ FocusScope {
}
}
property var image: {
if (floatImageViewerLoader.active)
floatImageViewerLoader.item
@ -368,8 +394,8 @@ FocusScope {
else
qtImageViewerLoader.item
}
width: image ? image.width : 1
height: image ? image.height : 1
width: image ? (image.width > 0 ? image.width : 1) : 1
height: image ? (image.height > 0 ? image.height : 1) : 1
scale: 1.0
// FeatureViewer: display view extracted feature points
@ -829,12 +855,14 @@ FocusScope {
padding: 0
Layout.minimumWidth: 0
checkable: true
checked: false
checked: root.aliceVisionPluginAvailable
enabled: root.aliceVisionPluginAvailable
visible: root.enable8bitViewer
onCheckedChanged : {
if(displayLensDistortionViewer.checked && checked){
if (displayLensDistortionViewer.checked && checked) {
displayLensDistortionViewer.checked = false;
}
root.useFloatImageViewer = !root.useFloatImageViewer
}
}
MaterialToolButton {
@ -865,9 +893,11 @@ FocusScope {
checked: false
enabled: activeNode && isComputed
onCheckedChanged : {
if((displayHDR.checked || displayPanoramaViewer.checked) && checked){
if ((displayHDR.checked || displayPanoramaViewer.checked) && checked) {
displayHDR.checked = false;
displayPanoramaViewer.checked = false;
} else if (!checked) {
displayHDR.checked = true;
}
}
}
@ -897,15 +927,15 @@ FocusScope {
checked: false
enabled: activeNode && isComputed
onCheckedChanged : {
if(displayLensDistortionViewer.checked && checked){
if (displayLensDistortionViewer.checked && checked) {
displayLensDistortionViewer.checked = false;
}
if(displayFisheyeCircleLoader.checked && checked){
if (displayFisheyeCircleLoader.checked && checked) {
displayFisheyeCircleLoader.checked = false;
}
}
onEnabledChanged : {
if(!enabled){
if (!enabled) {
checked = false;
}
}