|
- from macrovision import ops
-
- import bpy
-
- class MV_UL_ViewList(bpy.types.UIList):
- def draw_item(self, context, layout: bpy.types.UILayout, data, item, icon, active_data, active_propname, index):
- if self.layout_type in {'DEFAULT', 'COMPACT'}:
- layout.prop(item, "view", text="")
- layout.prop(item, "name", text="")
- elif self.layout_type in {'GRID'}:
- layout.alignment = 'CENTER'
- layout.label(text='', icon = 'OBJECT_DATAMODE')
-
- class MV_Views_List_Add(bpy.types.Operator):
- bl_idname = "mv.views_list_add"
- bl_label = "Add view"
-
- def execute(self, context: bpy.types.Context):
- context.scene.mv_views.add()
- return {'FINISHED'}
-
- class MV_Views_List_Delete(bpy.types.Operator):
- bl_idname = "mv.views_list_delete"
- bl_label = "Delete view"
-
- @classmethod
- def poll(self, context: bpy.types.Context):
- return context.scene.mv_views
-
- def execute(self, context: bpy.types.Context):
- lst = context.scene.mv_views
- index = context.scene.mv_views_index
-
- lst.remove(index)
-
- index = max(0, index - 1)
- index = min(index, len(lst) - 1)
-
- context.scene.mv_views_index = index
- return {'FINISHED'}
-
- class MVScenePanel(bpy.types.Panel):
- bl_idname="OBJECT_PT_MV_scene_menu"
- bl_label="Macrovision"
- bl_space_type="VIEW_3D"
- bl_region_type="UI"
- bl_category = "Macrovision"
-
- @classmethod
- def poll(cls, context):
- return True
-
- def draw(self, context):
- layout = self.layout
-
- box = layout.box()
- box.label(text="Setup")
-
- box.prop(context.scene, "mv_entity_mass_mode")
- box.prop(context.scene, "mv_entity_volume_mode")
-
- op_props = box.operator("mv.config_collection")
- op_props = box.operator("mv.assign_materials")
-
- box.prop(context.scene, "mv_material_mode")
-
- if context.scene.mv_material_mode in ('NAMES', 'FACE_MAPS'):
- box.prop(context.scene, "mv_material_names_light")
- box.prop(context.scene, "mv_material_names_medium")
-
- box = layout.box()
- box.label(text="Execute")
-
- op_props = box.operator("mv.export")
-
- box.prop(context.scene, "mv_name")
- box.prop(context.scene, "mv_kind")
- box.prop(context.scene, "mv_trace_mode")
- box.template_list(
- "MV_UL_ViewList",
- "Views",
- context.scene,
- "mv_views",
- context.scene,
- "mv_views_index"
- )
- row = box.row()
-
- row.operator("mv.views_list_add", text="+")
- row.operator("mv.views_list_delete", text="-")
- box.prop(context.scene, 'mv_scale_factor')
-
- class MVCollectionPanel(bpy.types.Panel):
- bl_idname="OBJECT_PT_MV_collection_menu"
- bl_label="Entity"
- bl_space_type="VIEW_3D"
- bl_region_type="UI"
- bl_category = "Macrovision"
-
- @classmethod
- def poll(cls, context: bpy.context):
- return context.collection.name in bpy.data.collections['Macrovision'].children
-
- def draw(self, context):
- layout = self.layout
-
- box = layout.box()
- box.label(text="Entity")
-
- if context.scene.mv_entity_mass_mode == "MANUAL":
- row = box.row()
- row.label(text="Mass")
- row.prop(context.collection.mv_entity_mass, "base")
- row.prop(context.collection.mv_entity_mass, "power")
-
- if context.scene.mv_entity_mass_mode == "DENSITY":
- row = box.row()
- row.label(text="Density")
- row.prop(context.collection.mv_entity_density, "base")
- row.prop(context.collection.mv_entity_density, "power")
-
- if context.scene.mv_entity_volume_mode == "MANUAL":
- row = box.row()
- row.label(text="Volume")
- row.prop(context.collection.mv_entity_volume, "base")
- row.prop(context.collection.mv_entity_volume, "power")
-
- clses = [
- MV_UL_ViewList,
- MV_Views_List_Add,
- MV_Views_List_Delete,
- MVScenePanel,
- MVCollectionPanel
- ]
|