mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-01 02:12:04 +02:00
Add "label" as an internal attribute
Setting the "label" internal attribute allows to give a custom label to replace the node's default label.
This commit is contained in:
parent
9bc9e2c129
commit
330382ab0c
4 changed files with 31 additions and 1 deletions
|
@ -168,6 +168,10 @@ class Attribute(BaseObject):
|
||||||
# TODO: only update the graph if this attribute participates to a UID
|
# TODO: only update the graph if this attribute participates to a UID
|
||||||
if self.isInput:
|
if self.isInput:
|
||||||
self.requestGraphUpdate()
|
self.requestGraphUpdate()
|
||||||
|
# TODO: only call update of the node if the attribute is internal
|
||||||
|
# Internal attributes are set as inputs
|
||||||
|
self.requestNodeUpdate()
|
||||||
|
|
||||||
self.valueChanged.emit()
|
self.valueChanged.emit()
|
||||||
|
|
||||||
def upgradeValue(self, exportedValue):
|
def upgradeValue(self, exportedValue):
|
||||||
|
@ -181,6 +185,12 @@ class Attribute(BaseObject):
|
||||||
self.node.graph.markNodesDirty(self.node)
|
self.node.graph.markNodesDirty(self.node)
|
||||||
self.node.graph.update()
|
self.node.graph.update()
|
||||||
|
|
||||||
|
def requestNodeUpdate(self):
|
||||||
|
# Update specific node information that do not affect the rest of the graph
|
||||||
|
# (like internal attributes)
|
||||||
|
if self.node:
|
||||||
|
self.node.updateInternalAttributes()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def isOutput(self):
|
def isOutput(self):
|
||||||
return self._isOutput
|
return self._isOutput
|
||||||
|
|
|
@ -501,6 +501,13 @@ class Node(object):
|
||||||
value="",
|
value="",
|
||||||
semantic="multiline",
|
semantic="multiline",
|
||||||
uid=[0],
|
uid=[0],
|
||||||
|
),
|
||||||
|
StringParam(
|
||||||
|
name="label",
|
||||||
|
label="Label",
|
||||||
|
description="Custom label to replace the node's default label.",
|
||||||
|
value="",
|
||||||
|
uid=[],
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
inputs = []
|
inputs = []
|
||||||
|
|
|
@ -524,8 +524,12 @@ class BaseNode(BaseObject):
|
||||||
def getLabel(self):
|
def getLabel(self):
|
||||||
"""
|
"""
|
||||||
Returns:
|
Returns:
|
||||||
str: the high-level label of this node
|
str: the user-provided label if it exists, the high-level label of this node otherwise
|
||||||
"""
|
"""
|
||||||
|
if self.hasInternalAttribute("label"):
|
||||||
|
label = self.internalAttribute("label").value.strip()
|
||||||
|
if label:
|
||||||
|
return label
|
||||||
return self.nameToLabel(self._name)
|
return self.nameToLabel(self._name)
|
||||||
|
|
||||||
@Slot(str, result=str)
|
@Slot(str, result=str)
|
||||||
|
@ -856,6 +860,9 @@ class BaseNode(BaseObject):
|
||||||
if self.internalFolder != folder:
|
if self.internalFolder != folder:
|
||||||
self.internalFolderChanged.emit()
|
self.internalFolderChanged.emit()
|
||||||
|
|
||||||
|
def updateInternalAttributes(self):
|
||||||
|
self.internalAttributesChanged.emit()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def internalFolder(self):
|
def internalFolder(self):
|
||||||
return self._internalFolder.format(**self._cmdVars)
|
return self._internalFolder.format(**self._cmdVars)
|
||||||
|
@ -1089,6 +1096,7 @@ class BaseNode(BaseObject):
|
||||||
y = Property(float, lambda self: self._position.y, notify=positionChanged)
|
y = Property(float, lambda self: self._position.y, notify=positionChanged)
|
||||||
attributes = Property(BaseObject, getAttributes, constant=True)
|
attributes = Property(BaseObject, getAttributes, constant=True)
|
||||||
internalAttributes = Property(BaseObject, getInternalAttributes, constant=True)
|
internalAttributes = Property(BaseObject, getInternalAttributes, constant=True)
|
||||||
|
internalAttributesChanged = Signal()
|
||||||
internalFolderChanged = Signal()
|
internalFolderChanged = Signal()
|
||||||
internalFolder = Property(str, internalFolder.fget, notify=internalFolderChanged)
|
internalFolder = Property(str, internalFolder.fget, notify=internalFolderChanged)
|
||||||
depthChanged = Signal()
|
depthChanged = Signal()
|
||||||
|
|
|
@ -71,6 +71,10 @@ Item {
|
||||||
root.x = root.node.x
|
root.x = root.node.x
|
||||||
root.y = root.node.y
|
root.y = root.node.y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onInternalAttributesChanged: {
|
||||||
|
nodeLabel.text = node ? node.label : ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Whether an attribute can be displayed as an attribute pin on the node
|
// Whether an attribute can be displayed as an attribute pin on the node
|
||||||
|
@ -181,6 +185,7 @@ Item {
|
||||||
|
|
||||||
// Node Name
|
// Node Name
|
||||||
Label {
|
Label {
|
||||||
|
id: nodeLabel
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: node ? node.label : ""
|
text: node ? node.label : ""
|
||||||
padding: 4
|
padding: 4
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue