Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support display and connection of attributes that are part of GroupAttributes #2544

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
164163d
[core] Attribute: Add notion of depth for attributes with parents
cbentejac Sep 17, 2024
4ab9347
[core] Attribute: Add a `flattenedChildren` property
cbentejac Sep 19, 2024
7c7cae0
[core] Correctly match descriptions for connected attributes within g…
cbentejac Sep 23, 2024
b9dcc7f
[core] Attribute: Parent's `exposed` property takes precedence over d…
cbentejac Sep 20, 2024
a97778f
[GraphEditor] Allow to display and connect attributes within `GroupAt…
cbentejac Sep 23, 2024
5c7f75f
[ui] Graph: `canExpandForLoop`: Ensure all checks are performed on a …
cbentejac Sep 23, 2024
55ae221
[GraphEditor] Refer to an attribute's parent in its tooltip
cbentejac Sep 23, 2024
521d7b7
[core] Add dedicated `flatStaticChildren` property for GroupAttributes
cbentejac Dec 12, 2024
50c4347
[tests] Add test node with `GroupAttributes` and unit tests
cbentejac Oct 21, 2024
06f9d15
[MaterialIcons] MaterialToolLabel: Add new accessors to the item's el…
cbentejac Dec 12, 2024
201c961
[GraphEditor] AttributePin: Add a tree view for children attributes
cbentejac Dec 12, 2024
4280295
[GraphEditor] Node: Display connected children when the parent is col…
cbentejac Dec 12, 2024
f521bfa
[GraphEditor] Remove enabling/disabling pins depending on edge's visi…
cbentejac Dec 13, 2024
279582b
[core] Attribute: Use `root`'s values for `depth` and `exposed`
cbentejac Dec 19, 2024
f6c9da1
[GraphEditor] AttributePin: Add a delay before displaying the tooltip
cbentejac Dec 20, 2024
3a1ab9b
[GraphEditor] AttributePin: Use `root` accessor for QML properties
cbentejac Dec 30, 2024
431c528
[GraphEditor] AttributePin: Disable connections between `GroupAttribu…
cbentejac Dec 30, 2024
d5a7e25
[GraphEditor] AttributePin: Do not start dragging edge on `pressed`
cbentejac Dec 30, 2024
11f2576
[MaterialIcons] MaterialToolLabel: Handle label's size correctly
cbentejac Dec 31, 2024
3234bb9
[MaterialIcons] MaterialToolLabel: Use `control` accessor for properties
cbentejac Dec 31, 2024
0716f00
[GraphEditor] AttributePin: Handle width and elide for attributes' name
cbentejac Jan 10, 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
36 changes: 35 additions & 1 deletion meshroom/core/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def __init__(self, node, attributeDesc, isOutput, root=None, parent=None):
self._description = attributeDesc.description
self._invalidate = False if self._isOutput else attributeDesc.invalidate

self._exposed = root.exposed if root is not None else attributeDesc.exposed
self._depth = root.depth + 1 if root is not None else 0

# invalidation value for output attributes
self._invalidationValue = ""

Expand All @@ -79,6 +82,12 @@ def node(self):
def root(self):
return self._root() if self._root else None

def getDepth(self):
return self._depth

def getExposed(self):
return self._exposed

def getName(self):
""" Attribute name """
return self._name
Expand Down Expand Up @@ -330,7 +339,7 @@ def _applyExpr(self):
elif self.isInput and Attribute.isLinkExpression(v):
# value is a link to another attribute
link = v[1:-1]
linkNode, linkAttr = link.split('.')
linkNode, linkAttr = link.split('.', 1)
try:
g.addEdge(g.node(linkNode).attribute(linkAttr), self)
except KeyError as err:
Expand Down Expand Up @@ -397,6 +406,13 @@ def updateInternals(self):
# Emit if the enable status has changed
self.setEnabled(self.getEnabled())

def getFlatStaticChildren(self):
""" Return a list of all the attributes that refer to this instance as their parent through
the 'root' property. If no such attribute exist, return an empty list. The depth difference is not
taken into account in the list, which is thus always flat. """
# For all attributes but GroupAttributes, there cannot be any child
return []

name = Property(str, getName, constant=True)
fullName = Property(str, getFullName, constant=True)
fullNameToNode = Property(str, getFullNameToNode, constant=True)
Expand All @@ -409,6 +425,7 @@ def updateInternals(self):
type = Property(str, getType, constant=True)
baseType = Property(str, getType, constant=True)
isReadOnly = Property(bool, _isReadOnly, constant=True)
exposed = Property(bool, getExposed, constant=True)

