wip [panoramaViewer] add viewer files

This commit is contained in:
Landrodie 2021-01-12 11:18:07 +01:00 committed by Fabien Castan
parent a9abd29019
commit e23b20cd70
2 changed files with 95 additions and 1 deletions

View file

@ -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
}
}

View file

@ -15,6 +15,7 @@ FocusScope {
property Component floatViewerComp: Qt.createComponent("FloatImage.qml") property Component floatViewerComp: Qt.createComponent("FloatImage.qml")
property alias useFloatImageViewer: displayHDR.checked property alias useFloatImageViewer: displayHDR.checked
property alias usePanoramaImageViewer: displayPanoramaViewer.checked
Loader { Loader {
id: aliceVisionPluginLoader 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) // Simple QML Image Viewer (using Qt or qtOIIO to load images)
Loader { Loader {
id: qtImageViewerLoader id: qtImageViewerLoader
active: !floatImageViewerLoader.active active: !floatImageViewerLoader.active && !panoramaViewerLoader.active
anchors.centerIn: parent anchors.centerIn: parent
sourceComponent: Image { sourceComponent: Image {
id: qtImageViewer id: qtImageViewer
@ -694,6 +719,19 @@ FocusScope {
checked: false checked: false
enabled: root.aliceVisionPluginAvailable 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 { MaterialToolButton {
id: displayFeatures id: displayFeatures
ToolTip.text: "Display Features" ToolTip.text: "Display Features"