mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-21 13:06:28 +02:00
[core] Node: add duplicate nodes list property
This commit is contained in:
parent
8a5f4939b2
commit
fd51237fa3
2 changed files with 34 additions and 0 deletions
|
@ -1009,6 +1009,24 @@ class Graph(BaseObject):
|
||||||
for node in self._nodes:
|
for node in self._nodes:
|
||||||
node.updateStatisticsFromCache()
|
node.updateStatisticsFromCache()
|
||||||
|
|
||||||
|
def updateNodesPerUid(self):
|
||||||
|
""" Update the duplicate nodes (sharing same uid) list of each node. """
|
||||||
|
# First step is to construct a map uid/nodes
|
||||||
|
nodesPerUid = {}
|
||||||
|
for node in self.nodes:
|
||||||
|
uid = node._uids.get(0)
|
||||||
|
|
||||||
|
# We try to add the node to the list corresponding to this uid
|
||||||
|
try:
|
||||||
|
nodesPerUid.get(uid).append(node)
|
||||||
|
# If it fails because the uid is not in the map, we add it
|
||||||
|
except AttributeError:
|
||||||
|
nodesPerUid.update({uid: [node]})
|
||||||
|
|
||||||
|
# Now, update each individual node
|
||||||
|
for node in self.nodes:
|
||||||
|
node.updateDuplicates(nodesPerUid)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
if not self._updateEnabled:
|
if not self._updateEnabled:
|
||||||
# To do the update once for multiple changes
|
# To do the update once for multiple changes
|
||||||
|
@ -1021,6 +1039,8 @@ class Graph(BaseObject):
|
||||||
for node in self.nodes:
|
for node in self.nodes:
|
||||||
node.dirty = False
|
node.dirty = False
|
||||||
|
|
||||||
|
self.updateNodesPerUid()
|
||||||
|
|
||||||
# Graph topology has changed
|
# Graph topology has changed
|
||||||
if self.dirtyTopology:
|
if self.dirtyTopology:
|
||||||
# update nodes topological data cache
|
# update nodes topological data cache
|
||||||
|
|
|
@ -463,6 +463,7 @@ class BaseNode(BaseObject):
|
||||||
self._attributes = DictModel(keyAttrName='name', parent=self)
|
self._attributes = DictModel(keyAttrName='name', parent=self)
|
||||||
self.attributesPerUid = defaultdict(set)
|
self.attributesPerUid = defaultdict(set)
|
||||||
self._locked = False
|
self._locked = False
|
||||||
|
self._duplicates = ListModel(parent=self) # list of nodes with the same uid
|
||||||
|
|
||||||
self.globalStatusChanged.connect(self.updateLocked)
|
self.globalStatusChanged.connect(self.updateLocked)
|
||||||
|
|
||||||
|
@ -865,6 +866,17 @@ class BaseNode(BaseObject):
|
||||||
|
|
||||||
self.setLocked(False)
|
self.setLocked(False)
|
||||||
|
|
||||||
|
def updateDuplicates(self, nodesPerUid):
|
||||||
|
""" Update the list of duplicate nodes (sharing the same uid). """
|
||||||
|
if not nodesPerUid:
|
||||||
|
self._duplicates.clear()
|
||||||
|
self.duplicatesChanged.emit()
|
||||||
|
return
|
||||||
|
|
||||||
|
uid = self._uids.get(0)
|
||||||
|
self._duplicates.setObjectList([node for node in nodesPerUid.get(uid) if node != self])
|
||||||
|
self.duplicatesChanged.emit()
|
||||||
|
|
||||||
name = Property(str, getName, constant=True)
|
name = Property(str, getName, constant=True)
|
||||||
label = Property(str, getLabel, constant=True)
|
label = Property(str, getLabel, constant=True)
|
||||||
nodeType = Property(str, nodeType.fget, constant=True)
|
nodeType = Property(str, nodeType.fget, constant=True)
|
||||||
|
@ -888,6 +900,8 @@ class BaseNode(BaseObject):
|
||||||
isComputed = Property(bool, _isComputed, notify=globalStatusChanged)
|
isComputed = Property(bool, _isComputed, notify=globalStatusChanged)
|
||||||
lockedChanged = Signal()
|
lockedChanged = Signal()
|
||||||
locked = Property(bool, getLocked, setLocked, notify=lockedChanged)
|
locked = Property(bool, getLocked, setLocked, notify=lockedChanged)
|
||||||
|
duplicatesChanged = Signal()
|
||||||
|
duplicates = Property(Variant, lambda self: self._duplicates, notify=duplicatesChanged)
|
||||||
|
|
||||||
|
|
||||||
class Node(BaseNode):
|
class Node(BaseNode):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue