5.0 (#60)
* feat: Add Bioxel asset catalog and layer management functionality - Introduced a new asset catalog definition file for Blender to manage Bioxel assets. - Implemented layer caching and snapshot functionality in `layer.py`, allowing for VDB file generation and low-resolution snapshots. - Created node management functions in `node.py` for handling Bioxel nodes within Blender's Geometry Node Editor. - Added an operator to extract mesh data from selected nodes in `structure.py`. - Developed UI panels in `panels.py` for layer management, including import options and layer library display. * Add unit tests for bioxel module and documentation - Created README.md for test instructions and categories. - Implemented comprehensive unit tests for the Data, Layer, and utility functions in the bioxel module. - Added tests for reading NRRD and DICOM formats, data properties, and edge cases. - Included tests for real data files to ensure functionality with actual datasets. * feat: Update .gitattributes and .gitignore for improved asset management and ignore patterns chore: Add app.json and omoolab.css for Obsidian integration refactor: Clean up AGENTS.md and remove outdated test files * feat: Update .gitignore to include scipy_ndimage directory * feat: Update release workflow and manifest for improved dependency management and layer handling * feat: Update .gitignore and add binary files for scipy_ndimage across multiple platforms * feat: Add OPSX commands for archiving, exploring, and proposing changes * feat: Refactor asset library management and update manifest for improved organization * feat: Downgrade h5py version to 3.14.0 in requirements and manifest * feat: Update Help operator and panel labels to use English terminology * Translate documentation to Chinese, add support format details, and enhance styling with new fonts. Update mkdocs configuration for multilingual support and improve package dependencies. * feat: Remove default version setting from extra configuration in mkdocs.yml * fix: Update documentation links to point to the correct URLs for Chinese and English versions * Add documentation for basic usage, supported formats, and performance tips - Created English and Chinese documentation for basic usage of the add-on, including data download, import, extraction, and rendering steps. - Added support format documentation listing compatible file types for the add-on. - Included links to open databases for volumetric data. - Provided performance improvement tips for voxel reconstruction and rendering, including settings for low-resolution previews and balanced rendering configurations.
This commit is contained in:
@@ -1,187 +1,40 @@
|
||||
import bpy
|
||||
from .operators.structure import ExtractMesh
|
||||
|
||||
from .constants import MENU_ITEMS, VERSIONS
|
||||
from .node_menu import NodeMenu
|
||||
|
||||
from .bioxelutils.common import (get_container_obj,
|
||||
get_container_layer_objs, get_layer_label,
|
||||
get_layer_prop_value, get_node_version, is_incompatible)
|
||||
from .operators.layer import (FetchLayer, RelocateLayer, RetimeLayer, RenameLayer,
|
||||
RemoveSelectedLayers, SaveSelectedLayersCache,
|
||||
ResampleLayer, SignScalar, CombineLabels,
|
||||
FillByLabel, FillByThreshold, FillByRange)
|
||||
from .operators.container import (AddLocator, AddSlicer, ContainerProps,
|
||||
SaveContainerLayersCache, RemoveContainerMissingLayers,
|
||||
SaveContainer, LoadContainer,
|
||||
AddPieCutter, AddPlaneCutter,
|
||||
AddCylinderCutter, AddCubeCutter, AddSphereCutter,
|
||||
ExtractBboxWire, ExtractMesh, ExtractShapeWire,
|
||||
ExtractNodeMesh, ExtractNodeBboxWire, ExtractNodeShapeWire)
|
||||
|
||||
from .operators.io import (ImportAsLabel, ImportAsScalar, ImportAsColor)
|
||||
from .operators.misc import (AddEeveeEnv, CleanTemp, Help,
|
||||
ReLinkNodeLib, RemoveAllMissingLayers,
|
||||
RenderSettingPreset, SaveAllLayersCache,
|
||||
SaveNodeLib, SliceViewer)
|
||||
|
||||
|
||||
class IncompatibleMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXELNODES_MT_INCOMPATIBLE"
|
||||
bl_label = "Bioxel Nodes"
|
||||
|
||||
def draw(self, context):
|
||||
tip_text = "please downgrade addon version."
|
||||
node_version = get_node_version()
|
||||
if node_version:
|
||||
version_str = "v"+".".join([str(i) for i in list(node_version)])
|
||||
tip_text = f"please downgrade addon version to {version_str}."
|
||||
|
||||
layout = self.layout
|
||||
layout.label(text="Incompatible node version detected.")
|
||||
layout.separator()
|
||||
layout.label(
|
||||
text="If you still want to edit this file with bioxel nodes, ")
|
||||
layout.label(text=tip_text)
|
||||
layout.separator()
|
||||
layout.label(text="If this file is archived, "
|
||||
"please relink node library, ")
|
||||
layout.label(text="check if it still works, "
|
||||
"then save node library.")
|
||||
layout.separator()
|
||||
layout.menu(ReLinkNodeLibMenu.bl_idname)
|
||||
layout.operator(SaveNodeLib.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.menu(DangerZoneMenu.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.menu(RenderSettingMenu.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.operator(Help.bl_idname,
|
||||
icon=Help.bl_icon)
|
||||
|
||||
|
||||
class FetchLayerMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXELNODES_MT_ADD_LAYER"
|
||||
bl_label = "Fetch Layer"
|
||||
|
||||
def draw(self, context):
|
||||
container_obj = get_container_obj(bpy.context.active_object)
|
||||
layer_objs = get_container_layer_objs(container_obj)
|
||||
layout = self.layout
|
||||
|
||||
for layer_obj in layer_objs:
|
||||
op = layout.operator(FetchLayer.bl_idname,
|
||||
text=get_layer_label(layer_obj))
|
||||
op.layer_obj_name = layer_obj.name
|
||||
|
||||
|
||||
class ExtractFromContainerMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXELNODES_MT_PICK"
|
||||
bl_label = "Extract from Container"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.operator(ExtractMesh.bl_idname)
|
||||
layout.operator(ExtractShapeWire.bl_idname)
|
||||
layout.operator(ExtractBboxWire.bl_idname)
|
||||
|
||||
|
||||
class AddCutterMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXELNODES_MT_CUTTERS"
|
||||
bl_label = "Add a Cutter"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.operator(AddPlaneCutter.bl_idname,
|
||||
icon=AddPlaneCutter.bl_icon, text="Plane Cutter")
|
||||
layout.operator(AddCylinderCutter.bl_idname,
|
||||
icon=AddCylinderCutter.bl_icon, text="Cylinder Cutter")
|
||||
layout.operator(AddCubeCutter.bl_idname,
|
||||
icon=AddCubeCutter.bl_icon, text="Cube Cutter")
|
||||
layout.operator(AddSphereCutter.bl_idname,
|
||||
icon=AddSphereCutter.bl_icon, text="Sphere Cutter")
|
||||
layout.operator(AddPieCutter.bl_idname,
|
||||
icon=AddPieCutter.bl_icon, text="Pie Cutter")
|
||||
from .operators.io import ImportAsLabel, ImportAsScalar, ImportAsColor
|
||||
from .operators.misc import (
|
||||
CleanTemp,
|
||||
Help,
|
||||
RenderSettingPreset,
|
||||
TogglePhantom,
|
||||
)
|
||||
|
||||
|
||||
class ImportLayerMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXELNODES_MT_IMPORTLAYER"
|
||||
bl_idname = "BIOXEL_MT_IMPORTLAYER"
|
||||
bl_label = "Import Volumetric Data (Init)"
|
||||
bl_icon = "FILE_NEW"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.operator(ImportAsScalar.bl_idname,
|
||||
text="as Scalar")
|
||||
layout.operator(ImportAsLabel.bl_idname,
|
||||
text="as Label")
|
||||
layout.operator(ImportAsColor.bl_idname,
|
||||
text="as Color")
|
||||
|
||||
|
||||
class AddLayerMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXELNODES_MT_ADDLAYER"
|
||||
bl_label = "Import Volumetric Data (Add)"
|
||||
bl_icon = "FILE_NEW"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.operator(ImportAsScalar.bl_idname,
|
||||
text="as Scalar")
|
||||
layout.operator(ImportAsLabel.bl_idname,
|
||||
text="as Label")
|
||||
layout.operator(ImportAsColor.bl_idname,
|
||||
text="as Color")
|
||||
|
||||
|
||||
class ModifyLayerMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXELNODES_MT_MODIFYLAYER"
|
||||
bl_label = "Modify Layer"
|
||||
bl_icon = "FILE_NEW"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.operator(SignScalar.bl_idname,
|
||||
icon=SignScalar.bl_icon)
|
||||
layout.operator(FillByThreshold.bl_idname,
|
||||
icon=FillByThreshold.bl_icon)
|
||||
layout.operator(FillByRange.bl_idname,
|
||||
icon=FillByRange.bl_icon)
|
||||
layout.operator(FillByLabel.bl_idname,
|
||||
icon=FillByLabel.bl_icon)
|
||||
layout.operator(CombineLabels.bl_idname,
|
||||
icon=CombineLabels.bl_icon)
|
||||
|
||||
|
||||
class ReLinkNodeLibMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXELNODES_MT_RELINK"
|
||||
bl_label = "Relink Node Library"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
for index, version in enumerate(VERSIONS):
|
||||
op = layout.operator(ReLinkNodeLib.bl_idname,
|
||||
text=version["label"])
|
||||
op.index = index
|
||||
layout.operator(ImportAsScalar.bl_idname, text="as Scalar")
|
||||
layout.operator(ImportAsLabel.bl_idname, text="as Label")
|
||||
layout.operator(ImportAsColor.bl_idname, text="as Color")
|
||||
|
||||
|
||||
class RenderSettingMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXELNODES_MT_RENDER"
|
||||
bl_idname = "BIOXEL_MT_RENDER"
|
||||
bl_label = "Render Setting Presets"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
for k, v in RenderSettingPreset.PRESETS.items():
|
||||
op = layout.operator(RenderSettingPreset.bl_idname,
|
||||
text=v)
|
||||
op = layout.operator(RenderSettingPreset.bl_idname, text=v)
|
||||
op.preset = k
|
||||
|
||||
|
||||
class DangerZoneMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXELNODES_MT_DANGER"
|
||||
bl_idname = "BIOXEL_MT_DANGER"
|
||||
bl_label = "Danger Zone"
|
||||
|
||||
def draw(self, context):
|
||||
@@ -190,118 +43,44 @@ class DangerZoneMenu(bpy.types.Menu):
|
||||
|
||||
|
||||
class BioxelNodesTopbarMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXELNODES_MT_TOPBAR"
|
||||
bl_idname = "BIOXEL_MT_TOPBAR"
|
||||
bl_label = "Bioxel Nodes"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.menu(ImportLayerMenu.bl_idname,
|
||||
icon=ImportLayerMenu.bl_icon)
|
||||
layout.operator(LoadContainer.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.operator(SaveAllLayersCache.bl_idname)
|
||||
layout.operator(RemoveAllMissingLayers.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.menu(ReLinkNodeLibMenu.bl_idname)
|
||||
layout.operator(SaveNodeLib.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.menu(DangerZoneMenu.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.operator(AddEeveeEnv.bl_idname)
|
||||
layout.menu(RenderSettingMenu.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.operator(Help.bl_idname,
|
||||
icon=Help.bl_icon)
|
||||
|
||||
|
||||
def TOPBAR(self, context):
|
||||
layout = self.layout
|
||||
|
||||
if is_incompatible():
|
||||
layout.menu(IncompatibleMenu.bl_idname)
|
||||
else:
|
||||
layout.menu(BioxelNodesTopbarMenu.bl_idname)
|
||||
|
||||
|
||||
class NodeHeadMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXELNODES_MT_NODE_HEAD"
|
||||
bl_label = "Bioxel Nodes"
|
||||
bl_icon = "FILE_VOLUME"
|
||||
|
||||
def draw(self, context):
|
||||
|
||||
layout = self.layout
|
||||
layout.menu(AddLayerMenu.bl_idname,
|
||||
icon=AddLayerMenu.bl_icon)
|
||||
layout.operator(SaveContainer.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.operator(ContainerProps.bl_idname)
|
||||
layout.menu(ExtractFromContainerMenu.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.operator(SaveContainerLayersCache.bl_idname,
|
||||
icon=SaveContainerLayersCache.bl_icon)
|
||||
layout.operator(RemoveContainerMissingLayers.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.operator(AddLocator.bl_idname,
|
||||
icon=AddLocator.bl_icon)
|
||||
layout.operator(AddSlicer.bl_idname,
|
||||
icon=AddSlicer.bl_icon)
|
||||
layout.menu(AddCutterMenu.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.menu(FetchLayerMenu.bl_idname)
|
||||
layout.operator(Help.bl_idname, icon=Help.bl_icon)
|
||||
|
||||
|
||||
class NodeContextMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXELNODES_MT_NODE_CONTEXT"
|
||||
bl_idname = "BIOXEL_MT_NODE_CONTEXT"
|
||||
bl_label = "Bioxel Nodes"
|
||||
bl_icon = "FILE_VOLUME"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.operator(ExtractNodeMesh.bl_idname)
|
||||
layout.operator(ExtractNodeShapeWire.bl_idname)
|
||||
layout.operator(ExtractNodeBboxWire.bl_idname)
|
||||
layout.operator(ExtractMesh.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.operator(SaveSelectedLayersCache.bl_idname,
|
||||
icon=SaveSelectedLayersCache.bl_icon)
|
||||
layout.operator(RemoveSelectedLayers.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.operator(RenameLayer.bl_idname,
|
||||
icon=RenameLayer.bl_icon)
|
||||
layout.operator(RetimeLayer.bl_idname)
|
||||
layout.operator(RelocateLayer.bl_idname)
|
||||
class ObjectContextMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXEL_MT_OBJECT_CONTEXT"
|
||||
bl_label = "Bioxel Nodes"
|
||||
bl_icon = "FILE_VOLUME"
|
||||
|
||||
layout.separator()
|
||||
layout.operator(ResampleLayer.bl_idname,
|
||||
icon=ResampleLayer.bl_icon)
|
||||
layout.operator(SignScalar.bl_idname)
|
||||
layout.operator(FillByThreshold.bl_idname)
|
||||
layout.operator(FillByRange.bl_idname)
|
||||
layout.operator(FillByLabel.bl_idname)
|
||||
layout.operator(CombineLabels.bl_idname)
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.operator(TogglePhantom.bl_idname)
|
||||
|
||||
|
||||
def NODE_CONTEXT(self, context):
|
||||
if is_incompatible():
|
||||
return
|
||||
|
||||
container_obj = context.object
|
||||
is_geo_nodes = context.area.ui_type == "GeometryNodeTree"
|
||||
is_container = get_container_obj(container_obj)
|
||||
|
||||
if not is_geo_nodes or not is_container:
|
||||
if not is_geo_nodes or not container_obj:
|
||||
return
|
||||
|
||||
layout = self.layout
|
||||
@@ -309,127 +88,18 @@ def NODE_CONTEXT(self, context):
|
||||
layout.menu(NodeContextMenu.bl_idname)
|
||||
|
||||
|
||||
def NODE_HEAD(self, context):
|
||||
if is_incompatible():
|
||||
return
|
||||
|
||||
container_obj = context.object
|
||||
is_geo_nodes = context.area.ui_type == "GeometryNodeTree"
|
||||
is_container = get_container_obj(container_obj)
|
||||
|
||||
if not is_geo_nodes or not is_container:
|
||||
return
|
||||
|
||||
# 定义添加到右键菜单的函数,放在首位
|
||||
def OBJECT_CONTEXT(self, context):
|
||||
layout = self.layout
|
||||
layout.separator()
|
||||
layout.menu(NodeHeadMenu.bl_idname)
|
||||
|
||||
|
||||
def NODE_PROP(self, context):
|
||||
if is_incompatible():
|
||||
return
|
||||
|
||||
container_obj = context.object
|
||||
is_geo_nodes = context.area.ui_type == "GeometryNodeTree"
|
||||
is_container = get_container_obj(container_obj)
|
||||
self.bl_label = "Group"
|
||||
|
||||
if not is_geo_nodes or not is_container:
|
||||
return
|
||||
|
||||
if container_obj.modifiers[0].node_group != context.space_data.edit_tree:
|
||||
return
|
||||
|
||||
self.bl_label = "Bioxel Nodes"
|
||||
|
||||
layer_list_UL = bpy.context.window_manager.bioxelnodes_layer_list_UL
|
||||
layer_list = layer_list_UL.layer_list
|
||||
layer_list.clear()
|
||||
|
||||
for layer_obj in get_container_layer_objs(container_obj):
|
||||
layer_item = layer_list.add()
|
||||
layer_item.label = get_layer_label(layer_obj)
|
||||
layer_item.obj_name = layer_obj.name
|
||||
layer_item.info_text = "\n".join([f"{prop}: {get_layer_prop_value(layer_obj, prop)}"
|
||||
for prop in ["kind",
|
||||
"bioxel_size",
|
||||
"shape",
|
||||
"frame_count",
|
||||
"channel_count",
|
||||
"min", "max"]])
|
||||
|
||||
layout = self.layout
|
||||
layout.label(text="Layer List")
|
||||
split = layout.row()
|
||||
split.template_list(listtype_name="BIOXELNODES_UL_layer_list",
|
||||
list_id="layer_list",
|
||||
dataptr=layer_list_UL,
|
||||
propname="layer_list",
|
||||
active_dataptr=layer_list_UL,
|
||||
active_propname="layer_list_active",
|
||||
item_dyntip_propname="info_text",
|
||||
rows=20)
|
||||
|
||||
# sidebar = split.column(align=True)
|
||||
# sidebar.menu(AddLayerMenu.bl_idname,
|
||||
# icon=AddLayerMenu.bl_icon, text="")
|
||||
|
||||
# sidebar.operator(SaveContainerLayersCache.bl_idname,
|
||||
# icon=SaveContainerLayersCache.bl_icon, text="")
|
||||
# sidebar.operator(RemoveContainerMissingLayers.bl_idname,
|
||||
# icon=RemoveContainerMissingLayers.bl_icon, text="")
|
||||
|
||||
# sidebar.separator()
|
||||
# sidebar.operator(SaveSelectedLayersCache.bl_idname,
|
||||
# icon=SaveSelectedLayersCache.bl_icon, text="")
|
||||
# sidebar.operator(RemoveSelectedLayers.bl_idname,
|
||||
# icon=RemoveSelectedLayers.bl_icon, text="")
|
||||
|
||||
# sidebar.separator()
|
||||
# sidebar.operator(RenameLayer.bl_idname,
|
||||
# icon=RenameLayer.bl_icon, text="")
|
||||
# sidebar.operator(ResampleLayer.bl_idname,
|
||||
# icon=ResampleLayer.bl_icon, text="")
|
||||
# sidebar.operator(RetimeLayer.bl_idname,
|
||||
# icon=RetimeLayer.bl_icon, text="")
|
||||
|
||||
# sidebar.separator()
|
||||
# sidebar.operator(SignScalar.bl_idname,
|
||||
# icon=SignScalar.bl_icon, text="")
|
||||
# sidebar.operator(FillByThreshold.bl_idname,
|
||||
# icon=FillByThreshold.bl_icon, text="")
|
||||
# sidebar.operator(FillByRange.bl_idname,
|
||||
# icon=FillByRange.bl_icon, text="")
|
||||
# sidebar.operator(FillByLabel.bl_idname,
|
||||
# icon=FillByLabel.bl_icon, text="")
|
||||
|
||||
# sidebar.separator()
|
||||
# layout.separator()
|
||||
|
||||
|
||||
def VIEW3D_TOPBAR(self, context):
|
||||
layout = self.layout
|
||||
layout.operator(SliceViewer.bl_idname)
|
||||
|
||||
|
||||
node_menu = NodeMenu(
|
||||
menu_items=MENU_ITEMS
|
||||
)
|
||||
layout.menu(ObjectContextMenu.bl_idname)
|
||||
|
||||
|
||||
def add():
|
||||
node_menu.register()
|
||||
# bpy.types.VIEW3D_HT_header.append(VIEW3D_TOPBAR)
|
||||
bpy.types.TOPBAR_MT_editor_menus.append(TOPBAR)
|
||||
bpy.types.NODE_PT_node_tree_properties.prepend(NODE_PROP)
|
||||
bpy.types.NODE_MT_editor_menus.append(NODE_HEAD)
|
||||
bpy.types.NODE_MT_context_menu.append(NODE_CONTEXT)
|
||||
bpy.types.VIEW3D_MT_object_context_menu.append(OBJECT_CONTEXT)
|
||||
# bpy.types.NODE_MT_context_menu.append(NODE_CONTEXT)
|
||||
|
||||
|
||||
def remove():
|
||||
# bpy.types.VIEW3D_HT_header.remove(VIEW3D_TOPBAR)
|
||||
bpy.types.TOPBAR_MT_editor_menus.remove(TOPBAR)
|
||||
bpy.types.NODE_PT_node_tree_properties.remove(NODE_PROP)
|
||||
bpy.types.NODE_MT_editor_menus.remove(NODE_HEAD)
|
||||
bpy.types.NODE_MT_context_menu.remove(NODE_CONTEXT)
|
||||
node_menu.unregister()
|
||||
bpy.types.VIEW3D_MT_object_context_menu.remove(OBJECT_CONTEXT)
|
||||
# bpy.types.NODE_MT_context_menu.remove(NODE_CONTEXT)
|
||||
|
||||
Reference in New Issue
Block a user