diff --git a/oscillode/__init__.py b/oscillode/__init__.py
index 8df68c7..184fbf3 100644
--- a/oscillode/__init__.py
+++ b/oscillode/__init__.py
@@ -14,21 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# oscillode Copyright (C) 2024 oscillode Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""A visual DSL for electromagnetic simulation design and analysis implemented as a Blender node editor."""
from . import assets, node_trees, operators, preferences, registration
diff --git a/oscillode/assets/__init__.py b/oscillode/assets/__init__.py
index 617a250..2ba4717 100644
--- a/oscillode/assets/__init__.py
+++ b/oscillode/assets/__init__.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
from . import geonodes
BL_REGISTER = [
diff --git a/oscillode/assets/geonodes.py b/oscillode/assets/geonodes.py
index c9c7ae2..fb7ac37 100644
--- a/oscillode/assets/geonodes.py
+++ b/oscillode/assets/geonodes.py
@@ -14,29 +14,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Provides for the linking and/or appending of geometry nodes trees from vendored libraries included in Blender maxwell."""
import enum
from pathlib import Path
import bpy
-
from blender_maxwell import contracts as ct
from blender_maxwell.utils import logger
@@ -401,7 +384,7 @@ class GeoNodesToStructureNode(bpy.types.Operator):
####################
def invoke(
self, context: bpy.types.Context, _: bpy.types.Event
- ) -> set[ct.BLOperatorStatus]:
+ ) -> ct.BLOperatorStatus:
"""Commences the drag-and-drop of a GeoNodes asset.
- Starts the modal timer, which listens for a mouse-release event.
diff --git a/oscillode/contracts/__init__.py b/oscillode/contracts/__init__.py
index c8eff91..f103c0e 100644
--- a/oscillode/contracts/__init__.py
+++ b/oscillode/contracts/__init__.py
@@ -14,21 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+"""Independent constants and types, which represent a kind of 'social contract' governing communication between all components of the addon."""
from . import addon
from .bl import (
@@ -53,13 +39,18 @@ from .bl import (
PropName,
SocketName,
)
-from .bl_types import BLEnumStrEnum
+from .icons import Icon
+from .mobj_types import ManagedObjType
+from .node_tree_types import (
+ NodeTreeType,
+)
from .operator_types import (
OperatorType,
)
from .panel_types import (
PanelType,
)
+from .unit_systems import UNITS_BLENDER, UNITS_TIDY3D
__all__ = [
'addon',
@@ -80,12 +71,16 @@ __all__ = [
'BLSpaceType',
'KeymapItemDef',
'ManagedObjName',
+ 'ManagedObjType',
'PresetName',
'PropName',
'SocketName',
- 'BLEnumStrEnum',
+ 'Icon',
'BLInstance',
'InstanceID',
+ 'NodeTreeType',
'OperatorType',
'PanelType',
+ 'UNITS_BLENDER',
+ 'UNITS_TIDY3D',
]
diff --git a/oscillode/contracts/addon.py b/oscillode/contracts/addon.py
index 74cee30..2bdb7e4 100644
--- a/oscillode/contracts/addon.py
+++ b/oscillode/contracts/addon.py
@@ -62,8 +62,8 @@ def operator(
raise ValueError(msg)
# Run Operator
- operator = getattr(getattr(bpy.ops, NAME), operator_name)
- operator(*operator_args, **operator_kwargs)
+ bl_operator = getattr(getattr(bpy.ops, NAME), operator_name)
+ bl_operator(*operator_args, **operator_kwargs)
## TODO: Can't we constrain 'name' to be an OperatorType somehow?
diff --git a/oscillode/contracts/bl.py b/oscillode/contracts/bl.py
index ddca3a7..15c4000 100644
--- a/oscillode/contracts/bl.py
+++ b/oscillode/contracts/bl.py
@@ -14,21 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+"""Explicit type annotations for Blender objects, making it easier to guarantee correctness in communications with Blender."""
import typing as typ
diff --git a/oscillode/contracts/bl_types.py b/oscillode/contracts/bl_types.py
deleted file mode 100644
index 3e47760..0000000
--- a/oscillode/contracts/bl_types.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# oscillode
-# Copyright (C) 2024 oscillode Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
-import typing as typ
-
-
-####################
-# - Blender Enum (w/EnumProperty support)
-####################
-class BLEnumStrEnum(typ.Protocol):
- @staticmethod
- def to_name(value: typ.Self) -> str: ...
-
- @staticmethod
- def to_icon(value: typ.Self) -> str: ...
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/icons.py b/oscillode/contracts/icons.py
similarity index 54%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/icons.py
rename to oscillode/contracts/icons.py
index 2a789e0..788d6e7 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/icons.py
+++ b/oscillode/contracts/icons.py
@@ -14,26 +14,14 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+"""Provides an enum that semantically constrains the use of icons throughout the addon."""
import enum
class Icon(enum.StrEnum):
+ """Identifiers for icons used throughout this addon."""
+
# Node Tree
SimNodeEditor = 'MOD_SIMPLEDEFORM'
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/mobj_types.py b/oscillode/contracts/mobj_types.py
similarity index 81%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/mobj_types.py
rename to oscillode/contracts/mobj_types.py
index 0e0495a..a896923 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/mobj_types.py
+++ b/oscillode/contracts/mobj_types.py
@@ -30,12 +30,16 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
+"""Provides identifiers for objects in Blender that are managed on behalf of the user, for use by the addon, in order to provide a safe and streamlined integration of more complex data representations that flow between the addon and Blender."""
+
import enum
from blender_maxwell.utils import blender_type_enum
class ManagedObjType(blender_type_enum.BlenderTypeEnum):
+ """Identifiers for 'managed objects', which encapsulates a particular Blender object and provides alternative semantics more suited to the needs of this addon."""
+
ManagedBLImage = enum.auto()
ManagedBLCollection = enum.auto()
diff --git a/oscillode/contracts/node_tree_types.py b/oscillode/contracts/node_tree_types.py
new file mode 100644
index 0000000..3b43e6b
--- /dev/null
+++ b/oscillode/contracts/node_tree_types.py
@@ -0,0 +1,28 @@
+# oscillode
+# Copyright (C) 2024 oscillode Project Contributors
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+
+"""Provides identifiers for node trees defined by this addon."""
+
+import enum
+
+from oscillode.utils import blender_type_enum
+
+
+@blender_type_enum.append_cls_name_to_values
+class NodeTreeType(blender_type_enum.BlenderTypeEnum):
+ """Identifiers for addon-defined node trees."""
+
+ MaxwellSim = enum.auto()
diff --git a/oscillode/contracts/operator_types.py b/oscillode/contracts/operator_types.py
index ef89753..a5ec15b 100644
--- a/oscillode/contracts/operator_types.py
+++ b/oscillode/contracts/operator_types.py
@@ -14,27 +14,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
-"""Defines Operator Types as an enum, making it easy for any part of the addon to refer to any operator."""
+"""Provides identifiers for Blender operators defined by this addon."""
import enum
-from ..utils import blender_type_enum
+from oscillode.utils import blender_type_enum
+
from .addon import NAME as ADDON_NAME
diff --git a/oscillode/contracts/panel_types.py b/oscillode/contracts/panel_types.py
index 137ae65..64b09a4 100644
--- a/oscillode/contracts/panel_types.py
+++ b/oscillode/contracts/panel_types.py
@@ -14,27 +14,11 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Defines Panel Types as an enum, making it easy for any part of the addon to refer to any panel."""
import enum
-from blender_maxwell.nodeps.utils import blender_type_enum
+from oscillode.utils import blender_type_enum
from .addon import NAME as ADDON_NAME
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/unit_systems.py b/oscillode/contracts/unit_systems.py
similarity index 77%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/unit_systems.py
rename to oscillode/contracts/unit_systems.py
index e16944f..415d5c2 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/unit_systems.py
+++ b/oscillode/contracts/unit_systems.py
@@ -14,23 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
-"""Specifies unit systems for use in the node tree.
+"""Provides particular pre-defined unit systems for use by the addon.
Attributes:
UNITS_BLENDER: A unit system that serves as a reasonable default for the a 3D workspace that interprets the results of electromagnetic simulations.
@@ -45,7 +29,7 @@ import typing as typ
import sympy.physics.units as spu
from frozendict import frozendict
-from blender_maxwell.utils import sympy_extra as spux
+from oscillode.utils import sympy_extra as spux
####################
# - Unit Systems
diff --git a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/__init__.py b/oscillode/managed_objs/__init__.py
similarity index 50%
rename from oscillode/node_trees/maxwell_sim_nodes/managed_objs/__init__.py
rename to oscillode/managed_objs/__init__.py
index b09060c..5f94ac3 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/__init__.py
+++ b/oscillode/managed_objs/__init__.py
@@ -14,29 +14,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+"""Provides various useful managed objects, which enables the clean and safe use of objects external to this addon."""
from .base import ManagedObj
-
-# from .managed_bl_empty import ManagedBLEmpty
from .managed_bl_image import ManagedBLImage
-
-# from .managed_bl_collection import ManagedBLCollection
-# from .managed_bl_object import ManagedBLObject
from .managed_bl_mesh import ManagedBLMesh
# from .managed_bl_volume import ManagedBLVolume
@@ -44,13 +25,8 @@ from .managed_bl_modifier import ManagedBLModifier
__all__ = [
'ManagedObj',
- #'ManagedBLEmpty',
'ManagedBLImage',
- #'ManagedBLCollection',
- #'ManagedBLObject',
'ManagedBLMesh',
#'ManagedBLVolume',
'ManagedBLModifier',
]
-
-## REMEMBER: Add the appropriate entry to the bl_cache.DECODER
diff --git a/oscillode/managed_objs/base.py b/oscillode/managed_objs/base.py
new file mode 100644
index 0000000..4f82b1e
--- /dev/null
+++ b/oscillode/managed_objs/base.py
@@ -0,0 +1,125 @@
+# oscillode
+# Copyright (C) 2024 oscillode Project Contributors
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+
+"""Provides the base protocol on which all ManagedObjs are derived, as well as explicit protocols describing common features supported by some `ManagedObjs`."""
+
+import abc
+import typing as typ
+
+from blender_maxwell.utils import logger, serialize
+
+from .. import contracts as ct
+
+log = logger.get(__name__)
+
+
+class ManagedObj(typ.Protocol):
+ """A weak name-based reference to some kind of object external to this software.
+
+ While the object doesn't have to come from Blender's `bpy.types`, that is the driving motivation for this class: To encapsulate access to the powerful visual tools granted by Blender's 3D viewport, image editor, and UI.
+ Through extensive trial-and-error, this transparently-cached immediate-mode interface has emerged as the best compromise.
+
+ While not suited to all use cases, the `ManagedObj` paradigm is ideal for the common situation of 'node ownership of external logic'.
+ For example, a plotting node needs access to its own image buffer; however, for it to be displayable, that image buffer must be owned by Blender.
+ This is where `ManagedObj` provides the ability of the plotting node to "loosely own" a particular Blender image, which both allows the user to see/interact with the image as a typical Blender image, but also allows the node to drive ex. lifecycle (like removing the image plot when the node is deleted).
+
+ This approach of loose name-coupling is not perfect. To name a few examples:
+
+ - A particular challenge is that of identifying and namespacing managed datablocks. The user may, for example, change the name of an object - and what do we do then? Is generating new data under the now-vacant name a feature? Or is it a systematic memory leak backed by dangling fake-owned datablocks?
+ - The precise definition of "loose ownership" is itself a matter of taste. Stronger ownership presumptions allow for stronger guarantees and simpler caching - but at the cost of more brittle breaks when the underlying objects are manipulated in ways we don't expect.
+ - `.blend` persistance is not the default when it comes to certain Blender objects, which raises deeper UX questions about how opinionated we should be about where users put data.
+ - Solving this doesn't help actually deal with data. There's a lot of very specific nuance in every single data pipeline, and that complexity is only added to watever this approach incurs.
+
+ This abstract base class serves to provide a few of the most basic of commonly-available operations.
+ In particular, implementations of `dump_as_msgspec`/`parse_as_msgspec` are enforced, for use with `oscillode.utils.serialize`.
+ This way, ex. opening a `.blend` file will allow a newly-deserialized `ManagedObj` to re-attach transparently to the also-persisted underlying datablock.
+
+ Parameters:
+ managed_obj_type: Enum identifier indicating which of the `ct.ManagedObjType` the instance should declare itself as.
+ """
+
+ managed_obj_type: ct.ManagedObjType
+
+ @abc.abstractmethod
+ def __init__(self, name: ct.ManagedObjName, prev_name: str | None = None):
+ """Initializes the managed object with a unique name.
+
+ Use `prev_name` to indicate that the managed object will initially be avaiable under `prev_name`, but that it should be renamed to `name`.
+ """
+
+ ####################
+ # - Properties
+ ####################
+ @property
+ @abc.abstractmethod
+ def name(self) -> str:
+ """Retrieve the name of the managed object."""
+
+ @name.setter
+ @abc.abstractmethod
+ def name(self, value: str) -> None:
+ """Retrieve the name of the managed object."""
+
+ ####################
+ # - Methods
+ ####################
+ @abc.abstractmethod
+ def free(self) -> None:
+ """Cleanup the resources managed by the managed object."""
+
+ @abc.abstractmethod
+ def hide_preview(self) -> None:
+ """Hide any active preview of the managed object, if it exists, and if such an operation makes sense."""
+
+ ####################
+ # - Serialization
+ ####################
+ def dump_as_msgspec(self) -> serialize.NaiveRepresentation:
+ """Bijectively transform this managed object into a 'naive representation' that uses only basic Python types, which may be serialized cleanly."""
+ return [
+ serialize.TypeID.ManagedObj,
+ self.__class__.__name__,
+ self.name,
+ ]
+
+ @staticmethod
+ def parse_as_msgspec(obj: serialize.NaiveRepresentation) -> typ.Self:
+ """Bijectively construct an instance of this managed object from the 'naive representation', which may have been deserialized into."""
+ return next(
+ subclass(obj[2])
+ for subclass in ManagedObj.__subclasses__()
+ if subclass.__name__ == obj[1]
+ )
+
+
+####################
+# - Support Flags
+####################
+class SupportsBlenderSelect(typ.Protocol):
+ """Protocol guaranteeing the ability to select the object in Blender."""
+
+ def bl_select(self) -> None:
+ """Select the managed object in Blender."""
+
+
+class Supportsreview(typ.Protocol):
+ """Protocol guaranteeing support for previewing the object."""
+
+ def show_preview(self) -> None:
+ """Shows a preview of the managed object."""
+
+ def hide_preview(self) -> None:
+ """Hide any active preview of the managed object, if it exists."""
diff --git a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_collection.py b/oscillode/managed_objs/managed_bl_collection.py
similarity index 95%
rename from oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_collection.py
rename to oscillode/managed_objs/managed_bl_collection.py
index 5f2e2bd..473f06d 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_collection.py
+++ b/oscillode/managed_objs/managed_bl_collection.py
@@ -32,12 +32,12 @@
import bpy
-from blender_maxwell.utils import logger
+from oscillode.utils import logger
log = logger.get(__name__)
-MANAGED_COLLECTION_NAME = 'BLMaxwell'
-PREVIEW_COLLECTION_NAME = 'BLMaxwell Visible'
+MANAGED_COLLECTION_NAME = 'Oscillode'
+PREVIEW_COLLECTION_NAME = 'Oscillode Visible'
####################
diff --git a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_image.py b/oscillode/managed_objs/managed_bl_image.py
similarity index 90%
rename from oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_image.py
rename to oscillode/managed_objs/managed_bl_image.py
index baac2a0..dfd80f3 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_image.py
+++ b/oscillode/managed_objs/managed_bl_image.py
@@ -14,23 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
-"""Declares `ManagedBLImage`."""
+"""Declares an object encapsulating access to a Blender image datablock from this addon."""
import time
import typing as typ
@@ -39,15 +23,17 @@ import bpy
import matplotlib.axis as mpl_ax
import numpy as np
-from blender_maxwell.utils import image_ops, logger
+from oscillode.utils import image_ops, logger
from .. import contracts as ct
from . import base
log = logger.get(__name__)
-AREA_TYPE = 'IMAGE_EDITOR'
-SPACE_TYPE = 'IMAGE_EDITOR'
+AREA_TYPE: ct.BLSpaceType = (
+ 'IMAGE_EDITOR' ##TODO: Is SpaceType different than AreaType?
+)
+SPACE_TYPE: ct.BLSpaceType = 'IMAGE_EDITOR'
####################
@@ -60,7 +46,7 @@ class ManagedBLImage(base.ManagedObj):
name: The name of the image.
"""
- managed_obj_type = ct.ManagedObjType.ManagedBLImage
+ managed_obj_type: str = ct.ManagedObjType.ManagedBLImage
_bl_image_name: str
def __init__(self, name: str, prev_name: str | None = None):
@@ -186,6 +172,7 @@ class ManagedBLImage(base.ManagedObj):
####################
# - Methods
####################
+ ## TODO: Rename to show_preview()
def bl_select(self) -> None:
"""Selects the image by loading it into an on-screen UI area/space.
diff --git a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_mesh.py b/oscillode/managed_objs/managed_bl_mesh.py
similarity index 90%
rename from oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_mesh.py
rename to oscillode/managed_objs/managed_bl_mesh.py
index 7e708e4..8bf2d14 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_mesh.py
+++ b/oscillode/managed_objs/managed_bl_mesh.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import contextlib
import bmesh
@@ -37,7 +21,7 @@ import bpy
import jax
import numpy as np
-from blender_maxwell.utils import logger
+from oscillode.utils import logger
from .. import contracts as ct
from . import base
diff --git a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_modifier.py b/oscillode/managed_objs/managed_bl_modifier.py
similarity index 91%
rename from oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_modifier.py
rename to oscillode/managed_objs/managed_bl_modifier.py
index 442adcf..fd0a1cc 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_modifier.py
+++ b/oscillode/managed_objs/managed_bl_modifier.py
@@ -14,31 +14,17 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""A managed Blender modifier, associated with some Blender object."""
+## TODO: Make a common core for modifier manipulation, then specify each modifier as a seperate ManagedObj.
+
import typing as typ
import bpy
import jax
import numpy as np
-from blender_maxwell.utils import logger
+from oscillode.utils import logger
from .. import bl_socket_map
from .. import contracts as ct
@@ -170,6 +156,8 @@ def write_modifier(
# - ManagedObj
####################
class ManagedBLModifier(base.ManagedObj):
+ """Manages a particular modifier attached to a Blender mesh also managed by this construction."""
+
managed_obj_type = ct.ManagedObjType.ManagedBLModifier
_modifier_name: str | None = None
twin_bl_mesh: ManagedBLMesh | None = None
diff --git a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_text.py b/oscillode/managed_objs/managed_bl_text.py
similarity index 83%
rename from oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_text.py
rename to oscillode/managed_objs/managed_bl_text.py
index d18d5a4..66ca540 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_text.py
+++ b/oscillode/managed_objs/managed_bl_text.py
@@ -14,32 +14,13 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Declares `ManagedBLText`."""
-import time
import typing as typ
import bpy
-import matplotlib.axis as mpl_ax
-import numpy as np
-from blender_maxwell.utils import image_ops, logger
+from oscillode.utils import logger
from .. import contracts as ct
from . import base
@@ -54,10 +35,10 @@ SPACE_TYPE = 'IMAGE_EDITOR'
# - Managed BL Image
####################
class ManagedBLText(base.ManagedObj):
- """Represents a Blender Image datablock, encapsulating various useful interactions with it.
+ """Represents a Blender text datablock, encapsulating various useful interactions with it.
Attributes:
- name: The name of the image.
+ name: The name of the text datablock.
"""
managed_obj_type = ct.ManagedObjType.ManagedBLText
diff --git a/oscillode/node_trees/maxwell_sim_nodes/bl_socket_map.py b/oscillode/node_trees/maxwell_sim_nodes/bl_socket_map.py
index 959731e..21c599c 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/bl_socket_map.py
+++ b/oscillode/node_trees/maxwell_sim_nodes/bl_socket_map.py
@@ -46,6 +46,8 @@ from . import sockets
log = _logger.get(__name__)
+## TODO: Coordinate w/refactor of managed modifiers; for example, the contents of this file would be ideally specified as the implementation of a Protocol, for the particular case of this node tree.
+
####################
# - Blender -> Socket Def(s)
diff --git a/oscillode/node_trees/maxwell_sim_nodes/categories.py b/oscillode/node_trees/maxwell_sim_nodes/categories.py
index eeb7f29..04d9c28 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/categories.py
+++ b/oscillode/node_trees/maxwell_sim_nodes/categories.py
@@ -38,6 +38,9 @@ import nodeitems_utils
from . import contracts as ct
from .nodes import BL_NODES
+## TODO: Completely refactor this file, and rename it to reflect that it doesn't define or implement any categories - it simply, dumbly, implements the menu.
+## - Actually; we could delete this file by refactoring it, implementing the logic in a utils/ module, then running the dangling registration as a rote-registration matter in __init__.py.
+
DYNAMIC_SUBMENU_REGISTRATIONS = []
@@ -117,7 +120,7 @@ BL_REGISTER = [*DYNAMIC_SUBMENU_REGISTRATIONS] ## Must be run after, right now.
def menu_draw(self, context):
- if context.space_data.tree_type == ct.TreeType.MaxwellSim.value:
+ if context.space_data.tree_type == ct.NodeTreeType.MaxwellSim.value:
for nodeitem_or_submenu in BL_NODE_CATEGORIES:
if isinstance(nodeitem_or_submenu, str):
submenu_id = nodeitem_or_submenu
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/__init__.py b/oscillode/node_trees/maxwell_sim_nodes/contracts/__init__.py
index 23b228a..f245250 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/__init__.py
+++ b/oscillode/node_trees/maxwell_sim_nodes/contracts/__init__.py
@@ -31,6 +31,8 @@
# along with this program. If not, see .
from blender_maxwell.contracts import (
+ UNITS_BLENDER,
+ UNITS_TIDY3D,
BLClass,
BLColorRGBA,
BLEnumElement,
@@ -45,8 +47,11 @@ from blender_maxwell.contracts import (
BLPropFlag,
BLRegionType,
BLSpaceType,
+ Icon,
KeymapItemDef,
ManagedObjName,
+ ManagedObjType,
+ NodeTreeType,
OperatorType,
PanelType,
PresetName,
@@ -72,8 +77,6 @@ from .flow_kinds import (
ValueFlow,
)
from .flow_signals import FlowSignal
-from .icons import Icon
-from .mobj_types import ManagedObjType
from .node_types import NodeType
from .sim_types import (
BoundCondType,
@@ -90,8 +93,6 @@ from .sim_types import (
)
from .socket_colors import SOCKET_COLORS
from .socket_types import SocketType
-from .tree_types import TreeType
-from .unit_systems import UNITS_BLENDER, UNITS_TIDY3D
__all__ = [
'BLClass',
@@ -108,16 +109,17 @@ __all__ = [
'BLPropFlag',
'BLRegionType',
'BLSpaceType',
+ 'Icon',
'KeymapItemDef',
'ManagedObjName',
+ 'ManagedObjType',
+ 'NodeTreeType',
'OperatorType',
'PanelType',
'PresetName',
'PropName',
'SocketName',
'addon',
- 'Icon',
- 'TreeType',
'SocketType',
'SOCKET_COLORS',
'SOCKET_SHAPES',
@@ -139,7 +141,6 @@ __all__ = [
'manual_amp_time',
'NodeCategory',
'NODE_CAT_LABELS',
- 'ManagedObjType',
'FlowEvent',
'ArrayFlow',
'CapabilitiesFlow',
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/category_labels.py b/oscillode/node_trees/maxwell_sim_nodes/contracts/category_labels.py
index 7f6dfc0..d7b398d 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/category_labels.py
+++ b/oscillode/node_trees/maxwell_sim_nodes/contracts/category_labels.py
@@ -30,6 +30,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
+## TODO: Unify w/category_types.py
+
from .category_types import NodeCategory as NC # noqa: N817
NODE_CAT_LABELS = {
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/node_types.py b/oscillode/node_trees/maxwell_sim_nodes/contracts/node_types.py
index e21addb..32f58b8 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/node_types.py
+++ b/oscillode/node_trees/maxwell_sim_nodes/contracts/node_types.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import enum
from blender_maxwell.utils import blender_type_enum
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/socket_colors.py b/oscillode/node_trees/maxwell_sim_nodes/contracts/socket_colors.py
index ed10300..ed56c47 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/socket_colors.py
+++ b/oscillode/node_trees/maxwell_sim_nodes/contracts/socket_colors.py
@@ -14,23 +14,9 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+"""Socket base colors for Maxwell Sim sockets."""
-from .socket_types import SocketType as ST
+from .socket_types import SocketType as ST # noqa: N817
## TODO: Don't just presume sRGB.
SOCKET_COLORS = {
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/socket_types.py b/oscillode/node_trees/maxwell_sim_nodes/contracts/socket_types.py
index 88bf47d..a1bf962 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/socket_types.py
+++ b/oscillode/node_trees/maxwell_sim_nodes/contracts/socket_types.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import enum
from blender_maxwell.utils import blender_type_enum
@@ -37,6 +21,8 @@ from blender_maxwell.utils import blender_type_enum
@blender_type_enum.append_cls_name_to_values
class SocketType(blender_type_enum.BlenderTypeEnum):
+ """Identifiers for valid sockets in Maxwell Sim node trees."""
+
Expr = enum.auto()
# Base
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/tree_types.py b/oscillode/node_trees/maxwell_sim_nodes/contracts/tree_types.py
deleted file mode 100644
index b192aac..0000000
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/tree_types.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# oscillode
-# Copyright (C) 2024 oscillode Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
-import enum
-
-from blender_maxwell.utils import blender_type_enum
-
-
-@blender_type_enum.append_cls_name_to_values
-class TreeType(blender_type_enum.BlenderTypeEnum):
- MaxwellSim = enum.auto()
diff --git a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/base.py b/oscillode/node_trees/maxwell_sim_nodes/managed_objs/base.py
deleted file mode 100644
index dc27246..0000000
--- a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/base.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# oscillode
-# Copyright (C) 2024 oscillode Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
-import abc
-import typing as typ
-
-from blender_maxwell.utils import logger, serialize
-
-from .. import contracts as ct
-
-log = logger.get(__name__)
-
-
-class ManagedObj(abc.ABC):
- """A weak name-based reference to some kind of object external to this software.
-
- While the object doesn't have to come from Blender's `bpy.types`, that is admittedly the driving motivation for this class: To encapsulate access to the powerful visual tools granted by Blender's 3D viewport, image editor, and UI.
- Through extensive testing, the functionality of an implicitly-cached, semi-strictly immediate-mode interface, demanding only a weakly-referenced name as persistance, has emerged (with all of the associated tradeoffs).
-
- While not suited to all use cases, the `ManagedObj` paradigm is perfect for many situations where a node needs to "loosely own" something external and non-trivial.
- Intriguingly, the precise definition of "loose" has grown to vary greatly between subclasses, as it ends of demonstrating itself to be a matter of taste more than determinism.
-
- This abstract base class serves to provide a few of the most basic of commonly-available - especially the `dump_as_msgspec`/`parse_as_msgspec` methods that allow it to be persisted using `blender_maxwell.utils.serialize`.
-
- Parameters:
- managed_obj_type: Enum identifier indicating which of the `ct.ManagedObjType` the instance should declare itself as.
- """
-
- managed_obj_type: ct.ManagedObjType
-
- @abc.abstractmethod
- def __init__(self, name: ct.ManagedObjName, prev_name: str | None = None):
- """Initializes the managed object with a unique name.
-
- Use `prev_name` to indicate that the managed object will initially be avaiable under `prev_name`, but that it should be renamed to `name`.
- """
-
- ####################
- # - Properties
- ####################
- @property
- @abc.abstractmethod
- def name(self) -> str:
- """Retrieve the name of the managed object."""
-
- @name.setter
- @abc.abstractmethod
- def name(self, value: str) -> None:
- """Retrieve the name of the managed object."""
-
- ####################
- # - Methods
- ####################
- @abc.abstractmethod
- def free(self) -> None:
- """Cleanup the resources managed by the managed object."""
-
- @abc.abstractmethod
- def bl_select(self) -> None:
- """Select the managed object in Blender, if such an operation makes sense."""
-
- @abc.abstractmethod
- def hide_preview(self) -> None:
- """Hide any active preview of the managed object, if it exists, and if such an operation makes sense."""
-
- ####################
- # - Serialization
- ####################
- def dump_as_msgspec(self) -> serialize.NaiveRepresentation:
- return [
- serialize.TypeID.ManagedObj,
- self.__class__.__name__,
- self.name,
- ]
-
- @staticmethod
- def parse_as_msgspec(obj: serialize.NaiveRepresentation) -> typ.Self:
- return next(
- subclass(obj[2])
- for subclass in ManagedObj.__subclasses__()
- if subclass.__name__ == obj[1]
- )
diff --git a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_empty.py b/oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_empty.py
deleted file mode 100644
index a220f4a..0000000
--- a/oscillode/node_trees/maxwell_sim_nodes/managed_objs/managed_bl_empty.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# oscillode
-# Copyright (C) 2024 oscillode Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
diff --git a/oscillode/node_trees/maxwell_sim_nodes/node_tree.py b/oscillode/node_trees/maxwell_sim_nodes/node_tree.py
index 135d6e3..e63a5fc 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/node_tree.py
+++ b/oscillode/node_trees/maxwell_sim_nodes/node_tree.py
@@ -14,33 +14,17 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+# TODO: Factor this stuff into a dedicated utils/ module, so that this particular node tree becomes simple (aka. the deathly complicated logic is factored out, and can be ex. unit tested all on its own).
+## - Then this file can focus on what is special about a Maxwell Sim node tree, as opposed to the lower-level details of how we've chosen to structure our node trees in general.
+## - Right now there may not be a distinction. And there may never be. But it's a healthy way to think about the problem.
-import contextlib
-import functools
import queue
import typing as typ
import bpy
-
-from blender_maxwell.utils import logger, serialize
+from blender_maxwell.utils import logger
from . import contracts as ct
-from .managed_objs.managed_bl_image import ManagedBLImage
log = logger.get(__name__)
@@ -320,7 +304,7 @@ class MaxwellSimTree(bpy.types.NodeTree):
In general, only one `MaxwellSimTree` should be active at a time.
"""
- bl_idname = ct.TreeType.MaxwellSim.value
+ bl_idname = ct.NodeTreeType.MaxwellSim.value
bl_label = 'Maxwell Sim Editor'
bl_icon = ct.Icon.SimNodeEditor
@@ -552,7 +536,8 @@ def populate_missing_persistence(_) -> None:
for node_tree in [
_node_tree
for _node_tree in bpy.data.node_groups
- if _node_tree.bl_idname == ct.TreeType.MaxwellSim.value and _node_tree.is_active
+ if _node_tree.bl_idname == ct.NodeTreeType.MaxwellSim.value
+ and _node_tree.is_active
]:
log.debug(
'%s: Regenerating Dynamic Field Persistance for NodeTree nodes/sockets',
diff --git a/oscillode/node_trees/maxwell_sim_nodes/nodes/__init__.py b/oscillode/node_trees/maxwell_sim_nodes/nodes/__init__.py
index c2b1496..b2f4f6e 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/nodes/__init__.py
+++ b/oscillode/node_trees/maxwell_sim_nodes/nodes/__init__.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
from . import (
analysis,
inputs,
diff --git a/oscillode/node_trees/maxwell_sim_nodes/nodes/base.py b/oscillode/node_trees/maxwell_sim_nodes/nodes/base.py
index 6a28b02..fc62197 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/nodes/base.py
+++ b/oscillode/node_trees/maxwell_sim_nodes/nodes/base.py
@@ -1196,7 +1196,7 @@ class MaxwellSimNode(bpy.types.Node, bl_instance.BLInstance):
Returns:
Whether or not the node can be instantiated within the given node tree.
"""
- return node_tree.bl_idname == ct.TreeType.MaxwellSim.value
+ return node_tree.bl_idname == ct.NodeTreeType.MaxwellSim
def init(self, _: bpy.types.Context) -> None:
"""Initialize the node instance, including ID, name, socket, presets, and the execution of any `on_value_changed` methods with the `run_on_init` keyword set.
diff --git a/oscillode/node_trees/maxwell_sim_nodes/nodes/inputs/scene.py b/oscillode/node_trees/maxwell_sim_nodes/nodes/inputs/scene.py
index b7cbc48..184141d 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/nodes/inputs/scene.py
+++ b/oscillode/node_trees/maxwell_sim_nodes/nodes/inputs/scene.py
@@ -146,7 +146,8 @@ def update_scene_node_after_frame_changed(
for node_tree in [
_node_tree
for _node_tree in bpy.data.node_groups
- if _node_tree.bl_idname == ct.TreeType.MaxwellSim.value and _node_tree.is_active
+ if _node_tree.bl_idname == ct.NodeTreeType.MaxwellSim.value
+ and _node_tree.is_active
]:
for node in [
_node
diff --git a/oscillode/node_trees/maxwell_sim_nodes/sockets/expr.py b/oscillode/node_trees/maxwell_sim_nodes/sockets/expr.py
index 7cd9095..c5a2dea 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/sockets/expr.py
+++ b/oscillode/node_trees/maxwell_sim_nodes/sockets/expr.py
@@ -385,7 +385,7 @@ class ExprBLSocket(base.MaxwellSimSocket):
####################
lazy_range_name: sim_symbols.SimSymbolName = bl_cache.BLField(
sim_symbols.SimSymbolName.Expr
- )
+ ) ## TODO: Delete (...what is it for?)
output_name: sim_symbols.SimSymbolName = bl_cache.BLField(
sim_symbols.SimSymbolName.Constant
)
@@ -989,6 +989,7 @@ class ExprBLSocket(base.MaxwellSimSocket):
####################
# - FlowKind: Func (w/Params if Constant)
####################
+ ## TODO: Consider some way of checking compatibility between the three.
@bl_cache.cached_bl_property(depends_on={'output_sym'})
def lazy_func(self) -> ct.FuncFlow:
"""Returns a lazy value that computes the expression returned by `self.value`.
@@ -1076,6 +1077,7 @@ class ExprBLSocket(base.MaxwellSimSocket):
####################
# - FlowKind: Capabilities
####################
+ ## TODO: Rename to 'capabilities_when_linked'
def linked_capabilities(self, info: ct.InfoFlow) -> ct.CapabilitiesFlow:
"""When this socket is linked as an output socket, expose these capabilities instead of querying `self.capabilities`.
diff --git a/oscillode/operators/__init__.py b/oscillode/operators/__init__.py
index d367c42..7411c0f 100644
--- a/oscillode/operators/__init__.py
+++ b/oscillode/operators/__init__.py
@@ -14,21 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+"""Blender operators that ship with Oscillode."""
from . import connect_viewer
diff --git a/oscillode/operators/connect_viewer.py b/oscillode/operators/connect_viewer.py
index 13b7ca6..f745cff 100644
--- a/oscillode/operators/connect_viewer.py
+++ b/oscillode/operators/connect_viewer.py
@@ -14,74 +14,98 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+"""Operator allowing the user to use the conventional CTRL+SHIFT+LMB to connect arbitrary node outputs to either an existing, or a new, viewer node."""
import bpy
-from blender_maxwell import contracts as ct
-from blender_maxwell.utils import logger
+from oscillode import contracts as ct
+from oscillode.node_trees.maxwell_sim_nodes.contracts import node_types
+from oscillode.utils import logger
log = logger.get(__name__)
class ConnectViewerNode(bpy.types.Operator):
+ """Connecting the viewer node to the active node in a Maxwell Sim node tree, as defined by selection and mouse-cursor location.
+
+ If there is no active viewer node, then one is created.
+ """
+
bl_idname = ct.OperatorType.ConnectViewerNode
bl_label = 'Connect Viewer to Active'
bl_description = 'Connect active node to Viewer Node'
- bl_options = {'REGISTER', 'UNDO'}
+ bl_options = frozenset({'REGISTER', 'UNDO'})
@classmethod
- def poll(cls, context):
+ def poll(cls, context: bpy.types.Context) -> bool:
+ """Require the active space to be a Maxwell Sim node tree defined by this addon.
+
+ Notes:
+ Run by Blender when determining whether the operator can run.
+
+ Returns:
+ Whether the operator can run.
+ """
space = context.space_data
return (
space.type == 'NODE_EDITOR'
and space.node_tree is not None
- and space.node_tree.bl_idname == 'MaxwellSimTreeType'
+ and space.node_tree.bl_idname == ct.NodeTreeType.MaxwellSim
)
- def invoke(self, context, event):
+ def invoke(
+ self, context: bpy.types.Context, event: bpy.types.Event
+ ) -> ct.BLOperatorStatus:
+ """Require the active space to be a particular node tree defined by this addon.
+
+ Notes:
+ Run by Blender when determining whether the operator can run.
+
+ Returns:
+ Whether the operator can run.
+ """
node_tree = context.space_data.node_tree
+
+ # Retrieve Mouse Location
mlocx = event.mouse_region_x
mlocy = event.mouse_region_y
+
+ # Select Node at Location
+ ## - Deselect all other nodes.
bpy.ops.node.select(
extend=False,
location=(mlocx, mlocy),
)
- select_node = context.selected_nodes[0]
+ selected_node = context.selected_nodes[0]
+ # Find Viewer Node...
for node in node_tree.nodes:
- if node.bl_idname == 'ViewerNodeType':
+ # TODO: Support multiple viewer nodes.
+ if hasattr(node, 'node_type') and node.node_type is node_types.Viewer:
viewer_node = node
break
- else:
- viewer_node = node_tree.nodes.new('ViewerNodeType')
- viewer_node.location.x = select_node.location.x + 250
- viewer_node.location.y = select_node.location.y
- select_node.select = False
- new_link = True
+ # ...OR: Create Viewer Node
+ else:
+ # TODO: Place viewer where it doesn't overlap other nodes.
+ viewer_node = node_tree.nodes.new(node_types.Viewer.value)
+ viewer_node.location.x = selected_node.location.x + 250
+ viewer_node.location.y = selected_node.location.y
+ selected_node.select = False
+
+ # Remove Input Links from Viewer
+ ## - Unless the selected node is already linked to the viewer.
+ should_create_new_link = True
for link in viewer_node.inputs[0].links:
- if link.from_node.name == select_node.name:
- new_link = False
+ if link.from_node.name == selected_node.name:
+ should_create_new_link = False
continue
node_tree.links.remove(link)
- if new_link:
- node_tree.links.new(select_node.outputs[0], viewer_node.inputs[0])
+ # Create Link from Selected Node to Viewer
+ if should_create_new_link:
+ node_tree.links.new(selected_node.outputs[0], viewer_node.inputs[0])
+
return {'FINISHED'}
diff --git a/oscillode/registration.py b/oscillode/registration.py
index 6fe6fdb..f1fd812 100644
--- a/oscillode/registration.py
+++ b/oscillode/registration.py
@@ -18,8 +18,6 @@
Attributes:
_ADDON_KEYMAP: Addon-specific keymap used to register operator hotkeys.
- DELAYED_REGISTRATIONS: Currently pending registration operations, which can be realized with `run_delayed_registration()`.
-
REG__CLASSES: Currently registered Blender classes.
_REGISTERED_HOTKEYS: Currently registered Blender keymap items.
"""
diff --git a/oscillode/services/tdcloud.py b/oscillode/services/tdcloud.py
index d4250c2..7ee5af7 100644
--- a/oscillode/services/tdcloud.py
+++ b/oscillode/services/tdcloud.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Defines a sane interface to the Tidy3D cloud, as constructed by reverse-engineering the official open-source `tidy3d` client library.
- SimulationTask:
@@ -48,7 +32,7 @@ import bpy
import tidy3d as td
import tidy3d.web as td_web
-from blender_maxwell.utils import logger
+from oscillode.utils import logger
log = logger.get(__name__)
diff --git a/oscillode/utils/bl_cache/__init__.py b/oscillode/utils/bl_cache/__init__.py
index 3098f43..d9275ed 100644
--- a/oscillode/utils/bl_cache/__init__.py
+++ b/oscillode/utils/bl_cache/__init__.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Package providing various tools to handle cached data on Blender objects, especially nodes and node socket classes."""
from ..keyed_cache import KeyedCache, keyed_cache
diff --git a/oscillode/utils/bl_cache/bl_field.py b/oscillode/utils/bl_cache/bl_field.py
index ab3c781..e88971c 100644
--- a/oscillode/utils/bl_cache/bl_field.py
+++ b/oscillode/utils/bl_cache/bl_field.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Implements various key caches on instances of Blender objects, especially nodes and sockets."""
import contextlib
@@ -39,8 +23,8 @@ import typing as typ
import bpy
-from blender_maxwell import contracts as ct
-from blender_maxwell.utils import bl_instance, logger
+from oscillode import contracts as ct
+from oscillode.utils import bl_instance, logger
from .bl_prop import BLProp
from .bl_prop_type import BLPropType
@@ -202,11 +186,12 @@ class BLField:
name: The name of the attribute that an instance of descriptor was assigned to.
"""
prop_type = inspect.get_annotations(owner).get(name)
+ bl_prop_type = BLPropType.from_type(prop_type)
self.bl_prop = BLProp(
name=name,
prop_info=self.prop_info,
prop_type=prop_type,
- bl_prop_type=BLPropType.from_type(prop_type),
+ bl_prop_type=bl_prop_type,
)
# Initialize Field on BLClass
diff --git a/oscillode/utils/bl_cache/bl_prop.py b/oscillode/utils/bl_cache/bl_prop.py
index 5ff202c..ae05e09 100644
--- a/oscillode/utils/bl_cache/bl_prop.py
+++ b/oscillode/utils/bl_cache/bl_prop.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Defines `BLProp`, a high-level wrapper for interacting with Blender properties."""
import dataclasses
@@ -50,7 +34,7 @@ log = logger.get(__name__)
####################
@dataclasses.dataclass(kw_only=True, frozen=True)
class BLProp:
- """A high-level wrapper encapsulating access to a Blender property.
+ """A mid-level representation of a Blender property, which implements unsafe requests from flexible high-level fields using cache operations and normalized Blender type operations.
Attributes:
name: The name of the Blender property, as one uses it.
diff --git a/oscillode/utils/bl_cache/bl_prop_type.py b/oscillode/utils/bl_cache/bl_prop_type.py
index 96b52e5..5a133a4 100644
--- a/oscillode/utils/bl_cache/bl_prop_type.py
+++ b/oscillode/utils/bl_cache/bl_prop_type.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Defines `BLPropType`, which provides stronger lower-level interfaces for interacting with data that can be conformed to work with Blender properties."""
import builtins
@@ -43,9 +27,9 @@ from pathlib import Path
import bpy
import numpy as np
-from blender_maxwell import contracts as ct
-from blender_maxwell.utils import logger, serialize
-from blender_maxwell.utils.staticproperty import staticproperty
+from oscillode import contracts as ct
+from oscillode.utils import logger, serialize
+from oscillode.utils.staticproperty import staticproperty
from .signal import Signal
@@ -106,7 +90,7 @@ def _is_bl_id_struct(T: type) -> bool: # noqa: N803
# - Blender Property Type
####################
class BLPropType(enum.StrEnum):
- """A type identifier which can be directly associated with a Blender property.
+ """A low-level identifier that maps directly to Blender property types.
For general use, the higher-level interface `BLProp` is more appropriate.
diff --git a/oscillode/utils/bl_cache/cached_bl_property.py b/oscillode/utils/bl_cache/cached_bl_property.py
index 5c78807..b2c8bc7 100644
--- a/oscillode/utils/bl_cache/cached_bl_property.py
+++ b/oscillode/utils/bl_cache/cached_bl_property.py
@@ -14,29 +14,13 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Implements various key caches on instances of Blender objects, especially nodes and sockets."""
import contextlib
import inspect
import typing as typ
-from blender_maxwell.utils import bl_instance, logger, serialize
+from oscillode.utils import bl_instance, logger, serialize
from .bl_prop import BLProp
from .bl_prop_type import BLPropType
diff --git a/oscillode/utils/bl_cache/managed_cache.py b/oscillode/utils/bl_cache/managed_cache.py
index 06d5742..f29dee7 100644
--- a/oscillode/utils/bl_cache/managed_cache.py
+++ b/oscillode/utils/bl_cache/managed_cache.py
@@ -14,29 +14,13 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Implements various key caches on instances of Blender objects, especially nodes and sockets."""
## TODO: Note that persist=True on cached_bl_property may cause a draw method to try and write to a Blender property, which Blender disallows.
import typing as typ
-from blender_maxwell.utils import bl_instance, logger
+from oscillode.utils import bl_instance, logger
from .signal import Signal
diff --git a/oscillode/utils/bl_cache/signal.py b/oscillode/utils/bl_cache/signal.py
index b7f06b9..2421f20 100644
--- a/oscillode/utils/bl_cache/signal.py
+++ b/oscillode/utils/bl_cache/signal.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import enum
import uuid
diff --git a/oscillode/utils/bl_instance.py b/oscillode/utils/bl_instance.py
index 7fb0b69..dfcc31e 100644
--- a/oscillode/utils/bl_instance.py
+++ b/oscillode/utils/bl_instance.py
@@ -14,30 +14,14 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import typing as typ
import uuid
from types import MappingProxyType
import bpy
-from blender_maxwell.utils import bl_cache, logger
-from blender_maxwell.utils.keyed_cache import keyed_cache
+from oscillode.utils import bl_cache, logger
+from oscillode.utils.keyed_cache import keyed_cache
InstanceID: typ.TypeAlias = str ## Stringified UUID4
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/bl_socket_types.py b/oscillode/utils/bl_socket_types.py
similarity index 99%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/bl_socket_types.py
rename to oscillode/utils/bl_socket_types.py
index 6671dcc..cee8548 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/bl_socket_types.py
+++ b/oscillode/utils/bl_socket_types.py
@@ -24,8 +24,6 @@ import bpy
import jax
import numpy as np
import pydantic as pyd
-import sympy as sp
-
from blender_maxwell.utils import logger
from blender_maxwell.utils import sympy_extra as spux
diff --git a/oscillode/utils/blender_type_enum.py b/oscillode/utils/blender_type_enum.py
index ee3b4e1..319c146 100644
--- a/oscillode/utils/blender_type_enum.py
+++ b/oscillode/utils/blender_type_enum.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import enum
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/__init__.py b/oscillode/utils/flow_kinds/__init__.py
similarity index 61%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/__init__.py
rename to oscillode/utils/flow_kinds/__init__.py
index a68e20e..bafd3f2 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/__init__.py
+++ b/oscillode/utils/flow_kinds/__init__.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
from .array import ArrayFlow
from .capabilities import CapabilitiesFlow
from .flow_kinds import FlowKind
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/array.py b/oscillode/utils/flow_kinds/array.py
similarity index 88%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/array.py
rename to oscillode/utils/flow_kinds/array.py
index 042124a..07152f1 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/array.py
+++ b/oscillode/utils/flow_kinds/array.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import base64
import functools
import io
@@ -38,14 +22,13 @@ import typing as typ
import jax
import jax.numpy as jnp
import jaxtyping as jtyp
-import numpy as np
import pydantic as pyd
import sympy as sp
-from blender_maxwell.utils import logger
-from blender_maxwell.utils import sympy_extra as spux
-from blender_maxwell.utils.jaxarray import JaxArrayBytes
-from blender_maxwell.utils.lru_method import method_lru
+from oscillode.utils import logger
+from oscillode.utils import sympy_extra as spux
+from oscillode.utils.jaxarray import JaxArrayBytes
+from oscillode.utils.lru_method import method_lru
log = logger.get(__name__)
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/capabilities.py b/oscillode/utils/flow_kinds/capabilities.py
similarity index 80%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/capabilities.py
rename to oscillode/utils/flow_kinds/capabilities.py
index 6e0fcb3..cffa475 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/capabilities.py
+++ b/oscillode/utils/flow_kinds/capabilities.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import dataclasses
import typing as typ
from types import MappingProxyType
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/expr_info.py b/oscillode/utils/flow_kinds/expr_info.py
similarity index 59%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/expr_info.py
rename to oscillode/utils/flow_kinds/expr_info.py
index 167d578..4f081ee 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/expr_info.py
+++ b/oscillode/utils/flow_kinds/expr_info.py
@@ -14,21 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+# TODO: Consider moving this to the new math system.
import typing as typ
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_events.py b/oscillode/utils/flow_kinds/flow_events.py
similarity index 79%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/flow_events.py
rename to oscillode/utils/flow_kinds/flow_events.py
index 5425d0c..7ad9863 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_events.py
+++ b/oscillode/utils/flow_kinds/flow_events.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import enum
import typing as typ
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/flow_kinds.py b/oscillode/utils/flow_kinds/flow_kinds.py
similarity index 87%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/flow_kinds.py
rename to oscillode/utils/flow_kinds/flow_kinds.py
index d6d6ee9..d303deb 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/flow_kinds.py
+++ b/oscillode/utils/flow_kinds/flow_kinds.py
@@ -14,30 +14,14 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import enum
import functools
import typing as typ
-from blender_maxwell.contracts import BLEnumElement
-from blender_maxwell.utils import logger
-from blender_maxwell.utils import sympy_extra as spux
-from blender_maxwell.utils.staticproperty import staticproperty
+from oscillode.contracts import BLEnumElement
+from oscillode.utils import logger
+from oscillode.utils import sympy_extra as spux
+from oscillode.utils.staticproperty import staticproperty
log = logger.get(__name__)
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_signals.py b/oscillode/utils/flow_kinds/flow_signals.py
similarity index 83%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/flow_signals.py
rename to oscillode/utils/flow_kinds/flow_signals.py
index 9a93522..5d7e14a 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_signals.py
+++ b/oscillode/utils/flow_kinds/flow_signals.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import enum
import typing as typ
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/info.py b/oscillode/utils/flow_kinds/info.py
similarity index 98%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/info.py
rename to oscillode/utils/flow_kinds/info.py
index a63d80d..6e02efb 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/info.py
+++ b/oscillode/utils/flow_kinds/info.py
@@ -36,10 +36,10 @@ import typing as typ
import pydantic as pyd
-from blender_maxwell.utils import logger, sim_symbols
-from blender_maxwell.utils import sympy_extra as spux
-from blender_maxwell.utils.frozendict import FrozenDict, frozendict
-from blender_maxwell.utils.lru_method import method_lru
+from oscillode.utils import logger, sim_symbols
+from oscillode.utils import sympy_extra as spux
+from oscillode.utils.frozendict import FrozenDict, frozendict
+from oscillode.utils.lru_method import method_lru
from .array import ArrayFlow
from .lazy_range import RangeFlow
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/lazy_func.py b/oscillode/utils/flow_kinds/lazy_func.py
similarity index 96%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/lazy_func.py
rename to oscillode/utils/flow_kinds/lazy_func.py
index 23cf9c4..04cdf97 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/lazy_func.py
+++ b/oscillode/utils/flow_kinds/lazy_func.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
r"""Implements the core of the math system via `FuncFlow`, which allows high-performance, fully-expressive workflows with data that can be "very large", and/or whose input parameters are not yet fully known.
# Introduction
@@ -235,17 +219,16 @@ But above all, we hope that this math system is fun, practical, and maybe even i
import functools
import typing as typ
-from types import MappingProxyType
import jax
import jaxtyping as jtyp
import pydantic as pyd
import sympy as sp
-from blender_maxwell.utils import logger, sim_symbols
-from blender_maxwell.utils import sympy_extra as spux
-from blender_maxwell.utils.frozendict import FrozenDict, frozendict
-from blender_maxwell.utils.lru_method import method_lru
+from oscillode.utils import logger, sim_symbols
+from oscillode.utils import sympy_extra as spux
+from oscillode.utils.frozendict import FrozenDict, frozendict
+from oscillode.utils.lru_method import method_lru
from .array import ArrayFlow
from .info import InfoFlow
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/lazy_range.py b/oscillode/utils/flow_kinds/lazy_range.py
similarity index 96%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/lazy_range.py
rename to oscillode/utils/flow_kinds/lazy_range.py
index a186118..45cf071 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/lazy_range.py
+++ b/oscillode/utils/flow_kinds/lazy_range.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import enum
import functools
import typing as typ
@@ -39,10 +23,10 @@ import jaxtyping as jtyp
import pydantic as pyd
import sympy as sp
-from blender_maxwell.utils import logger, sim_symbols
-from blender_maxwell.utils import sympy_extra as spux
-from blender_maxwell.utils.frozendict import frozendict
-from blender_maxwell.utils.lru_method import method_lru
+from oscillode.utils import logger, sim_symbols
+from oscillode.utils import sympy_extra as spux
+from oscillode.utils.frozendict import frozendict
+from oscillode.utils.lru_method import method_lru
from .array import ArrayFlow
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/params.py b/oscillode/utils/flow_kinds/params.py
similarity index 93%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/params.py
rename to oscillode/utils/flow_kinds/params.py
index 909a7f8..745c162 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/params.py
+++ b/oscillode/utils/flow_kinds/params.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import functools
import typing as typ
from fractions import Fraction
@@ -39,10 +23,10 @@ import jaxtyping as jtyp
import pydantic as pyd
import sympy as sp
-from blender_maxwell.utils import logger, sim_symbols
-from blender_maxwell.utils import sympy_extra as spux
-from blender_maxwell.utils.frozendict import FrozenDict, frozendict
-from blender_maxwell.utils.lru_method import method_lru
+from oscillode.utils import logger, sim_symbols
+from oscillode.utils import sympy_extra as spux
+from oscillode.utils.frozendict import FrozenDict, frozendict
+from oscillode.utils.lru_method import method_lru
from .array import ArrayFlow
from .expr_info import ExprInfo
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/previews.py b/oscillode/utils/flow_kinds/previews.py
similarity index 89%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/previews.py
rename to oscillode/utils/flow_kinds/previews.py
index b11763d..e928e6a 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/previews.py
+++ b/oscillode/utils/flow_kinds/previews.py
@@ -14,28 +14,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import typing as typ
import bpy
import pydantic as pyd
-from blender_maxwell.utils import logger
+from oscillode.utils import logger
IMAGE_AREA_TYPE = 'IMAGE_EDITOR'
IMAGE_SPACE_TYPE = 'IMAGE_EDITOR'
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/value.py b/oscillode/utils/flow_kinds/value.py
similarity index 100%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/flow_kinds/value.py
rename to oscillode/utils/flow_kinds/value.py
diff --git a/oscillode/utils/frozendict.py b/oscillode/utils/frozendict.py
index 8b9a561..7dffadd 100644
--- a/oscillode/utils/frozendict.py
+++ b/oscillode/utils/frozendict.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Implements a `pydantic`-compatible field, `FrozenDict`, which encapsulates a `frozendict` in a serializable way, with semantics identical to `dict`."""
import typing as typ
diff --git a/oscillode/utils/image_ops.py b/oscillode/utils/image_ops.py
index 2d13a6c..ca5dd71 100644
--- a/oscillode/utils/image_ops.py
+++ b/oscillode/utils/image_ops.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Useful image processing operations for use in the addon."""
import enum
@@ -45,9 +29,9 @@ import matplotlib.figure
import seaborn as sns
import sympy as sp
-from blender_maxwell import contracts as ct
-from blender_maxwell.utils import logger
-from blender_maxwell.utils import sympy_extra as spux
+from oscillode import contracts as ct
+from oscillode.utils import logger
+from oscillode.utils import sympy_extra as spux
sns.set_theme()
diff --git a/oscillode/utils/jaxarray.py b/oscillode/utils/jaxarray.py
index daf124e..ec07d55 100644
--- a/oscillode/utils/jaxarray.py
+++ b/oscillode/utils/jaxarray.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Implements a `pydantic`-compatible field, `JaxArray`, which encapsulates a `jax.Array` in a serializable way."""
import base64
@@ -42,6 +26,9 @@ import numpy as np
import pydantic as pyd
from pydantic_core import core_schema as pyd_core_schema
+# TODO: It's possible this is all pointless.
+# Is https://github.com/p2p-ld/numpydantic our lord and savior?
+
####################
# - Simple JAX Array
diff --git a/oscillode/utils/keyed_cache.py b/oscillode/utils/keyed_cache.py
index dfcb7ae..d92222d 100644
--- a/oscillode/utils/keyed_cache.py
+++ b/oscillode/utils/keyed_cache.py
@@ -14,27 +14,11 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import functools
import inspect
import typing as typ
-from blender_maxwell.utils import logger, serialize
+from oscillode.utils import logger, serialize
log = logger.get(__name__)
diff --git a/oscillode/utils/logger.py b/oscillode/utils/logger.py
index 4ba1ea3..f8c6e35 100644
--- a/oscillode/utils/logger.py
+++ b/oscillode/utils/logger.py
@@ -23,7 +23,8 @@ from pathlib import Path
import rich.console
import rich.logging
import rich.traceback
-from blender_maxwell import contracts as ct
+
+from oscillode import contracts as ct
from ..services import init_settings
diff --git a/oscillode/utils/lru_method.py b/oscillode/utils/lru_method.py
index 64ba4e3..07c5a99 100644
--- a/oscillode/utils/lru_method.py
+++ b/oscillode/utils/lru_method.py
@@ -14,21 +14,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+"""Provides a Least Recently Used cache for methods, which uses a weak reference to `self` to attach the cache to the object.
+
+This is a specialized construct to be used carefully and sparsely, when other tradeoffs have failed. Misuse can have serious consequences.
+"""
import functools
import weakref
diff --git a/oscillode/node_trees/maxwell_sim_nodes/math_system/__init__.py b/oscillode/utils/math_system/__init__.py
similarity index 100%
rename from oscillode/node_trees/maxwell_sim_nodes/math_system/__init__.py
rename to oscillode/utils/math_system/__init__.py
diff --git a/oscillode/node_trees/maxwell_sim_nodes/math_system/filter.py b/oscillode/utils/math_system/filter.py
similarity index 100%
rename from oscillode/node_trees/maxwell_sim_nodes/math_system/filter.py
rename to oscillode/utils/math_system/filter.py
diff --git a/oscillode/node_trees/maxwell_sim_nodes/math_system/map.py b/oscillode/utils/math_system/map.py
similarity index 100%
rename from oscillode/node_trees/maxwell_sim_nodes/math_system/map.py
rename to oscillode/utils/math_system/map.py
diff --git a/oscillode/node_trees/maxwell_sim_nodes/math_system/operate.py b/oscillode/utils/math_system/operate.py
similarity index 100%
rename from oscillode/node_trees/maxwell_sim_nodes/math_system/operate.py
rename to oscillode/utils/math_system/operate.py
diff --git a/oscillode/node_trees/maxwell_sim_nodes/math_system/reduce.py b/oscillode/utils/math_system/reduce.py
similarity index 100%
rename from oscillode/node_trees/maxwell_sim_nodes/math_system/reduce.py
rename to oscillode/utils/math_system/reduce.py
diff --git a/oscillode/node_trees/maxwell_sim_nodes/math_system/transform.py b/oscillode/utils/math_system/transform.py
similarity index 100%
rename from oscillode/node_trees/maxwell_sim_nodes/math_system/transform.py
rename to oscillode/utils/math_system/transform.py
diff --git a/oscillode/utils/sci_constants.py b/oscillode/utils/sci_constants.py
index 21a819f..8dcdee1 100644
--- a/oscillode/utils/sci_constants.py
+++ b/oscillode/utils/sci_constants.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Access `scipy.constants` using `sympy` units.
Notes:
diff --git a/oscillode/utils/serialize.py b/oscillode/utils/serialize.py
index 3f3f586..f055fe0 100644
--- a/oscillode/utils/serialize.py
+++ b/oscillode/utils/serialize.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""A fast, robust `msgspec`-based serialization tool providing for string-based persistance of many objects.
Blender provides for strong persistence guarantees based on its `bpy.types.Property` system.
@@ -69,7 +53,6 @@ import typing as typ
import uuid
import msgspec
-import numpy as np
import sympy as sp
import tidy3d as td
diff --git a/oscillode/utils/sim_symbols/__init__.py b/oscillode/utils/sim_symbols/__init__.py
index bab9de8..a5b5a40 100644
--- a/oscillode/utils/sim_symbols/__init__.py
+++ b/oscillode/utils/sim_symbols/__init__.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Declares a useful, flexible symbolic representation."""
from .common import (
@@ -114,4 +98,12 @@ __all__ = [
'int_min'
'mk_interval'
'unicode_superscript',
+ 'SimSymbolName',
+ 'SimSymbol',
+ 'float_max',
+ 'float_min',
+ 'int_max',
+ 'int_min',
+ 'mk_interval',
+ 'unicode_superscript',
]
diff --git a/oscillode/utils/sim_symbols/common.py b/oscillode/utils/sim_symbols/common.py
index 638e9b7..0ed35d3 100644
--- a/oscillode/utils/sim_symbols/common.py
+++ b/oscillode/utils/sim_symbols/common.py
@@ -14,29 +14,13 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import enum
import typing as typ
import sympy as sp
-from blender_maxwell.utils import logger
-from blender_maxwell.utils import sympy_extra as spux
+from oscillode.utils import logger
+from oscillode.utils import sympy_extra as spux
from .name import SimSymbolName
from .sim_symbol import SimSymbol
@@ -210,6 +194,7 @@ class CommonSimSymbol(enum.StrEnum):
),
)
+ ## TODO: Optimize; SimSymbol is constructed an enormous amount of times!
return {
CSS.Index: SimSymbol(
sym_name=self.name,
diff --git a/oscillode/utils/sim_symbols/name.py b/oscillode/utils/sim_symbols/name.py
index eb48694..93e0c31 100644
--- a/oscillode/utils/sim_symbols/name.py
+++ b/oscillode/utils/sim_symbols/name.py
@@ -14,27 +14,11 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import enum
import string
import typing as typ
-from blender_maxwell.utils import logger
+from oscillode.utils import logger
log = logger.get(__name__)
diff --git a/oscillode/utils/sim_symbols/sim_symbol.py b/oscillode/utils/sim_symbols/sim_symbol.py
index 4293851..78594ec 100644
--- a/oscillode/utils/sim_symbols/sim_symbol.py
+++ b/oscillode/utils/sim_symbols/sim_symbol.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
"""Implements `SimSymbol`, a convenient representation of a symbolic variable suiteable for use when describing various mathematical and numerical interfaces."""
import functools
@@ -45,10 +29,10 @@ import sympy as sp
import sympy.stats as sps
from sympy.tensor.array.expressions import ArraySymbol
-from blender_maxwell.utils import logger, serialize
-from blender_maxwell.utils import sympy_extra as spux
-from blender_maxwell.utils.frozendict import frozendict
-from blender_maxwell.utils.lru_method import method_lru
+from oscillode.utils import logger, serialize
+from oscillode.utils import sympy_extra as spux
+from oscillode.utils.frozendict import frozendict
+from oscillode.utils.lru_method import method_lru
from .name import SimSymbolName
from .utils import unicode_superscript
@@ -95,7 +79,7 @@ class SimSymbol(pyd.BaseModel):
physical_type: spux.PhysicalType = spux.PhysicalType.NonPhysical
# Units
- ## -> 'None' indicates that no particular unit has yet been chosen.
+ ## -> 'None' indicates that no particular unit has (yet) been chosen.
## -> When 'self.physical_type' is NonPhysical, _no unit_ can be chosen.
unit: spux.Unit | None = None
@@ -768,7 +752,8 @@ class SimSymbol(pyd.BaseModel):
) -> typ.Self | None:
"""Deduce a `SimSymbol` that matches the output of a given expression (and unit expression).
- This is an essential method, allowing for the ded
+ This is an essential method, allowing arbitrary expressions to be assigned a correct symbolic representation.
+ It is also a heuristic method of parsing, which does its best to interpret the expression - but does not guarantee the expected transcription in all cases.
Notes:
`PhysicalType` **cannot be set** from an expression in the generic sense.
diff --git a/oscillode/utils/sim_symbols/utils.py b/oscillode/utils/sim_symbols/utils.py
index daca41b..ac2a111 100644
--- a/oscillode/utils/sim_symbols/utils.py
+++ b/oscillode/utils/sim_symbols/utils.py
@@ -14,22 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-
import sys
from fractions import Fraction
diff --git a/oscillode/node_trees/maxwell_sim_nodes/contracts/sim_types.py b/oscillode/utils/sim_types/sim_types.py
similarity index 99%
rename from oscillode/node_trees/maxwell_sim_nodes/contracts/sim_types.py
rename to oscillode/utils/sim_types/sim_types.py
index a2c7474..537d942 100644
--- a/oscillode/node_trees/maxwell_sim_nodes/contracts/sim_types.py
+++ b/oscillode/utils/sim_types/sim_types.py
@@ -36,7 +36,6 @@ import dataclasses
import enum
import functools
import typing as typ
-from fractions import Fraction
from pathlib import Path
import jax.numpy as jnp
@@ -45,13 +44,13 @@ import numpy as np
import polars as pl
import pydantic as pyd
import tidy3d as td
-
from blender_maxwell.contracts import BLEnumElement
from blender_maxwell.services import tdcloud
from blender_maxwell.utils import logger, sim_symbols
from blender_maxwell.utils import sympy_extra as spux
from .flow_kinds.info import InfoFlow
+## TODO: Use a Protocol interface from data_pipelines/
log = logger.get(__name__)
diff --git a/oscillode/utils/staticproperty.py b/oscillode/utils/staticproperty.py
index 493b28a..61430a2 100644
--- a/oscillode/utils/staticproperty.py
+++ b/oscillode/utils/staticproperty.py
@@ -14,21 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-# blender_maxwell
-# Copyright (C) 2024 blender_maxwell Project Contributors
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+"""Provides a '@staticproperty', which is like '@property', but static. It can be very useful in specific situations."""
class staticproperty(property): # noqa: N801
diff --git a/oscillode/utils/sympy_extra/sympy_sets.py b/oscillode/utils/sympy_extra/sympy_sets.py
index 656d480..62763b9 100644
--- a/oscillode/utils/sympy_extra/sympy_sets.py
+++ b/oscillode/utils/sympy_extra/sympy_sets.py
@@ -49,9 +49,8 @@ import jax
import jax.numpy as jnp
import pydantic as pyd
import sympy as sp
-from sympy.sets.setexpr import SetExpr
-
from blender_maxwell.utils.lru_method import method_lru
+from sympy.sets.setexpr import SetExpr
from .. import logger
from .math_type import MathType as MT # noqa: N817
diff --git a/pyproject.toml b/pyproject.toml
index 0ef4d46..a410ff0 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -170,6 +170,7 @@ ignore = [
"F722", # jaxtyping uses type annotations that ruff sees as "syntax error"
"N806", # Sometimes we like using types w/uppercase in functions, sue me
"RUF001", # We use a lot of unicode, yes, on purpose!
+ #"RUF012", # ruff misunderstands which ClassVars are actually mutable.
# Line Length - Controversy Incoming
## Hot Take: Let the Formatter Worry about Line Length