Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions meshroom/nodes/aliceVision/Texturing.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class Texturing(desc.AVCommandLineNode):
label="Bump Type",
description="Export normal map or height map.",
value="Normal",
values=("Height", "Normal"),
values=["Height", "Normal"],
exclusive=True,
uid=[0],
enabled=lambda node: node.bumpMapping.enable.value,
Expand All @@ -140,7 +140,7 @@ class Texturing(desc.AVCommandLineNode):
label="File Type",
description="File type for the normal map texture.",
value="exr",
values = ("exr", "png", "tiff", "jpg"),
values=["exr", "png", "tiff", "jpg"],
exclusive=True,
uid=[0],
enabled=lambda node: node.bumpMapping.enable.value and node.bumpMapping.bumpType.value == "Normal",
Expand All @@ -150,7 +150,7 @@ class Texturing(desc.AVCommandLineNode):
label="File Type",
description="File type for the height map texture.",
value="exr",
values=("exr",),
values=["exr",],
exclusive=True,
uid=[0],
enabled=lambda node: node.bumpMapping.enable.value and node.bumpMapping.bumpType.value == "Height",
Expand All @@ -177,7 +177,7 @@ class Texturing(desc.AVCommandLineNode):
label="File Type",
description="File type for the height map texture.",
value="exr",
values=("exr"),
values=["exr"],
exclusive=True,
uid=[0],
enabled=lambda node: node.displacementMapping.enable.value,
Expand All @@ -192,7 +192,7 @@ class Texturing(desc.AVCommandLineNode):
" - LSCM (<= 600k faces): optimize space. Generates one atlas.\n"
" - ABF (<= 300k faces): optimize space and stretch. Generates one atlas.",
value="Basic",
values=("Basic", "LSCM", "ABF"),
values=["Basic", "LSCM", "ABF"],
exclusive=True,
uid=[0],
),
Expand Down
175 changes: 175 additions & 0 deletions meshroom/ui/qml/Controls/FilterComboBox.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import Utils 1.0

/**
* ComboBox with filter text area
*
* @param inputModel - model to filter
* @param editingFinished - signal emitted when editing is finished
* @alias filterText - text to filter the model
*/

ComboBox {
id: combo

property var inputModel
signal editingFinished(var value)

property alias filterText: filterTextArea
property bool validValue: true

enabled: root.editable
model: {
var filteredData = inputModel.filter(condition => {
if (filterTextArea.text.length > 0) return condition.toString().toLowerCase().includes(filterTextArea.text.toLowerCase())
return true
})
if (filteredData.length > 0) {
filterTextArea.background.color = Qt.lighter(palette.base, 2)
validValue = true

// order filtered data by relevance (results that start with the filter text come first)
filteredData.sort((a, b) => {
const nameA = a.toString().toLowerCase();
const nameB = b.toString().toLowerCase();
const filterText = filterTextArea.text.toLowerCase()
if (nameA.startsWith(filterText) && !nameB.startsWith(filterText))
return -1
if (!nameA.startsWith(filterText) && nameB.startsWith(filterText))
return 1
return 0
})
} else {
filterTextArea.background.color = Colors.red
validValue = false
}

if (filteredData.length == 0 || filterTextArea.length == 0) {
filteredData = inputModel
}

return filteredData
}

background: Rectangle {
implicitHeight: root.implicitHeight
color: {
if (validValue) {
return palette.mid
} else {
return Colors.red
}
}
border.color: palette.base
}

popup: Popup {
width: combo.width
implicitHeight: contentItem.implicitHeight

onAboutToShow: {
filterTextArea.forceActiveFocus()

if (mapToGlobal(popup.x, popup.y).y + root.implicitHeight * (model.length + 1) > _window.contentItem.height) {
y = -root.implicitHeight * (model.length + 1)
} else {
y = 0
}
}

contentItem: Item {
anchors.fill: parent
TextArea {
id: filterTextArea
leftPadding: 12
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top

selectByMouse: true
hoverEnabled: true
wrapMode: TextEdit.WrapAnywhere
placeholderText: "Filter"
background: Rectangle {}

onEditingFinished: {
combo.popup.close()
combo.editingFinished(displayText)
}

Keys.onEnterPressed: {
if (!validValue) {
displayText = filterTextArea.text
} else {
displayText = currentText
}
editingFinished()
}

Keys.onReturnPressed: {
if (!validValue) {
displayText = filterTextArea.text
} else {
displayText = currentText
}
editingFinished()
}

Keys.onUpPressed: {
// if the current index is 0, the user wants to go to the last item
if (combo.currentIndex == 0) {
combo.currentIndex = combo.model.length - 1
} else {
combo.currentIndex--
}
}

Keys.onDownPressed: {
// if the current index is the last one, the user wants to go to the first item
if (combo.currentIndex == combo.model.length - 1) {
combo.currentIndex = 0
} else {
combo.currentIndex++
}
}
}
}

ListView {
clip: true
anchors.left: parent.left
anchors.right: parent.right
anchors.top: filterTextArea.bottom

implicitHeight: contentHeight
model: combo.popup.visible ? combo.delegateModel : null

ScrollIndicator.vertical: ScrollIndicator {}
}
}

delegate: ItemDelegate {
width: combo.width
height: combo.height

contentItem: Text {
text: modelData
color: palette.text
}

highlighted: validValue ? combo.currentIndex === index : false

hoverEnabled: true
}

onHighlightedIndexChanged: {
if (highlightedIndex >= 0) {
combo.currentIndex = highlightedIndex
}
}

onCurrentTextChanged: {
displayText = currentText
}
}
1 change: 1 addition & 0 deletions meshroom/ui/qml/Controls/qmldir
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ SearchBar 1.0 SearchBar.qml
TabPanel 1.0 TabPanel.qml
TextFileViewer 1.0 TextFileViewer.qml
ExifOrientedViewer 1.0 ExifOrientedViewer.qml
FilterComboBox 1.0 FilterComboBox.qml
40 changes: 33 additions & 7 deletions meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import QtQuick.Controls 2.2
import QtQuick.Dialogs 1.3
import MaterialIcons 2.2
import Utils 1.0
import Controls 1.0

/**
Instantiate a control to visualize and edit an Attribute based on its type.
Expand Down Expand Up @@ -342,16 +343,41 @@ RowLayout {

Component {
id: comboBox_component
ComboBox {
id: combo
enabled: root.editable
model: attribute.values
Component.onCompleted: currentIndex = find(attribute.value)
onActivated: _reconstruction.setAttribute(attribute, currentText)

FilterComboBox {
inputModel: attribute.values

Component.onCompleted: {
// if value not in list, override the text and precise it is not valid
var idx = find(attribute.value)
if (idx === -1) {
displayText = attribute.value
validValue = false
} else {
currentIndex = idx
}
}

onEditingFinished: function(value) {
_reconstruction.setAttribute(attribute, value)
}

Connections {
target: attribute
function onValueChanged() {
combo.currentIndex = combo.find(attribute.value)
// when reset, clear and find the current index
// but if only reopen the combo box, keep the current value

//convert all values of desc values as string
var valuesAsString = attribute.values.map(function(value) {
return value.toString()
})
if (valuesAsString.includes(attribute.value) || attribute.value === attribute.desc.value) {
filterText.clear()
validValue = true
displayText = currentText
currentIndex = find(attribute.value)
}
}
}
}
Expand Down