refactor: Renamed DataFlowKind to FlowKind
parent
dfeb65feec
commit
76d15b0c92
|
@ -54,7 +54,7 @@ from .managed_obj_type import ManagedObjType
|
|||
# - Data Flows
|
||||
####################
|
||||
from .data_flows import (
|
||||
DataFlowKind,
|
||||
FlowKind,
|
||||
DataCapabilities,
|
||||
DataValue,
|
||||
DataValueArray,
|
||||
|
@ -89,7 +89,7 @@ __all__ = [
|
|||
'NodeCategory',
|
||||
'NODE_CAT_LABELS',
|
||||
'ManagedObjType',
|
||||
'DataFlowKind',
|
||||
'FlowKind',
|
||||
'DataCapabilities',
|
||||
'DataValue',
|
||||
'DataValueArray',
|
||||
|
|
|
@ -103,7 +103,7 @@ class MapMathNode(base.MaxwellSimNode):
|
|||
'Data',
|
||||
props={'active_socket_set', 'operation'},
|
||||
input_sockets={'Data', 'Mapper'},
|
||||
input_socket_kinds={'Mapper': ct.DataFlowKind.LazyValue},
|
||||
input_socket_kinds={'Mapper': ct.FlowKind.LazyValue},
|
||||
input_sockets_optional={'Mapper': True},
|
||||
)
|
||||
def compute_data(self, props: dict, input_sockets: dict):
|
||||
|
|
|
@ -81,7 +81,7 @@ class ReduceMathNode(base.MaxwellSimNode):
|
|||
'Data',
|
||||
props={'operation'},
|
||||
input_sockets={'Data', 'Axis', 'Reducer'},
|
||||
input_socket_kinds={'Reducer': ct.DataFlowKind.LazyValue},
|
||||
input_socket_kinds={'Reducer': ct.FlowKind.LazyValue},
|
||||
input_sockets_optional={'Reducer': True},
|
||||
)
|
||||
def compute_data(self, props: dict, input_sockets: dict):
|
||||
|
|
|
@ -273,7 +273,7 @@ class MaxwellSimNode(bpy.types.Node):
|
|||
msg = f'Tried to set preset socket/value pair ({socket_name}={socket_value}), but socket is not in active input sockets ({self.inputs})'
|
||||
raise ValueError(msg)
|
||||
|
||||
## TODO: Account for DataFlowKind
|
||||
## TODO: Account for FlowKind
|
||||
bl_socket.value = socket_value
|
||||
|
||||
@events.on_show_preview()
|
||||
|
@ -558,7 +558,7 @@ class MaxwellSimNode(bpy.types.Node):
|
|||
def _compute_input(
|
||||
self,
|
||||
input_socket_name: ct.SocketName,
|
||||
kind: ct.DataFlowKind = ct.DataFlowKind.Value,
|
||||
kind: ct.FlowKind = ct.FlowKind.Value,
|
||||
unit_system: dict[ct.SocketType, sp.Expr] | None = None,
|
||||
optional: bool = False,
|
||||
) -> typ.Any:
|
||||
|
@ -574,7 +574,7 @@ class MaxwellSimNode(bpy.types.Node):
|
|||
"""
|
||||
if (bl_socket := self.inputs.get(input_socket_name)) is not None:
|
||||
return (
|
||||
ct.DataFlowKind.scale_to_unit_system(
|
||||
ct.FlowKind.scale_to_unit_system(
|
||||
kind,
|
||||
bl_socket.compute_data(kind=kind),
|
||||
bl_socket.socket_type,
|
||||
|
@ -599,14 +599,14 @@ class MaxwellSimNode(bpy.types.Node):
|
|||
def compute_output(
|
||||
self,
|
||||
output_socket_name: ct.SocketName,
|
||||
kind: ct.DataFlowKind = ct.DataFlowKind.Value,
|
||||
kind: ct.FlowKind = ct.FlowKind.Value,
|
||||
optional: bool = False,
|
||||
) -> typ.Any:
|
||||
"""Computes the value of an output socket.
|
||||
|
||||
Parameters:
|
||||
output_socket_name: The name declaring the output socket, for which this method computes the output.
|
||||
kind: The DataFlowKind to use when computing the output socket value.
|
||||
kind: The FlowKind to use when computing the output socket value.
|
||||
|
||||
Returns:
|
||||
The value of the output socket, as computed by the dedicated method
|
||||
|
|
|
@ -26,16 +26,16 @@ class InfoDataChanged:
|
|||
@dataclasses.dataclass(kw_only=True, frozen=True)
|
||||
class InfoOutputRequested:
|
||||
output_socket_name: ct.SocketName
|
||||
kind: ct.DataFlowKind
|
||||
kind: ct.FlowKind
|
||||
|
||||
depon_props: set[str]
|
||||
|
||||
depon_input_sockets: set[ct.SocketName]
|
||||
depon_input_socket_kinds: dict[ct.SocketName, ct.DataFlowKind]
|
||||
depon_input_socket_kinds: dict[ct.SocketName, ct.FlowKind]
|
||||
depon_all_loose_input_sockets: bool
|
||||
|
||||
depon_output_sockets: set[ct.SocketName]
|
||||
depon_output_socket_kinds: dict[ct.SocketName, ct.DataFlowKind]
|
||||
depon_output_socket_kinds: dict[ct.SocketName, ct.FlowKind]
|
||||
depon_all_loose_output_sockets: bool
|
||||
|
||||
|
||||
|
@ -58,10 +58,10 @@ def event_decorator(
|
|||
props: set[PropName] = frozenset(),
|
||||
input_sockets: set[ct.SocketName] = frozenset(),
|
||||
input_sockets_optional: dict[ct.SocketName, bool] = MappingProxyType({}),
|
||||
input_socket_kinds: dict[ct.SocketName, ct.DataFlowKind] = MappingProxyType({}),
|
||||
input_socket_kinds: dict[ct.SocketName, ct.FlowKind] = MappingProxyType({}),
|
||||
output_sockets: set[ct.SocketName] = frozenset(),
|
||||
output_sockets_optional: dict[ct.SocketName, bool] = MappingProxyType({}),
|
||||
output_socket_kinds: dict[ct.SocketName, ct.DataFlowKind] = MappingProxyType({}),
|
||||
output_socket_kinds: dict[ct.SocketName, ct.FlowKind] = MappingProxyType({}),
|
||||
all_loose_input_sockets: bool = False,
|
||||
all_loose_output_sockets: bool = False,
|
||||
# Request Unit System Scaling
|
||||
|
@ -81,8 +81,8 @@ def event_decorator(
|
|||
Other methods defined on the same node will still run.
|
||||
managed_objs: Set of `managed_objs` to retrieve, then pass to the decorated method.
|
||||
input_sockets: Set of `input_sockets` to compute, then pass to the decorated method.
|
||||
input_socket_kinds: The `ct.DataFlowKind` to compute per-input-socket.
|
||||
If an input socket isn't specified, it defaults to `ct.DataFlowKind.Value`.
|
||||
input_socket_kinds: The `ct.FlowKind` to compute per-input-socket.
|
||||
If an input socket isn't specified, it defaults to `ct.FlowKind.Value`.
|
||||
output_sockets: Set of `output_sockets` to compute, then pass to the decorated method.
|
||||
all_loose_input_sockets: Whether to compute all loose input sockets and pass them to the decorated method.
|
||||
Used when the names of the loose input sockets are unknown, but all of their values are needed.
|
||||
|
@ -157,7 +157,7 @@ def event_decorator(
|
|||
input_socket_name: node._compute_input(
|
||||
input_socket_name,
|
||||
kind=input_socket_kinds.get(
|
||||
input_socket_name, ct.DataFlowKind.Value
|
||||
input_socket_name, ct.FlowKind.Value
|
||||
),
|
||||
unit_system=(
|
||||
unit_system := unit_systems.get(
|
||||
|
@ -179,10 +179,10 @@ def event_decorator(
|
|||
method_kw_args |= (
|
||||
{
|
||||
'output_sockets': {
|
||||
output_socket_name: ct.DataFlowKind.scale_to_unit_system(
|
||||
output_socket_name: ct.FlowKind.scale_to_unit_system(
|
||||
(
|
||||
output_socket_kind := output_socket_kinds.get(
|
||||
output_socket_name, ct.DataFlowKind.Value
|
||||
output_socket_name, ct.FlowKind.Value
|
||||
)
|
||||
),
|
||||
node.compute_output(
|
||||
|
@ -201,7 +201,7 @@ def event_decorator(
|
|||
else node.compute_output(
|
||||
output_socket_name,
|
||||
kind=output_socket_kinds.get(
|
||||
output_socket_name, ct.DataFlowKind.Value
|
||||
output_socket_name, ct.FlowKind.Value
|
||||
),
|
||||
optional=output_sockets_optional.get(
|
||||
output_socket_name, False
|
||||
|
@ -316,7 +316,7 @@ def on_value_changed(
|
|||
## TODO: Change name to 'on_output_requested'
|
||||
def computes_output_socket(
|
||||
output_socket_name: ct.SocketName | None,
|
||||
kind: ct.DataFlowKind = ct.DataFlowKind.Value,
|
||||
kind: ct.FlowKind = ct.FlowKind.Value,
|
||||
**kwargs,
|
||||
):
|
||||
return event_decorator(
|
||||
|
|
|
@ -38,7 +38,7 @@ class WaveConstantNode(base.MaxwellSimNode):
|
|||
####################
|
||||
@events.computes_output_socket(
|
||||
'WL',
|
||||
kind=ct.DataFlowKind.Value,
|
||||
kind=ct.FlowKind.Value,
|
||||
# Data
|
||||
input_sockets={'WL', 'Freq'},
|
||||
input_sockets_optional={'WL': True, 'Freq': True},
|
||||
|
@ -55,7 +55,7 @@ class WaveConstantNode(base.MaxwellSimNode):
|
|||
|
||||
@events.computes_output_socket(
|
||||
'Freq',
|
||||
kind=ct.DataFlowKind.Value,
|
||||
kind=ct.FlowKind.Value,
|
||||
# Data
|
||||
input_sockets={'WL', 'Freq'},
|
||||
input_sockets_optional={'WL': True, 'Freq': True},
|
||||
|
@ -73,7 +73,7 @@ class WaveConstantNode(base.MaxwellSimNode):
|
|||
|
||||
@events.computes_output_socket(
|
||||
'WL',
|
||||
kind=ct.DataFlowKind.LazyValueRange,
|
||||
kind=ct.FlowKind.LazyValueRange,
|
||||
# Data
|
||||
input_sockets={'WL', 'Freq'},
|
||||
input_sockets_optional={'WL': True, 'Freq': True},
|
||||
|
@ -92,12 +92,12 @@ class WaveConstantNode(base.MaxwellSimNode):
|
|||
|
||||
@events.computes_output_socket(
|
||||
'Freq',
|
||||
kind=ct.DataFlowKind.LazyValueRange,
|
||||
kind=ct.FlowKind.LazyValueRange,
|
||||
# Data
|
||||
input_sockets={'WL', 'Freq'},
|
||||
input_socket_kinds={
|
||||
'WL': ct.DataFlowKind.LazyValueRange,
|
||||
'Freq': ct.DataFlowKind.LazyValueRange,
|
||||
'WL': ct.FlowKind.LazyValueRange,
|
||||
'Freq': ct.FlowKind.LazyValueRange,
|
||||
},
|
||||
input_sockets_optional={'WL': True, 'Freq': True},
|
||||
)
|
||||
|
|
|
@ -67,7 +67,7 @@ class EHFieldMonitorNode(base.MaxwellSimNode):
|
|||
'Freqs',
|
||||
},
|
||||
input_socket_kinds={
|
||||
'Freqs': ct.DataFlowKind.LazyValueRange,
|
||||
'Freqs': ct.FlowKind.LazyValueRange,
|
||||
},
|
||||
unit_systems={'Tidy3DUnits': ct.UNITS_TIDY3D},
|
||||
scale_input_sockets={
|
||||
|
|
|
@ -67,7 +67,7 @@ class PowerFluxMonitorNode(base.MaxwellSimNode):
|
|||
'Direction',
|
||||
},
|
||||
input_socket_kinds={
|
||||
'Freqs': ct.DataFlowKind.LazyValueRange,
|
||||
'Freqs': ct.FlowKind.LazyValueRange,
|
||||
},
|
||||
unit_systems={'Tidy3DUnits': ct.UNITS_TIDY3D},
|
||||
scale_input_sockets={
|
||||
|
|
|
@ -35,7 +35,7 @@ class FDTDSimNode(base.MaxwellSimNode):
|
|||
####################
|
||||
@events.computes_output_socket(
|
||||
'FDTD Sim',
|
||||
kind=ct.DataFlowKind.Value,
|
||||
kind=ct.FlowKind.Value,
|
||||
input_sockets={'Sources', 'Structures', 'Domain', 'BCs', 'Monitors'},
|
||||
)
|
||||
def compute_fdtd_sim(self, input_sockets: dict) -> sp.Expr:
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#class MaxwellSimProp(bpy.types.PropertyGroup):
|
||||
# """A Blender property usable in nodes and sockets."""
|
||||
# name: str = ""
|
||||
# data_flow_kind: ct.DataFlowKind
|
||||
# data_flow_kind: ct.FlowKind
|
||||
#
|
||||
# value: dict[str, tuple[bpy.types.Property, dict]] | None = None
|
||||
#
|
||||
|
|
|
@ -138,7 +138,7 @@ class MaxwellSimSocket(bpy.types.NodeSocket):
|
|||
cls.__annotations__['active_kind'] = bpy.props.StringProperty(
|
||||
name='Active Kind',
|
||||
description='The active Data Flow Kind',
|
||||
default=str(ct.DataFlowKind.Value),
|
||||
default=str(ct.FlowKind.Value),
|
||||
update=lambda self, _: self.sync_active_kind(),
|
||||
)
|
||||
|
||||
|
@ -226,15 +226,15 @@ class MaxwellSimSocket(bpy.types.NodeSocket):
|
|||
def sync_active_kind(self):
|
||||
"""Called when the active data flow kind of the socket changes.
|
||||
|
||||
Alters the shape of the socket to match the active DataFlowKind, then triggers `ct.DataFlowAction.DataChanged` on the current socket.
|
||||
Alters the shape of the socket to match the active FlowKind, then triggers `ct.DataFlowAction.DataChanged` on the current socket.
|
||||
"""
|
||||
self.display_shape = {
|
||||
ct.DataFlowKind.Value: ct.SOCKET_SHAPES[self.socket_type],
|
||||
ct.DataFlowKind.ValueArray: 'SQUARE',
|
||||
ct.DataFlowKind.ValueSpectrum: 'SQUARE',
|
||||
ct.DataFlowKind.LazyValue: ct.SOCKET_SHAPES[self.socket_type],
|
||||
ct.DataFlowKind.LazyValueRange: 'SQUARE',
|
||||
ct.DataFlowKind.LazyValueSpectrum: 'SQUARE',
|
||||
ct.FlowKind.Value: ct.SOCKET_SHAPES[self.socket_type],
|
||||
ct.FlowKind.ValueArray: 'SQUARE',
|
||||
ct.FlowKind.ValueSpectrum: 'SQUARE',
|
||||
ct.FlowKind.LazyValue: ct.SOCKET_SHAPES[self.socket_type],
|
||||
ct.FlowKind.LazyValueRange: 'SQUARE',
|
||||
ct.FlowKind.LazyValueSpectrum: 'SQUARE',
|
||||
}[self.active_kind] + ('_DOT' if self.use_units else '')
|
||||
|
||||
self.trigger_action(ct.DataFlowAction.DataChanged)
|
||||
|
@ -360,19 +360,19 @@ class MaxwellSimSocket(bpy.types.NodeSocket):
|
|||
####################
|
||||
def _compute_data(
|
||||
self,
|
||||
kind: ct.DataFlowKind = ct.DataFlowKind.Value,
|
||||
kind: ct.FlowKind = ct.FlowKind.Value,
|
||||
) -> typ.Any:
|
||||
"""Computes the internal data of this socket, ONLY.
|
||||
|
||||
**NOTE**: Low-level method. Use `compute_data` instead.
|
||||
"""
|
||||
return {
|
||||
ct.DataFlowKind.Value: lambda: self.value,
|
||||
ct.DataFlowKind.ValueArray: lambda: self.value_array,
|
||||
ct.DataFlowKind.ValueSpectrum: lambda: self.value_spectrum,
|
||||
ct.DataFlowKind.LazyValue: lambda: self.lazy_value,
|
||||
ct.DataFlowKind.LazyValueRange: lambda: self.lazy_value_range,
|
||||
ct.DataFlowKind.LazyValueSpectrum: lambda: self.lazy_value_spectrum,
|
||||
ct.FlowKind.Value: lambda: self.value,
|
||||
ct.FlowKind.ValueArray: lambda: self.value_array,
|
||||
ct.FlowKind.ValueSpectrum: lambda: self.value_spectrum,
|
||||
ct.FlowKind.LazyValue: lambda: self.lazy_value,
|
||||
ct.FlowKind.LazyValueRange: lambda: self.lazy_value_range,
|
||||
ct.FlowKind.LazyValueSpectrum: lambda: self.lazy_value_spectrum,
|
||||
}[kind]()
|
||||
|
||||
msg = f'socket._compute_data was called with invalid kind "{kind}"'
|
||||
|
@ -380,7 +380,7 @@ class MaxwellSimSocket(bpy.types.NodeSocket):
|
|||
|
||||
def compute_data(
|
||||
self,
|
||||
kind: ct.DataFlowKind = ct.DataFlowKind.Value,
|
||||
kind: ct.FlowKind = ct.FlowKind.Value,
|
||||
):
|
||||
"""Computes the value of this socket, including all relevant factors.
|
||||
|
||||
|
@ -463,10 +463,10 @@ class MaxwellSimSocket(bpy.types.NodeSocket):
|
|||
|
||||
Can be overridden if more specific logic is required.
|
||||
"""
|
||||
if self.active_kind == ct.DataFlowKind.Value:
|
||||
if self.active_kind == ct.FlowKind.Value:
|
||||
self.value = self.value / self.unit * self.prev_unit
|
||||
|
||||
elif self.active_kind == ct.DataFlowKind.LazyValueRange:
|
||||
elif self.active_kind == ct.FlowKind.LazyValueRange:
|
||||
lazy_value_range = self.lazy_value_range
|
||||
self.lazy_value_range = (
|
||||
lazy_value_range.start / self.unit * self.prev_unit,
|
||||
|
@ -565,12 +565,12 @@ class MaxwellSimSocket(bpy.types.NodeSocket):
|
|||
# Data Column(s)
|
||||
col = row.column(align=True)
|
||||
{
|
||||
ct.DataFlowKind.Value: self.draw_value,
|
||||
ct.DataFlowKind.ValueArray: self.draw_value_array,
|
||||
ct.DataFlowKind.ValueSpectrum: self.draw_value_spectrum,
|
||||
ct.DataFlowKind.LazyValue: self.draw_lazy_value,
|
||||
ct.DataFlowKind.LazyValueRange: self.draw_lazy_value_range,
|
||||
ct.DataFlowKind.LazyValueSpectrum: self.draw_lazy_value_spectrum,
|
||||
ct.FlowKind.Value: self.draw_value,
|
||||
ct.FlowKind.ValueArray: self.draw_value_array,
|
||||
ct.FlowKind.ValueSpectrum: self.draw_value_spectrum,
|
||||
ct.FlowKind.LazyValue: self.draw_lazy_value,
|
||||
ct.FlowKind.LazyValueRange: self.draw_lazy_value_range,
|
||||
ct.FlowKind.LazyValueSpectrum: self.draw_lazy_value_spectrum,
|
||||
}[self.active_kind](col)
|
||||
|
||||
def draw_output(
|
||||
|
@ -598,7 +598,7 @@ class MaxwellSimSocket(bpy.types.NodeSocket):
|
|||
row.label(text=text)
|
||||
|
||||
####################
|
||||
# - DataFlowKind draw() Methods
|
||||
# - FlowKind draw() Methods
|
||||
####################
|
||||
def draw_value(self, col: bpy.types.UILayout) -> None:
|
||||
pass
|
||||
|
|
|
@ -18,7 +18,7 @@ class MaxwellMonitorSocketDef(base.SocketDef):
|
|||
|
||||
def init(self, bl_socket: MaxwellMonitorBLSocket) -> None:
|
||||
if self.is_list:
|
||||
bl_socket.active_kind = ct.DataFlowKind.ValueArray
|
||||
bl_socket.active_kind = ct.FlowKind.ValueArray
|
||||
|
||||
|
||||
####################
|
||||
|
|
|
@ -18,7 +18,7 @@ class MaxwellSourceSocketDef(base.SocketDef):
|
|||
|
||||
def init(self, bl_socket: MaxwellSourceBLSocket) -> None:
|
||||
if self.is_list:
|
||||
bl_socket.active_kind = ct.DataFlowKind.ValueArray
|
||||
bl_socket.active_kind = ct.FlowKind.ValueArray
|
||||
|
||||
|
||||
####################
|
||||
|
|
|
@ -18,7 +18,7 @@ class MaxwellStructureSocketDef(base.SocketDef):
|
|||
|
||||
def init(self, bl_socket: MaxwellStructureBLSocket) -> None:
|
||||
if self.is_list:
|
||||
bl_socket.active_kind = ct.DataFlowKind.ValueArray
|
||||
bl_socket.active_kind = ct.FlowKind.ValueArray
|
||||
|
||||
|
||||
####################
|
||||
|
|
|
@ -111,7 +111,7 @@ class PhysicalFreqSocketDef(base.SocketDef):
|
|||
|
||||
bl_socket.value = self.default_value
|
||||
if self.is_array:
|
||||
bl_socket.active_kind = ct.DataFlowKind.LazyValueRange
|
||||
bl_socket.active_kind = ct.FlowKind.LazyValueRange
|
||||
bl_socket.lazy_value_range = (self.min_freq, self.max_freq, self.steps)
|
||||
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ class PhysicalLengthSocketDef(base.SocketDef):
|
|||
|
||||
bl_socket.value = self.default_value
|
||||
if self.is_array:
|
||||
bl_socket.active_kind = ct.DataFlowKind.LazyValueRange
|
||||
bl_socket.active_kind = ct.FlowKind.LazyValueRange
|
||||
bl_socket.lazy_value_range = (self.min_len, self.max_len, self.steps)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue