Merge pull request #1545 from alicevision/dev/hideWidgets

[ui] widgets visibility options
This commit is contained in:
Fabien Castan 2021-10-22 10:32:07 +02:00 committed by GitHub
commit c3cfa21b25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 94 additions and 44 deletions

View file

@ -22,7 +22,7 @@ Item {
property variant reconstruction: _reconstruction property variant reconstruction: _reconstruction
readonly property variant cameraInits: _reconstruction.cameraInits readonly property variant cameraInits: _reconstruction.cameraInits
property bool readOnly: false property bool readOnly: false
readonly property Viewer3D viewer3D: viewer3D property alias panel3dViewer: panel3dViewerLoader.item
readonly property Viewer2D viewer2D: viewer2D readonly property Viewer2D viewer2D: viewer2D
implicitWidth: 300 implicitWidth: 300
@ -31,12 +31,18 @@ Item {
// Load a 3D media file in the 3D viewer // Load a 3D media file in the 3D viewer
function load3DMedia(filepath) { function load3DMedia(filepath) {
viewer3D.load(filepath); if(panel3dViewerLoader.active) {
panel3dViewerLoader.item.viewer3D.load(filepath);
}
} }
Connections { Connections {
target: reconstruction target: reconstruction
onGraphChanged: viewer3D.clear() onGraphChanged: {
if(panel3dViewerLoader.active) {
panel3dViewerLoader.item.viewer3D.clear()
}
}
onSfmChanged: viewSfM() onSfmChanged: viewSfM()
onSfmReportChanged: viewSfM() onSfmReportChanged: viewSfM()
} }
@ -47,7 +53,9 @@ Item {
var activeNode = _reconstruction.activeNodes.get('sfm').node; var activeNode = _reconstruction.activeNodes.get('sfm').node;
if(!activeNode) if(!activeNode)
return; return;
viewer3D.view(activeNode.attribute('output')); if(panel3dViewerLoader.active) {
panel3dViewerLoader.item.viewer3D.view(activeNode.attribute('output'));
}
} }
SystemPalette { id: activePalette } SystemPalette { id: activePalette }
@ -57,7 +65,9 @@ Item {
Controls1.SplitView { Controls1.SplitView {
orientation: Qt.Vertical orientation: Qt.Vertical
Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
implicitWidth: Math.round(parent.width * 0.2)
Layout.minimumWidth: imageGallery.defaultCellSize Layout.minimumWidth: imageGallery.defaultCellSize
ImageGallery { ImageGallery {
@ -78,8 +88,11 @@ Item {
Layout.preferredHeight: childrenRect.height Layout.preferredHeight: childrenRect.height
} }
} }
Panel { Panel {
title: "Image Viewer" title: "Image Viewer"
visible: settings_UILayout.showImageViewer
implicitWidth: Math.round(parent.width * 0.35)
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumWidth: 50 Layout.minimumWidth: 50
@ -159,55 +172,76 @@ Item {
} }
} }
Panel { Item {
title: "3D Viewer" visible: settings_UILayout.showViewer3D
implicitWidth: Math.round(parent.width * 0.45)
Layout.minimumWidth: 20 Layout.minimumWidth: 20
Layout.minimumHeight: 80 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 anchors.fill: parent
Viewer3D { sourceComponent: panel3dViewerComponent
id: viewer3D }
}
Layout.fillWidth: true Component {
Layout.fillHeight: true id: panel3dViewerComponent
Layout.minimumWidth: 20 Panel {
id: panel3dViewer
title: "3D Viewer"
DropArea { property alias viewer3D: c_viewer3D
anchors.fill: parent
keys: ["text/uri-list"] Controls1.SplitView {
onDropped: { id: c_viewer3DSplitView
drop.urls.forEach(function(url){ load3DMedia(url); }); 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"))
} }
} }
// Load reconstructed model // Inspector Panel
Button { Inspector3D {
readonly property var outputAttribute: _reconstruction.texturing ? _reconstruction.texturing.attribute("outputMesh") : null id: inspector3d
readonly property bool outputReady: outputAttribute && _reconstruction.texturing.globalStatus === "SUCCESS" width: 200
readonly property int outputMediaIndex: viewer3D.library.find(outputAttribute) Layout.minimumWidth: 5
text: "Load Model" mediaLibrary: c_viewer3D.library
anchors.bottom: parent.bottom camera: c_viewer3D.mainCamera
anchors.bottomMargin: 10 uigraph: reconstruction
anchors.horizontalCenter: parent.horizontalCenter onNodeActivated: _reconstruction.setActiveNode(node)
visible: outputReady && outputMediaIndex == -1
onClicked: viewer3D.view(_reconstruction.texturing.attribute("outputMesh"))
} }
} }
// Inspector Panel
Inspector3D {
id: inspector3d
width: 200
Layout.minimumWidth: 5
mediaLibrary: viewer3D.library
camera: viewer3D.mainCamera
uigraph: reconstruction
onNodeActivated: _reconstruction.setActiveNode(node)
}
} }
} }
} }

View file

@ -58,6 +58,8 @@ ApplicationWindow {
category: 'UILayout' category: 'UILayout'
property alias showLiveReconstruction: liveSfMVisibilityCB.checked property alias showLiveReconstruction: liveSfMVisibilityCB.checked
property alias showGraphEditor: graphEditorVisibilityCB.checked property alias showGraphEditor: graphEditorVisibilityCB.checked
property alias showImageViewer: imageViewerVisibilityCB.checked
property alias showViewer3D: viewer3DVisibilityCB.checked
} }
Component.onDestruction: { Component.onDestruction: {
@ -581,6 +583,18 @@ ApplicationWindow {
checkable: true checkable: true
checked: false checked: false
} }
MenuItem {
id: imageViewerVisibilityCB
text: "Image Viewer"
checkable: true
checked: true
}
MenuItem {
id: viewer3DVisibilityCB
text: "3D Viewer"
checkable: true
checked: true
}
MenuSeparator {} MenuSeparator {}
Action { Action {
text: "Fullscreen" text: "Fullscreen"
@ -742,10 +756,12 @@ ApplicationWindow {
} }
function viewIn3D(attribute, mouse) { 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 // solo media if Control modifier was held
if(loaded && mouse && mouse.modifiers & Qt.ControlModifier) if(loaded && mouse && mouse.modifiers & Qt.ControlModifier)
viewer3D.solo(attribute); panel3dViewer.viewer3D.solo(attribute);
return loaded; return loaded;
} }