Skip to content
Snippets Groups Projects
ui.py 142 KiB
Newer Older
  • Learn to ignore specific revisions
  • 
            layout.active = cam.pov.normal_enable
    
    
            layout.prop(cam.pov, "normal_patterns")
            layout.prop(cam.pov, "cam_normal")
            layout.prop(cam.pov, "turbulence")
            layout.prop(cam.pov, "scale")
    
    class CAMERA_PT_POV_replacement_text(CameraDataButtonsPanel, Panel):
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
        """Use this class for camera text replacement field."""
    
    
    Thomas Dinges's avatar
    Thomas Dinges committed
            col = layout.column()
    
            col.prop(cam.pov, "replacement_text", text="")
    
    ###############################################################################
    # Text Povray Settings
    ###############################################################################
    
    
    class TEXT_OT_POV_insert(Operator):
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
        """Use this class to create blender text editor operator to insert pov snippets like other pov IDEs."""
    
        bl_idname = "text.povray_insert"
        bl_label = "Insert"
    
    
        filepath: bpy.props.StringProperty(name="Filepath", subtype='FILE_PATH')
    
    
        @classmethod
        def poll(cls, context):
            # context.area.type == 'TEXT_EDITOR'
            return bpy.ops.text.insert.poll()
    
        def execute(self, context):
            if self.filepath and isfile(self.filepath):
                file = open(self.filepath, "r")
                bpy.ops.text.insert(text=file.read())
    
                # places the cursor at the end without scrolling -.-
                # context.space_data.text.write(file.read())
                file.close()
            return {'FINISHED'}
    
    
        return ext in {".txt", ".inc", ".pov"}
    
    
    class TEXT_MT_POV_insert(bpy.types.Menu):
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
        """Use this class to create a menu launcher in text editor for the TEXT_OT_POV_insert operator ."""
    
    
        bl_idname = "TEXT_MT_POV_insert"
    
    
        def draw(self, context):
            pov_documents = locate_docpath()
    
            prop = self.layout.operator(
                "wm.path_open", text="Open folder", icon='FILE_FOLDER'
            )
    
            prop.filepath = pov_documents
            self.layout.separator()
    
            list = []
            for root, dirs, files in os.walk(pov_documents):
    
            self.path_menu(
                list,
                "text.povray_insert",
                # {"internal": True},
                filter_ext=validinsert,
            )
    
    
    class TEXT_PT_POV_custom_code(TextButtonsPanel, Panel):
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
        """Use this class to create a panel in text editor for the user to decide if he renders text only or adds to 3d scene."""
    
    
    Thomas Dinges's avatar
    Thomas Dinges committed
            text = context.space_data.text
    
                layout.label(text="Please configure ", icon="INFO")
                layout.label(text="default pov include path ")
                layout.label(text="in addon preferences")
    
                # layout.separator()
                layout.operator(
                    "preferences.addon_show",
                    text="Go to Render: Persistence of Vision addon",
                    icon="PREFERENCES",
                ).module = "render_povray"
    
                # layout.separator()
    
                # print(pov_documents)
    
                layout.menu(TEXT_MT_POV_insert.bl_idname)
    
                box.label(text='Source to render:', icon='RENDER_STILL')
    
                row.prop(text.pov, "custom_code", expand=True)
    
                    box.operator("render.render", icon='OUTLINER_DATA_POSE')
    
                if text.pov.custom_code in {'text'}:
                    rtext = bpy.context.space_data.text
                    box.operator("text.run", icon='POSE_DATA')
    
                # layout.prop(text.pov, "custom_code")
    
                elif text.pov.custom_code in {'both'}:
                    box.operator("render.render", icon='POSE_HLT')
                    layout.label(text="Please specify declared", icon="INFO")
                    layout.label(text="items in properties ")
    
                    # layout.label(text="")
    
    ###############################################
    # Text editor templates from header menu
    
    class TEXT_MT_POV_templates(bpy.types.Menu):
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
        """Use this class to create a menu for the same pov templates scenes as other pov IDEs."""
    
    
    
        # We list templates on file evaluation, we can assume they are static data,
        # and better avoid running this on every draw call.
        import os
    
        template_paths = [os.path.join(os.path.dirname(__file__), "templates_pov")]
    
        def draw(self, context):
            self.path_menu(
    
                self.template_paths, "text.open", props_default={"internal": True}
    
    def menu_func_templates(self, context):
    
        # Do not depend on POV being active renderer here...
        self.layout.menu("TEXT_MT_POV_templates")
    
        WORLD_MT_POV_presets,
        WORLD_OT_POV_add_preset,
    
        WORLD_TEXTURE_SLOTS_UL_List,
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
        WORLD_PT_POV_mist,
    
        # RenderButtonsPanel,
        # ModifierButtonsPanel,
        # MaterialButtonsPanel,
        # TextureButtonsPanel,
        # ObjectButtonsPanel,
        # CameraDataButtonsPanel,
        # WorldButtonsPanel,
        # TextButtonsPanel,
        # 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,
    
        # PovLampButtonsPanel,
    
        LIGHT_PT_POV_preview,
        LIGHT_PT_POV_light,
    
        LIGHT_MT_POV_presets,
        LIGHT_OT_POV_add_preset,
        OBJECT_PT_POV_rainbow,
        RENDER_PT_POV_export_settings,
        RENDER_PT_POV_render_settings,
        RENDER_PT_POV_photons,
        RENDER_PT_POV_antialias,
        RENDER_PT_POV_radiosity,
    
        POV_RADIOSITY_MT_presets,
    
        RENDER_OT_POV_radiosity_add_preset,
        RENDER_PT_POV_media,
        MODIFIERS_PT_POV_modifiers,
    
        MATERIAL_MT_POV_sss_presets,
    
        MATERIAL_OT_POV_sss_add_preset,
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
        MATERIAL_PT_strand,
    
        MATERIAL_PT_POV_activate_node,
        MATERIAL_PT_POV_active_node,
    
        MATERIAL_PT_POV_specular,
    
        MATERIAL_PT_POV_reflection,
    
        # MATERIAL_PT_POV_interior,
    
        MATERIAL_PT_POV_fade_color,
        MATERIAL_PT_POV_caustics,
        MATERIAL_PT_POV_replacement_text,
        TEXTURE_MT_POV_specials,
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
        TEXTURE_PT_POV_context_texture,
    
        TEXTURE_PT_POV_type,
        TEXTURE_PT_POV_preview,
        TEXTURE_PT_POV_parameters,
        TEXTURE_PT_POV_tex_gamma,
        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,
        OBJECT_PT_POV_obj_parametric,
    
        OBJECT_PT_povray_replacement_text,
    
        VIEW_MT_POV_primitives_add,
        VIEW_MT_POV_Basic_Shapes,
        VIEW_MT_POV_import,
        NODE_MT_POV_map_create,
        CAMERA_PT_POV_cam_dof,
        CAMERA_PT_POV_cam_nor,
        CAMERA_PT_POV_replacement_text,
        TEXT_OT_POV_insert,
        TEXT_MT_POV_insert,
        TEXT_PT_POV_custom_code,
        TEXT_MT_POV_templates,
    
        # TEXTURE_PT_context,
    
        # TEXTURE_PT_POV_povray_texture_slots,
    
        TEXTURE_UL_POV_texture_slots,
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
        MATERIAL_TEXTURE_SLOTS_UL_POV_layerlist,
    
        MATERIAL_OT_POV_texture_slot_add,
        MATERIAL_OT_POV_texture_slot_remove,
    
        TEXTURE_PT_POV_influence,
    
        # from bpy.utils import register_class
    
    
        for cls in classes:
            register_class(cls)
    
        bpy.types.VIEW3D_MT_add.prepend(menu_func_add)
        bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
        bpy.types.TEXT_MT_templates.append(menu_func_templates)
    
        bpy.types.RENDER_PT_POV_radiosity.prepend(rad_panel_func)
    
        bpy.types.LIGHT_PT_POV_light.prepend(light_panel_func)
    
        # bpy.types.WORLD_PT_POV_world.prepend(world_panel_func)
    
        # was used for parametric objects but made the other addon unreachable on
        # unregister for other tools to use created a user action call instead
    
        # addon_utils.enable("add_mesh_extra_objects", default_set=False, persistent=True)
    
        # bpy.types.TEXTURE_PT_context_texture.prepend(TEXTURE_PT_POV_type)
    
        # from bpy.utils import unregister_class
    
        # bpy.types.TEXTURE_PT_context_texture.remove(TEXTURE_PT_POV_type)
        # addon_utils.disable("add_mesh_extra_objects", default_set=False)
        # bpy.types.WORLD_PT_POV_world.remove(world_panel_func)
    
        bpy.types.LIGHT_PT_POV_light.remove(light_panel_func)
    
        bpy.types.RENDER_PT_POV_radiosity.remove(rad_panel_func)
    
        bpy.types.TEXT_MT_templates.remove(menu_func_templates)
        bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
    
        bpy.types.VIEW3D_MT_add.remove(menu_func_add)
    
        for cls in reversed(classes):
            unregister_class(cls)