mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-19 17:47:25 +02:00
[desc] Attribute inherits BaseObject and expose members as properties
* also expose graph.Attribute's desc as a property * introduce Variant in data structure backend API
This commit is contained in:
parent
74e4089c68
commit
9c7d0c1b1c
5 changed files with 38 additions and 19 deletions
|
@ -5,13 +5,14 @@ Slot = None
|
||||||
Signal = None
|
Signal = None
|
||||||
Property = None
|
Property = None
|
||||||
BaseObject = None
|
BaseObject = None
|
||||||
|
Variant = None
|
||||||
|
|
||||||
if meshroom.backend == meshroom.Backend.PYSIDE:
|
if meshroom.backend == meshroom.Backend.PYSIDE:
|
||||||
# PySide types
|
# PySide types
|
||||||
from .qt import Model, Slot, Signal, Property, BaseObject
|
from .qt import Model, Slot, Signal, Property, BaseObject, Variant
|
||||||
elif meshroom.backend == meshroom.Backend.STANDALONE:
|
elif meshroom.backend == meshroom.Backend.STANDALONE:
|
||||||
# Core types
|
# Core types
|
||||||
from .core import Model, Slot, Signal, Property, BaseObject
|
from .core import Model, Slot, Signal, Property, BaseObject, Variant
|
||||||
|
|
||||||
|
|
||||||
class _BaseModel:
|
class _BaseModel:
|
||||||
|
|
|
@ -83,3 +83,4 @@ Slot = CoreSlot
|
||||||
Signal = CoreSignal
|
Signal = CoreSignal
|
||||||
Property = CoreProperty
|
Property = CoreProperty
|
||||||
BaseObject = CoreObject
|
BaseObject = CoreObject
|
||||||
|
Variant = object
|
||||||
|
|
|
@ -306,3 +306,4 @@ Slot = QtCore.Slot
|
||||||
Signal = QtCore.Signal
|
Signal = QtCore.Signal
|
||||||
Property = QtCore.Property
|
Property = QtCore.Property
|
||||||
BaseObject = QtCore.QObject
|
BaseObject = QtCore.QObject
|
||||||
|
Variant = "QVariant"
|
||||||
|
|
|
@ -1,19 +1,26 @@
|
||||||
|
from meshroom.common import BaseObject, Property, Variant, Signal
|
||||||
|
|
||||||
class Attribute(object):
|
|
||||||
|
class Attribute(BaseObject):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
isOutput = False
|
|
||||||
uid = []
|
|
||||||
group = 'allParams'
|
|
||||||
commandLine = '{nodeType} --help' # need to be overridden
|
|
||||||
|
|
||||||
def __init__(self, label, description, value, uid, group):
|
def __init__(self, label, description, value, uid, group):
|
||||||
self.label = label
|
super(Attribute, self).__init__()
|
||||||
self.description = description
|
self._label = label
|
||||||
self.value = value
|
self._description = description
|
||||||
self.uid = uid
|
self._value = value
|
||||||
self.group = group
|
self._uid = uid
|
||||||
|
self._group = group
|
||||||
|
self._isOutput = False
|
||||||
|
|
||||||
|
label = Property(str, lambda self: self._label, constant=True)
|
||||||
|
description = Property(str, lambda self: self._description, constant=True)
|
||||||
|
value = Property(Variant, lambda self: self._value, constant=True)
|
||||||
|
uid = Property(Variant, lambda self: self._uid, constant=True)
|
||||||
|
group = Property(str, lambda self: self._group, constant=True)
|
||||||
|
isOutput = Property(bool, lambda self: self._isOutput, constant=True)
|
||||||
|
|
||||||
|
|
||||||
class Param(Attribute):
|
class Param(Attribute):
|
||||||
"""
|
"""
|
||||||
|
@ -26,8 +33,8 @@ class File(Attribute):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
def __init__(self, label, description, value, uid, isOutput, group='allParams'):
|
def __init__(self, label, description, value, uid, isOutput, group='allParams'):
|
||||||
self.isOutput = isOutput
|
|
||||||
super(File, self).__init__(label=label, description=description, value=value, uid=uid, group=group)
|
super(File, self).__init__(label=label, description=description, value=value, uid=uid, group=group)
|
||||||
|
self._isOutput = isOutput
|
||||||
|
|
||||||
|
|
||||||
class BoolParam(Param):
|
class BoolParam(Param):
|
||||||
|
@ -41,27 +48,35 @@ class IntParam(Param):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
def __init__(self, label, description, value, range, uid, group='allParams'):
|
def __init__(self, label, description, value, range, uid, group='allParams'):
|
||||||
self.range = range
|
self._range = range
|
||||||
super(IntParam, self).__init__(label=label, description=description, value=value, uid=uid, group=group)
|
super(IntParam, self).__init__(label=label, description=description, value=value, uid=uid, group=group)
|
||||||
|
|
||||||
|
range = Property(Variant, lambda self: self._range, constant=True)
|
||||||
|
|
||||||
|
|
||||||
class FloatParam(Param):
|
class FloatParam(Param):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
def __init__(self, label, description, value, range, uid, group='allParams'):
|
def __init__(self, label, description, value, range, uid, group='allParams'):
|
||||||
self.range = range
|
self._range = range
|
||||||
super(FloatParam, self).__init__(label=label, description=description, value=value, uid=uid, group=group)
|
super(FloatParam, self).__init__(label=label, description=description, value=value, uid=uid, group=group)
|
||||||
|
|
||||||
|
range = Property(Variant, lambda self: self._range, constant=True)
|
||||||
|
|
||||||
|
|
||||||
class ChoiceParam(Param):
|
class ChoiceParam(Param):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
def __init__(self, label, description, value, values, exclusive, uid, group='allParams', joinChar=' '):
|
def __init__(self, label, description, value, values, exclusive, uid, group='allParams', joinChar=' '):
|
||||||
self.values = values
|
self._values = values
|
||||||
self.exclusive = exclusive
|
self._exclusive = exclusive
|
||||||
self.joinChar = joinChar
|
self._joinChar = joinChar
|
||||||
super(ChoiceParam, self).__init__(label=label, description=description, value=value, uid=uid, group=group)
|
super(ChoiceParam, self).__init__(label=label, description=description, value=value, uid=uid, group=group)
|
||||||
|
|
||||||
|
values = Property(Variant, lambda self: self._values, constant=True)
|
||||||
|
exclusive = Property(bool, lambda self: self._exclusive, constant=True)
|
||||||
|
joinChar = Property(str, lambda self: self._joinChar, constant=True)
|
||||||
|
|
||||||
|
|
||||||
class StringParam(Param):
|
class StringParam(Param):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -151,6 +151,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)
|
||||||
|
desc = Property(desc.Attribute, lambda self: self.attributeDesc, constant=True)
|
||||||
valueChanged = Signal()
|
valueChanged = Signal()
|
||||||
value = Property("QVariant", value.fget, value.fset, notify=valueChanged)
|
value = Property("QVariant", value.fget, value.fset, notify=valueChanged)
|
||||||
isOutput = Property(bool, isOutput.fget, constant=True)
|
isOutput = Property(bool, isOutput.fget, constant=True)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue