Skip to content
Snippets Groups Projects
object_gui.py 40.5 KiB
Newer Older
  • Learn to ignore specific revisions
  •     bl_widget = None
        bl_keymap = (
            ("pov.addisosurface", {"type": 'LEFTMOUSE', "value": 'PRESS'},
        {"properties": None}),
            )
    
    
    class VIEW_WT_POV_isosurfacebox_add(WorkSpaceTool):
        bl_space_type='VIEW_3D'
        bl_context_mode='OBJECT'
    
        # The prefix of the idname should be your add-on name.
        bl_idname = "pov.addisosurfacebox"
        bl_label = "Add POV isosurface box"
        bl_options = {'REGISTER', 'UNDO'}
        bl_description = (
            "add a POV box shaped isosurface primitive"
        )
        bl_icon = os.path.join(icon_path, "pov.add.isosurfacebox")
        bl_widget = None
        bl_keymap = (
            ("pov.addisosurfacebox", {"type": 'LEFTMOUSE', "value": 'PRESS'},
        {"properties": None}),
            )
    
    
    class VIEW_WT_POV_isosurfacesphere_add(WorkSpaceTool):
        bl_space_type='VIEW_3D'
        bl_context_mode='OBJECT'
    
        # The prefix of the idname should be your add-on name.
        bl_idname = "pov.addisosurfacesphere"
        bl_label = "Add POV isosurface sphere"
        bl_options = {'REGISTER', 'UNDO'}
        bl_description = (
            "add a POV sphere shaped isosurface primitive"
        )
        bl_icon = os.path.join(icon_path, "pov.add.isosurfacesphere")
        bl_widget = None
        bl_keymap = (
            ("pov.addisosurfacesphere", {"type": 'LEFTMOUSE', "value": 'PRESS'},
        {"properties": None}),
            )
    
    
    class VIEW_WT_POV_isosurfacesupertorus_add(WorkSpaceTool):
        bl_space_type='VIEW_3D'
        bl_context_mode='OBJECT'
    
        # The prefix of the idname should be your add-on name.
        bl_idname = "pov.addsupertorus"
        bl_label = "Add POV isosurface supertorus"
        bl_options = {'REGISTER', 'UNDO'}
        bl_description = (
            "add a POV torus shaped isosurface primitive"
        )
        bl_icon = os.path.join(icon_path, "pov.add.isosurfacesupertorus")
        bl_widget = None
        bl_keymap = (
            ("pov.addsupertorus", {"type": 'LEFTMOUSE', "value": 'PRESS'},
        {"properties": None}),
            )
    
    
    class VIEW_WT_POV_blobsphere_add(WorkSpaceTool):
        bl_space_type='VIEW_3D'
        bl_context_mode='OBJECT'
    
        # The prefix of the idname should be your add-on name.
        bl_idname = "pov.addblobsphere"
        bl_label = "Add POV blob sphere"
        bl_options = {'REGISTER', 'UNDO'}
        bl_description = (
            "add a POV sphere shaped blob primitive"
        )
        bl_icon = os.path.join(icon_path, "pov.add.blobsphere")
        bl_widget = None
        bl_keymap = (
            ("pov.addblobsphere", {"type": 'LEFTMOUSE', "value": 'PRESS'},
        {"properties": None}),
            )
    
    
    class VIEW_WT_POV_blobcapsule_add(WorkSpaceTool):
        bl_space_type='VIEW_3D'
        bl_context_mode='OBJECT'
    
        # The prefix of the idname should be your add-on name.
        bl_idname = "pov.addblobcapsule"
        bl_label = "Add POV blob capsule"
        bl_options = {'REGISTER', 'UNDO'}
        bl_description = (
            "add a POV capsule shaped blob primitive"
        )
        bl_icon = os.path.join(icon_path, "pov.add.blobcapsule")
        bl_widget = None
        bl_keymap = (
            ("pov.addblobcapsule", {"type": 'LEFTMOUSE', "value": 'PRESS'},
        {"properties": None}),
            )
    
    
    class VIEW_WT_POV_blobplane_add(WorkSpaceTool):
        bl_space_type='VIEW_3D'
        bl_context_mode='OBJECT'
    
        # The prefix of the idname should be your add-on name.
        bl_idname = "pov.addblobplane"
        bl_label = "Add POV blob plane"
        bl_options = {'REGISTER', 'UNDO'}
        bl_description = (
            "add a POV plane shaped blob primitive"
        )
        bl_icon = os.path.join(icon_path, "pov.add.blobplane")
        bl_widget = None
        bl_keymap = (
            ("pov.addblobplane", {"type": 'LEFTMOUSE', "value": 'PRESS'},
        {"properties": None}),
            )
    
    
    class VIEW_WT_POV_blobellipsoid_add(WorkSpaceTool):
        bl_space_type='VIEW_3D'
        bl_context_mode='OBJECT'
    
        # The prefix of the idname should be your add-on name.
        bl_idname = "pov.addblobellipsoid"
        bl_label = "Add POV blob ellipsoid"
        bl_options = {'REGISTER', 'UNDO'}
        bl_description = (
            "add a POV ellipsoid shaped blob primitive"
        )
        bl_icon = os.path.join(icon_path, "pov.add.blobellipsoid")
        bl_widget = None
        bl_keymap = (
            ("pov.addblobellipsoid", {"type": 'LEFTMOUSE', "value": 'PRESS'},
        {"properties": None}),
            )
    
    
    class VIEW_WT_POV_blobcube_add(WorkSpaceTool):
        bl_space_type='VIEW_3D'
        bl_context_mode='OBJECT'
    
        # The prefix of the idname should be your add-on name.
        bl_idname = "pov.addsblobcube"
        bl_label = "Add POV blob cube"
        bl_options = {'REGISTER', 'UNDO'}
        bl_description = (
            "add a POV cube shaped blob primitive"
        )
        bl_icon = os.path.join(icon_path, "pov.add.blobcube")
        bl_widget = None
        bl_keymap = (
            ("pov.addblobcube", {"type": 'LEFTMOUSE', "value": 'PRESS'},
        {"properties": None}),
            )
    
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
    
    classes = (
        # ObjectButtonsPanel,
        # PovDataButtonsPanel,
        DATA_PT_POV_normals,
        DATA_PT_POV_texture_space,
        DATA_PT_POV_vertex_groups,
        DATA_PT_POV_shape_keys,
        DATA_PT_POV_uv_texture,
        DATA_PT_POV_vertex_colors,
        DATA_PT_POV_customdata,
        MODIFIERS_PT_POV_modifiers,
        OBJECT_PT_POV_obj_parameters,
        OBJECT_PT_POV_obj_sphere,
        OBJECT_PT_POV_obj_cylinder,
        OBJECT_PT_POV_obj_cone,
        OBJECT_PT_POV_obj_superellipsoid,
        OBJECT_PT_POV_obj_torus,
        OBJECT_PT_POV_obj_supertorus,
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
        OBJECT_PT_POV_obj_parametric,
        OBJECT_PT_povray_replacement_text,
        VIEW_MT_POV_primitives_add,
        VIEW_MT_POV_Basic_Shapes,
    )
    
    tool_classes = (
        VIEW_WT_POV_plane_add,
        VIEW_WT_POV_box_add,
        VIEW_WT_POV_sphere_add,
        VIEW_WT_POV_cylinder_add,
        VIEW_WT_POV_cone_add,
        VIEW_WT_POV_torus_add,
        VIEW_WT_POV_prism_add,
        VIEW_WT_POV_lathe_add,
        VIEW_WT_POV_spheresweep_add,
        VIEW_WT_POV_heightfield_add,
        VIEW_WT_POV_superellipsoid_add,
        VIEW_WT_POV_rainbow_add,
        VIEW_WT_POV_loft_add,
        VIEW_WT_POV_polytocircle_add,
        VIEW_WT_POV_parametric_add,
        VIEW_WT_POV_isosurface_add,
        VIEW_WT_POV_isosurfacebox_add,
        VIEW_WT_POV_isosurfacesphere_add,
        VIEW_WT_POV_isosurfacesupertorus_add,
        VIEW_WT_POV_blobsphere_add,
        VIEW_WT_POV_blobcapsule_add,
        VIEW_WT_POV_blobplane_add,
        VIEW_WT_POV_blobellipsoid_add,
        VIEW_WT_POV_blobcube_add,
    )
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
    
    def register():
        for cls in classes:
            register_class(cls)
    
    
        # Register tools
        last_tool = {"builtin.measure"}
        for index, wtl in enumerate(tool_classes):
            # Only separate first and 12th tools and hide subtools only in 8th (isosurfaces)
            register_tool(wtl, after=last_tool, separator=index in [0,7,11,12,14,19], group=index == 15)
            last_tool = {wtl.bl_idname}
    
        bpy.types.VIEW3D_MT_add.prepend(menu_func_add)
        # Below was used for parametric objects but made the other addon unreachable on
        # unregister for other tools to use. Created a user action call instead
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
        # addon_utils.enable("add_mesh_extra_objects", default_set=False, persistent=True)
    
    
    def unregister():
        # addon_utils.disable("add_mesh_extra_objects", default_set=False)
        bpy.types.VIEW3D_MT_add.remove(menu_func_add)
    
    
        for wtl in reversed(tool_classes):
            unregister_tool(wtl)
    
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
        for cls in reversed(classes):
            unregister_class(cls)