Skip to content
Snippets Groups Projects
ui.py 66.4 KiB
Newer Older
Luca Bonavita's avatar
Luca Bonavita committed
# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

Luca Bonavita's avatar
Luca Bonavita committed
import bpy

# Use some of the existing buttons.
from bl_ui import properties_render
properties_render.RENDER_PT_render.COMPAT_ENGINES.add('POVRAY_RENDER')
properties_render.RENDER_PT_dimensions.COMPAT_ENGINES.add('POVRAY_RENDER')
# properties_render.RENDER_PT_antialiasing.COMPAT_ENGINES.add('POVRAY_RENDER')
properties_render.RENDER_PT_shading.COMPAT_ENGINES.add('POVRAY_RENDER')
properties_render.RENDER_PT_output.COMPAT_ENGINES.add('POVRAY_RENDER')
Luca Bonavita's avatar
Luca Bonavita committed
del properties_render

Luca Bonavita's avatar
Luca Bonavita committed
# Use only a subset of the world panels
from bl_ui import properties_world
properties_world.WORLD_PT_preview.COMPAT_ENGINES.add('POVRAY_RENDER')
properties_world.WORLD_PT_context_world.COMPAT_ENGINES.add('POVRAY_RENDER')
properties_world.WORLD_PT_world.COMPAT_ENGINES.add('POVRAY_RENDER')
properties_world.WORLD_PT_mist.COMPAT_ENGINES.add('POVRAY_RENDER')
Luca Bonavita's avatar
Luca Bonavita committed
del properties_world


# Example of wrapping every class 'as is'
from bl_ui import properties_texture
from bl_ui.properties_texture import context_tex_datablock
Luca Bonavita's avatar
Luca Bonavita committed
for member in dir(properties_texture):
    subclass = getattr(properties_texture, member)
    try:
        subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
Luca Bonavita's avatar
Luca Bonavita committed
    except:
        pass
del properties_texture

# Example of wrapping every class 'as is' except some
from bl_ui import properties_material
for member in dir(properties_material):
    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:
            #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):
            subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
        except:
            pass
del properties_material


from bl_ui import properties_data_camera
Luca Bonavita's avatar
Luca Bonavita committed
for member in dir(properties_data_camera):
    subclass = getattr(properties_data_camera, member)
    try:
        subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
Luca Bonavita's avatar
Luca Bonavita committed
    except:
        pass
del properties_data_camera

Maurice Raybaud's avatar
Maurice Raybaud committed

from bl_ui import properties_particle as properties_particle
for member in dir(properties_particle):  # add all "particle" panels from blender
    subclass = getattr(properties_particle, member)
    try:
        subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
    except:
        pass
del properties_particle

class RenderButtonsPanel():
Luca Bonavita's avatar
Luca Bonavita committed
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "render"
    # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here

    @classmethod
    def poll(cls, context):
Luca Bonavita's avatar
Luca Bonavita committed
        rd = context.scene.render
Campbell Barton's avatar
Campbell Barton committed
        return (rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES)
Luca Bonavita's avatar
Luca Bonavita committed

Maurice Raybaud's avatar
Maurice Raybaud committed
class MaterialButtonsPanel():
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "material"
    # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here

    @classmethod
    def poll(cls, context):
        mat = context.material
        rd = context.scene.render
Campbell Barton's avatar
Campbell Barton committed
        return mat and (rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES)
class TextureButtonsPanel():
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "texture"
    # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here

    @classmethod
    def poll(cls, context):
        tex = context.texture
        rd = context.scene.render
Campbell Barton's avatar
Campbell Barton committed
        return tex and (rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES)
Maurice Raybaud's avatar
Maurice Raybaud committed

# class TextureTypePanel(TextureButtonsPanel):

    # @classmethod
    # def poll(cls, context):
        # tex = context.texture
        # engine = context.scene.render.engine
        # return tex and ((tex.type == cls.tex_type and not tex.use_nodes) and (engine in cls.COMPAT_ENGINES))

Maurice Raybaud's avatar
Maurice Raybaud committed
class ObjectButtonsPanel():
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"
    # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here

    @classmethod
    def poll(cls, context):
        obj = context.object
        rd = context.scene.render
Campbell Barton's avatar
Campbell Barton committed
        return obj and (rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES)
class CameraDataButtonsPanel():
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "data"
    # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here

    @classmethod
    def poll(cls, context):
        cam = context.camera
        rd = context.scene.render
Campbell Barton's avatar
Campbell Barton committed
        return cam and (rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES)
class WorldButtonsPanel():
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "world"
    # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
    @classmethod
    def poll(cls, context):
        wld = context.world
        rd = context.scene.render
        return wld and (rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES)
        
class TextButtonsPanel():
    bl_space_type = 'TEXT_EDITOR'
    bl_region_type = 'UI'
    # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here

    @classmethod
    def poll(cls, context):
        text = context.space_data
        rd = context.scene.render
Campbell Barton's avatar
Campbell Barton committed
        return text and (rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES)
from bl_ui import properties_data_mesh
# These panels are kept
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')
 
## make some native panels contextual to some object variable
## by recreating custom panels inheriting their properties
 
class PovDataButtonsPanel(properties_data_mesh.MeshButtonsPanel):
    COMPAT_ENGINES = {'POVRAY_RENDER'}
    POV_OBJECT_TYPES = {'PLANE', 'BOX', 'SPHERE', 'CYLINDER', 'CONE', 'TORUS', 'BLOB',
                        'ISOSURFACE', 'SUPERELLIPSOID', 'SUPERTORUS', 'HEIGHT_FIELD',
                        'PARAMETRIC', 'POLYCIRCLE'}
 
    @classmethod
Loading
Loading full blame...