diff --git a/meshroom/ui/qml/Viewer/DepthMapLoader.qml b/meshroom/ui/qml/Viewer/DepthMapLoader.qml new file mode 100644 index 00000000..3f7c7e1a --- /dev/null +++ b/meshroom/ui/qml/Viewer/DepthMapLoader.qml @@ -0,0 +1,9 @@ +import DepthMapEntity 1.0 + +/** + * Support for Depth Map files (EXR) in Qt3d. + * Create this component dynamically to test for DepthMapEntity plugin availability. + */ +DepthMapEntity { + id: root +} diff --git a/meshroom/ui/qml/Viewer/Viewer3D.qml b/meshroom/ui/qml/Viewer/Viewer3D.qml index 6d7f054a..e72a6c7e 100644 --- a/meshroom/ui/qml/Viewer/Viewer3D.qml +++ b/meshroom/ui/qml/Viewer/Viewer3D.qml @@ -12,12 +12,15 @@ FocusScope { property alias source: modelLoader.source property alias abcSource: modelLoader.abcSource + property alias depthMapSource: modelLoader.depthMapSource readonly property alias loading: modelLoader.loading // Alembic optional support => won't be available if AlembicEntity plugin is not available readonly property Component abcLoaderComp: Qt.createComponent("AlembicLoader.qml") readonly property bool supportAlembic: abcLoaderComp.status == Component.Ready + readonly property Component depthMapLoaderComp: Qt.createComponent("DepthMapLoader.qml") + readonly property bool supportDepthMap: depthMapLoaderComp.status == Component.Ready // functions function resetCameraCenter() { @@ -233,6 +236,7 @@ FocusScope { id: modelLoader property string source property string abcSource + property string depthMapSource property bool meshHasTexture: false // SceneLoader status is not reliable when loading a 3D file property bool loading: false @@ -313,6 +317,32 @@ FocusScope { } } + Entity { + id: depthMapLoaderEntity + // Instantiate the DepthMapEntity dynamically + // to avoid import errors if the plugin is not available + property Entity depthMapLoader: undefined + enabled: showDepthMapCheckBox.checked + + Component.onCompleted: { + if(!root.supportDepthMap) // DepthMap plugin not available + return + + // destroy previously created entity + if(depthMapLoader != undefined) + depthMapLoader.destroy() + + depthMapLoader = depthMapLoaderComp.createObject(depthMapLoaderEntity, { + 'source': Qt.binding(function() { return modelLoader.depthMapSource } ) + }); + // 'sourceChanged' signal is emitted once the depthMap file is loaded + // set the 'loading' property to false when it's emitted + // TODO: DepthMapEntity should expose a status + depthMapLoader.onSourceChanged.connect(function(){ modelLoader.loading = false }) + modelLoader.loading = false + } + } + Locator3D { enabled: locatorCheckBox.checked } } Grid3D { enabled: gridCheckBox.checked } @@ -363,6 +393,16 @@ FocusScope { ToolTip.visible: hovered } } + Row { + visible: root.depthMapSource != '' + CheckBox { id: showDepthMapCheckBox; text: "DepthMap"; checked: true; } + ToolButton { + text: MaterialIcons.clear; font.family: MaterialIcons.fontFamily; + onClicked: root.depthMapSource = '' + ToolTip.text: "Unload" + ToolTip.visible: hovered + } + } Row { CheckBox { id: showMeshCheckBox; text: "Mesh"; checked: true; opacity: root.source ? 1.0 : 0.6 } ToolButton { diff --git a/meshroom/ui/qml/WorkspaceView.qml b/meshroom/ui/qml/WorkspaceView.qml index 1f738cc5..d4dede7c 100644 --- a/meshroom/ui/qml/WorkspaceView.qml +++ b/meshroom/ui/qml/WorkspaceView.qml @@ -36,6 +36,11 @@ Item { viewer3D.clearAbc() viewer3D.abcSource = filepath } + if(Filepath.extension(filepath) === ".exr") + { + // viewer3D.clearDepthMap() + viewer3D.depthMapSource = filepath + } else viewer3D.source = filepath }