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
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 }
@ -57,7 +65,9 @@ Item {
Controls1.SplitView {
orientation: Qt.Vertical
Layout.fillWidth: true
Layout.fillHeight: true
implicitWidth: Math.round(parent.width * 0.2)
Layout.minimumWidth: imageGallery.defaultCellSize
ImageGallery {
@ -78,8 +88,11 @@ Item {
Layout.preferredHeight: childrenRect.height
}
}
Panel {
title: "Image Viewer"
visible: settings_UILayout.showImageViewer
implicitWidth: Math.round(parent.width * 0.35)
Layout.fillHeight: true
Layout.fillWidth: true
Layout.minimumWidth: 50
@ -159,55 +172,76 @@ Item {
}
}
Panel {
title: "3D Viewer"
implicitWidth: Math.round(parent.width * 0.45)
Item {
visible: settings_UILayout.showViewer3D
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)
}
}
}
}

View file

@ -58,6 +58,8 @@ ApplicationWindow {
category: 'UILayout'
property alias showLiveReconstruction: liveSfMVisibilityCB.checked
property alias showGraphEditor: graphEditorVisibilityCB.checked
property alias showImageViewer: imageViewerVisibilityCB.checked
property alias showViewer3D: viewer3DVisibilityCB.checked
}
Component.onDestruction: {
@ -581,6 +583,18 @@ ApplicationWindow {
checkable: true
checked: false
}
MenuItem {
id: imageViewerVisibilityCB
text: "Image Viewer"
checkable: true
checked: true
}
MenuItem {
id: viewer3DVisibilityCB
text: "3D Viewer"
checkable: true
checked: true
}
MenuSeparator {}
Action {
text: "Fullscreen"
@ -742,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;
}