Skip to content
Snippets Groups Projects
ui.py 58.2 KiB
Newer Older
  • Learn to ignore specific revisions
  • Maurice Raybaud's avatar
    Maurice Raybaud committed
    
            obj = context.object
    
    
    Thomas Dinges's avatar
    Thomas Dinges committed
            col = layout.column()
            col.label(text="Radiosity:")
    
            col.prop(obj.pov, "importance_value", text="Importance")
    
    Thomas Dinges's avatar
    Thomas Dinges committed
            col.label(text="Photons:")
    
            col.prop(obj.pov, "collect_photons", text="Receive Photon Caustics")
    
            if obj.pov.collect_photons:
                col.prop(obj.pov, "spacing_multiplier", text="Photons Spacing Multiplier")
    
    class OBJECT_PT_povray_obj_sphere(PovDataButtonsPanel, bpy.types.Panel):
        bl_label = "POV-Ray Sphere"
        COMPAT_ENGINES = {'POVRAY_RENDER'}
        #bl_options = {'HIDE_HEADER'}
        @classmethod
        def poll(cls, context):
            engine = context.scene.render.engine
            obj = context.object
            return (obj and obj.pov.object_as == 'SPHERE' and (engine in cls.COMPAT_ENGINES))    
        def draw(self, context):
            layout = self.layout
    
            obj = context.object
            
            col = layout.column()
    
            if obj.pov.object_as == 'SPHERE':
                if obj.pov.unlock_parameters == False:
                    col.prop(obj.pov, "unlock_parameters", text="Exported parameters below", icon='LOCKED') 
                    col.label(text="Sphere radius: " + str(obj.pov.sphere_radius))
    
                else:
                    col.prop(obj.pov, "unlock_parameters", text="Edit exported parameters", icon='UNLOCKED') 
                    col.label(text="3D view proxy may get out of synch")
                    col.active = obj.pov.unlock_parameters
                    
    
                    layout.operator("pov.sphere_update", text="Update",icon="SOLID")        
                    
                    #col.label(text="Parameters:")
                    col.prop(obj.pov, "sphere_radius", text="Radius of Sphere")
    
    
    
    class OBJECT_PT_povray_obj_cylinder(PovDataButtonsPanel, bpy.types.Panel):
        bl_label = "POV-Ray Cylinder"
        COMPAT_ENGINES = {'POVRAY_RENDER'}
        #bl_options = {'HIDE_HEADER'}
        @classmethod
        def poll(cls, context):
            engine = context.scene.render.engine
            obj = context.object
            return (obj and obj.pov.object_as == 'CYLINDER' and (engine in cls.COMPAT_ENGINES))    
        def draw(self, context):
            layout = self.layout
    
            obj = context.object
            
            col = layout.column()
    
            if obj.pov.object_as == 'CYLINDER':
                if obj.pov.unlock_parameters == False:
                    col.prop(obj.pov, "unlock_parameters", text="Exported parameters below", icon='LOCKED') 
                    col.label(text="Cylinder radius: " + str(obj.pov.cylinder_radius))
                    col.label(text="Cylinder cap location: " + str(obj.pov.cylinder_location_cap))
    
                else:
                    col.prop(obj.pov, "unlock_parameters", text="Edit exported parameters", icon='UNLOCKED') 
                    col.label(text="3D view proxy may get out of synch")
                    col.active = obj.pov.unlock_parameters
                    
    
                    layout.operator("pov.cylinder_update", text="Update",icon="MESH_CYLINDER")        
                    
                    #col.label(text="Parameters:")
                    col.prop(obj.pov, "cylinder_radius")
                    col.prop(obj.pov, "cylinder_location_cap")
    
    
    class OBJECT_PT_povray_obj_cone(PovDataButtonsPanel, bpy.types.Panel):
        bl_label = "POV-Ray Cone"
        COMPAT_ENGINES = {'POVRAY_RENDER'}
        #bl_options = {'HIDE_HEADER'}
        @classmethod
        def poll(cls, context):
            engine = context.scene.render.engine
            obj = context.object
            return (obj and obj.pov.object_as == 'CONE' and (engine in cls.COMPAT_ENGINES))    
        def draw(self, context):
            layout = self.layout
    
            obj = context.object
            
            col = layout.column()
    
            if obj.pov.object_as == 'CONE':
                if obj.pov.unlock_parameters == False:
                    col.prop(obj.pov, "unlock_parameters", text="Exported parameters below", icon='LOCKED') 
                    col.label(text="Cone base radius: " + str(obj.pov.cone_base_radius))
                    col.label(text="Cone cap radius: " + str(obj.pov.cone_cap_radius))
                    col.label(text="Cone proxy segments: " + str(obj.pov.cone_segments))
                    col.label(text="Cone height: " + str(obj.pov.cone_height))
                else:
                    col.prop(obj.pov, "unlock_parameters", text="Edit exported parameters", icon='UNLOCKED') 
                    col.label(text="3D view proxy may get out of synch")
                    col.active = obj.pov.unlock_parameters
                    
    
                    layout.operator("pov.cone_update", text="Update",icon="MESH_CONE")        
                    
                    #col.label(text="Parameters:")
                    col.prop(obj.pov, "cone_base_radius", text="Radius of Cone Base")
                    col.prop(obj.pov, "cone_cap_radius", text="Radius of Cone Cap")
                    col.prop(obj.pov, "cone_segments", text="Segmentation of Cone proxy")
                    col.prop(obj.pov, "cone_height", text="Height of the cone")
    
    class OBJECT_PT_povray_obj_superellipsoid(PovDataButtonsPanel, bpy.types.Panel):
        bl_label = "POV-Ray Superquadric ellipsoid"
        COMPAT_ENGINES = {'POVRAY_RENDER'}
        #bl_options = {'HIDE_HEADER'}
        @classmethod
        def poll(cls, context):
            engine = context.scene.render.engine
            obj = context.object
            return (obj and obj.pov.object_as == 'SUPERELLIPSOID' and (engine in cls.COMPAT_ENGINES))    
        def draw(self, context):
            layout = self.layout
    
            obj = context.object
            
            col = layout.column()
    
            if obj.pov.object_as == 'SUPERELLIPSOID':
                if obj.pov.unlock_parameters == False:
                    col.prop(obj.pov, "unlock_parameters", text="Exported parameters below", icon='LOCKED') 
                    col.label(text="Radial segmentation: " + str(obj.pov.se_u))
                    col.label(text="Lateral segmentation: " + str(obj.pov.se_v))
                    col.label(text="Ring shape: " + str(obj.pov.se_n1))
                    col.label(text="Cross-section shape: " + str(obj.pov.se_n2))
                    col.label(text="Fill up and down: " + str(obj.pov.se_edit))
                else:
                    col.prop(obj.pov, "unlock_parameters", text="Edit exported parameters", icon='UNLOCKED') 
                    col.label(text="3D view proxy may get out of synch")
                    col.active = obj.pov.unlock_parameters
                    
    
                    layout.operator("pov.superellipsoid_update", text="Update",icon="MOD_SUBSURF")        
                    
                    #col.label(text="Parameters:")
                    col.prop(obj.pov, "se_u")
                    col.prop(obj.pov, "se_v")
                    col.prop(obj.pov, "se_n1")
                    col.prop(obj.pov, "se_n2")
                    col.prop(obj.pov, "se_edit")
                    
                    
    class OBJECT_PT_povray_obj_torus(PovDataButtonsPanel, bpy.types.Panel):
        bl_label = "POV-Ray Torus"
        COMPAT_ENGINES = {'POVRAY_RENDER'}
        #bl_options = {'HIDE_HEADER'}
        @classmethod
        def poll(cls, context):
            engine = context.scene.render.engine
            obj = context.object
            return (obj and obj.pov.object_as == 'TORUS' and (engine in cls.COMPAT_ENGINES))    
        def draw(self, context):
            layout = self.layout
    
            obj = context.object
            
            col = layout.column()
    
            if obj.pov.object_as == 'TORUS':
                if obj.pov.unlock_parameters == False:
                    col.prop(obj.pov, "unlock_parameters", text="Exported parameters below", icon='LOCKED') 
                    col.label(text="Torus major radius: " + str(obj.pov.torus_major_radius))
                    col.label(text="Torus minor radius: " + str(obj.pov.torus_minor_radius))
                    col.label(text="Torus major segments: " + str(obj.pov.torus_major_segments))
                    col.label(text="Torus minor segments: " + str(obj.pov.torus_minor_segments))
                else:
                    col.prop(obj.pov, "unlock_parameters", text="Edit exported parameters", icon='UNLOCKED') 
                    col.label(text="3D view proxy may get out of synch")
                    col.active = obj.pov.unlock_parameters
                    
    
                    layout.operator("pov.torus_update", text="Update",icon="MESH_TORUS")        
                    
                    #col.label(text="Parameters:")
                    col.prop(obj.pov, "torus_major_radius")
                    col.prop(obj.pov, "torus_minor_radius")
                    col.prop(obj.pov, "torus_major_segments")
                    col.prop(obj.pov, "torus_minor_segments")
    
    class OBJECT_PT_povray_obj_supertorus(PovDataButtonsPanel, bpy.types.Panel):
        bl_label = "POV-Ray SuperTorus"
        COMPAT_ENGINES = {'POVRAY_RENDER'}
        #bl_options = {'HIDE_HEADER'}
        @classmethod
        def poll(cls, context):
            engine = context.scene.render.engine
            obj = context.object
            return (obj and obj.pov.object_as == 'SUPERTORUS' and (engine in cls.COMPAT_ENGINES))    
        def draw(self, context):
            layout = self.layout
    
            obj = context.object
            
            col = layout.column()
    
            if obj.pov.object_as == 'SUPERTORUS':
                if obj.pov.unlock_parameters == False:
                    col.prop(obj.pov, "unlock_parameters", text="Exported parameters below", icon='LOCKED') 
                    col.label(text="SuperTorus major radius: " + str(obj.pov.st_major_radius))
                    col.label(text="SuperTorus minor radius: " + str(obj.pov.st_minor_radius))
                    col.label(text="SuperTorus major segments: " + str(obj.pov.st_u))
                    col.label(text="SuperTorus minor segments: " + str(obj.pov.st_v))
                    
                    col.label(text="SuperTorus Ring Manipulator: " + str(obj.pov.st_ring))
                    col.label(text="SuperTorus Cross Manipulator: " + str(obj.pov.st_cross))
                    col.label(text="SuperTorus Internal And External radii: " + str(obj.pov.st_ie))
                    
                    col.label(text="SuperTorus accuracy: " + str(ob.pov.st_accuracy))
                    col.label(text="SuperTorus max gradient: " + str(ob.pov.st_max_gradient))
                    
    
                else:
                    col.prop(obj.pov, "unlock_parameters", text="Edit exported parameters", icon='UNLOCKED') 
                    col.label(text="3D view proxy may get out of synch")
                    col.active = obj.pov.unlock_parameters
                    
    
                    layout.operator("pov.supertorus_update", text="Update",icon="MESH_TORUS")        
                    
                    #col.label(text="Parameters:")
                    col.prop(obj.pov, "st_major_radius")
                    col.prop(obj.pov, "st_minor_radius")
                    col.prop(obj.pov, "st_u")
                    col.prop(obj.pov, "st_v")
                    col.prop(obj.pov, "st_ring")
                    col.prop(obj.pov, "st_cross")
                    col.prop(obj.pov, "st_ie")
                    #col.prop(obj.pov, "st_edit") #?
                    col.prop(obj.pov, "st_accuracy")
                    col.prop(obj.pov, "st_max_gradient")
                    
    class OBJECT_PT_povray_obj_parametric(PovDataButtonsPanel, bpy.types.Panel):
        bl_label = "POV-Ray Parametric surface"
        COMPAT_ENGINES = {'POVRAY_RENDER'}
        #bl_options = {'HIDE_HEADER'}
        @classmethod
        def poll(cls, context):
            engine = context.scene.render.engine
            obj = context.object
            return (obj and obj.pov.object_as == 'PARAMETRIC' and (engine in cls.COMPAT_ENGINES))    
        def draw(self, context):
            layout = self.layout
    
            obj = context.object
            
            col = layout.column()
    
            if obj.pov.object_as == 'PARAMETRIC':
                if obj.pov.unlock_parameters == False:
                    col.prop(obj.pov, "unlock_parameters", text="Exported parameters below", icon='LOCKED') 
                    col.label(text="Minimum U: " + str(obj.pov.u_min))
                    col.label(text="Minimum V: " + str(obj.pov.v_min))
                    col.label(text="Maximum U: " + str(obj.pov.u_max))
                    col.label(text="Minimum V: " + str(obj.pov.v_min))
                    col.label(text="X Function: " + str(obj.pov.x_eq))
                    col.label(text="Y Function: " + str(obj.pov.y_eq))
                    col.label(text="Z Function: " + str(obj.pov.x_eq))
    
                else:
                    col.prop(obj.pov, "unlock_parameters", text="Edit exported parameters", icon='UNLOCKED') 
                    col.label(text="3D view proxy may get out of synch")
                    col.active = obj.pov.unlock_parameters
                    
    
                    layout.operator("pov.parametric_update", text="Update",icon="SCRIPTPLUGINS")        
                    
                    col.prop(obj.pov, "u_min", text="Minimum U")
                    col.prop(obj.pov, "v_min", text="Minimum V")
                    col.prop(obj.pov, "u_max", text="Maximum U")
                    col.prop(obj.pov, "v_max", text="Minimum V")
                    col.prop(obj.pov, "x_eq", text="X Function")
                    col.prop(obj.pov, "y_eq", text="Y Function")
                    col.prop(obj.pov, "z_eq", text="Z Function")
    
                    
    
    class OBJECT_PT_povray_replacement_text(ObjectButtonsPanel, bpy.types.Panel):
        bl_label = "Custom POV Code"
    
    Thomas Dinges's avatar
    Thomas Dinges committed
            col = layout.column()
    
            col.prop(obj.pov, "replacement_text", text="")
    
    ###############################################################################
    # Add Povray Objects
    ###############################################################################
            
    
    class Povray_primitives_add_menu(bpy.types.Menu):
        """Define the menu with presets"""
        bl_idname = "Povray_primitives_add_menu"
        bl_label = "Povray"
        COMPAT_ENGINES = {'POVRAY_RENDER'}
        
        @classmethod
        def poll(cls, context):
            engine = context.scene.render.engine
            return (engine == 'POVRAY_RENDER')    
            
        def draw(self,context):
            layout = self.layout
            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.menu(BasicShapesMenu.bl_idname, text = "Primitives",icon="GROUP")
            layout.menu(ImportMenu.bl_idname, text = "Import",icon="IMPORT")
    
    class BasicShapesMenu(bpy.types.Menu):
        bl_idname = "Basic_shapes_calls"
        bl_label = "Basic_shapes"
        
        def draw(self,context):
            pov = bpy.types.Object.pov #context.object.pov ? 
            layout = self.layout
            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("pov.addplane", text="Infinite Plane",icon = 'MESH_PLANE')
            layout.operator("pov.addbox", text="Box",icon = 'MESH_CUBE')
            layout.operator("pov.addsphere", text="Sphere",icon = 'SOLID')
            layout.operator("pov.addcylinder", text="Cylinder",icon="MESH_CYLINDER")
            layout.operator("pov.cone_add", text="Cone",icon="MESH_CONE")
            layout.operator("pov.addtorus", text="Torus",icon = 'MESH_TORUS')
            layout.separator()
            layout.operator("pov.addparametric", text="Parametric",icon = 'SCRIPTPLUGINS')
            layout.operator("pov.addrainbow", text="Rainbow",icon="COLOR")
            layout.operator("pov.addlathe", text="Lathe",icon = 'MOD_SCREW')
            layout.operator("pov.addprism", text="Prism",icon = 'MOD_SOLIDIFY')
            layout.operator("pov.addsuperellipsoid", text="Superquadric Ellipsoid",icon = 'MOD_SUBSURF')
            layout.operator("pov.addheightfield", text="Height Field",icon="RNDCURVE")
            layout.operator("pov.addspheresweep", text="Sphere Sweep",icon = 'FORCE_CURVE')
            layout.separator()
            layout.operator("pov.addblobsphere", text="Blob Sphere",icon = 'META_DATA')
            layout.separator()
            layout.label("Isosurfaces")
            layout.operator("pov.addisosurfacebox", text="Isosurface Box",icon="META_CUBE")
            layout.operator("pov.addisosurfacesphere", text="Isosurface Sphere",icon="META_BALL")
            layout.operator("pov.addsupertorus", text="Supertorus",icon="SURFACE_NTORUS")
            layout.separator()
            layout.label(text = "Macro based")
            layout.operator("pov.addpolygontocircle", text="Polygon To Circle Blending",icon="RETOPO")
            layout.operator("pov.addloft", text="Loft",icon="SURFACE_NSURFACE")
            
    class ImportMenu(bpy.types.Menu):
        bl_idname = "Importer_calls"
        bl_label = "Import"
    
        def draw(self,context):
            pov = bpy.types.Object.pov #context.object.pov ? 
            layout = self.layout
            layout.operator_context = 'INVOKE_REGION_WIN'
    
            layout.operator("import_scene.pov",icon="FORCE_LENNARDJONES")
    
    
    def menu_func_add(self, context):
        engine = context.scene.render.engine
        if engine == 'POVRAY_RENDER':
            self.layout.menu("Povray_primitives_add_menu", icon="PLUGIN") 
    
    def menu_func_import(self, context):
        engine = context.scene.render.engine
        if engine == 'POVRAY_RENDER':
    
            self.layout.operator("import_scene.pov",icon="FORCE_LENNARDJONES")
    
    
            
    ###############################################################################
    # Camera Povray Settings
    ############################################################################### 
    
    class CAMERA_PT_povray_cam_dof(CameraDataButtonsPanel, bpy.types.Panel):
    
        bl_label = "POV-Ray Depth Of Field"
        COMPAT_ENGINES = {'POVRAY_RENDER'}
    
        def draw_header(self, context):
            cam = context.camera
    
    
            self.layout.prop(cam.pov, "dof_enable", text="")
    
        def draw(self, context):
            layout = self.layout
    
            cam = context.camera
    
    
            split = layout.split()
    
            col = split.column()
    
            col.prop(cam.pov, "dof_samples_min")
            col.prop(cam.pov, "dof_variance")
    
            col = split.column()
    
            col.prop(cam.pov, "dof_samples_max")
            col.prop(cam.pov, "dof_confidence")
    
    
    
    class CAMERA_PT_povray_replacement_text(CameraDataButtonsPanel, bpy.types.Panel):
        bl_label = "Custom POV Code"
    
    Thomas Dinges's avatar
    Thomas Dinges committed
            col = layout.column()
    
            col.prop(cam.pov, "replacement_text", text="")
    
    
    
    class TEXT_PT_povray_custom_code(TextButtonsPanel, bpy.types.Panel):
        bl_label = "P.O.V-Ray"
    
    Thomas Dinges's avatar
    Thomas Dinges committed
            text = context.space_data.text
    
                layout.prop(text.pov, "custom_code", text="Add as POV code")