Changeset View
Changeset View
Standalone View
Standalone View
render_povray/ui.py
| Show First 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | for member in dir(properties_data_modifier): | ||||
| except: | except: | ||||
| pass | pass | ||||
| del properties_data_modifier | del properties_data_modifier | ||||
| # Example of wrapping every class 'as is' except some | # Example of wrapping every class 'as is' except some | ||||
| from bl_ui import properties_material | from bl_ui import properties_material | ||||
| for member in dir(properties_material): | for member in dir(properties_material): | ||||
| subclass = getattr(properties_material, member) | subclass = getattr(properties_material, member) | ||||
| if subclass not in (properties_material.MATERIAL_PT_transp_game, | |||||
| properties_material.MATERIAL_PT_game_settings, | |||||
| properties_material.MATERIAL_PT_physics): | |||||
| try: | try: | ||||
| #mat=context.material | #mat=context.material | ||||
| #if mat and mat.type == "SURFACE" and (engine in cls.COMPAT_ENGINES) and not (mat.pov.material_use_nodes or mat.use_nodes): | #if mat and mat.type == "SURFACE" and (engine in cls.COMPAT_ENGINES) and not (mat.pov.material_use_nodes or mat.use_nodes): | ||||
| subclass.COMPAT_ENGINES.add('POVRAY_RENDER') | subclass.COMPAT_ENGINES.add('POVRAY_RENDER') | ||||
| except: | except: | ||||
| pass | pass | ||||
| del properties_material | del properties_material | ||||
| from bl_ui import properties_data_camera | from bl_ui import properties_data_camera | ||||
| for member in dir(properties_data_camera): | for member in dir(properties_data_camera): | ||||
| subclass = getattr(properties_data_camera, member) | subclass = getattr(properties_data_camera, member) | ||||
| try: | try: | ||||
| subclass.COMPAT_ENGINES.add('POVRAY_RENDER') | subclass.COMPAT_ENGINES.add('POVRAY_RENDER') | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | class RenderButtonsPanel(): | ||||
| bl_space_type = 'PROPERTIES' | bl_space_type = 'PROPERTIES' | ||||
| bl_region_type = 'WINDOW' | bl_region_type = 'WINDOW' | ||||
| bl_context = "render" | bl_context = "render" | ||||
| # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| rd = context.scene.render | rd = context.scene.render | ||||
| return (rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES) | return (rd.engine in cls.COMPAT_ENGINES) | ||||
| class ModifierButtonsPanel(): | class ModifierButtonsPanel(): | ||||
| bl_space_type = 'PROPERTIES' | bl_space_type = 'PROPERTIES' | ||||
| bl_region_type = 'WINDOW' | bl_region_type = 'WINDOW' | ||||
| bl_context = "modifier" | bl_context = "modifier" | ||||
| # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| mods = context.object.modifiers | mods = context.object.modifiers | ||||
| rd = context.scene.render | rd = context.scene.render | ||||
| return mods and (rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES) | return mods and (rd.engine in cls.COMPAT_ENGINES) | ||||
| class MaterialButtonsPanel(): | class MaterialButtonsPanel(): | ||||
| bl_space_type = 'PROPERTIES' | bl_space_type = 'PROPERTIES' | ||||
| bl_region_type = 'WINDOW' | bl_region_type = 'WINDOW' | ||||
| bl_context = "material" | bl_context = "material" | ||||
| # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| mat = context.material | mat = context.material | ||||
| rd = context.scene.render | rd = context.scene.render | ||||
| return mat and (rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES) | return mat (rd.engine in cls.COMPAT_ENGINES) | ||||
| class TextureButtonsPanel(): | class TextureButtonsPanel(): | ||||
| bl_space_type = 'PROPERTIES' | bl_space_type = 'PROPERTIES' | ||||
| bl_region_type = 'WINDOW' | bl_region_type = 'WINDOW' | ||||
| bl_context = "texture" | bl_context = "texture" | ||||
| # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| tex = context.texture | tex = context.texture | ||||
| rd = context.scene.render | rd = context.scene.render | ||||
| return tex and (rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES) | return tex and (rd.engine in cls.COMPAT_ENGINES) | ||||
| # class TextureTypePanel(TextureButtonsPanel): | # class TextureTypePanel(TextureButtonsPanel): | ||||
| # @classmethod | # @classmethod | ||||
| # def poll(cls, context): | # def poll(cls, context): | ||||
| # tex = context.texture | # tex = context.texture | ||||
| # engine = context.scene.render.engine | # engine = context.scene.render.engine | ||||
| # return tex and ((tex.type == cls.tex_type and not tex.use_nodes) and (engine in cls.COMPAT_ENGINES)) | # return tex and ((tex.type == cls.tex_type and not tex.use_nodes) and (engine in cls.COMPAT_ENGINES)) | ||||
| class ObjectButtonsPanel(): | class ObjectButtonsPanel(): | ||||
| bl_space_type = 'PROPERTIES' | bl_space_type = 'PROPERTIES' | ||||
| bl_region_type = 'WINDOW' | bl_region_type = 'WINDOW' | ||||
| bl_context = "object" | bl_context = "object" | ||||
| # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| obj = context.object | obj = context.object | ||||
| rd = context.scene.render | rd = context.scene.render | ||||
| return obj and (rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES) | return obj and (rd.engine in cls.COMPAT_ENGINES) | ||||
| class CameraDataButtonsPanel(): | class CameraDataButtonsPanel(): | ||||
| bl_space_type = 'PROPERTIES' | bl_space_type = 'PROPERTIES' | ||||
| bl_region_type = 'WINDOW' | bl_region_type = 'WINDOW' | ||||
| bl_context = "data" | bl_context = "data" | ||||
| # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| cam = context.camera | cam = context.camera | ||||
| rd = context.scene.render | rd = context.scene.render | ||||
| return cam and (rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES) | return cam and (rd.engine in cls.COMPAT_ENGINES) | ||||
| class WorldButtonsPanel(): | class WorldButtonsPanel(): | ||||
| bl_space_type = 'PROPERTIES' | bl_space_type = 'PROPERTIES' | ||||
| bl_region_type = 'WINDOW' | bl_region_type = 'WINDOW' | ||||
| bl_context = "world" | bl_context = "world" | ||||
| # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| wld = context.world | wld = context.world | ||||
| rd = context.scene.render | rd = context.scene.render | ||||
| return wld and (rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES) | return wld and (rd.engine in cls.COMPAT_ENGINES) | ||||
| class TextButtonsPanel(): | class TextButtonsPanel(): | ||||
| bl_space_type = 'TEXT_EDITOR' | bl_space_type = 'TEXT_EDITOR' | ||||
| bl_region_type = 'UI' | bl_region_type = 'UI' | ||||
| bl_label = "POV-Ray" | bl_label = "POV-Ray" | ||||
| # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| text = context.space_data | text = context.space_data | ||||
| rd = context.scene.render | rd = context.scene.render | ||||
| return text and (rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES) | return text and (rd.engine in cls.COMPAT_ENGINES) | ||||
| from bl_ui import properties_data_mesh | from bl_ui import properties_data_mesh | ||||
| # These panels are kept | # These panels are kept | ||||
| properties_data_mesh.DATA_PT_custom_props_mesh.COMPAT_ENGINES.add('POVRAY_RENDER') | properties_data_mesh.DATA_PT_custom_props_mesh.COMPAT_ENGINES.add('POVRAY_RENDER') | ||||
| properties_data_mesh.DATA_PT_context_mesh.COMPAT_ENGINES.add('POVRAY_RENDER') | properties_data_mesh.DATA_PT_context_mesh.COMPAT_ENGINES.add('POVRAY_RENDER') | ||||
| ## make some native panels contextual to some object variable | ## make some native panels contextual to some object variable | ||||
| ## by recreating custom panels inheriting their properties | ## by recreating custom panels inheriting their properties | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | class DATA_PT_POV_customdata(PovDataButtonsPanel, bpy.types.Panel): | ||||
| draw = properties_data_mesh.DATA_PT_customdata.draw | draw = properties_data_mesh.DATA_PT_customdata.draw | ||||
| del properties_data_mesh | del properties_data_mesh | ||||
| ################################################################################ | ################################################################################ | ||||
| # from bl_ui import properties_data_lamp | # from bl_ui import properties_data_light | ||||
| # for member in dir(properties_data_lamp): | # for member in dir(properties_data_light): | ||||
| # subclass = getattr(properties_data_lamp, member) | # subclass = getattr(properties_data_light, member) | ||||
| # try: | # try: | ||||
| # subclass.COMPAT_ENGINES.add('POVRAY_RENDER') | # subclass.COMPAT_ENGINES.add('POVRAY_RENDER') | ||||
| # except: | # except: | ||||
| # pass | # pass | ||||
| # del properties_data_lamp | # del properties_data_light | ||||
| #########################LAMPS################################ | #########################LIGHTS################################ | ||||
| from bl_ui import properties_data_lamp | from bl_ui import properties_data_light | ||||
| # These panels are kept | # These panels are kept | ||||
| properties_data_lamp.DATA_PT_custom_props_lamp.COMPAT_ENGINES.add('POVRAY_RENDER') | properties_data_light.DATA_PT_custom_props_light.COMPAT_ENGINES.add('POVRAY_RENDER') | ||||
| properties_data_lamp.DATA_PT_context_lamp.COMPAT_ENGINES.add('POVRAY_RENDER') | properties_data_light.DATA_PT_context_light.COMPAT_ENGINES.add('POVRAY_RENDER') | ||||
| ## make some native panels contextual to some object variable | ## make some native panels contextual to some object variable | ||||
| ## by recreating custom panels inheriting their properties | ## by recreating custom panels inheriting their properties | ||||
| class PovLampButtonsPanel(properties_data_lamp.DataButtonsPanel): | class PovLampButtonsPanel(properties_data_light.DataButtonsPanel): | ||||
| COMPAT_ENGINES = {'POVRAY_RENDER'} | COMPAT_ENGINES = {'POVRAY_RENDER'} | ||||
| POV_OBJECT_TYPES = {'RAINBOW'} | POV_OBJECT_TYPES = {'RAINBOW'} | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| engine = context.scene.render.engine | engine = context.scene.render.engine | ||||
| obj = context.object | obj = context.object | ||||
| # We use our parent class poll func too, avoids to re-define too much things... | # We use our parent class poll func too, avoids to re-define too much things... | ||||
| return (super(PovLampButtonsPanel, cls).poll(context) and | return (super(PovLampButtonsPanel, cls).poll(context) and | ||||
| obj and obj.pov.object_as not in cls.POV_OBJECT_TYPES) | obj and obj.pov.object_as not in cls.POV_OBJECT_TYPES) | ||||
| # We cannot inherit from RNA classes (like e.g. properties_data_mesh.DATA_PT_vertex_groups). | # We cannot inherit from RNA classes (like e.g. properties_data_mesh.DATA_PT_vertex_groups). | ||||
| # Complex py/bpy/rna interactions (with metaclass and all) simply do not allow it to work. | # Complex py/bpy/rna interactions (with metaclass and all) simply do not allow it to work. | ||||
| # So we simply have to explicitly copy here the interesting bits. ;) | # So we simply have to explicitly copy here the interesting bits. ;) | ||||
| class LAMP_PT_POV_preview(PovLampButtonsPanel, bpy.types.Panel): | class LIGHT_PT_POV_preview(PovLampButtonsPanel, bpy.types.Panel): | ||||
| bl_label = properties_data_lamp.DATA_PT_preview.bl_label | bl_label = properties_data_light.DATA_PT_preview.bl_label | ||||
| draw = properties_data_lamp.DATA_PT_preview.draw | draw = properties_data_light.DATA_PT_preview.draw | ||||
| class LAMP_PT_POV_lamp(PovLampButtonsPanel, bpy.types.Panel): | class LIGHT_PT_POV_light(PovLampButtonsPanel, bpy.types.Panel): | ||||
| bl_label = properties_data_lamp.DATA_PT_lamp.bl_label | bl_label = properties_data_light.DATA_PT_light.bl_label | ||||
| draw = properties_data_lamp.DATA_PT_lamp.draw | draw = properties_data_light.DATA_PT_light.draw | ||||
| class POV_LAMP_MT_presets(bpy.types.Menu): | class POV_LIGHT_MT_presets(bpy.types.Menu): | ||||
| bl_label = "Lamp Presets" | bl_label = "Lamp Presets" | ||||
| preset_subdir = "pov/lamp" | preset_subdir = "pov/lamp" | ||||
| preset_operator = "script.execute_preset" | preset_operator = "script.execute_preset" | ||||
| draw = bpy.types.Menu.draw_preset | draw = bpy.types.Menu.draw_preset | ||||
| class AddPresetLamp(AddPresetBase, bpy.types.Operator): | class AddPresetLamp(AddPresetBase, bpy.types.Operator): | ||||
| '''Add a Lamp Preset''' | '''Add a Lamp Preset''' | ||||
| bl_idname = "object.lamp_preset_add" | bl_idname = "object.light_preset_add" | ||||
| bl_label = "Add Lamp Preset" | bl_label = "Add Lamp Preset" | ||||
| preset_menu = "POV_LAMP_MT_presets" | preset_menu = "POV_LIGHT_MT_presets" | ||||
| # variable used for all preset values | # variable used for all preset values | ||||
| preset_defines = [ | preset_defines = [ | ||||
| "lampdata = bpy.context.object.data" | "lightdata = bpy.context.object.data" | ||||
| ] | ] | ||||
| # properties to store in the preset | # properties to store in the preset | ||||
| preset_values = [ | preset_values = [ | ||||
| "lampdata.type", | "lightdata.type", | ||||
| "lampdata.color", | "lightdata.color", | ||||
| ] | ] | ||||
| # where to store the preset | # where to store the preset | ||||
| preset_subdir = "pov/lamp" | preset_subdir = "pov/lamp" | ||||
| # Draw into an existing panel | # Draw into an existing panel | ||||
| def lamp_panel_func(self, context): | def light_panel_func(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| row = layout.row(align=True) | row = layout.row(align=True) | ||||
| row.menu(POV_LAMP_MT_presets.__name__, text=POV_LAMP_MT_presets.bl_label) | row.menu(POV_LIGHT_MT_presets.__name__, text=POV_LIGHT_MT_presets.bl_label) | ||||
| row.operator(AddPresetLamp.bl_idname, text="", icon='ZOOMIN') | row.operator(AddPresetLamp.bl_idname, text="", icon='ZOOMIN') | ||||
| row.operator(AddPresetLamp.bl_idname, text="", icon='ZOOMOUT').remove_active = True | row.operator(AddPresetLamp.bl_idname, text="", icon='ZOOMOUT').remove_active = True | ||||
| classes = ( | classes = ( | ||||
| POV_LAMP_MT_presets, | POV_LIGHT_MT_presets, | ||||
| AddPresetLamp, | AddPresetLamp, | ||||
| ) | ) | ||||
| class LAMP_PT_POV_sunsky(PovLampButtonsPanel, bpy.types.Panel): | class LIGHT_PT_POV_sunsky(PovLampButtonsPanel, bpy.types.Panel): | ||||
| bl_label = properties_data_lamp.DATA_PT_sunsky.bl_label | bl_label = properties_data_light.DATA_PT_sunsky.bl_label | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| lamp = context.lamp | lamp = context.light | ||||
| engine = context.scene.render.engine | engine = context.scene.render.engine | ||||
| return (lamp and lamp.type == 'SUN') and (engine in cls.COMPAT_ENGINES) | return (lamp and lamp.type == 'SUN') and (engine in cls.COMPAT_ENGINES) | ||||
| draw = properties_data_lamp.DATA_PT_sunsky.draw | draw = properties_data_light.DATA_PT_sunsky.draw | ||||
| class LAMP_PT_POV_shadow(PovLampButtonsPanel, bpy.types.Panel): | class LIGHT_PT_POV_shadow(PovLampButtonsPanel, bpy.types.Panel): | ||||
| bl_label = properties_data_lamp.DATA_PT_shadow.bl_label | bl_label = properties_data_light.DATA_PT_shadow.bl_label | ||||
| draw = properties_data_lamp.DATA_PT_shadow.draw | draw = properties_data_light.DATA_PT_shadow.draw | ||||
| class LAMP_PT_POV_area(PovLampButtonsPanel, bpy.types.Panel): | class LIGHT_PT_POV_area(PovLampButtonsPanel, bpy.types.Panel): | ||||
| bl_label = properties_data_lamp.DATA_PT_area.bl_label | bl_label = properties_data_light.DATA_PT_area.bl_label | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| lamp = context.lamp | lamp = context.light | ||||
| engine = context.scene.render.engine | engine = context.scene.render.engine | ||||
| return (lamp and lamp.type == 'AREA') and (engine in cls.COMPAT_ENGINES) | return (lamp and lamp.type == 'AREA') and (engine in cls.COMPAT_ENGINES) | ||||
| draw = properties_data_lamp.DATA_PT_area.draw | draw = properties_data_light.DATA_PT_area.draw | ||||
| class LAMP_PT_POV_spot(PovLampButtonsPanel, bpy.types.Panel): | class LIGHT_PT_POV_spot(PovLampButtonsPanel, bpy.types.Panel): | ||||
| bl_label = properties_data_lamp.DATA_PT_spot.bl_label | bl_label = properties_data_light.DATA_PT_spot.bl_label | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| lamp = context.lamp | lamp = context.light | ||||
| engine = context.scene.render.engine | engine = context.scene.render.engine | ||||
| return (lamp and lamp.type == 'SPOT') and (engine in cls.COMPAT_ENGINES) | return (lamp and lamp.type == 'SPOT') and (engine in cls.COMPAT_ENGINES) | ||||
| draw = properties_data_lamp.DATA_PT_spot.draw | draw = properties_data_light.DATA_PT_spot.draw | ||||
| class LAMP_PT_POV_falloff_curve(PovLampButtonsPanel, bpy.types.Panel): | class LIGHT_PT_POV_falloff_curve(PovLampButtonsPanel, bpy.types.Panel): | ||||
| bl_label = properties_data_lamp.DATA_PT_falloff_curve.bl_label | bl_label = properties_data_light.DATA_PT_falloff_curve.bl_label | ||||
| bl_options = properties_data_lamp.DATA_PT_falloff_curve.bl_options | bl_options = properties_data_light.DATA_PT_falloff_curve.bl_options | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| lamp = context.lamp | lamp = context.light | ||||
| engine = context.scene.render.engine | engine = context.scene.render.engine | ||||
| return (lamp and lamp.type in {'POINT', 'SPOT'} and lamp.falloff_type == 'CUSTOM_CURVE') and (engine in cls.COMPAT_ENGINES) | return (lamp and lamp.type in {'POINT', 'SPOT'} and lamp.falloff_type == 'CUSTOM_CURVE') and (engine in cls.COMPAT_ENGINES) | ||||
| draw = properties_data_lamp.DATA_PT_falloff_curve.draw | draw = properties_data_light.DATA_PT_falloff_curve.draw | ||||
| class OBJECT_PT_povray_obj_rainbow(PovLampButtonsPanel, bpy.types.Panel): | class OBJECT_PT_povray_obj_rainbow(PovLampButtonsPanel, bpy.types.Panel): | ||||
| bl_label = "POV-Ray Rainbow" | bl_label = "POV-Ray Rainbow" | ||||
| COMPAT_ENGINES = {'POVRAY_RENDER'} | COMPAT_ENGINES = {'POVRAY_RENDER'} | ||||
| #bl_options = {'HIDE_HEADER'} | #bl_options = {'HIDE_HEADER'} | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| engine = context.scene.render.engine | engine = context.scene.render.engine | ||||
| Show All 25 Lines | def draw(self, context): | ||||
| #col.label(text="Parameters:") | #col.label(text="Parameters:") | ||||
| col.prop(obj.data, "spot_size", text="Rainbow Projection Angle") | col.prop(obj.data, "spot_size", text="Rainbow Projection Angle") | ||||
| col.prop(obj.data, "spot_blend", text="Rainbow width") | col.prop(obj.data, "spot_blend", text="Rainbow width") | ||||
| col.prop(obj.data, "shadow_buffer_clip_start", text="Visibility distance") | col.prop(obj.data, "shadow_buffer_clip_start", text="Visibility distance") | ||||
| col.prop(obj.pov, "arc_angle") | col.prop(obj.pov, "arc_angle") | ||||
| col.prop(obj.pov, "falloff_angle") | col.prop(obj.pov, "falloff_angle") | ||||
| del properties_data_lamp | del properties_data_light | ||||
| ############################################################################### | ############################################################################### | ||||
| class RENDER_PT_povray_export_settings(RenderButtonsPanel, bpy.types.Panel): | class RENDER_PT_povray_export_settings(RenderButtonsPanel, bpy.types.Panel): | ||||
| bl_label = "INI Options" | bl_label = "INI Options" | ||||
| bl_options = {'DEFAULT_CLOSED'} | bl_options = {'DEFAULT_CLOSED'} | ||||
| COMPAT_ENGINES = {'POVRAY_RENDER'} | COMPAT_ENGINES = {'POVRAY_RENDER'} | ||||
| ▲ Show 20 Lines • Show All 1,520 Lines • Show Last 20 Lines | |||||