# Description of the attribute
descriptionChanged = Signal()
Expand Down Expand Up @@ -438,6 +455,8 @@ def updateInternals(self):
validValueChanged = Signal()
validValue = Property(bool, getValidValue, setValidValue, notify=validValueChanged)
root = Property(BaseObject, root.fget, constant=True)
depth = Property(int, getDepth, constant=True)
flatStaticChildren = Property(Variant, getFlatStaticChildren, constant=True)


def raiseIfLink(func):
Expand Down Expand Up @@ -790,10 +809,25 @@ def updateInternals(self):
for attr in self._value:
attr.updateInternals()

def getFlatStaticChildren(self):
""" Return a list of all the attributes that refer to this instance of GroupAttribute as their parent
through the 'root' property. In the case of GroupAttributes, any attribute within said group will be
a child. The depth difference is not taken into account when generating the list, which is thus always
flat. """
attributes = []

# Iterate over the values and add the flat children of every child (if they exist)
for attribute in self._value:
attributes.append(attribute)
attributes = attributes + attribute.getFlatStaticChildren()

return attributes

@Slot(str, result=bool)
def matchText(self, text):
return super().matchText(text) or any(c.matchText(text) for c in self._value)

# Override value property
value = Property(Variant, Attribute._get_value, _set_value, notify=Attribute.valueChanged)
isDefault = Property(bool, _isDefault, notify=Attribute.valueChanged)
flatStaticChildren = Property(Variant, getFlatStaticChildren, constant=True)
11 changes: 10 additions & 1 deletion meshroom/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1711,9 +1711,18 @@
attrDesc = next((d for d in refAttributes if d.name == name), None)
if attrDesc is None:
return None

# We have found a description, and we still need to
# check if the value matches the attribute description.
#

# If it is a GroupAttribute, all attributes within the group should be matched individually
# so that links that can be correctly evaluated
if isinstance(attrDesc, desc.GroupAttribute):
for k, v in value.items():
if CompatibilityNode.attributeDescFromName(attrDesc.groupDesc, k, v, strict=True) is None:
return None

Check warning on line 1723 in meshroom/core/node.py

View check run for this annotation

Codecov / codecov/patch

meshroom/core/node.py#L1723

Added line #L1723 was not covered by tests
return attrDesc

# If it is a serialized link expression (no proper value to set/evaluate)
if Attribute.isLinkExpression(value):
return attrDesc
Expand Down
3 changes: 2 additions & 1 deletion meshroom/ui/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,8 @@ def duplicateNodesFrom(self, nodes: list[Node]) -> list[Node]:
def canExpandForLoop(self, currentEdge):
""" Check if the list attribute can be expanded by looking at all the edges connected to it. """
listAttribute = currentEdge.src.root
if not listAttribute:
# Check that the parent is indeed a ListAttribute (it could be a GroupAttribute, for instance)
if not listAttribute or not isinstance(listAttribute, ListAttribute):
return False
srcIndex = listAttribute.index(currentEdge.src)
allSrc = [e.src for e in self._graph.edges.values()]
Expand Down
5 changes: 3 additions & 2 deletions meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ RowLayout {
var tooltip = ""
if (!attribute.validValue && attribute.desc.errorMessage !== "")
tooltip += "<i><b>Error: </b>" + Format.plainToHtml(attribute.desc.errorMessage) + "</i><br><br>"
tooltip += "<b> " + attribute.desc.name + ":</b> " + attribute.type + "<br>" + Format.plainToHtml(attribute.desc.description)
tooltip += "<b> " + attribute.fullName + ":</b> " + attribute.type + "<br>" + Format.plainToHtml(attribute.desc.description)

console.warn(attribute.fullName)
parameterTooltip.text = tooltip
}
}
Expand Down Expand Up @@ -85,7 +86,7 @@ RowLayout {
var tooltip = ""
if (!object.validValue && object.desc.errorMessage !== "")
tooltip += "<i><b>Error: </b>" + Format.plainToHtml(object.desc.errorMessage) + "</i><br><br>"
tooltip += "<b>" + object.desc.name + ":</b> " + attribute.type + "<br>" + Format.plainToHtml(object.description)
tooltip += "<b>" + object.fullName + ":</b> " + attribute.type + "<br>" + Format.plainToHtml(object.description)
return tooltip
}
visible: parameterMA.containsMouse
Expand Down
Loading
Loading