Skip to content

Commit a73312b

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 76edb06 commit a73312b

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
@@ -1630,6 +1630,12 @@ def has3DOutputAttribute(self):
16301630
return True
16311631
return False
16321632

1633+
def _hasInvalidAttribute(self):
1634+
for attribute in self._attributes:
1635+
if len(attribute.errorMessages) > 0:
1636+
return True
1637+
return False
1638+
16331639
name = Property(str, getName, constant=True)
16341640
defaultLabel = Property(str, getDefaultLabel, constant=True)
16351641
nodeType = Property(str, nodeType.fget, constant=True)
@@ -1682,6 +1688,9 @@ def has3DOutputAttribute(self):
16821688
hasSequenceOutput = Property(bool, hasSequenceOutputAttribute, notify=outputAttrEnabledChanged)
16831689
has3DOutput = Property(bool, has3DOutputAttribute, notify=outputAttrEnabledChanged)
16841690

1691+
hasInvalidAttributeChanged = Signal()
1692+
hasInvalidAttribute = Property(bool, _hasInvalidAttribute, notify=hasInvalidAttributeChanged)
1693+
16851694

16861695
class Node(BaseNode):
16871696
"""

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
@@ -28,7 +28,6 @@ RowLayout {
2828
signal doubleClicked(var mouse, var attr)
2929
signal inAttributeClicked(var srcItem, var mouse, var inAttributes)
3030
signal outAttributeClicked(var srcItem, var mouse, var outAttributes)
31-
signal attributeEdited(var attribute)
3231

3332
spacing: 2
3433

@@ -356,7 +355,6 @@ RowLayout {
356355
onEditingFinished: {
357356
setTextFieldAttribute(text)
358357
errorMessages = attribute.errorMessages
359-
root.attributeEdited(attribute)
360358
}
361359

362360
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)