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
|
||||
Property = None
|
||||
BaseObject = None
|
||||
Variant = None
|
||||
|
||||
if meshroom.backend == meshroom.Backend.PYSIDE:
|
||||
# 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:
|
||||
# Core types
|
||||
from .core import Model, Slot, Signal, Property, BaseObject
|
||||
from .core import Model, Slot, Signal, Property, BaseObject, Variant
|
||||
|
||||
|
||||
class _BaseModel:
|
||||
|
|
|
@ -83,3 +83,4 @@ Slot = CoreSlot
|
|||
Signal = CoreSignal
|
||||
Property = CoreProperty
|
||||
BaseObject = CoreObject
|
||||
Variant = object
|
||||
|
|
|
@ -306,3 +306,4 @@ Slot = QtCore.Slot
|
|||
Signal = QtCore.Signal
|
||||
Property = QtCore.Property
|
||||
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):
|
||||
self.label = label
|
||||
self.description = description
|
||||
self.value = value
|
||||
self.uid = uid
|
||||
self.group = group
|
||||
|
||||
super(Attribute, self).__init__()
|
||||
self._label = label
|
||||
self._description = description
|
||||
self._value = value
|
||||
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):
|
||||
"""
|
||||
|
@ -26,8 +33,8 @@ class File(Attribute):
|
|||
"""
|
||||
"""
|
||||
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)
|
||||
self._isOutput = isOutput
|
||||
|
||||
|
||||
class BoolParam(Param):
|
||||
|
@ -41,27 +48,35 @@ class IntParam(Param):
|
|||
"""
|
||||
"""
|
||||
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)
|
||||
|
||||
range = Property(Variant, lambda self: self._range, constant=True)
|
||||
|
||||
|
||||
class FloatParam(Param):
|
||||
"""
|
||||
"""
|
||||
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)
|
||||
|
||||
range = Property(Variant, lambda self: self._range, constant=True)
|
||||
|
||||
|
||||
class ChoiceParam(Param):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, label, description, value, values, exclusive, uid, group='allParams', joinChar=' '):
|
||||
self.values = values
|
||||
self.exclusive = exclusive
|
||||
self.joinChar = joinChar
|
||||
self._values = values
|
||||
self._exclusive = exclusive
|
||||
self._joinChar = joinChar
|
||||
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):
|
||||
"""
|
||||
|
|
|
@ -151,6 +151,7 @@ class Attribute(BaseObject):
|
|||
|
||||
name = Property(str, getName, constant=True)
|
||||
label = Property(str, getLabel, constant=True)
|
||||
desc = Property(desc.Attribute, lambda self: self.attributeDesc, constant=True)
|
||||
valueChanged = Signal()
|
||||
value = Property("QVariant", value.fget, value.fset, notify=valueChanged)
|
||||
isOutput = Property(bool, isOutput.fget, constant=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue