From dedc5b44995f5e3307b05702fc35a3ead264dd7c Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Tue, 19 Oct 2021 15:17:54 +0200 Subject: [PATCH] [ui] 3DViewer: use a Loader to completely disable the 3D environment --- meshroom/ui/qml/WorkspaceView.qml | 111 +++++++++++++++++++----------- meshroom/ui/qml/main.qml | 6 +- 2 files changed, 73 insertions(+), 44 deletions(-) diff --git a/meshroom/ui/qml/WorkspaceView.qml b/meshroom/ui/qml/WorkspaceView.qml index 9172fb6b..d6291517 100644 --- a/meshroom/ui/qml/WorkspaceView.qml +++ b/meshroom/ui/qml/WorkspaceView.qml @@ -22,7 +22,7 @@ Item { property variant reconstruction: _reconstruction readonly property variant cameraInits: _reconstruction.cameraInits property bool readOnly: false - readonly property Viewer3D viewer3D: viewer3D + property alias panel3dViewer: panel3dViewerLoader.item readonly property Viewer2D viewer2D: viewer2D implicitWidth: 300 @@ -31,12 +31,18 @@ Item { // Load a 3D media file in the 3D viewer function load3DMedia(filepath) { - viewer3D.load(filepath); + if(panel3dViewerLoader.active) { + panel3dViewerLoader.item.viewer3D.load(filepath); + } } Connections { target: reconstruction - onGraphChanged: viewer3D.clear() + onGraphChanged: { + if(panel3dViewerLoader.active) { + panel3dViewerLoader.item.viewer3D.clear() + } + } onSfmChanged: viewSfM() onSfmReportChanged: viewSfM() } @@ -47,7 +53,9 @@ Item { var activeNode = _reconstruction.activeNodes.get('sfm').node; if(!activeNode) return; - viewer3D.view(activeNode.attribute('output')); + if(panel3dViewerLoader.active) { + panel3dViewerLoader.item.viewer3D.view(activeNode.attribute('output')); + } } SystemPalette { id: activePalette } @@ -80,6 +88,7 @@ Item { Layout.preferredHeight: childrenRect.height } } + Panel { title: "Image Viewer" visible: settings_UILayout.showImageViewer @@ -163,58 +172,76 @@ Item { } } - Panel { - title: "3D Viewer" + Item { visible: settings_UILayout.showViewer3D - implicitWidth: Math.round(parent.width * 0.45) Layout.minimumWidth: 20 Layout.minimumHeight: 80 Layout.fillHeight: true Layout.fillWidth: true + implicitWidth: Math.round(parent.width * 0.45) - Controls1.SplitView { + Loader { + id: panel3dViewerLoader + active: settings_UILayout.showViewer3D + visible: active anchors.fill: parent - Viewer3D { - id: viewer3D + sourceComponent: panel3dViewerComponent + } + } - Layout.fillWidth: true - Layout.fillHeight: true - Layout.minimumWidth: 20 + Component { + id: panel3dViewerComponent + Panel { + id: panel3dViewer + title: "3D Viewer" + + property alias viewer3D: c_viewer3D - DropArea { - anchors.fill: parent - keys: ["text/uri-list"] - onDropped: { - drop.urls.forEach(function(url){ load3DMedia(url); }); + Controls1.SplitView { + id: c_viewer3DSplitView + anchors.fill: parent + Viewer3D { + id: c_viewer3D + + Layout.fillWidth: true + Layout.fillHeight: true + Layout.minimumWidth: 20 + + DropArea { + anchors.fill: parent + keys: ["text/uri-list"] + onDropped: { + drop.urls.forEach(function(url){ load3DMedia(url); }); + } + } + + // Load reconstructed model + Button { + readonly property var outputAttribute: _reconstruction.texturing ? _reconstruction.texturing.attribute("outputMesh") : null + readonly property bool outputReady: outputAttribute && _reconstruction.texturing.globalStatus === "SUCCESS" + readonly property int outputMediaIndex: c_viewer3D.library.find(outputAttribute) + + text: "Load Model" + anchors.bottom: parent.bottom + anchors.bottomMargin: 10 + anchors.horizontalCenter: parent.horizontalCenter + visible: outputReady && outputMediaIndex == -1 + onClicked: viewer3D.view(_reconstruction.texturing.attribute("outputMesh")) } } + + // Inspector Panel + Inspector3D { + id: inspector3d + width: 200 + Layout.minimumWidth: 5 - // Load reconstructed model - Button { - readonly property var outputAttribute: _reconstruction.texturing ? _reconstruction.texturing.attribute("outputMesh") : null - readonly property bool outputReady: outputAttribute && _reconstruction.texturing.globalStatus === "SUCCESS" - readonly property int outputMediaIndex: viewer3D.library.find(outputAttribute) - - text: "Load Model" - anchors.bottom: parent.bottom - anchors.bottomMargin: 10 - anchors.horizontalCenter: parent.horizontalCenter - visible: outputReady && outputMediaIndex == -1 - onClicked: viewer3D.view(_reconstruction.texturing.attribute("outputMesh")) + mediaLibrary: c_viewer3D.library + camera: c_viewer3D.mainCamera + uigraph: reconstruction + onNodeActivated: _reconstruction.setActiveNode(node) } } - - // Inspector Panel - Inspector3D { - id: inspector3d - width: 200 - Layout.minimumWidth: 5 - - mediaLibrary: viewer3D.library - camera: viewer3D.mainCamera - uigraph: reconstruction - onNodeActivated: _reconstruction.setActiveNode(node) - } } } } diff --git a/meshroom/ui/qml/main.qml b/meshroom/ui/qml/main.qml index 1667e78d..e28a42b5 100755 --- a/meshroom/ui/qml/main.qml +++ b/meshroom/ui/qml/main.qml @@ -756,10 +756,12 @@ ApplicationWindow { } function viewIn3D(attribute, mouse) { - var loaded = viewer3D.view(attribute); + if(!panel3dViewer) + return false; + var loaded = panel3dViewer.viewer3D.view(attribute); // solo media if Control modifier was held if(loaded && mouse && mouse.modifiers & Qt.ControlModifier) - viewer3D.solo(attribute); + panel3dViewer.viewer3D.solo(attribute); return loaded; }