add ComboBox to select depth map file

This commit is contained in:
ChemicalXandco 2019-09-24 19:24:47 +01:00 committed by Fabien Castan
parent 978f4a9b00
commit 5652770a42

View file

@ -9,7 +9,9 @@ FocusScope {
id: root id: root
clip: true clip: true
property url source property url source
property url realSource
property var metadata property var metadata
function clear() function clear()
@ -26,6 +28,18 @@ FocusScope {
} }
} }
onSourceChanged: {
realSource = getImageFile(imageType.type)
}
Binding {
target: _reconstruction.onDepthMapChanged
value: {
realSource = getImageFile(imageType.type)
}
}
// functions // functions
function fit() { function fit() {
if(image.status != Image.Ready) if(image.status != Image.Ready)
@ -35,6 +49,18 @@ FocusScope {
image.y = Math.max((root.height-image.height*image.scale)*0.5, 0) image.y = Math.max((root.height-image.height*image.scale)*0.5, 0)
} }
function getImageFile(type) {
var withExtension
if (type == "nmodMap") {
withExtension = type + ".png";
} else if (type == "image") {
return root.source;
} else {
withExtension = type + ".exr";
}
return "file:///"+_reconstruction.depthMap.internalFolder+"/"+_reconstruction.selectedViewId+"_"+withExtension;
}
// context menu // context menu
property Component contextMenu: Menu { property Component contextMenu: Menu {
MenuItem { MenuItem {
@ -56,7 +82,7 @@ FocusScope {
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
autoTransform: true autoTransform: true
onWidthChanged: if(status==Image.Ready) fit() onWidthChanged: if(status==Image.Ready) fit()
source: root.source source: root.realSource
onStatusChanged: { onStatusChanged: {
// update cache source when image is loaded // update cache source when image is loaded
if(status === Image.Ready) if(status === Image.Ready)
@ -160,7 +186,7 @@ FocusScope {
font.pointSize: 8 font.pointSize: 8
readOnly: true readOnly: true
selectByMouse: true selectByMouse: true
text: Filepath.urlToString(source) text: Filepath.urlToString(realSource)
} }
} }
@ -227,6 +253,18 @@ FocusScope {
} }
} }
ComboBox {
id: imageType
property var types: ["image", "depthMap", "simMap", "nmodMap"]
property string type: types[currentIndex]
model: types
onCurrentIndexChanged: {
root.realSource = root.getImageFile(type)
}
}
ToolButton { ToolButton {
id: metadataCB id: metadataCB
padding: 3 padding: 3