Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ef57737
[ui] AttributeEditor: Add navigation buttons for linked attributes
nicolas-lambert-tc May 2, 2025
a26870c
[ui] AttributeEditor: Add missing singal connections to allow attribu…
nicolas-lambert-tc May 2, 2025
3a9565f
[ui] AttributeEditor: The attribute nav buttons are now aligned with …
nicolas-lambert-tc May 2, 2025
97196d9
[ui] Attribute: Add tests to check retrieving the linked input/output…
nicolas-lambert-tc May 2, 2025
2f39d41
[ui] Attribute: Refacto the test to avoid the coverage complaining ab…
nicolas-lambert-tc May 2, 2025
ea1adcd
[ui] AttributeEditor: Remove console.log
nicolas-lambert-tc May 2, 2025
a3056c8
[ui] AttributeEditor: Factorize the visibility conditions in nav buttons
nicolas-lambert-tc May 2, 2025
96a09fe
[ui,core] Attribute: Refacto the linked attributes method's name for …
nicolas-lambert-tc May 2, 2025
1de3834
[ui] AttributeDelegate: Use correct alignment strategy to avoid warnings
nicolas-lambert-tc May 2, 2025
1943474
[ui] AttributeEditor: Now, middle click on nav button fit the view to…
nicolas-lambert-tc May 2, 2025
cc4e1a2
[ui, core] AttributeEditor: Fix the ListAttribute navigation buttons …
nicolas-lambert-tc May 2, 2025
3de4471
[ui] AttributeItemDelegate: Add navButton ids for clarity and future …
nicolas-lambert-tc May 2, 2025
812cc65
[ui] NodeEditor: add the listing of connected attributes for rightCli…
nicolas-lambert-tc May 2, 2025
cc2d485
[ui] NodeEditor: Factorize attributeNavButton click behavior
nicolas-lambert-tc May 2, 2025
81f6924
[core] attributes: Add tests for coverage
nicolas-lambert-tc May 2, 2025
03c745a
[ui] AttributeEditor: Fix navButton left click behavior. (Wasn't sele…
nicolas-lambert-tc May 5, 2025
3da2918
[ui] AttributeEditor: navButton context show truncated text if the la…
nicolas-lambert-tc May 5, 2025
5d2c85b
[core] Attribute: Fix ListAttributes input / output connections retri…
nicolas-lambert-tc May 5, 2025
d1b434d
[ui] Attribute: Use bool type for shouldBeVisible property
nicolas-lambert-tc May 6, 2025
7881fa1
[ui] Attribute: Align non linked attributes label (in/out) with the l…
nicolas-lambert-tc May 6, 2025
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
34 changes: 34 additions & 0 deletions meshroom/core/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
from meshroom.common import BaseObject, Property, Variant, Signal, ListModel, DictModel, Slot
from meshroom.core import desc, hashValue

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from meshroom.core.graph import Edge

Check warning on line 18 in meshroom/core/attribute.py

View check run for this annotation

Codecov / codecov/patch

meshroom/core/attribute.py#L18

Added line #L18 was not covered by tests


def attributeFactory(description, value, isOutput, node, root=None, parent=None):
"""
Expand Down Expand Up @@ -326,6 +331,33 @@
any(attr.hasOutputConnections for attr in self._value if hasattr(attr, 'hasOutputConnections'))
return next((edge for edge in self.node.graph.edges.values() if edge.src == self), None) is not None

def getInputConnections(self) -> list["Edge"]:
""" Retrieve the upstreams connected edges """

if not self.node.graph or not self.node.graph.edges:
return []

Check warning on line 338 in meshroom/core/attribute.py

View check run for this annotation

Codecov / codecov/patch

meshroom/core/attribute.py#L338

Added line #L338 was not covered by tests

return [edge for edge in self.node.graph.edges.values() if edge.dst == self]

def getOutputConnections(self) -> list["Edge"]:
""" Retrieve all the edges connected to this attribute """

if not self.node.graph or not self.node.graph.edges:
return []

Check warning on line 346 in meshroom/core/attribute.py

View check run for this annotation

Codecov / codecov/patch

meshroom/core/attribute.py#L346

Added line #L346 was not covered by tests

return [edge for edge in self.node.graph.edges.values() if edge.src == self]

def getInputAttributes(self) -> list["Edge"]:
""" Return the upstreams connected attributes """

return [edge.src for edge in self.getInputConnections()]


def getOutputAttributes(self):
""" Return the downstreams connected attributes """

return [edge.dst for edge in self.getOutputConnections()]

def _applyExpr(self):
"""
For string parameters with an expression (when loaded from file),
Expand Down Expand Up @@ -449,6 +481,8 @@
isLinkNested = isLink
hasOutputConnectionsChanged = Signal()
hasOutputConnections = Property(bool, hasOutputConnections.fget, notify=hasOutputConnectionsChanged)
inputAttributes = Property(Variant, getInputAttributes)
outputAttributes = Property(Variant, getOutputAttributes)
isDefault = Property(bool, _isDefault, notify=valueChanged)
linkParam = Property(BaseObject, getLinkParam, notify=isLinkChanged)
rootLinkParam = Property(BaseObject, lambda self: self.getLinkParam(recursive=True), notify=isLinkChanged)
Expand Down
26 changes: 26 additions & 0 deletions meshroom/ui/qml/Application.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,33 @@ Page {
onUpgradeRequest: {
var n = _reconstruction.upgradeNode(node)
_reconstruction.selectedNode = n
}

onInAttributeClicked: function(mouse, inAttributes) {
selectNodesFromAttributes(inAttributes)
}

onOutAttributeClicked: function(mouse, outAttributes) {
selectNodesFromAttributes(outAttributes)
}

function selectNodesFromAttributes(attributes) {
/*
Retrieve the nodes from given attributes, and select its
*/

if ( !attributes || attributes.length == 0) { return }

graphEditor.uigraph.clearNodeSelection()

const nodes = attributes.map( attr => attr.node)

if (attributes.length == 1) {
_reconstruction.selectedNode = attributes[0].node
}
graphEditor.uigraph.selectNodes(nodes)
}

}
}
}
Expand Down
10 changes: 10 additions & 0 deletions meshroom/ui/qml/GraphEditor/AttributeEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ ListView {

signal upgradeRequest()
signal attributeDoubleClicked(var mouse, var attribute)
signal inAttributeClicked(var mouse, var inAttributes)
signal outAttributeClicked(var mouse, var outAttributes)

implicitHeight: contentHeight

Expand All @@ -40,9 +42,17 @@ ListView {
filterText: root.filterText
objectsHideable: root.objectsHideable
attribute: object

onDoubleClicked: function(mouse, attr) {
root.attributeDoubleClicked(mouse, attr)
}
onInAttributeClicked: function(mouse, inAttributes) {
root.inAttributeClicked(mouse, inAttributes)
}
onOutAttributeClicked: function(mouse, outAttributes) {
root.outAttributeClicked(mouse, outAttributes)
}

}

onActiveChanged: height = active ? item.implicitHeight : -spacing
Expand Down
39 changes: 39 additions & 0 deletions meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ RowLayout {
readonly property bool editable: !attribute.isOutput && !attribute.isLink && !readOnly

signal doubleClicked(var mouse, var attr)
signal inAttributeClicked(var mouse, var inAttributes)
signal outAttributeClicked(var mouse, var outAttributes)

spacing: 2

Expand Down Expand Up @@ -56,6 +58,24 @@ RowLayout {
width: parent.width
height: parent.height

// In connection
MaterialToolButton {
property var shouldBeVisible: (object != undefined && object.isLink)
Comment thread
fabiencastan marked this conversation as resolved.
Outdated

text: shouldBeVisible ? MaterialIcons.login : " "
enabled: shouldBeVisible
font.pointSize: 8
anchors.top: parent.top
anchors.left: parent.left
Comment thread
fabiencastan marked this conversation as resolved.
Outdated
topPadding: 7
ToolTip.text: shouldBeVisible ? object.linkParam.label : ""

onClicked: function(mouse) {
root.inAttributeClicked(mouse, object.inputAttributes)
}

}

Label {
id: parameterLabel

Expand Down Expand Up @@ -167,6 +187,23 @@ RowLayout {
}
}
}

MaterialToolButton {
property var shouldBeVisible: (attribute != undefined && attribute.hasOutputConnections)

text: shouldBeVisible ? MaterialIcons.logout : ""
font.pointSize: 8
enabled: shouldBeVisible
anchors.top: parent.top
anchors.right: parent.right
topPadding: 7

onClicked: function(mouse) {
root.outAttributeClicked(mouse, attribute.outputAttributes)
}

}

MaterialLabel {
visible: attribute.desc.advanced
text: MaterialIcons.build
Expand Down Expand Up @@ -666,6 +703,8 @@ RowLayout {
obj.label.horizontalAlignment = Text.AlignHCenter
obj.label.verticalAlignment = Text.AlignVCenter
obj.doubleClicked.connect(function(attr) { root.doubleClicked(attr) })
obj.inAttributeClicked.connect(function(mouse, inAttributes) { root.inAttributeClicked(mouse, inAttributes) })
obj.outAttributeClicked.connect(function(mouse, outAttributes) { root.outAttributeClicked(mouse, outAttributes) })
}
ToolButton {
enabled: root.editable
Expand Down
9 changes: 9 additions & 0 deletions meshroom/ui/qml/GraphEditor/NodeEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Panel {
property string nodeStartDateTime: ""

signal attributeDoubleClicked(var mouse, var attribute)
signal inAttributeClicked(var mouse, var inAttributes)
signal outAttributeClicked(var mouse, var outAttributes)
signal upgradeRequest()

title: "Node" + (node !== null ? " - <b>" + node.label + "</b>" + (node.label !== node.defaultLabel ? " (" + node.defaultLabel + ")" : "") : "")
Expand Down Expand Up @@ -301,6 +303,13 @@ Panel {
onAttributeDoubleClicked: function(mouse, attribute) { root.attributeDoubleClicked(mouse, attribute) }
onUpgradeRequest: root.upgradeRequest()
filterText: searchBar.text

onInAttributeClicked: function(mouse, inAttributes) {
root.inAttributeClicked(mouse, inAttributes)
}
onOutAttributeClicked: function(mouse, outAttributes) {
root.outAttributeClicked(mouse, outAttributes)
}
}

Loader {
Expand Down
29 changes: 29 additions & 0 deletions tests/test_attributes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from meshroom.core.graph import Graph


def test_attribute_retrieve_linked_input_and_output_attributes():
"""
Check that an attribute can retrieve the linked input and output attributes
"""

# n0 -- n1 -- n2
# \ \
# ---------- n3

g = Graph('')
n0 = g.addNewNode('Ls', input='')
n1 = g.addNewNode('Ls', input=n0.output)
n2 = g.addNewNode('Ls', input=n1.output)
n3 = g.addNewNode('AppendFiles', input=n1.output, input2=n2.output)

# check that the attribute can retrieve its linked input attributes
assert len(n0.input.getInputAttributes()) == 0
assert len(n1.input.getInputAttributes()) == 1
assert n1.input.getInputAttributes()[0] == n0.output

assert len(n1.output.getOutputAttributes()) == 2

assert n1.output.getOutputAttributes()[0] == n2.input
assert n1.output.getOutputAttributes()[1] == n3.input