From e23b20cd70d25b70cf9e83dfdc421e4b1b725832 Mon Sep 17 00:00:00 2001 From: Landrodie Date: Tue, 12 Jan 2021 11:18:07 +0100 Subject: [PATCH] wip [panoramaViewer] add viewer files --- meshroom/ui/qml/Viewer/PanoramaViewer.qml | 56 +++++++++++++++++++++++ meshroom/ui/qml/Viewer/Viewer2D.qml | 40 +++++++++++++++- 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 meshroom/ui/qml/Viewer/PanoramaViewer.qml diff --git a/meshroom/ui/qml/Viewer/PanoramaViewer.qml b/meshroom/ui/qml/Viewer/PanoramaViewer.qml new file mode 100644 index 00000000..9314afbc --- /dev/null +++ b/meshroom/ui/qml/Viewer/PanoramaViewer.qml @@ -0,0 +1,56 @@ +import QtQuick 2.11 +import Utils 1.0 + +import AliceVision 1.0 as AliceVision + +/** + * FloatImage displays an Image with gamma / offset / channel controls + * Requires QtAliceVision plugin. + */ + +AliceVision.PanoramaViewer { + id: root + + width: textureSize.width + height: textureSize.height + visible: (status === Image.Ready) + + // paintedWidth / paintedHeight / status for compatibility with standard Image + property int paintedWidth: textureSize.width + property int paintedHeight: textureSize.height + property var status: { + if(root.loading) + return Image.Loading; + else if((root.source === "") || + (root.sourceSize.height <= 0) || + (root.sourceSize.height <= 0)) + return Image.Null; + return Image.Ready; + } + + property string channelModeString : "rgba" + + channelMode: { + switch(channelModeString) + { + case "rgb": return AliceVision.FloatImageViewer.EChannelMode.RGB + case "r": return AliceVision.FloatImageViewer.EChannelMode.R + case "g": return AliceVision.FloatImageViewer.EChannelMode.G + case "b": return AliceVision.FloatImageViewer.EChannelMode.B + case "a": return AliceVision.FloatImageViewer.EChannelMode.A + default: return AliceVision.FloatImageViewer.EChannelMode.RGBA + } + } + clearBeforeLoad: true + + property alias containsMouse: mouseArea.containsMouse + property alias mouseX: mouseArea.mouseX + property alias mouseY: mouseArea.mouseY + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + // Do not intercept mouse events, only get the mouse over information + acceptedButtons: Qt.NoButton + } +} diff --git a/meshroom/ui/qml/Viewer/Viewer2D.qml b/meshroom/ui/qml/Viewer/Viewer2D.qml index 83b1b2e3..36687f45 100644 --- a/meshroom/ui/qml/Viewer/Viewer2D.qml +++ b/meshroom/ui/qml/Viewer/Viewer2D.qml @@ -15,6 +15,7 @@ FocusScope { property Component floatViewerComp: Qt.createComponent("FloatImage.qml") property alias useFloatImageViewer: displayHDR.checked + property alias usePanoramaImageViewer: displayPanoramaViewer.checked Loader { id: aliceVisionPluginLoader @@ -227,10 +228,34 @@ FocusScope { } } + Loader { + id: panoramaViewerLoader + active: root.aliceVisionPluginAvailable && root.usePanoramaImageViewer + visible: (panoramaViewerLoader.status === Loader.Ready) + anchors.centerIn: parent + + onActiveChanged: { + 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, { + setSource("PanoramaViewer.qml", { + 'source': Qt.binding(function() { return getImageFile(imageType.type); }), + 'gamma': Qt.binding(function() { return hdrImageToolbar.gammaValue; }), + 'gain': Qt.binding(function() { return hdrImageToolbar.gainValue; }), + 'channelModeString': Qt.binding(function() { return hdrImageToolbar.channelModeValue; }), + }) + } else { + // Force the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14 + setSource("", {}) + } + } + } + // Simple QML Image Viewer (using Qt or qtOIIO to load images) Loader { id: qtImageViewerLoader - active: !floatImageViewerLoader.active + active: !floatImageViewerLoader.active && !panoramaViewerLoader.active anchors.centerIn: parent sourceComponent: Image { id: qtImageViewer @@ -694,6 +719,19 @@ FocusScope { checked: false enabled: root.aliceVisionPluginAvailable } + MaterialToolButton { + id: displayPanoramaViewer + ToolTip.text: "Panorama Viewer" + text: MaterialIcons.panorama_horizontal + // larger font but smaller padding, + // so it is visually similar. + font.pointSize: 16 + padding: 0 + Layout.minimumWidth: 0 + checkable: true + checked: false + enabled: root.aliceVisionPluginAvailable + } MaterialToolButton { id: displayFeatures ToolTip.text: "Display Features"