2024-02-19 14:28:35 +01:00
|
|
|
import typing as typ
|
|
|
|
|
2024-02-26 16:16:06 +01:00
|
|
|
import bpy
|
2024-02-19 14:28:35 +01:00
|
|
|
import pydantic as pyd
|
|
|
|
|
|
|
|
from .. import base
|
|
|
|
from ... import contracts
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Blender Socket
|
|
|
|
####################
|
|
|
|
class PhysicalPolBLSocket(base.BLSocket):
|
|
|
|
socket_type = contracts.SocketType.PhysicalPol
|
|
|
|
bl_label = "PhysicalPol"
|
|
|
|
|
2024-02-26 16:16:06 +01:00
|
|
|
####################
|
|
|
|
# - Properties
|
|
|
|
####################
|
|
|
|
default_choice: bpy.props.EnumProperty(
|
|
|
|
name="Bound Face",
|
|
|
|
description="A choice of default boundary face",
|
|
|
|
items=[
|
|
|
|
("EX", "Ex", "Linear x-pol of E field"),
|
|
|
|
("EY", "Ey", "Linear y-pol of E field"),
|
|
|
|
("EZ", "Ez", "Linear z-pol of E field"),
|
|
|
|
("HX", "Hx", "Linear x-pol of H field"),
|
|
|
|
("HY", "Hy", "Linear x-pol of H field"),
|
|
|
|
("HZ", "Hz", "Linear x-pol of H field"),
|
|
|
|
],
|
|
|
|
default="EX",
|
|
|
|
update=(lambda self, context: self.trigger_updates()),
|
|
|
|
)
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - UI
|
|
|
|
####################
|
|
|
|
def draw_value(self, col: bpy.types.UILayout) -> None:
|
|
|
|
col_row = col.row(align=True)
|
|
|
|
col_row.prop(self, "default_choice", text="")
|
|
|
|
|
2024-02-19 14:28:35 +01:00
|
|
|
####################
|
|
|
|
# - Default Value
|
|
|
|
####################
|
|
|
|
@property
|
2024-02-26 16:16:06 +01:00
|
|
|
def default_value(self) -> str:
|
|
|
|
return {
|
|
|
|
"EX": "Ex",
|
|
|
|
"EY": "Ey",
|
|
|
|
"EZ": "Ez",
|
|
|
|
"HX": "Hx",
|
|
|
|
"HY": "Hy",
|
|
|
|
"HZ": "Hz",
|
|
|
|
}[self.default_choice]
|
2024-02-19 14:28:35 +01:00
|
|
|
|
|
|
|
@default_value.setter
|
|
|
|
def default_value(self, value: typ.Any) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Socket Configuration
|
|
|
|
####################
|
|
|
|
class PhysicalPolSocketDef(pyd.BaseModel):
|
|
|
|
socket_type: contracts.SocketType = contracts.SocketType.PhysicalPol
|
|
|
|
label: str
|
|
|
|
|
|
|
|
def init(self, bl_socket: PhysicalPolBLSocket) -> None:
|
|
|
|
pass
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Blender Registration
|
|
|
|
####################
|
|
|
|
BL_REGISTER = [
|
|
|
|
PhysicalPolBLSocket,
|
|
|
|
]
|