Skip to content

Commit 0c704d2

Browse files
[ui] Node: If a node have at least one attribute not validated, it displays a warning icon, and selection border is orange
1 parent 845936d commit 0c704d2

File tree

6 files changed

+46
-7
lines changed

6 files changed

+46
-7
lines changed

meshroom/core/graph.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,7 @@ def setVerbose(self, v):
15641564
updated = Signal()
15651565
canComputeLeavesChanged = Signal()
15661566
canComputeLeaves = Property(bool, lambda self: self._canComputeLeaves, notify=canComputeLeavesChanged)
1567+
attributeValueChanged = Signal(Attribute)
15671568

15681569

15691570
def loadGraph(filepath, strictCompatibility: bool = False) -> Graph:

meshroom/core/node.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,12 @@ def has3DOutputAttribute(self):
16201620

16211621
return next((attr for attr in self._attributes if attr.enabled and attr.isOutput and attr.is3D), None) is not None
16221622

1623+
def _hasInvalidAttribute(self):
1624+
for attribute in self._attributes:
1625+
if len(attribute.errorMessages) > 0:
1626+
return True
1627+
return False
1628+
16231629
name = Property(str, getName, constant=True)
16241630
defaultLabel = Property(str, getDefaultLabel, constant=True)
16251631
nodeType = Property(str, nodeType.fget, constant=True)
@@ -1672,6 +1678,9 @@ def has3DOutputAttribute(self):
16721678
hasSequenceOutput = Property(bool, hasSequenceOutputAttribute, notify=outputAttrEnabledChanged)
16731679
has3DOutput = Property(bool, has3DOutputAttribute, notify=outputAttrEnabledChanged)
16741680

1681+
hasInvalidAttributeChanged = Signal()
1682+
hasInvalidAttribute = Property(bool, _hasInvalidAttribute, notify=hasInvalidAttributeChanged)
1683+
16751684

16761685
class Node(BaseNode):
16771686
"""

meshroom/ui/commands.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,23 @@ def redoImpl(self):
295295
if self.value == self.oldValue:
296296
return False
297297
if self.graph.attribute(self.attrName) is not None:
298-
self.graph.attribute(self.attrName).value = self.value
298+
attribute = self.graph.attribute(self.attrName)
299299
else:
300-
self.graph.internalAttribute(self.attrName).value = self.value
300+
attribute = self.graph.internalAttribute(self.attrName)
301+
302+
attribute.value = self.value
303+
self.graph.attributeValueChanged.emit(attribute)
304+
301305
return True
302306

303307
def undoImpl(self):
304308
if self.graph.attribute(self.attrName) is not None:
305-
self.graph.attribute(self.attrName).value = self.oldValue
309+
attribute = self.graph.attribute(self.attrName)
306310
else:
307-
self.graph.internalAttribute(self.attrName).value = self.oldValue
308-
311+
attribute = self.graph.internalAttribute(self.attrName)
312+
313+
attribute.value = self.oldValue
314+
self.graph.attributeValueChanged.emit(attribute)
309315

310316
class AddEdgeCommand(GraphCommand):
311317
def __init__(self, graph, src, dst, parent=None):

meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ RowLayout {
2929
signal inAttributeClicked(var srcItem, var mouse, var inAttributes)
3030
signal outAttributeClicked(var srcItem, var mouse, var outAttributes)
3131
signal showInViewer(var attr)
32-
signal attributeEdited(var attribute)
3332

3433
spacing: 2
3534

@@ -382,7 +381,6 @@ RowLayout {
382381
onEditingFinished: {
383382
setTextFieldAttribute(text)
384383
errorMessages = attribute.errorMessages
385-
root.attributeEdited(attribute)
386384
}
387385

388386
onAccepted: {

meshroom/ui/qml/GraphEditor/GraphEditor.qml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ Item {
851851

852852
mainSelected: uigraph.selectedNode === node
853853
hovered: uigraph.hoveredNode === node
854+
hasWarnings: node.hasInvalidAttribute
854855

855856
// ItemSelectionModel.hasSelection triggers updates anytime the selectionChanged() signal is emitted.
856857
selected: uigraph.nodeSelection.hasSelection ? uigraph.nodeSelection.isRowSelected(index) : false
@@ -979,6 +980,13 @@ Item {
979980
enabled: !nodeRepeater.ongoingDrag
980981
NumberAnimation { duration: 100 }
981982
}
983+
984+
Connections {
985+
target: uigraph.graph
986+
function onAttributeValueChanged() {
987+
hasWarnings = node.hasInvalidAttribute
988+
}
989+
}
982990
}
983991
}
984992
}

meshroom/ui/qml/GraphEditor/Node.qml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Item {
3232
property color baseColor: defaultColor
3333

3434
property point mousePosition: Qt.point(mouseArea.mouseX, mouseArea.mouseY)
35+
property bool hasWarnings: false
3536

3637
Item {
3738
id: m
@@ -154,6 +155,11 @@ Item {
154155
return 2
155156
}
156157
border.color: {
158+
159+
if(hasWarnings === true) {
160+
return "orange"
161+
}
162+
157163
if(root.mainSelected)
158164
return activePalette.highlight
159165
if(root.selected)
@@ -272,6 +278,17 @@ Item {
272278
}
273279
}
274280

281+
// Attribute warnings
282+
MaterialLabel {
283+
visible: hasWarnings
284+
text: MaterialIcons.warning
285+
color: "orange"
286+
padding: 2
287+
font.pointSize: 7
288+
palette.text: Colors.sysPalette.text
289+
ToolTip.text: "Some attribute validation are failing"
290+
}
291+
275292
// Submitted externally indicator
276293
MaterialLabel {
277294
visible: node.isExternal

0 commit comments

Comments
 (0)