mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-21 13:06:28 +02:00
[processGraph] Attribute.value as an "hybrid" property
Use "hybrid" property to simplify naming of properties. No matter the backend used (qt or core), the property is always accessible via its name, without differently named getter or setter methods.
This commit is contained in:
parent
d556547d0b
commit
a81aa53a6b
2 changed files with 12 additions and 7 deletions
|
@ -74,10 +74,12 @@ class Attribute(BaseObject):
|
||||||
def getLabel(self):
|
def getLabel(self):
|
||||||
return self._label
|
return self._label
|
||||||
|
|
||||||
def getValue(self):
|
@property
|
||||||
|
def value(self):
|
||||||
return self._value
|
return self._value
|
||||||
|
|
||||||
def setValue(self, value):
|
@value.setter
|
||||||
|
def value(self, value):
|
||||||
if self._value == value:
|
if self._value == value:
|
||||||
return
|
return
|
||||||
self._value = value
|
self._value = value
|
||||||
|
@ -135,7 +137,7 @@ class Attribute(BaseObject):
|
||||||
name = Property(str, getName, constant=True)
|
name = Property(str, getName, constant=True)
|
||||||
label = Property(str, getLabel, constant=True)
|
label = Property(str, getLabel, constant=True)
|
||||||
valueChanged = Signal()
|
valueChanged = Signal()
|
||||||
value = Property("QVariant", getValue, setValue, notify=valueChanged)
|
value = Property("QVariant", value.fget, value.fset, notify=valueChanged)
|
||||||
|
|
||||||
class Edge(BaseObject):
|
class Edge(BaseObject):
|
||||||
|
|
||||||
|
@ -301,7 +303,7 @@ class Node(BaseObject):
|
||||||
for name, attr in self._attributes.objects.items():
|
for name, attr in self._attributes.objects.items():
|
||||||
if not attr.attributeDesc.isOutput:
|
if not attr.attributeDesc.isOutput:
|
||||||
continue # skip inputs
|
continue # skip inputs
|
||||||
attr._value = attr.attributeDesc.value.format(
|
attr.value = attr.attributeDesc.value.format(
|
||||||
nodeType=self.nodeType(),
|
nodeType=self.nodeType(),
|
||||||
**self._cmdVars)
|
**self._cmdVars)
|
||||||
v = attr._value
|
v = attr._value
|
||||||
|
|
|
@ -117,11 +117,14 @@ class SetAttributeCommand(GraphCommand):
|
||||||
self.nodeName = attribute.node.getName()
|
self.nodeName = attribute.node.getName()
|
||||||
self.attrName = attribute.getName()
|
self.attrName = attribute.getName()
|
||||||
self.value = value
|
self.value = value
|
||||||
self.oldValue = attribute.getValue()
|
self.oldValue = attribute.value
|
||||||
|
self.setText("Set Attribute '{}'".format(attribute.fullName()))
|
||||||
|
|
||||||
def redoImpl(self):
|
def redoImpl(self):
|
||||||
self.graph.node(self.nodeName).attribute(self.attrName).setValue(self.value)
|
if self.value == self.oldValue:
|
||||||
|
return False
|
||||||
|
self.graph.node(self.nodeName).attribute(self.attrName).value = self.value
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def undoImpl(self):
|
def undoImpl(self):
|
||||||
self.graph.node(self.nodeName).attribute(self.attrName).setValue(self.oldValue)
|
self.graph.node(self.nodeName).attribute(self.attrName).value = self.oldValue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue